You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
Copy file name to clipboardExpand all lines: doc/src/build-instructions.md
+33-26Lines changed: 33 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,29 +239,31 @@ $ cd <atomvm-source-tree-root>
239
239
$ cd src/platforms/esp32
240
240
```
241
241
242
-
If you want to build an image with Elixir modules included you must first have a version of Elixir installed that is compatible with your OTP version, then add the following line to sdkconfig.defaults:
242
+
Start by configuring the default build configuration of local `sdkconfig` for your target device:
For those familiar with esp-idf the build can be customized using `menuconfig` instead of
256
-
`reconfigure`:
256
+
For those familiar with esp-idf the build can be customized using `menuconfig`:
257
257
258
+
$ idf.py set-target ${CHIP}
258
259
$ idf.py menuconfig
259
260
260
261
This command will bring up a curses dialog box where you can make adjustments such as not including
261
262
AtomVM components that are not desired in a particular build. You can also change the behavior of a
262
-
crash in the VM to print the error and reboot, or halt after the error is printed. Extreme caution
263
-
should be used when changing any non AtomVM settings. You can quit the program by typing `Q`.
264
-
Save the changes, and the program will exit.
263
+
crash in the VM to print the error and reboot, or halt after the error is printed. To configure an
264
+
Elixir supported build under the "Partition Table" setting selectthe Custom partitions CSV file and
265
+
set this to `partitions-elixir.csv`. Extreme caution should be used when changing any non AtomVM
266
+
settings. You can quit the program by typing `Q`. Save the changes, and the program will exit.
265
267
```
266
268
267
269
You can now build AtomVM using the build command:
@@ -482,9 +484,17 @@ core Erlang libraries will be written to the `build/libs` directory in the AtomV
482
484
you target a different build directory when running CMake.
483
485
```
484
486
485
-
Running this script will generate a single `atomvm-<sha>.img` file in the `build` directory of the esp32 source tree, where `<sha>` is the git hash of the current checkout. This image contains the ESP32 bootloader, AtomVM executable, and the `eavmlib` and `estdlib` Erlang libraries in one file, which can then be flashed to address `0x1000` for the esp32. The bootloader address varies for other chip variants. See the [flashing a binary image to ESP32](./getting-started-guide.md#flashing-a-binary-image-to-esp32) section of the [Getting Started Guide](./getting-started-guide.md) for a chart with the bootloader offset address of each model.
487
+
Running this script will generate a single `atomvm-<target-chip>.img` file in the `build` directory
488
+
of the esp32 source tree, where `<target-chip>` is the device configured with `set-target`. This
489
+
image contains the ESP32 bootloader, AtomVM executable, and the `eavmlib` and `estdlib` Erlang
490
+
libraries (and `exavmlib` Elixir libraries if configured for Elixir support) in one file, which can
491
+
then be flashed to address `0x1000` for the esp32. The bootloader address varies for other chip
492
+
variants. See the
493
+
[flashing a binary image to ESP32](./getting-started-guidemd#flashing-a-binary-image-to-esp32)
494
+
section of the [Getting Started Guide](./getting-started-guide.md) for a chart with the bootloader
495
+
offset address of each model.
486
496
487
-
To build a thin image with only Erlang libraries `mkimage.sh` script is run from the `src/platform/esp32` directory as follows:
497
+
To build a complete image use this command from the `src/platform/esp32` directory as follows:
488
498
489
499
```shell
490
500
$ ./build/mkimage.sh
@@ -496,18 +506,6 @@ Wrote AtomVM Virtual Machine at offset 0x10000 (65536)
496
506
Wrote AtomVM Core BEAM Library at offset 0x1D0000 (1114112)
497
507
```
498
508
499
-
To build a full image with Erlang and Elixir libraries the path to the previously (during the generic_unix build) built `elixir_esp32boot.avm` must be passed to the `mkimage.sh` script as follows (Note: this is still run from the AtomVM/src/platforms/esp32 directory for the relative path to work - feel free to use the absolute path to this file):
Writing output to /home/joe/AtomVM/src/platforms/esp32/build/atomvm-esp32.img
504
-
=============================================
505
-
Wrote bootloader at offset 0x1000 (4096)
506
-
Wrote partition-table at offset 0x8000 (32768)
507
-
Wrote AtomVM Virtual Machine at offset 0x10000 (65536)
508
-
Wrote AtomVM Core BEAM Library at offset 0x1D0000 (1114112)
509
-
```
510
-
511
509
Users can then use the `esptool.py` directly to flash the entire image to the ESP32 device, and then flash their applications to the `main.app` partition at address `0x210000`, (or `0x250000` for Elixir images)
512
510
513
511
But first, it is a good idea to erase the flash, e.g.,
@@ -602,7 +600,7 @@ applications for the AtomVM platform.
602
600
603
601
#### Flashing the core libraries
604
602
605
-
If you are doing development work on the core Erlang/Elixir libraries and wish to test changes that do not involve the `C` code in the core VM you may flash `esp32boot.avm`(or `elixir_esp32boot.avm`when using an Elixir partition table) to the boot.avm partition (offset 0x1D0000) by using the `flash.sh` script in the esp32 build directory as follows:
603
+
If you are doing development work on the core Erlang/Elixir libraries and wish to test changes that do not involve the `C` code in the core VM you may flash `esp32boot.avm` or `elixir_esp32boot.avm` to the boot.avm partition by using the `flash.sh` script in the esp32 build directory as follows:
It is important that you flash the `esp32boot` variant that matches the configuration used to
639
+
create the build currently on the device. Flashing `elixir_esp32boot.avm` to a device that was not
640
+
flashed with an Elixir support build will not work, AtomVM will still try to load an application
641
+
from an address that is now occupied by the `exavmlib` modules.
642
+
```
643
+
639
644
### Adding custom Nifs, Ports, and third-party components
640
645
641
646
While AtomVM is a functional implementation of the Erlang virtual machine, it is nonetheless designed to allow developers to extend the VM to support additional integrations with peripherals and protocols that are not otherwise supported in the core virtual machine.
@@ -651,7 +656,9 @@ documentation.
651
656
The instructions for adding custom Nifs and ports differ in slight detail, but are otherwise quite similar. In general, they involve:
652
657
653
658
1. Adding the custom Nif or Port to the `components` directory of the AtomVM source tree.
654
-
1. Run `idf.py reconfigure` to pick up any menuconfig options, many extra drivers have an option to disable them (they are enabled by default). Optionally use `idf.py menuconfig` and confirm the driver is enabled and save when quitting.
659
+
1. Run `idf.py set-target ${CHIP}` to pick up any menuconfig options, many extra drivers have an
660
+
option to disable them (they are enabled by default). Optionally use `idf.py menuconfig` and
661
+
confirm the driver is enabled and save when quitting.
0 commit comments