Skip to content

Commit 2aaf7a3

Browse files
committed
Merge pull request #1266 from bettio/esp32-with-bigger-elixir-partition
ESP32: move Elixir support to new Elixir images **BREAKING CHANGE**: Starting with this PR, Elixir support is only available in Elixir images with bigger boot.avm partition. Fixes #1262 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
2 parents d5762d9 + 5fc54c9 commit 2aaf7a3

File tree

7 files changed

+72
-17
lines changed

7 files changed

+72
-17
lines changed

.github/workflows/esp32-mkimage.yaml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
elixir_version: ["1.17"]
4444
compiler_pkgs: ["clang-10"]
4545
soc: ["esp32", "esp32c2", "esp32c3", "esp32s2", "esp32s3", "esp32c6", "esp32h2"]
46+
flavor: ["", "-elixir"]
4647

4748
env:
4849
CC: ${{ matrix.cc }}
@@ -117,36 +118,48 @@ jobs:
117118
run: |
118119
cp sdkconfig.release-defaults sdkconfig.defaults
119120
120-
- name: "Build ${{ matrix.soc }} with idf.py"
121+
- name: "Build ${{ matrix.soc }}${{ matrix.flavor }} with idf.py"
121122
shell: bash
122123
working-directory: ./src/platforms/esp32/
123124
run: |
124125
rm -rf build
125126
. $IDF_PATH/export.sh
127+
if [ ! -z "${{ matrix.flavor }}" ]
128+
then
129+
mv partitions${{ matrix.flavor }}.csv partitions.csv
130+
fi
126131
idf.py set-target ${{ matrix.soc }}
127132
idf.py reconfigure
128133
idf.py build
129134
130-
- name: "Create a ${{ matrix.soc }} image"
135+
- name: "Create a ${{ matrix.soc }}${{ matrix.flavor }} image"
131136
working-directory: ./src/platforms/esp32/build
132137
run: |
133-
./mkimage.sh
138+
if [ -z "${{ matrix.flavor }}" ]
139+
then
140+
./mkimage.sh
141+
else
142+
FLAVOR_SUFFIX=$(echo "${{ matrix.flavor }}" | sed 's/-//g')
143+
BOOT_FILE="build/libs/esp32boot/${FLAVOR_SUFFIX}_esp32boot.avm"
144+
./mkimage.sh --boot="$BOOT_FILE"
145+
mv atomvm-${{ matrix.soc }}.img atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img
146+
fi
134147
ls -l *.img
135148
136149
- name: "Upload ${{ matrix.soc }} artifacts"
137150
uses: actions/upload-artifact@v4
138151
with:
139-
name: atomvm-${{ matrix.soc }}-image
140-
path: ./src/platforms/esp32/build/atomvm-${{ matrix.soc }}.img
152+
name: atomvm-${{ matrix.soc }}${{ matrix.flavor }}-image
153+
path: ./src/platforms/esp32/build/atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img
141154
if-no-files-found: error
142155

143156
- name: "Rename and write sha256sum"
144157
if: startsWith(github.ref, 'refs/tags/')
145158
shell: bash
146159
working-directory: src/platforms/esp32/build
147160
run: |
148-
ATOMVM_IMG="AtomVM-${{ matrix.soc }}-${{ github.ref_name }}.img"
149-
mv atomvm-${{ matrix.soc }}.img "${ATOMVM_IMG}"
161+
ATOMVM_IMG="AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img"
162+
mv atomvm-${{ matrix.soc }}${{ matrix.flavor }}.img "${ATOMVM_IMG}"
150163
sha256sum "${ATOMVM_IMG}" > "${ATOMVM_IMG}.sha256"
151164
152165
- name: Release
@@ -156,5 +169,5 @@ jobs:
156169
draft: true
157170
fail_on_unmatched_files: true
158171
files: |
159-
src/platforms/esp32/build/AtomVM-${{ matrix.soc }}-${{ github.ref_name }}.img
160-
src/platforms/esp32/build/AtomVM-${{ matrix.soc }}-${{ github.ref_name }}.img.sha256
172+
src/platforms/esp32/build/AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img
173+
src/platforms/esp32/build/AtomVM-${{ matrix.soc }}${{ matrix.flavor }}-${{ github.ref_name }}.img.sha256

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [0.6.5] - Unreleased
88

9+
### Added
10+
11+
- ESP32: add a new Elixir release "flavor" with a bigger boot.avm partition that has room for
12+
Elixir standard library modules
13+
- ESP32: `--boot` option to mkimage.sh tool
14+
15+
### Changed
16+
17+
- ESP32: Elixir library is not shipped anymore with `esp32boot.avm`. Use `elixir_esp32boot.avm`
18+
instead
19+
20+
### Fixed
21+
22+
- ESP32: content of `boot.avm` partition is not truncated anymore
23+
924
## [0.6.4] - 2024-08-18
1025

1126
### Added

UPDATING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
# AtomVM Update Instructions
88

