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

Issue in flash_program.c example #510

Open
lautisilber opened this issue Aug 8, 2024 · 3 comments · May be fixed by #545
Open

Issue in flash_program.c example #510

lautisilber opened this issue Aug 8, 2024 · 3 comments · May be fixed by #545
Assignees

Comments

@lautisilber
Copy link

The functions flash_range_erase and flash_range_program are run without being surrounded by a

uint32_t interrupts = save_and_disable_interrupts();

...

restore_interrupts(interrupts);

block and in my tests, the program crashes without these.

(I'm sorry. This is my first time rising an issue. If this behaviour is excepted or my testing is wrong, sorry for the inconvenience)

@peterharperuk peterharperuk self-assigned this Aug 9, 2024
@peterharperuk
Copy link
Contributor

You are correct that if the processor is likely to run any code from flash when calling these functions, then they will cause a crash. However this program isn't doing anything else and so doesn't crash. Did you really reproduce a crash running this example?! Anyway - I will improve the example with some comments so anyone copying the code is aware of the problem.

peterharperuk added a commit to peterharperuk/pico-examples that referenced this issue Sep 3, 2024
Although it's not required in this example, demonstrate how to call
flash function using flash_safe_execute

Fixes raspberrypi#510
@peterharperuk peterharperuk linked a pull request Sep 3, 2024 that will close this issue
@lautisilber
Copy link
Author

lautisilber commented Sep 3, 2024

The demo run just fine. Only when I tried to copy paste it into a larger project it crashed without those lines. Sorry for the inconvenience and thank you for listening :)

Edit: The new demo is super clean!

@peterharperuk
Copy link
Contributor

I think you're right that we should fix the example to show the proper way to do things. So I've reopened the issue and I'll update the example

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