#
RP2040 Boot Instability on Power-Up (with W25Q16JVUXIQTR SPI Flash)
##
System Configuration
- **MCU**: Raspberry Pi RP2040
- **SPI Flash**: W25Q16JVUXIQTR (2MB)
- **Firmware**: QMK-based (`.uf2` image)
- **Power Source**: USB (connected to PC)
- **Repository (source + schematic)**:
https://github.com/jys923/sonocap_v2_2/ ... onocap_v2/
---
##
config.h Settings
```c
#define RP2040_FLASH_GENERIC_03H
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
```
---
##
Observed Symptoms
- When the **PC powers on** and supplies USB power to the RP2040, it **occasionally fails to boot**.
- Two main failure patterns:
1. **No LED activity at all** – appears that firmware doesn't start.
2. **LEDs light up and stay on longer than expected** (not the intended 200ms flash), and the board becomes unresponsive (no key input, no USB HID).
- When **USB is unplugged and reconnected**, the board boots **correctly** every time.
---
##
LED Boot Behavior
```c
void keyboard_post_init_kb(void) {
if (!boot_flash_done) {
for (uint8_t i = 0; i < MATRIX_CNT; i++) update_led(i, 255, true);
boot_flash_done = true;
}
}
```
- **Normal case**: All LEDs turn on briefly (~200ms), then turn off.
- **Failure case**:
- Sometimes: **no LED flash at all**.
- Other times: **LEDs flash but remain on too long** and the board remains unresponsive.
---
##
GDB Debug Information (on failure)
```
pc = 0xfffffffe
lr = 0xfffffff1
sp = 0x20040290
x/8i $pc → movs r0, r0 (endless loop)
```
- `pc = 0xfffffffe` indicates a fallback condition, often due to boot vector fetch failure.
- May imply **XIP failure** during external flash access.
- Stack pointer is within a valid SRAM range.
---
##
Verified Behavior
| Scenario | Result |
|----------------------------------|----------------------|
| Unplug and replug USB | Always boots fine |
| GPIO-only custom firmware | Boots reliably |
| QMK-based firmware | Boot occasionally fails |
| Same board/flash/schematic | Only QMK shows issue |
---
##
Suspected Causes
- RP2040 **boot ROM fails to read vector table** from SPI flash at cold start.
- Timing issue between flash response and RP2040 XIP engine?
- Flash not ready fast enough during QMK's early initialization?
- QMK boot sequence may touch memory or peripherals too early.
- USB + flash power sequencing?
---
##
Request for Help
Any insights or similar experiences would be very appreciated.
I'm happy to share additional logs, boot2 binaries, oscilloscope traces, or minimal repro cases if needed.
Thank you!
##
- **MCU**: Raspberry Pi RP2040
- **SPI Flash**: W25Q16JVUXIQTR (2MB)
- **Firmware**: QMK-based (`.uf2` image)
- **Power Source**: USB (connected to PC)
- **Repository (source + schematic)**:
https://github.com/jys923/sonocap_v2_2/ ... onocap_v2/
---
##
```c
#define RP2040_FLASH_GENERIC_03H
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
```
---
##
- When the **PC powers on** and supplies USB power to the RP2040, it **occasionally fails to boot**.
- Two main failure patterns:
1. **No LED activity at all** – appears that firmware doesn't start.
2. **LEDs light up and stay on longer than expected** (not the intended 200ms flash), and the board becomes unresponsive (no key input, no USB HID).
- When **USB is unplugged and reconnected**, the board boots **correctly** every time.
---
##
```c
void keyboard_post_init_kb(void) {
if (!boot_flash_done) {
for (uint8_t i = 0; i < MATRIX_CNT; i++) update_led(i, 255, true);
boot_flash_done = true;
}
}
```
- **Normal case**: All LEDs turn on briefly (~200ms), then turn off.
- **Failure case**:
- Sometimes: **no LED flash at all**.
- Other times: **LEDs flash but remain on too long** and the board remains unresponsive.
---
##
```
pc = 0xfffffffe
lr = 0xfffffff1
sp = 0x20040290
x/8i $pc → movs r0, r0 (endless loop)
```
- `pc = 0xfffffffe` indicates a fallback condition, often due to boot vector fetch failure.
- May imply **XIP failure** during external flash access.
- Stack pointer is within a valid SRAM range.
---
##
| Scenario | Result |
|----------------------------------|----------------------|
| Unplug and replug USB | Always boots fine |
| GPIO-only custom firmware | Boots reliably |
| QMK-based firmware | Boot occasionally fails |
| Same board/flash/schematic | Only QMK shows issue |
---
##
- RP2040 **boot ROM fails to read vector table** from SPI flash at cold start.
- Timing issue between flash response and RP2040 XIP engine?
- Flash not ready fast enough during QMK's early initialization?
- QMK boot sequence may touch memory or peripherals too early.
- USB + flash power sequencing?
---
##
Any insights or similar experiences would be very appreciated.
I'm happy to share additional logs, boot2 binaries, oscilloscope traces, or minimal repro cases if needed.
Thank you!
Statistics: Posted by jys923 — Thu Jun 05, 2025 2:34 am