platformio / platformio/platform-raspberrypi

Error with USB using DualCore

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
94
Forks
141
PR merge metrics
No merged PRs in 30d

Description

I have a program using both cores, one for logging some sensors and send/receive data by I2C, and the other to save the data in a SD Card and send by USB.

I have some problems with mutexes and dynamic memory created in some of them. For example, I must create a custom SPI class to use with the library SDFat, because the default SPI of Arduino framework uses a mutex and my program crashes. Now I have a similar problem with the USB. I copy the call stack during debuging to ask for some help.

I didn't use the USB in both cores, just in the second, and it is not using shared data.

If I change the loops between Cores it works. For me that's weird!

Call Stack Core 0

multicore_fifo_push_blocking_inline@0x1001a0e4 (Unknown Source:0)
multicore_fifo_push_blocking@0x1001a0f6 (/multicore_fifo_push_blocking.dbgasm:3)
App::loop@0x10006e72 (/home/pedro/projects/valvometry/rp2040-logger/lib/app/src/app.cpp:262)
setupApp@0x10007226 (/home/pedro/projects/valvometry/rp2040-logger/lib/app/src/app.cpp:346)
main@0x1000726e (/home/pedro/projects/valvometry/rp2040-logger/src/main.cpp:12)

Call Stack Core 1

update_present_time@0x100163d8 (Unknown Source:0)
ticker_read_us@0x1001673e (/ticker_read_us.dbgasm:7)
ticker_read@0x10016754 (/ticker_read.dbgasm:3)
wait_us@0x10017bca (/wait_us.dbgasm:9)
mbed_die@0x10016ea8 (/mbed_die.dbgasm:27)
mbed_halt_system@0x10016fe4 (Unknown Source:0)
mbed_error@0x10017284 (/mbed_error.dbgasm:21)
trap_rtx_error@0x1001387e (Unknown Source:0)
EvrRtxSemaphoreError@0x1001395a (/EvrRtxSemaphoreError.dbgasm:7)
osSemaphoreNew@0x10012adc (/osSemaphoreNew.dbgasm:12)
rtos::Semaphore::constructor(long, unsigned short)@0x10017d54 (Unknown Source:0)
rtos::Semaphore::Semaphore(long)@0x10017d7a (Unknown Source:0)
AsyncOp::wait(rtos::Mutex*, std::chrono::duration<unsigned long, std::ratio<1ll, 1000ll> >)@0x1001497e (Unknown Source:0)
arduino::USBCDC::send@0x1001061c (/home/pedro/.platformio/packages/framework-arduino-mbed/cores/arduino/USB/USBCDC.cpp:371)
arduino::USBSerial::write@0x1000f7de (/home/pedro/.platformio/packages/framework-arduino-mbed/cores/arduino/USB/PluggableUSBSerial.h:263)
arduino::UART::write@0x1000f7de (/home/pedro/.platformio/packages/framework-arduino-mbed/cores/arduino/Serial.cpp:232)
arduino::Print::write@0x10000fd6 (/home/pedro/.platformio/packages/framework-arduino-mbed/cores/arduino/api/Print.h:53)
SerialUSBHal::write@0x10000fd6 (/home/pedro/projects/valvometry/rp2040-logger/.pio/libdeps/pico/SERIAL_HAL_USB/src/serial_usb_hal.cpp:26)
SerialController::write@0x100010b6 (/home/pedro/projects/valvometry/rp2040-logger/.pio/libdeps/pico/SERIAL_CONTROLLER/src/serial_controller.h:18)
App::saveInSd@0x1000711c (/home/pedro/projects/valvometry/rp2040-logger/lib/app/src/app.cpp:210)
App::loop2@0x10007174 (/home/pedro/projects/valvometry/rp2040-logger/lib/app/src/app.cpp:305)

Thanks for your time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the dual-core crash and inspect lib/app/src/app.cpp at lines 210, 262, 305, and 346, together with the USB call path through USBSerial.cpp and serial_usb_hal.cpp. Compare the behavior when the loops are assigned to the opposite cores. Done means identifying the cause of the USB failure and documenting a verified fix or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.