mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-24 14:17:51 -04:00
🐛 [sw/bootloader] fixed bug in bootloader's (M)TIME handling
This commit is contained in:
parent
8d02a57749
commit
2b06872fbf
1 changed files with 6 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
// # ********************************************************************************************* #
|
||||
// # BSD 3-Clause License #
|
||||
// # #
|
||||
// # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
||||
// # Copyright (c) 2022, Stephan Nolting. All rights reserved. #
|
||||
// # #
|
||||
// # Redistribution and use in source and binary forms, with or without modification, are #
|
||||
// # permitted provided that the following conditions are met: #
|
||||
|
@ -331,9 +331,9 @@ int main(void) {
|
|||
neorv32_uart0_setup(UART_BAUD, PARITY_NONE, FLOW_CONTROL_NONE);
|
||||
#endif
|
||||
|
||||
// Configure machine system timer interrupt for ~2Hz
|
||||
// Configure machine system timer interrupt
|
||||
if (neorv32_mtime_available()) {
|
||||
neorv32_mtime_set_timecmp(neorv32_cpu_get_systime() + (NEORV32_SYSINFO.CLK/4));
|
||||
neorv32_mtime_set_timecmp(0 + (NEORV32_SYSINFO.CLK/4));
|
||||
// active timer IRQ
|
||||
neorv32_cpu_csr_write(CSR_MIE, 1 << CSR_MIE_MTIE); // activate MTIME IRQ source only!
|
||||
neorv32_cpu_eint(); // enable global interrupts
|
||||
|
@ -372,7 +372,7 @@ int main(void) {
|
|||
if (neorv32_mtime_available()) {
|
||||
|
||||
PRINT_TEXT("\n\nAutoboot in "xstr(AUTO_BOOT_TIMEOUT)"s. Press key to abort.\n");
|
||||
uint64_t timeout_time = neorv32_cpu_get_systime() + (uint64_t)(AUTO_BOOT_TIMEOUT * NEORV32_SYSINFO.CLK);
|
||||
uint64_t timeout_time = neorv32_mtime_get_time() + (uint64_t)(AUTO_BOOT_TIMEOUT * NEORV32_SYSINFO.CLK);
|
||||
|
||||
while(1){
|
||||
|
||||
|
@ -382,7 +382,7 @@ int main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (neorv32_cpu_get_systime() >= timeout_time) { // timeout? start auto boot sequence
|
||||
if (neorv32_mtime_get_time() >= timeout_time) { // timeout? start auto boot sequence
|
||||
get_exe(EXE_STREAM_FLASH); // try booting from flash
|
||||
PRINT_TEXT("\n");
|
||||
start_app();
|
||||
|
@ -504,7 +504,7 @@ void __attribute__((__interrupt__)) bootloader_trap_handler(void) {
|
|||
#endif
|
||||
// set time for next IRQ
|
||||
if (neorv32_mtime_available()) {
|
||||
neorv32_mtime_set_timecmp(neorv32_cpu_get_systime() + (NEORV32_SYSINFO.CLK/4));
|
||||
neorv32_mtime_set_timecmp(neorv32_mtime_get_timecmp() + (NEORV32_SYSINFO.CLK/4));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue