[bootloader] use CLINT instead of MTIME

This commit is contained in:
stnolting 2024-12-26 23:26:34 +01:00
parent 990088f060
commit d1e48b24fb
2 changed files with 106 additions and 105 deletions

View file

@ -1,7 +1,7 @@
-- The NEORV32 RISC-V Processor - github.com/stnolting/neorv32
-- Auto-generated memory initialization image (for internal BOOTROM)
-- Source: bootloader/build/main.bin
-- Built: 23.12.2024 21:24:24
-- Built: 26.12.2024 22:34:02
library ieee;
use ieee.std_logic_1164.all;
@ -11,7 +11,7 @@ use neorv32.neorv32_package.all;
package neorv32_bootloader_image is
constant bootloader_init_size_c : natural := 3960; -- bytes
constant bootloader_init_size_c : natural := 3964; -- bytes
constant bootloader_init_image_c : mem32_t := (
x"000020b7",
x"80008093",
@ -31,7 +31,7 @@ x"00000393",
x"00000413",
x"00000493",
x"00001597",
x"f3458593",
x"f3858593",
x"80200617",
x"fb460613",
x"80200697",
@ -82,7 +82,7 @@ x"ffe017b7",
x"00112823",
x"00812623",
x"00912423",
x"9d878793",
x"9dc78793",
x"30579073",
x"fffe07b7",
x"0087a783",
@ -120,7 +120,7 @@ x"000016b7",
x"60068693",
x"00d76733",
x"00e7a023",
x"46c000ef",
x"488000ef",
x"00050a63",
x"fffc07b7",
x"00100713",
@ -135,10 +135,10 @@ x"0007a683",
x"5ff70713",
x"00000793",
x"a0060613",
x"1ed76e63",
x"20d76063",
x"00000713",
x"3fe00613",
x"1ef66e63",
x"20f66063",
x"fff78793",
x"00679793",
x"01079793",
@ -149,72 +149,73 @@ x"00e7e7b3",
x"0017e793",
x"fff50737",
x"00f72023",
x"fffe0737",
x"00872783",
x"00f79693",
x"0206d863",
x"fff407b7",
x"0007a023",
x"0007a223",
x"00072703",
x"00275713",
x"00e7a423",
x"0007a623",
x"fffe07b7",
x"0087a703",
x"00f71693",
x"0206da63",
x"fff4c737",
x"fe072c23",
x"fe072c23",
x"0007a783",
x"fff44737",
x"0027d793",
x"00f72023",
x"00072223",
x"08000793",
x"30479073",
x"00800793",
x"3007a073",
x"ffe01537",
x"d4850513",
x"d4c50513",
x"6c8000ef",
x"f1302573",
x"65c000ef",
x"ffe01537",
x"d8050513",
x"d8450513",
x"6b4000ef",
x"fffe0437",
x"00042503",
x"644000ef",
x"ffe01537",
x"d8850513",
x"d8c50513",
x"69c000ef",
x"30102573",
x"630000ef",
x"ffe01537",
x"d9050513",
x"d9450513",
x"688000ef",
x"fc002573",
x"61c000ef",
x"ffe01537",
x"d9850513",
x"d9c50513",
x"674000ef",
x"00842503",
x"00100493",
x"604000ef",
x"ffe01537",
x"da050513",
x"da450513",
x"65c000ef",
x"00444503",
x"00a49533",
x"ffc57513",
x"5e8000ef",
x"ffe01537",
x"da850513",
x"dac50513",
x"640000ef",
x"00544783",
x"00f49533",
x"ffc57513",
x"5cc000ef",
x"ffe014b7",
x"d4448513",
x"d4848513",
x"624000ef",
x"00842783",
x"00f79713",
x"06075063",
x"ffe01537",
x"db050513",
x"db450513",
x"60c000ef",
x"308000ef",
x"2f4000ef",
x"00042703",
x"00271413",
x"00e40433",
@ -232,13 +233,13 @@ x"00f69613",
x"0a065863",
x"ffe01537",
x"00472783",
x"ddc50513",
x"de050513",
x"5bc000ef",
x"ffe017b7",
x"de878513",
x"dec78513",
x"5b0000ef",
x"ffe01537",
x"e6850513",
x"e6c50513",
x"5a4000ef",
x"fff507b7",
x"0007a703",
@ -248,7 +249,7 @@ x"0047a403",
x"0ff47413",
x"00040513",
x"508000ef",
x"d4448513",
x"d4848513",
x"57c000ef",
x"03f00793",
x"24f40a63",
@ -257,31 +258,31 @@ x"0ff47413",
x"01300793",
x"2287e863",
x"ffe017b7",
x"f0478793",
x"f0878793",
x"00241413",
x"00f40433",
x"00042783",
x"00078067",
x"00c686b3",
x"00178793",
x"dfdff06f",
x"df9ff06f",
x"ffe70693",
x"ffd6f693",
x"00069863",
x"0037d793",
x"00170713",
x"df1ff06f",
x"dedff06f",
x"0017d793",
x"ff5ff06f",
x"00f12023",
x"218000ef",
x"204000ef",
x"00012783",
x"f285e4e3",
x"00b41463",
x"f2f560e3",
x"00100513",
x"6f8000ef",
x"d4448513",
x"d4848513",
x"4f8000ef",
x"00000513",
x"031000ef",
@ -294,20 +295,20 @@ x"800007b7",
x"0047a403",
x"00041863",
x"ffe01537",
x"e7050513",
x"e7450513",
x"f15ff06f",
x"ffe01537",
x"e8c50513",
x"e9050513",
x"4b8000ef",
x"00040513",
x"44c000ef",
x"ffe01537",
x"e9450513",
x"e9850513",
x"4a4000ef",
x"00400537",
x"438000ef",
x"ffe01537",
x"eac50513",
x"eb050513",
x"490000ef",
x"fff507b7",
x"0007a703",
@ -325,7 +326,7 @@ x"00050663",
x"00300513",
x"4a4000ef",
x"ffe01537",
x"eb850513",
x"ebc50513",
x"448000ef",
x"01045793",
x"00178793",
@ -363,7 +364,7 @@ x"00850513",
x"40e005b3",
x"2b4000ef",
x"ffe01537",
x"d2c50513",
x"d3050513",
x"e01ff06f",
x"00f12223",
x"1f8000ef",
@ -389,31 +390,31 @@ x"800007b7",
x"0047a783",
x"e60790e3",
x"ffe01537",
x"ec850513",
x"ecc50513",
x"d99ff06f",
x"fffe07b7",
x"0087a783",
x"2007f793",
x"00079863",
x"ffe01537",
x"ed850513",
x"edc50513",
x"d7dff06f",
x"00100513",
x"e35ff06f",
x"ffe01537",
x"ee450513",
x"ee850513",
x"d69ff06f",
x"fff4c7b7",
x"ffc7a583",
x"ff87a503",
x"ffc7a703",
x"fee59ae3",
x"00008067",
x"fffe07b7",
x"0087a503",
x"00f55513",
x"00157513",
x"00008067",
x"fff407b7",
x"0047a583",
x"0007a503",
x"0047a703",
x"fee59ae3",
x"00008067",
x"fff807b7",
x"0007a703",
x"00c71693",
@ -588,7 +589,7 @@ x"01c00493",
x"00945733",
x"ffe017b7",
x"00f77713",
x"f5478793",
x"f5878793",
x"00e787b3",
x"0007c503",
x"ffc48493",
@ -624,18 +625,18 @@ x"ff810113",
x"00812023",
x"00050413",
x"ffe01537",
x"cd450513",
x"cd850513",
x"00112223",
x"f99ff0ef",
x"00241793",
x"ffe01537",
x"008787b3",
x"f6450513",
x"f6850513",
x"00f50533",
x"f81ff0ef",
x"00800793",
x"3007b073",
x"c61ff0ef",
x"c79ff0ef",
x"00050a63",
x"fffc07b7",
x"00100713",
@ -660,7 +661,7 @@ x"342024f3",
x"800007b7",
x"00778793",
x"08f49863",
x"bfdff0ef",
x"c15ff0ef",
x"00050a63",
x"fffc0737",
x"00872783",
@ -670,17 +671,17 @@ x"fffe0437",
x"00842783",
x"00f79713",
x"02075863",
x"be9ff0ef",
x"bd5ff0ef",
x"00042783",
x"fff40737",
x"fff44737",
x"fff00693",
x"0027d793",
x"00a78533",
x"00f537b3",
x"00d72423",
x"00d72023",
x"00b787b3",
x"00f72623",
x"00a72423",
x"00f72223",
x"00a72023",
x"01c12403",
x"02c12083",
x"02812283",
@ -708,7 +709,7 @@ x"0087a783",
x"00e79713",
x"04075263",
x"ffe01537",
x"cdc50513",
x"ce050513",
x"e4dff0ef",
x"00048513",
x"de1ff0ef",
@ -721,7 +722,7 @@ x"db1ff0ef",
x"34302573",
x"dc1ff0ef",
x"ffe01537",
x"d4450513",
x"d4850513",
x"e19ff0ef",
x"00440413",
x"34141073",
@ -736,7 +737,7 @@ x"00a12023",
x"00f4a023",
x"02051863",
x"ffe01537",
x"ce850513",
x"cec50513",
x"dddff0ef",
x"00012503",
x"004005b7",
@ -747,12 +748,12 @@ x"04f50863",
x"00000513",
x"0380006f",
x"ffe01537",
x"d0850513",
x"d0c50513",
x"db1ff0ef",
x"00400537",
x"d45ff0ef",
x"ffe01537",
x"d2450513",
x"d2850513",
x"d9dff0ef",
x"fffe07b7",
x"0087a783",
@ -784,7 +785,7 @@ x"00d787b3",
x"00200513",
x"fa0792e3",
x"ffe01537",
x"d2c50513",
x"d3050513",
x"d1dff0ef",
x"800007b7",
x"0087a223",
@ -818,14 +819,14 @@ x"40a00533",
x"e0400437",
x"00a47433",
x"ffe01537",
x"d3050513",
x"d3450513",
x"c95ff0ef",
x"00040513",
x"c29ff0ef",
x"ffe01537",
x"d4050513",
x"d4450513",
x"c81ff0ef",
x"969ff0ef",
x"981ff0ef",
x"00050863",
x"fffc07b7",
x"0007a423",
@ -873,7 +874,7 @@ x"0a3e3e20",
x"444c420a",
x"44203a56",
x"32206365",
x"30322033",
x"30322036",
x"480a3432",
x"203a5657",
x"00000020",
@ -974,26 +975,26 @@ x"676e6974",
x"6f656e2f",
x"32337672",
x"00000000",
x"ffe005d0",
x"ffe005f8",
x"ffe005f8",
x"ffe00374",
x"ffe005f8",
x"ffe005f8",
x"ffe005f8",
x"ffe005c8",
x"ffe005f8",
x"ffe005f8",
x"ffe005f8",
x"ffe005f8",
x"ffe005f8",
x"ffe00440",
x"ffe00454",
x"ffe005f8",
x"ffe00448",
x"ffe005f8",
x"ffe005f8",
x"ffe005e8",
x"ffe005d4",
x"ffe005fc",
x"ffe005fc",
x"ffe00378",
x"ffe005fc",
x"ffe005fc",
x"ffe005fc",
x"ffe005cc",
x"ffe005fc",
x"ffe005fc",
x"ffe005fc",
x"ffe005fc",
x"ffe005fc",
x"ffe00444",
x"ffe00458",
x"ffe005fc",
x"ffe0044c",
x"ffe005fc",
x"ffe005fc",
x"ffe005ec",
x"33323130",
x"37363534",
x"62613938",

View file

@ -279,13 +279,13 @@ int main(void) {
#endif
#endif
// Configure machine system timer interrupt
if (neorv32_mtime_available()) {
NEORV32_MTIME->TIME_LO = 0;
NEORV32_MTIME->TIME_HI = 0;
NEORV32_MTIME->TIMECMP_LO = NEORV32_SYSINFO->CLK/4;
NEORV32_MTIME->TIMECMP_HI = 0;
neorv32_cpu_csr_write(CSR_MIE, 1 << CSR_MIE_MTIE); // activate MTIME IRQ source
// Configure CLINT timer interrupt
if (neorv32_clint_available()) {
NEORV32_CLINT->MTIME.uint32[0] = 0;
NEORV32_CLINT->MTIME.uint32[0] = 0;
NEORV32_CLINT->MTIMECMP[0].uint32[0] = NEORV32_SYSINFO->CLK/4;
NEORV32_CLINT->MTIMECMP[0].uint32[1] = 0;
neorv32_cpu_csr_write(CSR_MIE, 1 << CSR_MIE_MTIE); // activate timer IRQ source
neorv32_cpu_csr_set(CSR_MSTATUS, 1 << CSR_MSTATUS_MIE); // enable machine-mode interrupts
}
@ -316,10 +316,10 @@ int main(void) {
// ------------------------------------------------
#if (SPI_EN != 0)
#if (AUTO_BOOT_TIMEOUT != 0)
if (neorv32_mtime_available()) {
if (neorv32_clint_available()) {
PRINT_TEXT("\nAutoboot in "xstr(AUTO_BOOT_TIMEOUT)"s. Press any key to abort.\n");
uint64_t timeout_time = neorv32_mtime_get_time() + (uint64_t)(AUTO_BOOT_TIMEOUT * NEORV32_SYSINFO->CLK);
uint64_t timeout_time = neorv32_clint_time_get() + (uint64_t)(AUTO_BOOT_TIMEOUT * NEORV32_SYSINFO->CLK);
while(1){
@ -330,7 +330,7 @@ int main(void) {
}
}
if (neorv32_mtime_get_time() >= timeout_time) { // timeout? start auto boot sequence
if (neorv32_clint_time_get() >= timeout_time) { // timeout? start auto boot sequence
get_exe(EXE_STREAM_FLASH); // try booting from flash
PRINT_TEXT("\n");
start_app(0);
@ -469,7 +469,7 @@ void start_app(int boot_xip) {
/**********************************************************************//**
* Bootloader trap handler. Used for the MTIME tick and to capture any other traps.
* Bootloader trap handler. Used for the CLINT timer tick and to capture any other traps.
*
* @note Since we have no runtime environment we have to use the interrupt attribute here.
**************************************************************************/
@ -485,8 +485,8 @@ void __attribute__((interrupt("machine"))) bootloader_trap_handler(void) {
}
#endif
// set time for next IRQ
if (neorv32_mtime_available()) {
neorv32_mtime_set_timecmp(neorv32_mtime_get_time() + (NEORV32_SYSINFO->CLK/4));
if (neorv32_clint_available()) {
neorv32_clint_mtimecmp_set(0, neorv32_clint_time_get() + (NEORV32_SYSINFO->CLK/4));
}
}