Skip to content
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

Incorrect PICO_FLASH_SPI_CLKDIV for WaveShare RP2040-Zero #1304

Closed
ArkBrj opened this issue Mar 10, 2023 · 4 comments
Closed

Incorrect PICO_FLASH_SPI_CLKDIV for WaveShare RP2040-Zero #1304

ArkBrj opened this issue Mar 10, 2023 · 4 comments
Milestone

Comments

@ArkBrj
Copy link

ArkBrj commented Mar 10, 2023

src\boards\include\boards\waveshare_rp2040_zero.h sets PICO_FLASH_SPI_CLKDIV to 2.
However, according to the board schematics (https://www.waveshare.com/w/upload/4/4c/RP2040_Zero.pdf), this board uses Winbond W25Q16JVUXIQ chip. According to the chip's datasheet (https://www.winbond.com/resource-files/w25q16jv%20spi%20revh%2004082019%20plus.pdf), its max Clock frequency for Read Data instruction (03h) is 50 MHz (Section 10.6 AC Electrical Characteristics). PICO_FLASH_SPI_CLKDIV of 2 sets the clock to around 60 MHz exceeding the spec.
In my experiments with various binaries I see that the code always works right after flashing it, but does not work after restarting the board. This includes the officially released binary for picoprobe.
For home-built projects Debug binaries sometimes work even after reset but Release do not. Sometimes even Debug binaries do not work after reset.
CircuitPython works fine because it uses PICO_FLASH_SPI_CLKDIV of 4 (confirmed by disassembling the binary).
I think PICO_FLASH_SPI_CLKDIV should be set to 4 in SDK for this board.

AlynxZhou added a commit to AlynxZhou/pico-sdk that referenced this issue Jun 11, 2023
Some RP2040-Zero boards from WaveShare can only be recognized via USB
after flashing UF2 into it, and if you unplug and replug it, nothing
happens on both USB host and device, RP2040-Zero seems just not booting.

According to @ArkBrj, it seems that setting `PICO_FLASH_SPI_CLKDIV` to
`2` makes the clock chip exceed the spec, setting it to `4` fixes this
bug.

I tested it with the blink program in pico-examples, this does fix the
bug for me.

Fixes <raspberrypi#1304>.
@AlynxZhou
Copy link

I meet this problem too with 2 of 3 RP2040-Zeros I bought, a interesting thing is I found setting PICO_XOSC_STARTUP_DELAY_MULTIPLIER to 64 also fixes this bug, I think it makes program waits longer before startup.

But your words are more reasonable, and I tried your suggestion, it does fix the bug, so I submit a PR according to this issue. Thanks!

@lurch
Copy link
Contributor

lurch commented Jun 11, 2023

In case it's useful, see the related discussion in #401

@AlynxZhou
Copy link

In case it's useful, see the related discussion in #401

Thanks!

My test shows that only change PICO_FLASH_SPI_CLKDIV to 4 is enough, there is no need to change both PICO_FLASH_SPI_CLKDIV and PICO_XOSC_STARTUP_DELAY_MULTIPLIER.

kilograham pushed a commit that referenced this issue Dec 15, 2023
)

Some RP2040-Zero boards from WaveShare can only be recognized via USB
after flashing UF2 into it, and if you unplug and replug it, nothing
happens on both USB host and device, RP2040-Zero seems just not booting.

According to @ArkBrj, it seems that setting `PICO_FLASH_SPI_CLKDIV` to
`2` makes the clock chip exceed the spec, setting it to `4` fixes this
bug.

I tested it with the blink program in pico-examples, this does fix the
bug for me.

Fixes <#1304>.
@kilograham kilograham added this to the 1.5.2 milestone Dec 15, 2023
@kilograham
Copy link
Contributor

merged into develop

mungewell pushed a commit to mungewell/pico-sdk that referenced this issue Mar 18, 2024
…spberrypi#1421)

Some RP2040-Zero boards from WaveShare can only be recognized via USB
after flashing UF2 into it, and if you unplug and replug it, nothing
happens on both USB host and device, RP2040-Zero seems just not booting.

According to @ArkBrj, it seems that setting `PICO_FLASH_SPI_CLKDIV` to
`2` makes the clock chip exceed the spec, setting it to `4` fixes this
bug.

I tested it with the blink program in pico-examples, this does fix the
bug for me.

Fixes <raspberrypi#1304>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants