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

Set up VTOR as early as possible, on startup #3

Open
EitanTal opened this issue Dec 5, 2022 · 2 comments · May be fixed by #4
Open

Set up VTOR as early as possible, on startup #3

EitanTal opened this issue Dec 5, 2022 · 2 comments · May be fixed by #4

Comments

@EitanTal
Copy link

EitanTal commented Dec 5, 2022

ROM bootloader (in STM32L476VG, at least), will not necessarily alias buffer at memory address 0x0 to the correct bank flash (or the even the flash at all)

By default, the value in the register SCB->VTOR is zero, meaning you rely on the bootloader to correctly alias the flash bank for you, which may not happen. If you leave it at zero, you could end up with someone else's interrupt vector table.

I suggest doing this: SCB->VTOR = 0x08000000;

/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

@EitanTal
Copy link
Author

EitanTal commented Dec 5, 2022

Worse yet, because the two firmware images are essentially identical, you could end up with the other firmware's interrupt vector table and use it successfully without even knowing it. But when a real firmware upgrade comes, the interrupt tables will no longer match. Classic example of what worked in the lab, didn't work in the field

@barafael barafael linked a pull request Dec 6, 2022 that will close this issue
@barafael
Copy link
Owner

barafael commented Dec 6, 2022

Thanks for sharing your insight about this!
I fixed it as you suggested, but do not currently have any way to test whether this even compiles (STM32CubeIDE refusing to import this project). Until I can confirm this works, I'll leave this issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants