update bootloader

Bootloader does not longer require ispace_base/dspace_base addresses from SYSINFO
This commit is contained in:
stnolting 2023-07-28 10:19:00 +02:00
parent 2e99380297
commit ae56e0073e
4 changed files with 185 additions and 190 deletions

View file

@ -92,8 +92,8 @@ CLK: 0x05f5e100
MISA: 0x40901106
XISA: 0xc0000fab
SOC: 0xffff402f
IMEM: 0x00008000 bytes @0x00000000
DMEM: 0x00002000 bytes @0x80000000
IMEM: 0x00008000
DMEM: 0x00002000
Autoboot in 8s. Press any key to abort.
----
@ -105,12 +105,12 @@ The start-up screen gives some brief information about the bootloader and severa
|=======================
| `BLDV` | Bootloader version (built date).
| `HWV` | Processor hardware version (the <<_mimpid>> CSR); in BCD format; example: `0x01040606` = v1.4.6.6).
| `CLK` | Processor clock speed in Hz (via the `CLK` register from <<_system_configuration_information_memory_sysinfo>>.
| `CLK` | Processor clock speed in Hz (via the `CLK` register from the <<_system_configuration_information_memory_sysinfo>>.
| `MISA` | RISC-V CPU extensions (<<_misa>> CSR).
| `XISA` | NEORV32-specific CPU extensions (<<_mxisa>> CSR).
| `SOC` | Processor configuration (via the `SOC` register from the <<_system_configuration_information_memory_sysinfo>>.
| `IMEM` | IMEM memory base address and size in byte (via the `IMEM_SIZE` and `ISPACE_BASE` registers from the <<_system_configuration_information_memory_sysinfo>>.
| `DMEM` | DMEM memory base address and size in byte (via the `DMEM_SIZE` and `DSPACE_BASE` registers from the <<_system_configuration_information_memory_sysinfo>>.
| `IMEM` | Internal IMEM size in byte (via the `MEM` register from the <<_system_configuration_information_memory_sysinfo>>.
| `DMEM` | Internal DMEM size in byte (via the `MEM` register from the <<_system_configuration_information_memory_sysinfo>>.
|=======================
Now you have 8 seconds to press _any_ key. Otherwise, the bootloader starts the <<_auto_boot_sequence>>. When
@ -126,8 +126,8 @@ CLK: 0x05f5e100
MISA: 0x40901106
XISA: 0xc0000fab
SOC: 0xffff402f
IMEM: 0x00008000 bytes @0x00000000
DMEM: 0x00002000 bytes @0x80000000
IMEM: 0x00008000
DMEM: 0x00002000
Autoboot in 8s. Press any key to abort. <1>
Aborted.

View file

@ -19,6 +19,8 @@ minimal base + privileged ISA `rv32i_zicsr` only to ensure it can work independe
[options="header", grid="rows"]
|=======================
| Parameter | Default | Legal values | Description
4+^| Memory layout
| `EXE_BASE_ADDR` | `0x00000000` | _any_ | Base address / boot address for the executable (see section <<_address_space>>)
4+^| Serial console interface
| `UART_EN` | `1` | `0`, `1` | Set to `0` to disable UART0 (no serial console at all)
| `UART_BAUD` | `19200` | _any_ | Baud rate of UART0

View file

@ -1,8 +1,8 @@
-- The NEORV32 RISC-V Processor: https://github.com/stnolting/neorv32
-- Auto-generated memory initialization file (for BOOTLOADER) from source file <bootloader/main.bin>
-- Size: 4056 bytes
-- Size: 4012 bytes
-- MARCH: default
-- Built: 27.07.2023 09:57:13
-- Built: 28.07.2023 09:12:06
-- prototype defined in 'neorv32_package.vhd'
package body neorv32_bootloader_image is
@ -40,7 +40,7 @@ x"00000e93",
x"00000f13",
x"00000f93",
x"00001597",
x"f5c58593",
x"f3058593",
x"80004617",
x"f7c60613",
x"80004697",
@ -85,26 +85,26 @@ x"00012403",
x"00412483",
x"00810113",
x"30200073",
x"fb010113",
x"04912223",
x"fc010113",
x"02912a23",
x"800004b7",
x"0004a223",
x"800007b7",
x"0007a023",
x"ffffd7b7",
x"04112623",
x"04812423",
x"05212023",
x"03312e23",
x"03412c23",
x"03512a23",
x"03612823",
x"03712623",
x"03812423",
x"03912223",
x"03a12023",
x"01b12e23",
x"a5478793",
x"02112e23",
x"02812c23",
x"03212823",
x"03312623",
x"03412423",
x"03512223",
x"03612023",
x"01712e23",
x"01812c23",
x"01912a23",
x"01a12823",
x"01b12623",
x"a3478793",
x"30579073",
x"e0802783",
x"00040737",
@ -162,10 +162,10 @@ x"ffff7637",
x"00000793",
x"5ff70713",
x"a0060613",
x"1ed76c63",
x"1ed76463",
x"00000713",
x"3fe00613",
x"1ef66c63",
x"1ef66463",
x"000106b7",
x"fff78793",
x"00679793",
@ -192,60 +192,56 @@ x"30479073",
x"00800793",
x"3007a073",
x"ffffd537",
x"dec50513",
x"6bc000ef",
x"dbc50513",
x"69c000ef",
x"f1302573",
x"640000ef",
x"620000ef",
x"ffffd537",
x"e2450513",
x"6a8000ef",
x"df450513",
x"688000ef",
x"e0002503",
x"62c000ef",
x"ffffd537",
x"e2c50513",
x"694000ef",
x"30102573",
x"618000ef",
x"ffffd537",
x"e3450513",
x"680000ef",
x"fc002573",
x"604000ef",
x"ffffd537",
x"e3c50513",
x"66c000ef",
x"e0802503",
x"ffffd437",
x"ffffd937",
x"5e8000ef",
x"ffffd537",
x"e4450513",
x"650000ef",
x"e1802503",
x"5d4000ef",
x"e4c40513",
x"640000ef",
x"e1002503",
x"5c4000ef",
x"ffffd537",
x"e5850513",
x"62c000ef",
x"e1c02503",
x"5b0000ef",
x"e4c40513",
x"61c000ef",
x"e1402503",
x"5a0000ef",
x"de890513",
x"60c000ef",
x"ffffd537",
x"dfc50513",
x"674000ef",
x"30102573",
x"5f8000ef",
x"ffffd537",
x"e0450513",
x"660000ef",
x"fc002573",
x"5e4000ef",
x"ffffd537",
x"e0c50513",
x"64c000ef",
x"e0802503",
x"00100413",
x"ffffd937",
x"5c8000ef",
x"ffffd537",
x"e1450513",
x"630000ef",
x"e0404503",
x"00a41533",
x"ffc57513",
x"5ac000ef",
x"ffffd537",
x"e1c50513",
x"614000ef",
x"e0504783",
x"00f41533",
x"ffc57513",
x"590000ef",
x"db890513",
x"5fc000ef",
x"e0802783",
x"00010737",
x"00e7f7b3",
x"04078e63",
x"ffffd537",
x"e6050513",
x"5f0000ef",
x"2c8000ef",
x"e2450513",
x"5e0000ef",
x"2b8000ef",
x"e0002403",
x"00020ab7",
x"fffffa37",
@ -262,18 +258,18 @@ x"0167f7b3",
x"0a078063",
x"ffffd537",
x"504a2783",
x"e8c50513",
x"5a4000ef",
x"e5050513",
x"594000ef",
x"ffffda37",
x"e98a0513",
x"598000ef",
x"e5ca0513",
x"588000ef",
x"fffffab7",
x"06c00b13",
x"07800c13",
x"07300c93",
x"ffffd7b7",
x"f1878513",
x"57c000ef",
x"edc78513",
x"56c000ef",
x"500aa783",
x"000106b7",
x"00d7f7b3",
@ -281,72 +277,72 @@ x"fe078ae3",
x"504aa403",
x"0ff47413",
x"00040513",
x"4cc000ef",
x"de890513",
x"554000ef",
x"4bc000ef",
x"db890513",
x"544000ef",
x"07200793",
x"06f41063",
x"ffffc2b7",
x"00028067",
x"00c686b3",
x"00178793",
x"e01ff06f",
x"e11ff06f",
x"ffe70693",
x"ffd6f693",
x"00069863",
x"0037d793",
x"00170713",
x"df5ff06f",
x"e05ff06f",
x"0017d793",
x"ff5ff06f",
x"1f0000ef",
x"1e0000ef",
x"f485e4e3",
x"00b41463",
x"f53560e3",
x"00100513",
x"738000ef",
x"de890513",
x"4f8000ef",
x"728000ef",
x"db890513",
x"4e8000ef",
x"00000513",
x"089000ef",
x"19640c63",
x"069000ef",
x"19640463",
x"028b6663",
x"06500793",
x"18f40a63",
x"18f40263",
x"06800793",
x"e98a0513",
x"e5ca0513",
x"02f40c63",
x"03f00793",
x"18f40e63",
x"18f40663",
x"ffffd537",
x"fa850513",
x"f7c50513",
x"0240006f",
x"07500793",
x"02f40263",
x"17840e63",
x"17840663",
x"ff9414e3",
x"0044a403",
x"02041063",
x"ffffd537",
x"f2050513",
x"49c000ef",
x"ee450513",
x"48c000ef",
x"f15ff06f",
x"00000513",
x"6c8000ef",
x"6b8000ef",
x"f09ff06f",
x"ffffd537",
x"f3c50513",
x"480000ef",
x"f0050513",
x"470000ef",
x"00040513",
x"404000ef",
x"3f4000ef",
x"ffffd537",
x"f4450513",
x"46c000ef",
x"f0850513",
x"45c000ef",
x"00400537",
x"3f0000ef",
x"3e0000ef",
x"ffffd537",
x"f5c50513",
x"458000ef",
x"f2050513",
x"448000ef",
x"fffff737",
x"00010637",
x"50072783",
@ -355,49 +351,45 @@ x"fe078ce3",
x"50472983",
x"0ff9f993",
x"00098513",
x"3a4000ef",
x"394000ef",
x"07900793",
x"eaf994e3",
x"2b0000ef",
x"2a0000ef",
x"00050663",
x"00300513",
x"474000ef",
x"464000ef",
x"ffffd537",
x"f6850513",
x"410000ef",
x"f2c50513",
x"400000ef",
x"01045b93",
x"004009b7",
x"00010db7",
x"fff00d13",
x"230000ef",
x"154000ef",
x"220000ef",
x"144000ef",
x"0d800513",
x"0f8000ef",
x"0e8000ef",
x"00098513",
x"108000ef",
x"0d8000ef",
x"234000ef",
x"0f8000ef",
x"0c8000ef",
x"224000ef",
x"00157513",
x"fe051ce3",
x"fffb8b93",
x"01b989b3",
x"fdab98e3",
x"e1002683",
x"004009b7",
x"00000d13",
x"00000d93",
x"00c98793",
x"00dd0733",
x"00072583",
x"000d2583",
x"00fd0533",
x"00d12623",
x"00bd8db3",
x"27c000ef",
x"004007b7",
x"004d0d13",
x"00c12683",
x"00bd8db3",
x"274000ef",
x"004007b7",
x"00c78793",
x"fc8d6ce3",
x"fe8d62e3",
x"4788d5b7",
x"afe58593",
x"00400537",
@ -409,20 +401,20 @@ x"00898513",
x"41b005b3",
x"240000ef",
x"ffffd537",
x"dd050513",
x"ebdff06f",
x"da050513",
x"ecdff06f",
x"00100513",
x"ec1ff06f",
x"ed1ff06f",
x"0044a783",
x"e4079ae3",
x"e60792e3",
x"ffffd537",
x"f7850513",
x"ea1ff06f",
x"f3c50513",
x"eb1ff06f",
x"00100513",
x"e45ff06f",
x"e55ff06f",
x"ffffd537",
x"f8850513",
x"e8dff06f",
x"f4c50513",
x"e9dff06f",
x"fffff737",
x"40472583",
x"40072503",
@ -608,7 +600,7 @@ x"07800513",
x"ffffd4b7",
x"fb9ff0ef",
x"01c00413",
x"fb448493",
x"f8848493",
x"ffc00993",
x"008957b3",
x"00f7f793",
@ -650,13 +642,13 @@ x"ff010113",
x"00812423",
x"00050413",
x"ffffd537",
x"d8850513",
x"d5850513",
x"00112623",
x"f91ff0ef",
x"00241793",
x"ffffd537",
x"008787b3",
x"fc450513",
x"f9850513",
x"00f50533",
x"f79ff0ef",
x"00800793",
@ -748,7 +740,7 @@ x"00020737",
x"00e7f7b3",
x"04078263",
x"ffffd537",
x"d9050513",
x"d6050513",
x"e0dff0ef",
x"00048513",
x"d91ff0ef",
@ -761,7 +753,7 @@ x"d5dff0ef",
x"34302573",
x"d71ff0ef",
x"ffffd537",
x"de850513",
x"db850513",
x"dd9ff0ef",
x"00440413",
x"34141073",
@ -778,60 +770,58 @@ x"01312e23",
x"01412c23",
x"01512a23",
x"01712623",
x"01812423",
x"00fb2023",
x"00050413",
x"02051863",
x"ffffd537",
x"d9c50513",
x"d81ff0ef",
x"d6c50513",
x"d85ff0ef",
x"004005b7",
x"00040513",
x"ae9ff0ef",
x"aedff0ef",
x"4788d7b7",
x"afe78793",
x"04f50863",
x"00000513",
x"0380006f",
x"ffffd537",
x"dbc50513",
x"d55ff0ef",
x"d8c50513",
x"d59ff0ef",
x"00400537",
x"cd9ff0ef",
x"cddff0ef",
x"ffffd537",
x"dc850513",
x"d41ff0ef",
x"d9850513",
x"d45ff0ef",
x"e0802783",
x"00040737",
x"00e7f7b3",
x"00079663",
x"00300513",
x"d81ff0ef",
x"badff0ef",
x"d85ff0ef",
x"bb1ff0ef",
x"fa0502e3",
x"ff1ff06f",
x"004009b7",
x"00498593",
x"00040513",
x"a81ff0ef",
x"a85ff0ef",
x"00050a13",
x"00898593",
x"00040513",
x"a71ff0ef",
x"e1002c03",
x"a75ff0ef",
x"00050a93",
x"ffca7b93",
x"00000913",
x"00000493",
x"00c98993",
x"013905b3",
x"05791c63",
x"05791a63",
x"015484b3",
x"00200513",
x"fa0494e3",
x"fa0496e3",
x"ffffd537",
x"dd050513",
x"cc5ff0ef",
x"da050513",
x"ccdff0ef",
x"02c12083",
x"02812403",
x"800007b7",
@ -844,32 +834,30 @@ x"01812a03",
x"01412a83",
x"01012b03",
x"00c12b83",
x"00812c03",
x"03010113",
x"00008067",
x"00040513",
x"9f5ff0ef",
x"012c07b3",
x"a01ff0ef",
x"00a92023",
x"00a484b3",
x"00a7a023",
x"00490913",
x"f8dff06f",
x"f95ff06f",
x"ff010113",
x"00112623",
x"00812423",
x"00800793",
x"3007b073",
x"e1002403",
x"00000413",
x"00050463",
x"e0400437",
x"ffffd537",
x"dd450513",
x"c41ff0ef",
x"da450513",
x"c51ff0ef",
x"00040513",
x"bc5ff0ef",
x"bd5ff0ef",
x"ffffd537",
x"de450513",
x"c2dff0ef",
x"db450513",
x"c3dff0ef",
x"fffff737",
x"50072783",
x"fe07cee3",
@ -909,7 +897,7 @@ x"0a3e3e20",
x"444c420a",
x"4a203a56",
x"32206c75",
x"30322037",
x"30322038",
x"480a3332",
x"203a5657",
x"00000020",
@ -923,9 +911,6 @@ x"434f530a",
x"0020203a",
x"454d490a",
x"00203a4d",
x"74796220",
x"40207365",
x"00000000",
x"454d440a",
x"00203a4d",
x"7475410a",
@ -1002,14 +987,18 @@ x"65206f4e",
x"75636578",
x"6c626174",
x"00002e65",
x"68746967",
x"632e6275",
x"732f6d6f",
x"6c6f6e74",
x"676e6974",
x"6f656e2f",
x"32337672",
x"00000000",
x"53207962",
x"68706574",
x"4e206e61",
x"69746c6f",
x"670a676e",
x"75687469",
x"6f632e62",
x"74732f6d",
x"746c6f6e",
x"2f676e69",
x"726f656e",
x"00323376",
x"61766e49",
x"2064696c",
x"00444d43",

View file

@ -49,6 +49,13 @@
**************************************************************************/
/**@{*/
/* -------- Memory layout -------- */
/** Memory base address for the executable */
#ifndef EXE_BASE_ADDR
#define EXE_BASE_ADDR 0x00000000UL
#endif
/* -------- UART interface -------- */
/** Set to 0 to disable UART interface */
@ -324,7 +331,7 @@ int main(void) {
// Show bootloader intro and system info
// ------------------------------------------------
PRINT_TEXT("\n\n\n<< NEORV32 Bootloader >>\n\n"
"BLDV: "__DATE__"\nHWV: ");
"BLDV: "__DATE__"\nHWV: ");
PRINT_XNUM(neorv32_cpu_csr_read(CSR_MIMPID));
PRINT_TEXT("\nCLK: ");
PRINT_XNUM(NEORV32_SYSINFO->CLK);
@ -335,12 +342,9 @@ int main(void) {
PRINT_TEXT("\nSOC: ");
PRINT_XNUM(NEORV32_SYSINFO->SOC);
PRINT_TEXT("\nIMEM: ");
PRINT_XNUM(NEORV32_SYSINFO->IMEM_SIZE); PRINT_TEXT(" bytes @");
PRINT_XNUM(NEORV32_SYSINFO->ISPACE_BASE);
PRINT_XNUM((uint32_t)(1 << NEORV32_SYSINFO->MEM[SYSINFO_MEM_IMEM]) & 0xFFFFFFFCUL);
PRINT_TEXT("\nDMEM: ");
PRINT_XNUM(NEORV32_SYSINFO->DMEM_SIZE);
PRINT_TEXT(" bytes @");
PRINT_XNUM(NEORV32_SYSINFO->DSPACE_BASE);
PRINT_XNUM((uint32_t)(1 << NEORV32_SYSINFO->MEM[SYSINFO_MEM_DMEM]) & 0xFFFFFFFCUL);
PRINT_TEXT("\n");
@ -425,7 +429,7 @@ int main(void) {
}
#endif
else if (c == '?') {
PRINT_TEXT("github.com/stnolting/neorv32");
PRINT_TEXT("by Stephan Nolting\ngithub.com/stnolting/neorv32");
}
else { // unknown command
PRINT_TEXT("Invalid CMD");
@ -467,7 +471,7 @@ void start_app(int boot_xip) {
// deactivate global IRQs
neorv32_cpu_csr_clr(CSR_MSTATUS, 1 << CSR_MSTATUS_MIE);
register uint32_t app_base = NEORV32_SYSINFO->ISPACE_BASE; // default = start at beginning of IMEM
register uint32_t app_base = (uint32_t)EXE_BASE_ADDR; // default = start at beginning of IMEM
#if (XIP_EN != 0)
if (boot_xip) {
app_base = (uint32_t)(XIP_MEM_BASE_ADDRESS + SPI_BOOT_BASE_ADDR); // start from XIP mapped address
@ -576,7 +580,7 @@ void get_exe(int src) {
uint32_t check = get_exe_word(src, addr + EXE_OFFSET_CHECKSUM); // complement sum checksum
// transfer program data
uint32_t *pnt = (uint32_t*)NEORV32_SYSINFO->ISPACE_BASE;
uint32_t *pnt = (uint32_t*)EXE_BASE_ADDR;
uint32_t checksum = 0;
uint32_t d = 0, i = 0;
addr = addr + EXE_OFFSET_DATA;
@ -646,7 +650,7 @@ void save_exe(void) {
// store data from instruction memory and update checksum
uint32_t checksum = 0;
uint32_t *pnt = (uint32_t*)NEORV32_SYSINFO->ISPACE_BASE;
uint32_t *pnt = (uint32_t*)EXE_BASE_ADDR;
addr = addr + EXE_OFFSET_DATA;
uint32_t i = 0;
while (i < size) { // in chunks of 4 bytes