Line 1... |
Line 1... |
// #################################################################################################
|
// #################################################################################################
|
// # << NEORV32 - Bootloader >> #
|
// # << NEORV32 - Bootloader >> #
|
// # ********************************************************************************************* #
|
// # ********************************************************************************************* #
|
// # THE BOOTLOADER SHOULD BE COMPILED USING THE BASE ISA ONLY (rv32i or rv32e)! #
|
// # THE BOOTLOADER SHOULD BE COMPILED USING ONLY THE BASE ISA (rv32i or rv32e)! #
|
// # ********************************************************************************************* #
|
// # ********************************************************************************************* #
|
// # Boot from (internal) instruction memory, UART or SPI Flash. #
|
// # Boot from (internal) instruction memory, UART or SPI Flash. #
|
// # #
|
// # #
|
// # UART configuration: 8N1 at 19200 baud #
|
// # UART configuration: 8N1 at 19200 baud #
|
// # Boot Flash: 8-bit SPI, 24-bit addresses (like Micron N25Q032A) @ neorv32.spi_csn_o(0) #
|
// # Boot Flash: 8-bit SPI, 24-bit addresses (like Micron N25Q032A) @ neorv32.spi_csn_o(0) #
|
// # neorv32.gpio_o(0) is used as high-active status LED. #
|
// # neorv32.gpio_o(0) is used as high-active status LED (can be disabled via STATUS_LED_EN). #
|
// # #
|
// # #
|
// # Auto boot sequence after timeout: #
|
// # Auto boot sequence (can be disabled via AUTOBOOT_EN) after timeout (via AUTOBOOT_TIMEOUT): #
|
// # -> Try booting from SPI flash at spi_csn_o(0). #
|
// # -> Try booting from SPI flash at spi_csn_o(0). #
|
// # -> Permanently light up status led and freeze if SPI flash booting attempt fails. #
|
// # -> Permanently light up status led and freeze if SPI flash booting attempt fails. #
|
// # ********************************************************************************************* #
|
// # ********************************************************************************************* #
|
// # BSD 3-Clause License #
|
// # BSD 3-Clause License #
|
// # #
|
// # #
|
Line 62... |
Line 62... |
/**@{*/
|
/**@{*/
|
/** UART BAUD rate */
|
/** UART BAUD rate */
|
#define BAUD_RATE (19200)
|
#define BAUD_RATE (19200)
|
/** Time until the auto-boot sequence starts (in seconds) */
|
/** Time until the auto-boot sequence starts (in seconds) */
|
#define AUTOBOOT_TIMEOUT 8
|
#define AUTOBOOT_TIMEOUT 8
|
|
/** Enable auto-boot sequence if != 0 */
|
|
#define AUTOBOOT_EN (1)
|
/** Set to 0 to disable bootloader status LED */
|
/** Set to 0 to disable bootloader status LED */
|
#define STATUS_LED_EN (1)
|
#define STATUS_LED_EN (1)
|
/** Bootloader status LED at GPIO output port */
|
/** Bootloader status LED at GPIO output port */
|
#define STATUS_LED (0)
|
#define STATUS_LED (0)
|
/** SPI flash boot image base address */
|
/** SPI flash boot image base address */
|
Line 237... |
Line 239... |
|
|
|
|
// ------------------------------------------------
|
// ------------------------------------------------
|
// Auto boot sequence
|
// Auto boot sequence
|
// ------------------------------------------------
|
// ------------------------------------------------
|
|
#if (AUTOBOOT_EN != 0)
|
neorv32_uart_print("\n\nAutoboot in "xstr(AUTOBOOT_TIMEOUT)"s. Press key to abort.\n");
|
neorv32_uart_print("\n\nAutoboot in "xstr(AUTOBOOT_TIMEOUT)"s. Press key to abort.\n");
|
|
|
uint64_t timeout_time = neorv32_mtime_get_time() + (uint64_t)(AUTOBOOT_TIMEOUT * clock_speed);
|
uint64_t timeout_time = neorv32_mtime_get_time() + (uint64_t)(AUTOBOOT_TIMEOUT * clock_speed);
|
|
|
while ((UART_DATA & (1 << UART_DATA_AVAIL)) == 0) { // wait for any key to be pressed
|
while ((UART_DATA & (1 << UART_DATA_AVAIL)) == 0) { // wait for any key to be pressed
|
Line 250... |
Line 253... |
neorv32_uart_print("\n");
|
neorv32_uart_print("\n");
|
start_app();
|
start_app();
|
}
|
}
|
}
|
}
|
neorv32_uart_print("Aborted.\n\n");
|
neorv32_uart_print("Aborted.\n\n");
|
|
#else
|
|
neorv32_uart_print("\n\n");
|
|
#endif
|
|
|
print_help();
|
print_help();
|
|
|
|
|
// ------------------------------------------------
|
// ------------------------------------------------
|
// Bootloader console
|
// Bootloader console
|
Line 274... |
Line 281... |
print_help();
|
print_help();
|
}
|
}
|
else if (c == 'u') { // get executable via UART
|
else if (c == 'u') { // get executable via UART
|
get_exe(EXE_STREAM_UART);
|
get_exe(EXE_STREAM_UART);
|
}
|
}
|
else if (c == 's') { // program EEPROM from RAM
|
else if (c == 's') { // program flash from memory (IMEM)
|
save_exe();
|
save_exe();
|
}
|
}
|
else if (c == 'l') { // get executable from flash
|
else if (c == 'l') { // get executable from flash
|
get_exe(EXE_STREAM_FLASH);
|
get_exe(EXE_STREAM_FLASH);
|
}
|
}
|