Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [sw] fixed bug in bootloader's (M)TIME handling #267

Merged
merged 7 commits into from
Feb 1, 2022

Conversation

stnolting
Copy link
Owner

This PR fixes a bug in the bootloader's handling of the system time timer (MTIME), which is used the generate the blinking status LED and the "autoboot timeout".

The bootloader used the time[h] CSRs to access the current system time (these CSRs are driven by the MTIME unit). If the Zicntr ISA extensions is not enabled ( = time[h], cycle[h] and instret[h] CSRs not available) the bootloader crashed.

A second (minor) bug has also been fixed: when using the MTIME for generating precise timer interrupts, the interrupt handler has to update the MTIME.TIMECMP value. This has to be done by adding a fixed amount of cycles (= the time between interrupts) to the MTIME.TIMECMP value itself. To illustrate this issue, a demo program for the RISC-V machine timer MTIME has been added to sw/example/demo_mtime.

@stnolting stnolting added bug Something isn't working SW software-related labels Jan 31, 2022
@stnolting stnolting self-assigned this Jan 31, 2022
recompiled due to bugs in bootloader sources
do not use time CSRs as they might no be available (no Zicntr ISA extension)
recompiled due to bugs in neorv32_cpu_delay_ms function
bug-fix in bootloader's (M)TIME handling
@stnolting stnolting marked this pull request as ready for review January 31, 2022 08:00
@stnolting stnolting merged commit aa9fd0d into master Feb 1, 2022
@stnolting stnolting deleted the bootloader_mtime_fix branch February 1, 2022 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SW software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant