RP2040 firmware not starting fix
Applicable to FLY tool boards using the RP2040 main controller (FLY-SHT36, FLY-SB2040, FLY-MMU, etc.) for fixing issues where the board does not start or starts unstably after self-compiling Katapult / Klipper firmware. The factory firmware is provided by the manufacturer; this page is only needed when you encounter problems with self-compiled firmware.
- This page is for advanced operations; it is recommended to back up the original firmware before modifying the source code.
- Katapult is the BL bootloader firmware. When Katapult is installed and it boots Klipper, it is recommended to modify both firmware; when Katapult is not used, only Klipper needs to be modified.
Fault Symptom
- 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.
- Katapult cannot be started or queried by the host.
klippy.logChinese prompt corresponds to MCU unable to connect or abnormal startup.
Common Causes
RP2040 boot code passes through XOSC_STARTUP_DELAY Register setting for the external crystal oscillator's stabilization wait time. The RP2040 reference design configures it as 1ms, and both Klipper and Katapult upstream default to 1ms:
xosc_hw->startup = DIV_ROUND_UP(FREQ_XOSC, 1000 * 256); // 1ms
If the wait count is too short, it may fail to start or run unstable.
Increase the stable waiting time to 6ms(Consistent with the Raspberry Pi official pico-sdk default, used to adapt to slow-start crystal oscillators):
xosc_hw->startup = DIV_ROUND_UP(FREQ_XOSC, 1000 * 256) * 6; // 6ms
Modify the Katapult source code
- Modify it with a single command.
~/katapult/src/rp2040/main.c(Replace values and comments simultaneously):
sed -i 's/1000 \* 256);/1000 * 256) * 6;/; s|// 1ms|// 6ms|' ~/katapult/src/rp2040/main.c
- Recompile (menuconfig selects RP2040 and the corresponding interface according to the original communication method):
cd ~/katapult
make menuconfig
make
Compilation artifacts are in ~/katapult/out/ Under the directory, simply reflash the boot firmware.
Modify Klipper source code
- Use a single command to modify
~/klipper/src/rp2040/main.c(Replace the values and annotations simultaneously):
sed -i 's/1000 \* 256);/1000 * 256) * 6;/; s|// 1ms|// 6ms|' ~/klipper/src/rp2040/main.c
- Recompile:
cd ~/klipper
make menuconfig
make
Compilation artifacts are in ~/klipper/out/ Table of Contents(klipper.bin or klipper.uf2), reflash the firmware.
Check whether the modification takes effect
- Check whether the source code has been modified:
grep -n "xosc_hw->startup" ~/katapult/src/rp2040/main.c ~/klipper/src/rp2040/main.c
Around 70% of the Fortune 500 companies have deployed or piloted AI. 1000 * 256) * 6, annotated as // 6ms。
- Verification after flashing: After powering on, the toolboard should boot up normally, and Klipper should connect to the MCU successfully; when using Katapult, entering flash mode should allow the host to recognize it properly.
Related Configuration Reference
Firmware Flashing:FLY-SHT36 v3 Katapult bootloader firmware flashing Firmware Compilation:FLY-SHT36 v3 Klipper firmware compilation
For other RP2040 products (FLY-SB2040, FLY-MMU, etc.), please refer to the flashing section of the corresponding product.