I have a board that I'd like to flash once to load both CircuitPython and my code.py file. Also, the board will be deployed in such a way that I can only flash to update - I cannot make use of CircuiPython's presentation as a drive.
I see in the build instructions that it is possible to include modules in the built binary artifact.
- Is it also possible to include a default code.py in the build?
- If not, is it possible to update code.py by flashing a particular storage region?
Thanks!
P.S. I see similar questions here viewtopic.php?p=946858 and viewtopic.php?p=951129, but no responses.
Build CircuitPython with preloaded code.py
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- frankleonrose
- Posts: 18
- Joined: Fri Jun 24, 2016 3:49 pm
- danhalbert
- Posts: 4613
- Joined: Tue Aug 08, 2017 12:37 pm
Re: Build CircuitPython with preloaded code.py
The sample code.py that is created when CIRCUITPY is formatted is in `make_sample_code_file()` in `supervisor/shared/filesystem.c`. But instead of putting a large code.py there, I'd suggest you add a single `import something_or_other`, which runs the code you want to run. Then you can freeze that code in the frozen/ directory, and update it easily.
- frankleonrose
- Posts: 18
- Joined: Fri Jun 24, 2016 3:49 pm
Re: Build CircuitPython with preloaded code.py
Thanks, @danhalbert. That was exactly my plan given no formal support.
- neradoc
- Posts: 542
- Joined: Wed Apr 27, 2016 2:38 pm
Re: Build CircuitPython with preloaded code.py
You say you can only flash, but do you have access to the REPL ? For example if you are using an ESP32 board, it goes via a serial chip, there is no drive, that doesn't mean you can't install or update the files.
Maybe you can tell us more about your setup ?
What chip is it using ? How can you communicate with it ?
Also depending on the port, it is possible to create an image from another board with access to the drive, that can then be flashed to another board to clone its entire content, Circuitpython and drive alike.
For example on RP2040 picotool can be used to dump the content of the flash into a flashable bin or UF2, which will then flash everything back to any board it's installed on, and similarly with esptool for ESP32 boards.
Maybe you can tell us more about your setup ?
What chip is it using ? How can you communicate with it ?
Also depending on the port, it is possible to create an image from another board with access to the drive, that can then be flashed to another board to clone its entire content, Circuitpython and drive alike.
For example on RP2040 picotool can be used to dump the content of the flash into a flashable bin or UF2, which will then flash everything back to any board it's installed on, and similarly with esptool for ESP32 boards.
- frankleonrose
- Posts: 18
- Joined: Fri Jun 24, 2016 3:49 pm
Re: Build CircuitPython with preloaded code.py
Thanks for your interest, @neradoc.
It's an ESP32-S3-DevKitC-1-N8R8 (ESP32-S3-WROOM-1). A key requirement is the two USB ports - native USB to present as HID keyboard and debugging port for control and, as discussed, flashing.
I don't yet have my hands on the board, so, not sure whether I have REPL access with stock CircuitPython build. (Haven't dug into board definitions, yet.) It's a hard requirement that reprogramming happen over the control port and that there is no other hardware required.
I appreciate your suggestion of cloning the flash contents. However, that workflow is not compatible with building in CI.
Cheers,
- Frank
It's an ESP32-S3-DevKitC-1-N8R8 (ESP32-S3-WROOM-1). A key requirement is the two USB ports - native USB to present as HID keyboard and debugging port for control and, as discussed, flashing.
I don't yet have my hands on the board, so, not sure whether I have REPL access with stock CircuitPython build. (Haven't dug into board definitions, yet.) It's a hard requirement that reprogramming happen over the control port and that there is no other hardware required.
I appreciate your suggestion of cloning the flash contents. However, that workflow is not compatible with building in CI.
Cheers,
- Frank
Please be positive and constructive with your questions and comments.