Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4804

SDK • multicore_lockout_start_blocking() does not return

$
0
0
Hello!

I'm using an RP2040 to drive an 65c02 processor and call this a computer. Code is available on github.

This implements a mass storage device using the Pico's flash as backend. However, this implementation has a race condition when writing. To make sure that the write will not be interfered, I used code discussed in this forum.

This code runs on core1 (src/rp2040/native/dhara_flash.c):

Code:

   uint32_t interrupts = save_and_disable_interrupts();   multicore_lockout_start_blocking();  // <- this does not return   flash_range_program( FLASH_DRIVE_OFFSET + (p*PAGE_SIZE), data, PAGE_SIZE );   multicore_lockout_end_blocking();   restore_interrupts( interrupts );
Core0 had executed "multicore_lockout_victim_init();"

Running it in VSCode with a debug probe and breaking during the lockup has shown the following callstack:

Code:

cancel_alarm@0x100055a4 (.../pico-sdk/src/common/pico_time/include/pico/time.h:681)best_effort_wfe_or_timeout@0x10005730 (.../pico-sdk/src/common/pico_time/time.c:460)multicore_fifo_pop_timeout_us@0x1000aac2 (.../pico-sdk/src/rp2_common/pico_multicore/multicore.c:62)multicore_lockout_handshake@0x1000ab50 (.../pico-sdk/src/rp2_common/pico_multicore/multicore.c:256)multicore_lockout_start_block_until@0x1000aba6 (.../pico-sdk/src/rp2_common/pico_multicore/multicore.c:273)multicore_lockout_start_blocking@0x1000ad78 (.../pico-sdk/src/rp2_common/pico_multicore/multicore.c:284)dhara_nand_prog@0x100045e2 (.../github/src/rp2040/native/dhara_flash.c:248)dhara_journal_enqueue@0x10002734 (.../github/src/rp2040/dhara/journal.c:836)dhara_map_write@0x10002e58 (.../github/src/rp2040/dhara/map.c:359)dhara_flash_write@0x1000450a (.../github/src/rp2040/native/dhara_flash.c:148)handle_flash_dma@0x100035c2 (.../github/src/rp2040/native/core1.c:532)handle_io@0x10003960 (.../github/src/rp2040/native/core1.c:1014)bus_run@0x100042d6 (.../github/src/rp2040/native/core1.c:1071)core1_wrapper@0x1000a9e4 (.../pico-sdk/src/rp2_common/pico_multicore/multicore.c:97)??@0x0000017e (Unknown Source:0)
When I try to single step, the system locks up totally.

What am I doing wrong here?

I can't spot a difference between my implementation and other references, I've seen so far. Do I have to do something additionally, since I'm using USB UART?

What can I do to make my code bulletproof against this kind of problem? While I've got some experience in embedded development, I've got no idea what to try next

Statistics: Posted by SvOlli — Sun Dec 08, 2024 5:05 pm



Viewing all articles
Browse latest Browse all 4804

Trending Articles