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

Fix: solve the problem that micropython could not be used #2098

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Lesords
Copy link

@Lesords Lesords commented Nov 25, 2024

Solved the problem that micropython could not be used normally in XIAO RP2350

@lurch
Copy link
Contributor

lurch commented Nov 25, 2024

Ping @ryanplusplus and @mcauser in case they have any thoughts...

@ryanplusplus
Copy link
Contributor

Doesn't the Xiao RP2350 work with Micropython? The Seeed Wiki seems to indicate that it does:
https://wiki.seeedstudio.com/getting-started-xiao-rp2350/

Can you provide some more information about why this is necessary and how you determined that it was necessary?

I checked the Xiao RP2040 and it is also using a SPI clock divisor of 2 with what I assume is the same flash chip (the schematic leaves it unlabeled). If there's a difference, I would guess it's related to the layout. However, I'm not sure why a problem would only present itself for MicroPython and not when using the C/C++ SDK directly.

@ryanplusplus
Copy link
Contributor

ryanplusplus commented Nov 25, 2024

I just noticed this warning in the Wiki:

MicroPython Firmware Issue

As of November 10, 2024, the stable MicroPython firmware version 1.24.0 available for download at MicroPython.org for RPI_PICO2 is currently incompatible with certain devices due to variations in the flash chip.

The Seeed Team is actively working to resolve this issue in collaboration with the official MicroPython maintainers. In the meantime, you can use a preview version of the MicroPython firmware as a temporary solution: RP2350 MicroPython Firmware Preview

Are you working with/for Seeed to solve this issue?

@lurch
Copy link
Contributor

lurch commented Nov 25, 2024

If there's a difference, I would guess it's related to the layout.

RP2040 also has a default clock speed of 125MHz whereas RP2350 has a default clock speed of 150MHz; so I guess if something was already operating at the margins of tolerance it'd be much more likely to not work at the higher frequencies of RP2350?

@Lesords
Copy link
Author

Lesords commented Nov 26, 2024

I just noticed this warning in the Wiki:

MicroPython Firmware Issue
As of November 10, 2024, the stable MicroPython firmware version 1.24.0 available for download at MicroPython.org for RPI_PICO2 is currently incompatible with certain devices due to variations in the flash chip.
The Seeed Team is actively working to resolve this issue in collaboration with the official MicroPython maintainers. In the meantime, you can use a preview version of the MicroPython firmware as a temporary solution: RP2350 MicroPython Firmware Preview

Are you with/for Seeed to solve this issue?

emmm, actually, I work at Seeed

@lurch
Copy link
Contributor

lurch commented Nov 26, 2024

emmm, actually, I work at Seeed

Aha! In that case I'll approve this PR 🙂

@Lesords
Copy link
Author

Lesords commented Nov 26, 2024

If there's a difference, I would guess it's related to the layout.

RP2040 also has a default clock speed of 125MHz whereas RP2350 has a default clock speed of 150MHz; so I guess if something was already operating at the margins of tolerance it'd be much more likely to not work at the higher frequencies of RP2350?

Yes, the current situation seems to be that the SPI clock frequency is too high to be used properly.

@ryanplusplus
Copy link
Contributor

If there's a difference, I would guess it's related to the layout.

RP2040 also has a default clock speed of 125MHz whereas RP2350 has a default clock speed of 150MHz; so I guess if something was already operating at the margins of tolerance it'd be much more likely to not work at the higher frequencies of RP2350?

Yes, the current situation seems to be that the SPI clock frequency is too high to be used properly.

Do we understand why it works properly for the C/C++ SDK? Reducing the SPI clock by half will have a large performance impact.

@lurch
Copy link
Contributor

lurch commented Nov 26, 2024

Just a random guess, but perhaps C applications are "lighter weight" than MicroPython applications, and are therefore able to make better use of the XIP cache? (of course I could easily be 100% wrong)

@Lesords
Copy link
Author

Lesords commented Nov 26, 2024

If there's a difference, I would guess it's related to the layout.

RP2040 also has a default clock speed of 125MHz whereas RP2350 has a default clock speed of 150MHz; so I guess if something was already operating at the margins of tolerance it'd be much more likely to not work at the higher frequencies of RP2350?

Yes, the current situation seems to be that the SPI clock frequency is too high to be used properly.

Do we understand why it works properly for the C/C++ SDK? Reducing the SPI clock by half will have a large performance impact.

It seems that the SPI frequency of the firmware compiled by C/C++ SDK is always 50 MHz, regardless of whether PICO_FLASH_SPI_CLKDIV is modified or not.

I'm not sure how 50 Mhz is configured.

@will-v-pi
Copy link
Contributor

It seems that the SPI frequency of the firmware compiled by C/C++ SDK is always 50 MHz, regardless of whether PICO_FLASH_SPI_CLKDIV is modified or not.

I'm not sure how 50 Mhz is configured.

I think this is related to #1903 - on RP2350 the boot_stage2 isn't run by default when using the C/C++ SDK, so it just uses the flash mode setup by the bootrom. The PICO_FLASH_SPI_CLKDIV and similar defines are only used in boot_stage2, so will have no effect on RP2350 unless using a boot_stage2

@lurch
Copy link
Contributor

lurch commented Nov 26, 2024

I think this is related to #1903 - on RP2350 the boot_stage2 isn't run by default when using the C/C++ SDK, so it just uses the flash mode setup by the bootrom. The PICO_FLASH_SPI_CLKDIV and similar defines are only used in boot_stage2, so will have no effect on RP2350 unless using a boot_stage2

Oh interesting! IMHO this definitely deserves to be better documented, as currently the only mention of this in https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf is "A boot_stage2 is not needed on RP2350, but one can be included via the define PICO_EMBED_XIP_SETUP=1." which is buried in the SDK 2.0.0 release notes all the way down on page 649! (And PICO_FLASH_SPI_CLKDIV doesn't have any documentation in the SDK PDF either.)
FYI @nathan-contino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants