RP2040 non-boot(not seen) after flash\reset FIX

Basic Information:

Printer Model:
MCU / Printerboard: RP2040 Klipper/Klipper CAN bridge
Host / SBC
klippy.log

reason:

  • After flashing a self-compiled firmware, the tool board does not respond, USB is not recognized, or CAN cannot connect.
  • After power-on, it occasionally fails to start, and after repeatedly powering off and restarting, it can sometimes return to normal.
  • klippy.log Chinese prompt corresponds to MCU unable to connect or abnormal startup.

in klipper/src/rp2040/main.c

// PLL (rp2xxx) input: 5 to 100Mhz, vco: 750 to 1600Mhz

static void
xosc_setup(void)
{
xosc_hw->startup = DIV_ROUND_UP(FREQ_XOSC, 1000 * 256); // 1ms

in line 105 change to

xosc_hw->startup = DIV_ROUND_UP(FREQ_XOSC, 1000 * 256) * 6; // 6ms

Increase the stable waiting time to 6ms(Consistent with the Raspberry Pi official pico-sdk default, used to adapt to slow-start crystal oscillators).

tested on Waveshare RP2040-Zero.

Welcome ComProf,

I think your “main.c” change is ok. Only thing you could try out is extending line 105 for about a µs longer.

When I designed in µCs to PCBs was a long time ago. At least 20 years ago. But I know, pardon my french…, they can be a bit*#.

Please read these documents carefully https://files.waveshare.com/upload/4/4c/RP2040_Zero.pdf, https://pip-assets.raspberrypi.com/categories/814-rp2040/documents/RP-008279-DS-2-hardware-design-with-rp2040.pdf. I think both schematics differ on the oscillator side. This could be the reason,
… or bad handling of the oscillators before soldering on the PCB, or bad handling of the tested product (… shipping, storage, etc.).

What is a crystal oscillator basically https://en.wikipedia.org/wiki/Crystal_oscillator? It is a piezoelectric crystal, which is electrically caused to swing. When they get mechanically stressed, they can break or may have a loose connection!

I think the oscillator on your Waveshare board just starts to swing sometimes. So it could be caused by one of the reasons I described above. Good luck.

By the way, why do you want to do the “main.c” change?

Hello hcet14,

My story is simple, I brought a 2 boards on local market for make usb adxl345 on my own, for my TT Sapphire SP-5 because wires is too long. This is be in an end on 2024. But none board can boot compiled code. It`s just boots from time to time(hard to boot). But with example of neopixel code what is firmwared by default in it its works good, without a problems.

I read tons of info about problem, all says problems in a pico-sdk sources in a klipper src folder. Some says u need to change to generic_03h but nothing helps. 2 years and some of my rp2040 works, some didnt, it doesn’t matter what I did with them, troubles only went when i use klipper on it. From time to time, whose who works, 1 fail from 30-40 starts. As i understand, i dont have any Original RP2040 boards, all whey clones from other manufacturers.

But tomorrow i found a fix on 3dmellow in its official docs. And just repost it here. The remaining issues were fixed over these 2 years. After what change boards boot every time.

Thanks you for your attention.

I don’t really understand those 4 sentences.
Did you fix your booting problem? If yes, how did you fix it on which RP2040 clone boards? Can you explain more detailed? It might help others trying to get CAN running on RP2040 clone boards!