Deep Dive w/Scott: Flash config for RP2040 @tannewt #rp2040 #adafruit
Channel: Adafruit Industries
Date: 04/03/2021

I’m sponsored by Adafruit to work on CircuitPython. Support them, and by extension me, by purchasing hardware from https://adafruit.com

Chat with me and lot of others on the Adafruit Discord at https://adafru.it/discord.
Deep Dive happens every week. Normally Fridays at 2pm Pacific but occasionally shifted to Thursday at 2pm. Typically goes for two hours or more. Questions are welcome. Next week will be on Friday.

0:00 Getting started
04:44 Housekeeping
11:41 what sort of question/comments should go on Discord vs. YouTube chat?
13:59 Mailbag!  Showed the Feather goodie bag ladyada sent Scott.  Used CircuitPython to program a GameBoy and the RP2040s are destined to go there!  PIO can buffer and make sure it’s timing specific.
Scott was on the Tomshardware Pi Cast.  Idea of making CircuitPython run bare-metal on a Raspberry Pi.
Sneak peak of Simple Electronics. Does not officially come out until tomorrow.
18:49 More Mailbag!  Becca wanted a sensor to track temperature, humidity and light levels for an indoor plant sensor.  Hammond USB case (DigiKey part# 1551USB3TSK) with paper prototype.  Low profile pluggable sensors.
Q) Why not use a feather with a 3D printed case?  (1) Scott doesn’t have a 3D printer and (2) he really likes the Hammond case.
Saw Hammond enclosures on the manufacturer’s website.
Showed NeoPixel board to show measurement scale, and veml 7700 temperature and humidity sensor.
Q) Will you be able to isolate the temperature sensor from the electronics heat?  Temperature sensor in the enclosure can read some of the case temperature.
28:20 Today’s Deep Dive.  Let’s talk about flash!  Lady Ada was producing the Feather and found 4MB wasn’t working and switched to 8MB.  Saw pico-sdk GitHub and datasheet for RP2040 boot process with flowchart.  Let’s talk about the flash second stage after the checksum has passed.
Flash second stage: problem is the code stored off-chip.  How do you figure out what flash it is and how do you talk to it?  Common problem: IMX and ESP also have the execute-in-place problem.  Pico-sdk has boot stage and 4 options for flash initialization.  Thought we were using 0x3H, but we weren’t which is why the 4MB flash failed.
New nvm.toml repository. mram is useful in space for satellites running CircuitPython because memory doesn’t corrupt the same way.  Saw gigadevices.  
Q) Are their (sic) board where I can remove the flash and replace by sRam? Just like we add flash to QT-Py? Or SRam QT-Py?  Same question with mram.
Cascade TOML: can grab settings for a device using `cascadetoml cascade filter sku=\”GD25Q4C\”` for squishing settings into 1 TOML file.  We want to take the “database” and produce flash stage 2.
Lady Ada asked what if we came up with a stage 2 that could handle all the devices in here?
Showed assembly code.  Apparently it supports “#include”.  Can we use C instead of assembly here?  Tried making a stage2.c
Q) I'm afraid of the person for whom it isn't easier to read C code than assembly
Q) I used something called TAL, which is C like but lower level
stage2.c : In assembly you have to worry about setting registers and indirection, which you don’t have in C code because of the [convenient] assignment operator.
stage2.c : Explanation of vector table
Testing stage2.c *drum roll*
Q) Will the next revision have less flash?
Looked at stage2 assembly in boot2.elf, then the padded and checksummed assembly.
1:06:57 Lady Ada pops in to save Scott from assembly code.  Asks about the disassembler.
1:40:52 Scott answers some of Lady Ada’s comments about soldering after she leaves.
1:45:10 Q) So where is the ROM code?
1:46:58 More debugging of C stage2
2:02:07 wrap-up


Q) Out of curiosity, was there a benefit to the weird bootloader approach?

Lady Ada shows the tester pogo board.
Discussion of flash initializer assembler.
Q) Which flash chip will be on [the] itsy?
Q) What is the price of the RP2040 chips themselves?
Commentary about capacitor packages.
Optional USB host.  And the “bad idea” diode!
RP2040 board pin layout.
USB boot signal, chip select GPIO pin deep dive.
Q) Will that impact how fast the CS pin rises and falls? Does it matter?
Q) Scott: When will the next [RP2040] batch be in the store?


Showed SOIC-A clip to debug the flash chip on the Feather: https://www.digikey.com/en/products/detail/pomona-electronics/5250/745102 (link courtesy of Mr. Certainly)
Use Saleae to capture the data line trace.  Maybe failing the checksum?  No clock signal?
Is the clip orientation correct?  Pulled up the GigaDevice flash chip datasheet.


Visit the Adafruit shop online - http://www.adafruit.com