Add multicore "lockout" example.
Many of my pico projects store a "config" structure in the last 4k page of the flash.
I have one project where I use the second core for an important task. But when I wrote that, I of course tried locking out the other core as I'm supposed to, but it only crashed. So I had to resort to resetting the other core and simply rebooting after a flash write (to restart the other core).
Somehow, when I tried this yesterday again to do it the proper way it simply worked. But along the way... I couldn't find any easy example of how it was supposed to work.
My suggestion is to make an example, that counts on core 0 (about once per second), writes the current count to the last page in flash every 10 times, and does something else on core 1, so that core 1 needs to be "locked out".
If you think this is a good idea, I could write the example, and issue a pull request.
Many of my pico projects store a "config" structure in the last 4k page of the flash.
I assume you mean btstack. Yes, it would be good to have an example. We should probably have a specific example for bluetooth.
No, I don't think I mean btstack. I've not yet used the bluetooth option of the pico-W.
In my case the project is doing Ethernet (the wired stuff!) on the second core. But IMHO it doesn't matter what the second core is doing, we want to be able to write-to-flash on the first core when the second core is active. And a good example would help. (I wrote most of that 2 days ago, but didn't finish and forgot to hit 'comment'... )
I misread your comment. Be aware that picotool uses the last page on RP2350 to workaround errata RP2350-E10. And btstack uses the last two sectors (on rp2040) or the two sectors before the last sector (on rp2350 to avoid that errata workaround)
Oh, sigh! I was misreading your comment as well! OK. So, after I had decided to use the last 4k page, you guys change stuff to overwrite my config structure! You bastards! :-)
OK. So in the future I should store my config to "first page after 16k before end-of-flash".
A page is 256 bytes which is the minimum size that can be written to flash. A sector is 4096 bytes and is the minimum size that can be erased. 1/ picotool uses the last page. 2/ btstack avoids the whole last sector and uses the next two sectors. So you could get away with avoiding 4096*3 bytes from the end of flash.
Ok. Yeah, to me the "min erase size" is what I consider a page, not conforming to the flash-world terminology.
So my config will go from xxxC000 to xxxCFFF, I reserve 4k because that's what I can erase, it is difficult to have "other stuff" in there that I need to read, store and program back, so for ease of programming, 4k is the smallest unit. That's why I first put my data at end-of-flash minus 4k. So in the future I'll change that to end-of-flash minus 16k.
My config structure has not exceeded 100 bytes on any of my projects. wasting 3.9k when there is 1M available is one of my hobbies.