Quantcast
Channel: Raspberry Pi Forums
Viewing full articles (7807 articles)
Browse article index
↧

SDK • pico writing flash and using usb to printf

$
0
0
Hello,

I made the subject hoping it might help the one person who had the same problem.

Basically, I spent two days trying to write, erase, and read the last sector of the flash, but had no luck. My program would freeze on the erase function.

According to the SDK documentation, I tried:

Code:

        uint32_t interrupts = save_and_disable_interrupts();        multicore_lockout_start_blocking ();        flash_range_erase(WIFI_FLASH_OFFSET, FLASH_SECTOR_SIZE);        multicore_lockout_end_blocking();        restore_interrupts(interrupts);
I also tried different variations with sleep_ms(), but nothing helped. Even the SDK templates and examples were not working for me.
flash_safe_execute was not cutting it either

In the end, I found that the problem was related to stdio/USB output. You either need to disable USB output, not initialize it at all, or call stdio_flush() before performing the flash operation.

For me, this worked:

Code:

        stdio_flush();        uint32_t interrupts = save_and_disable_interrupts();        multicore_lockout_start_blocking ();        flash_range_erase(WIFI_FLASH_OFFSET, FLASH_SECTOR_SIZE);        multicore_lockout_end_blocking();        restore_interrupts(interrupts);
Hopefully this helps someone else who runs into the same issue.

Statistics: Posted by maciulex — Sat Aug 29, 2026 1:01 am — Replies 0 — Views 22


↧

Viewing full articles (7807 articles)
Browse article index

Latest Images

Trending Articles



Latest Images