TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

RP2040 Boot Sequence

186 pointsby vmooreabout 1 year ago

8 comments

croteabout 1 year ago
For those wondering about why there&#x27;s both a boot ROM and the boot2 in flash:<p>The flash chips used support both a basic SPI mode, and an advanced QSPI mode. There is a well-defined standard protocol for basic SPI mode, so virtually all chips will respond to the same read command for simple slow byte-by-byte reading. The only thing left to try is the four SPI modes (Does clock idle high or low? Do we transfer on the full pulse, or on the half pulse?) - hardware often even supports two of them, and there&#x27;s only one set which actually makes sense.<p>QSPI, on the other hand, is more of a wild-west. You need to run a bunch of chip-specific commands to enter QSPI mode, and there are quite a few possible variations for QSPI read commands, not to mention a lot of different timing requirements. Trying out all of them isn&#x27;t really possible, hence the chip-specific boot2 segment.<p>Staying in SPI mode isn&#x27;t really viable either because the application code is stored in the flash chip. To give an example, jumping to a random instruction would incur a 1280 ns read with a W25Q80BW flash chip operating in SPI mode (realistically x10 due to a lower safe clock frequency), whereas QSPI mode can reliably do that in as little as 125 ns. With the RP2040 running at 133MHz a 16-cycle delay for a random jump or a read from a data block is not too bad, but a 170 or even 1700-cycle delay is just way too much.
评论 #39752499 未加载
评论 #39748289 未加载
vbezhenarabout 1 year ago
This complexity forced me to abandon it for learning and switch to STM32. I was able to write blinky with few dozens of assembly instructions for STM32. I spent like month reading about SPI, QSPI, flash chips and still was not able to understand how to proceed with RP2040 other than copy&amp;paste their &quot;bootloader&quot; as an opaque blob.<p>May be I&#x27;m weird, but for me RP2040 was terrible chip for learning ARM. STM32 on the other hand just worked and I gradually learned to blink the chip, to write linker script, to write UART, to use C, to use CMSIS and so on. In the end I was able to write a commercial firmware with it.<p>I understand that if I would just use their SDK with cmake, that wouldn&#x27;t be a problem, but I&#x27;m not going to use their SDK. I hate cmake and I need to understand everything from the ground up.<p>I think that at this moment I can grok this bootloader and write my own version of it, because I know much more about it, but it wouldn&#x27;t serve its purpose as a chip for learning.<p>IMO that&#x27;s a flawed approach: to throw infinitely complex tools onto a beginner. It&#x27;s much easier to start simple, with just an assembler and may be linker. And a chip for beginners must not require those complex initialization procedures.<p>This chip is also incredibly complex with its two cores and PIO cores. It&#x27;s absolutely cool thing, but it&#x27;s absolutely not for beginners, it&#x27;s for experienced engineers. I&#x27;d prefer something simple, like STM32, with built-in flash, but with proper documentation and without any compromises. Like flexible voltage source, on-board programmer, plenty of hardware blocks, not cheap price (because who cares if chip cost is $1 or $10 for hobby).<p>RP2040 documentation is superb, I must admit. That&#x27;s what they did perfectly.
评论 #39750402 未加载
评论 #39749282 未加载
评论 #39753013 未加载
评论 #39749179 未加载
评论 #39750928 未加载
评论 #39758936 未加载
评论 #39749218 未加载
评论 #39750303 未加载
blueflowabout 1 year ago
Official documentation: <a href="https:&#x2F;&#x2F;datasheets.raspberrypi.com&#x2F;rp2040&#x2F;rp2040-datasheet.pdf" rel="nofollow">https:&#x2F;&#x2F;datasheets.raspberrypi.com&#x2F;rp2040&#x2F;rp2040-datasheet.p...</a>, Booting is page 130 ff
vha3about 1 year ago
Some fun easter eggs in the bootrom. It seems like kilograham is a Doors fan: <a href="https:&#x2F;&#x2F;github.com&#x2F;raspberrypi&#x2F;pico-bootrom&#x2F;blob&#x2F;ef22cd8ede5bc007f81d7f2416b48db90f313434&#x2F;bootrom&#x2F;bootrom.ld#L14">https:&#x2F;&#x2F;github.com&#x2F;raspberrypi&#x2F;pico-bootrom&#x2F;blob&#x2F;ef22cd8ede5...</a>
评论 #39750631 未加载
dmitrygrabout 1 year ago
This is a rehash of official docs, which are both clearer and more detailed. Suggest reading official docs. See “boot” section in rp2040 TRM
MenhirMikeabout 1 year ago
&gt; Power is applied to the chip, and the RUN pin is high. The chip will be held in reset for as long as RUN is not high.<p>Is that a typo, or do I not understand this? Should it be &quot;as long as RUN is high&quot;? Because I assume that the RUN pin is active low, so as long as it is high, the chip will be held in reset?
评论 #39748572 未加载
评论 #39751284 未加载
StefanBatoryabout 1 year ago
I encourage you to check the rest of his website. I only skimmed for a moment, but I&#x27;m deeply impressed.
crmdabout 1 year ago
It&#x27;s kind of annoying that the author made me search for what an RP2040 was, rather than including it in the first paragraph.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;RP2040" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;RP2040</a>
评论 #39749023 未加载
评论 #39749296 未加载