9+
## v0.6.4 -> v0.6.5
10+
11+
- ESP32: `esp32boot.avm` doesn't contain anymore Elixir standard library, use instead
12+
`elixir_esp32boot.avm`, or the Elixir release flavor when using an image.
13+
- ESP32: partitioning schema for Elixir flavor is different, so app offset has been changed for
14+
Elixir images. Make sure to use `0x250000` as offset in your mix.exs or when performing manual
15+
flashing.
16+
917
## v0.6.0-beta.1 -> v0.6.0-rc.0
1018

1119
- Drivers that send messages from Esp32 callbacks should use new functions

libs/esp32boot/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ project(esp32boot)
2323
include(BuildErlang)
2424

2525
if (Elixir_FOUND)
26-
pack_runnable(esp32boot esp32init esp32devmode eavmlib estdlib alisp exavmlib)
27-
else()
28-
pack_runnable(esp32boot esp32init esp32devmode eavmlib estdlib alisp)
26+
pack_runnable(elixir_esp32boot esp32init esp32devmode eavmlib estdlib alisp exavmlib)
2927
endif()
28+
29+
pack_runnable(esp32boot esp32init esp32devmode eavmlib estdlib alisp)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2018-2021 Davide Bettio <davide@uninstall.it>
2+
# Copyright 2018-2021 Fred Dushin <fred@dushin.net>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
5+
6+
# Name, Type, SubType, Offset, Size, Flags
7+
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
8+
nvs, data, nvs, 0x9000, 0x6000,
9+
phy_init, data, phy, 0xf000, 0x1000,
10+
factory, app, factory, 0x10000, 0x1C0000,
11+
boot.avm, data, phy, 0x1D0000, 0x80000,
12+
main.avm, data, phy, 0x250000, 0x100000

src/platforms/esp32/tools/mkimage.config.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#{
3939
name => "AtomVM Boot and Core BEAM Library",
4040
offset => "0x1D0000",
41-
path => ["${BUILD_DIR}/../../../../build/libs/esp32boot/esp32boot.avm"]
41+
path => ["$[BOOT_FILE]"]
4242
}
4343
]
4444
}.

src/platforms/esp32/tools/mkimage.erl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ do_main(Argv) ->
4242
RootDir ->
4343
try
4444
Config = load_config(maps:get(config, Opts, "mkimage.config")),
45+
BuildDir = get_build_dir(Opts, RootDir),
46+
BootFile = BuildDir ++ "/libs/esp32boot/esp32boot.avm",
4547
mkimage(
4648
RootDir,
47-
get_build_dir(Opts, RootDir),
49+
BuildDir,
50+
maps:get(boot, Opts, BootFile),
4851
maps:get(out, Opts, "atomvm.img"),
4952
maps:get(segments, Config)
5053
),
@@ -65,6 +68,8 @@ parse_args(Argv) ->
6568
%% @private
6669
parse_args([], {Opts, Args}) ->
6770
{Opts, lists:reverse(Args)};
71+
parse_args(["--boot", Path | T], {Opts, Args}) ->
72+
parse_args(T, {Opts#{boot => Path}, Args});
6873
parse_args(["--out", Path | T], {Opts, Args}) ->
6974
parse_args(T, {Opts#{out => Path}, Args});
7075
parse_args(["--root_dir", Path | T], {Opts, Args}) ->
@@ -92,6 +97,7 @@ print_help() ->
9297
"The following options are supported:"
9398
"~n"
9499
" * --root_dir <path> Path to the root directory of the AtomVM git checkout~n"
100+
" * --boot <path> Path to a esp32boot.avm file~n"
95101
" * --build_dir <path> Path to the AtomVM build directory (defaults to root_dir/build, if unspecifeid)~n"
96102
" * --out <path> Output path for AtomVM image file~n"
97103
" * --config <path> Path to mkimage configuration file~n"
@@ -124,7 +130,7 @@ get_build_dir(Opts, RootDir) ->
124130
end.
125131

126132
%% @private
127-
mkimage(RootDir, BuildDir, OutputFile, Segments) ->
133+
mkimage(RootDir, BuildDir, BootFile, OutputFile, Segments) ->
128134
io:format("Writing output to ~s~n", [OutputFile]),
129135
io:format("=============================================~n"),
130136
case file:open(OutputFile, [write, binary]) of
@@ -156,7 +162,7 @@ mkimage(RootDir, BuildDir, OutputFile, Segments) ->
156162
end
157163
end,
158164
SegmentPaths = [
159-
replace("BUILD_DIR", BuildDir, replace("ROOT_DIR", RootDir, SegmentPath))
165+
replace("BUILD_DIR", BuildDir, replace("BOOT_FILE", BootFile, replace("ROOT_DIR", RootDir, SegmentPath)))
160166
|| SegmentPath <- maps:get(path, Segment)
161167
],
162168
case try_read(SegmentPaths) of
@@ -200,4 +206,5 @@ from_hex([$0, $x | Bits]) ->
200206

201207
%% @private
202208
replace(VariableName, Value, String) ->
203-
string:replace(String, io_lib:format("${~s}", [VariableName]), Value).
209+
string:replace(String, io_lib:format("${~s}", [VariableName]), Value),
210+
string:replace(String, io_lib:format("$[~s]", [VariableName]), Value).

0 commit comments

Comments
 (0)