-
Notifications
You must be signed in to change notification settings - Fork 133
improvements to esp32 build configuration #1163
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
base: main
Are you sure you want to change the base?
Conversation
1f1e6b3 to
492105f
Compare
|
Not sure I like this bundling of commands:
But I'm also a poweruser of |
bettio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is an addition that fills some kind of huge gap in v0.6 (or not), so regardless to the outcome of this discussion I would target main branch anyway.
|
@petermm, I don’t want to disrupt anyone’s workflows. My goal was just to streamline the process for newer users who need to build a custom image to include additional components, like atomvm_mqtt. It makes more sense for me to add an additional cmake job called “deploy” (or similar) that will build the complete image and flash it to the target device using the generated ./build/flasjimage.sh script, leaving the default “build” task unchanged, this will better my goal and should have no affect on any pre-existing workflows. |
|
Should we keep a way to not create the image? (it's not much longer anyway). When working on the VM, I usually only reflash with idf.py flash which is faster than flashing the whole image. Also, one of my workflows (la machine, obviously) does not include esp32boot.avm at all because it seems to me that esp32boot.avm doesn't bring anything to production images. I'll definitely work around this improvement for newcomers, though. Likewise, qemu-based tests only use artifacts created by idf.py build (the VM, the partition map and the bootloader) and not the full image. |
I converted this back to draft, because I realize after @petermm’s comments that could be intrusive on existing workflows, so instead I will create and document a new build task that can be used as an alternative to |
This sounds like a better approach indeed and would be very welcome. I also find it frustrating to have to call the bash script to build the image when I need it. |
4b03b64 to
1901da0
Compare
f14c91d to
3923bf8
Compare
3923bf8 to
dd026f0
Compare
I backed out of assembling the complete image as part of the build process, and it is no longer needed for most users. Instead I added flashing the correct flavor of esp32boot.avm to the In the case of reflashing during development work |
doc/src/build-instructions.md
Outdated
| At this point, you can run `idf.py flash` to upload the 3 binaries up to your ESP32 device, and in some development scenarios, this is a preferable shortcut. | ||
| At this point, you can run `idf.py flash` and have a complete working image. In some development | ||
| scenarios is may be helpful to use `idf.py app-flash` or `idf.py bootloader-flash app-flash` to | ||
| avoid re-flashing the entire image if no changes were made to the Erlang or Elixir libraries, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by the naming of app-flash, and what it actually does..
avoid re-flashing the entire image if no changes were made to the Erlang or Elixir libraries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The app-flash is an IDF included task, I did not have a choice there. It only flashed the esp-idf application - in this case that is the AtomVM binary. Perhaps I should explain the name of this task in the documentation, and that it is a native IDF task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, but most unfortunate name in our context, almost feels like we should add this to cmakelists:
add_custom_target(libatomvm-flash)
add_dependencies(libatomvm-flash app-flash)
and maybe add eavmlib/exavmlib to this sentence..
avoid re-flashing the entire image if no changes were made to the Erlang(eavmlib) or Elixir (exavmlib) libraries
I'm assuming app-flash flashes libatomvm..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to the esp-idf application, app-flash means flash build/atomvm-{target-chip}.bin, which is the AtomVM executable with libatomvm statically linked in, not the atomvmlib.avm packed BEAM files. To flash those the documentation already describes using build/flash.sh -l ../../../build/libs/esp32boot/esp32boot.avm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To put it another way, it is the contents of the factory partition.
I think when you think of it in terms of ESP-IDF app-flash is a very natural name for it. It just doesn't match an application in terms of AtomVM, but I don't think anyone is expecting to flash their beam application with esp-idf tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this section, hopefully it is more clear now.
|
This is great.
|
|
also the simtest/wokwi ci will need some minor adjustment.. |
We don’t test Elixir in the simtest, and it has its own sdkconfig.defaults, so I don’t see any chances that need to be made… what did I miss? Also note that the old method of copying the partitions-elixir.csv to partitions.csv still works, so if Elixir tests are added to simtest that is a viable option for the CI to use. |
You are absolutely correct. Thank you! Not sure why I was keeping the reconfigure task. Simply set-target and include the Elixir support option is much cleaner and faster. |
89ca922 to
9ce9436
Compare
9ce9436 to
9d340e3
Compare
9a8bc73 to
3abb4c3
Compare
3abb4c3 to
0792dba
Compare
|
This is awesome, and smooths out a LOT of friction.. The AtomVM/doc/src/build-instructions.md Line 432 in 21671de
I suggest aliasing the app-flash name, and aligning the usage of AtomVM binary, to whatever is deemed correct. Maybe call it platform binary, or factory binary, esp32 factory binary etc. (or factory-flash? instead of platform-flash) thinking of it maybe alias it to factory-flash and call it factory binary But let's also ship this asap - it's great! |
|
The |
1fdaf24 to
a7aecd7
Compare
|
I don't think most users will be needing to use these fine grained flash commands. The majority are just wanting to use main branch, or build a custom image with a downstream driver included. For developers already familiar with ESP-IDF there is no point in shadowing a standard command with a custom alias, that seems like it could potentially add more confusion. If this was a custom command I added I certainly would have chosen a different name 😉 |
a7aecd7 to
0ba1771
Compare
| Building AtomVM for ESP32 must be done on either a Linux or MacOS build machine. | ||
|
|
||
| In order to build a complete AtomVM image for ESP32, you will also need to build AtomVM for the Generic UNIX platform (typically, the same build machine you are suing to build AtomVM for ESP32). | ||
| In order to build a complete AtomVM image for ESP32, you will also need to build AtomVM for the Generic UNIX platform (typically, the same build machine you are suing to build AtomVM for ESP32). This is expected to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suing -> using
UPDATING.md
Outdated
| using `idf.py -DATOMVM_ELIXIR_SUPPORT=on set-target ${CHIP}` instead of copying | ||
| partitions-elixir.csv to partitions.csv. This configures the build to use partitions-elixir.csv for | ||
| the partition table. The `main.avm` offset in the partition table will determine which flavor of | ||
| esp32boot libraries to include for the`idf.py flash` task and the image assembled by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space: theidf.py flash
CHANGELOG.md
Outdated
| - ESP32 Elixir support is determined automatically from the offset of `boot.avm` in the partiton | ||
| table. | ||
| - ESP32 ports now flash a complete working image using the `idf.py flash` task. | ||
| - ESP32 platform now uses reproducable builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reproducable -> reproducible
0ba1771 to
c7e2159
Compare
Exposes the settable build options for the ESP32 platform to the `idf.py menuconfig` utility, allowing for a more natural configuration experience for those already accustomed to the ESP-IDF development environment. Signed-off-by: Winford <[email protected]>
Changes GetVersion.cmake to allow use by platforms other than generic_unix, by allowing the cmake include of version.cmake before including GetVersion.cmake on other platforms. Fix version reporting for ESP32 builds when executing mkimage.sh by including the AtomVM/version.cmake and AtomVM/CMakeModules/GetVersion.cmake files to be able to get the correct version number when reporting build information during build/mkimage.sh execution. Signed-off-by: Winford <[email protected]>
Change the script to exit after printing the help, instead of erroneously reporting that the image was successfully created. Signed-off-by: Winford <[email protected]>
Modifies the ESP32 build configuration and mkimage tool to automatically detect the image flavor
based on the partition table used. By checking the offset of the application partition the correct
flavor of language support is used when creating images. Adds a config option to configure an
Elixir supported build by using `idf.py -DAVM_ELIXIR_BOOT=on set-target ${CHIP}`.
Signed-off-by: Winford <[email protected]>
Adds the esp32boot library flavor (determined from partition table) to the idf.py flash job, allowing developers to simply skip running mkimage.sh and flashimage.sh from the build directory to flash all of the necessary partitions for a complete install to their device. Signed-off-by: Winford <[email protected]>
Adds the option to provision nvs partition data at build time for the esp32 platform. If the file `nvs_partition.csv` is found in the AtomVM/src/platforms/esp32 directory when building; the nvs partition will be created and added to the `idf.py flash` task as well as to the configuration for the mkimage.sh script in the build directory. An example file is provided and `nvs_partition.csv` is added to `.gitignore` to prevent accidentally pushing secrets to remote repositories. Signed-off-by: Winford <[email protected]>
Use reproducible builds for ESP32 platform so that locally build binaries will be an exact match of release binaries for the same tag. Error message line info will start from the source path, trimming any diectories leading up to it. SHA256 sums of binaries built from release tags should be an exact match of release binaries. Signed-off-by: Winford <[email protected]>
c7e2159 to
bb855d7
Compare
These changes include several enhancements to the ESP32 build configuration and deployment of custom and test builds. The language flavor is determined by the offset of the main.avm partition in the partition table, simplifying Elixir supported builds and making the configuration of the image less error prone. The configuration of an Elixir build may be done without altering git tracked files by using
idf.py -DAVM_ELIXIR_SUPPORTT=on set-target ${CHIP}. This is the equivalent of setting the custom partition file name topartitions-elixir.csvusingidf.py menuconfig. Other existing AtomVM configuration options have been added to main/Kconfig.projbuild and are exposed inidf.py menuconfigunder the AtomVM menu to make the configuration process more natural for users already familiar with ESP-IDF and its build and configuration system.The auto discovered flavor of the esp32boot (
boot.avmpartition) libraries are now included in theidf.py flashtask. This makes use of the build/mkimage.sh script only necessary for building release images in the CI or to create a complete image for future use, and makes the experience like most other ESP-IDF based projects. To flash only the factory (AtomVM) partitionidf.py app-flashmay be used oridf.py bootloader-flash app-flashif changes made affect the bootloader partition as well.Changes the build configuration for reproducible builds, this strips leading path information (which is replaced by placeholders), and allows locally building from a release tag and generating a binary with the same sha256 checksum as official release binaries (as long as ESP-IDF and toolchain versions match those used to build the release). See:
https://docs.espressif.com/projects/esp-idf/en/v5.5/esp32/api-guides/reproducible-builds.html
The
nvspartition may now be generated and included in the build/mkimage.sh script (or flashed manually using theidf.py nvs-flashcommand) if the filenvs_partition.csvis present in the top level esp32 platform directory. An example is provided andnvs_partition.csvis added to.gitignoreto prevent accidental pushes of sensitive passwords.Closes atomvm/exatomvm#34
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later