-
-
Notifications
You must be signed in to change notification settings - Fork 212
tone crashes Pi 2040 #409
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
Comments
Hi @fabltd ,
|
With core 2.7.2, the sketch below runs fine in my Raspberry Pi Pico, both immediately after the Upload and also when pin 30 (the RUN pin) is toggled. Additionally, it does not matter if the Pico is or is not connected to USB. If delay(1000) is commented out, there is still no problem running the sketch when USB is disconnected. However, if the USB is left connected, then the results become unpredictable. With USB connected, and without the delay(1000), sometimes the first note is crackly, but it completes the rest of the sketch. In this case, more sketch Uploads can be performed. Other times, the first note is crackly, but it doesn't play any more notes. If it stops after a crackly first note, it also goes into a mode where the LED repeatedly flashes rapidly 4 times, then slowly 4 times. In #316, @facchinm explained the blink sequence is signaling an RTOS crash and recommended a crash report, which I added below the sketch. Side note: If it's signaling an RTOS crash, my Windows Arduino IDE 1.8.19 reports: "An error occurred while uploading the sketch." Another way to get back to being able to upload sketches is to put it into disk mode, as @fabltd reported. Responses to toggling the RUN pin with USB connected and without delay(1000) are similar to when the Arduino IDE's Upload button is clicked. Sometimes, the first note plays but sounds crackly, followed by the RTOS crash LED signal. Other times, the first note is crackly, but it completes the sketch. When this occurs, the Arduino IDE can successfully Upload to the Raspberry Pi Pico again.
Crash Report
|
Hi How do I enable the crash dump. I am using platform IO? |
If the Raspberry Pi Pico crashes, it'll transmit crash report data from pin 1 (GP0) at 115200 bits/s. Here are four ways to capture that data: Arduino UNO as a serial passthrough
Other Arduino devices as serial passthroughs USB/Serial Converter Raspberry Pi serial example |
I spotted this issue while I was revisiting an issue posted a year ago: #246 I tested my Raspberry Pi Pico board using the tone melody example and it works fine. My code is as follows (I'm using GPIO18):
However, looking at the tone library for mbed, there may be scope to change the library. For example, I see that a new pin declaration is made everytime tone is called ( I have reasoned, but cannot come up with a suitable change, is that the problem caused for core1 relates to how |
Oh yes, in the original example provided above, which created the crash, I see there is a |
@AndyLindsay I have facing the same issue. I have connected the UART and SWD to validated that the hang is a software issue and not related with my hardware.
The issue occurs intermittently when booting with USB connected and when triggering reset
I am driving neopixel using the Adafruit library ( I could use something better than bitbanging on RP2040, that would be for later ). I am using packages\arduino\hardware\mbed_rp2040\3.1.1 OpenOCD with SWD indicated an error since |
Hi @Kyklas , |
@facchinm Thanks for the feedback.
I am using Adafruit Neopixel to drive 60 LED across 3 bus. I just tested to connect the system to my android phone, same issue. |
i have another problem with tone function with pi pico. after using notone function, buzzer's gpio stays high. that can cause lots of problems with some installations. |
I have traced this a bit, it appears to happen when USB is connected and interrupts have been disabled for a while. It appears that USBDevice::_control_setup gets called, but the The The RP2040 datasheet notes on page 427: "Buffer status register. A bit set here indicates that a buffer has completed on the endpoint (if the buffer interrupt is enabled). It is possible for 2 buffers to be completed, so clearing the buffer status bit may instantly re set it on the next clock cycle." This means that the So my theory is:
I'm not sure what is the correct fix - maybe handling only one interrupt per endpoint per one |
Traced a bit more with USB analyzer and using the XIP bus for execution tracing. Time (ms) -1.9 Host sends SETUP EP0, RP2040 ACKs Payload 80: Device to host, standard device request 06: Request 6 = Get descriptor 00 02: Value = Configuration descriptor 0 00 00: Index 4B 00: Length -0.9 Host sends IN EP0, RP2040 responds with 64 bytes, ACK by host 0.0 Code disables interrupts for flash writing 0.1 Host sends IN EP0, RP2040 responds with 11 bytes, ACK by host 1.1 Host sends OUT EP0, 0 bytes payload, ACK from RP2040 2.1 Host sends SETUP EP0, ACK from RP2040 Payload 80: Device to host, standard device request 06: Request 6 = Get descriptor 00 03: Value = String descriptor 0 (LANGID) 00 00: Index FF 00: Length 3.1 Host sends IN EP0, RP2040 sends NAK ... ... SOF and IN EP0 / NAK repeats while IRQ disabled ... 47.1 Host sends IN EP 0, RP2040 sends NAK 47.5 Code enables interrupts 47.5 USBPhyHw::_usbisr() (code trace from XIP bus) 47.60 USBPhyHw::process() 47.61 USBDevice::ep0_setup() 47.62 USBDevice::_control_setup() 47.63 USBDevice::_control_setup() 47.64 arduino::internal::PluggableUSBModule::assert_locked() 47.65 USBDevice::complete_request() 47.66 USBDevice::unlock() 47.662 core_util_critical_section_exit() 47.665 USBDevice::unlock() 47.666 USBDevice::complete_request() 47.667 USBDevice::ep0_setup() 47.67 USBPhyHw::process() 47.68 USBDevice::_control_in() 47.69 USBDevice::ep0_out() 47.7 mbed_error() 48.1 Host sends IN EP 0, RP2040 sends STALL Does not exactly match my theory. Looks like there is SETUP EP0 and OUT EP0 in the queue when interrupts are enabled. But I can see a call to Or maybe it is processing the new SETUP packet first, and is then getting confused by the 0-length status stage of previous SETUP? The This problem makes it difficult to reprogram RP2040 external flash in a program that also uses USB. One workaround is to run everything from RAM, another is to sleep a bit after boot and hope that host is not communicating. @facchinm Do you have any ideas? |
The SD-card bootloader occassionally crashed due to either: - USB packets during flash writing (arduino/ArduinoCore-mbed#409) - Some flash XIP issues when function is not in RAM.
The SD-card bootloader occassionally crashed due to either: - USB packets during flash writing (arduino/ArduinoCore-mbed#409) - Some flash XIP issues when function is not in RAM.
Hi All
Trying to use the inbuilt - tone function.
This will casue the PI 2040 to crash and can only be recovered by putting into disk mode.
Any suggestions to diagnose.
Does the tone function only work on certian pins?
Thanks
The text was updated successfully, but these errors were encountered: