Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platforms/esp32/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ elseif(${CONFIG_IDF_TARGET} STREQUAL "esp32p4")
set(BOOTLOADER_OFFSET "0x2000")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mkimage.config.in ${CMAKE_BINARY_DIR}/mkimage.config)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mkimage.config.in ${CMAKE_BINARY_DIR}/mkimage.config @ONLY)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/dev/flash.sh ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/flash.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mkimage.erl ${CMAKE_BINARY_DIR}/mkimage.erl COPYONLY)
Expand Down
8 changes: 4 additions & 4 deletions src/platforms/esp32/tools/mkimage.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
segments => [
#{
name => "bootloader",
offset => "${BOOTLOADER_OFFSET}",
path => ["${BUILD_DIR}/bootloader/bootloader.bin"]
offset => "@BOOTLOADER_OFFSET@",
path => ["${ROOT_DIR}/src/platforms/esp32/build/bootloader/bootloader.bin"]
},
#{
name => "partition-table",
offset => "0x8000",
path => ["${BUILD_DIR}/partition_table/partition-table.bin", "${BUILD_DIR}/partitions.bin"]
path => ["${ROOT_DIR}/src/platforms/esp32/build/partition_table/partition-table.bin"]
},
#{
name => "AtomVM Virtual Machine",
offset => "0x10000",
path => ["${BUILD_DIR}/atomvm-esp32.bin", "${ROOT_DIR}/src/platforms/esp32/build/atomvvm-esp32.bin"]
path => ["${ROOT_DIR}/src/platforms/esp32/build/atomvm-esp32.bin"]
},
#{
name => "AtomVM Boot and Core BEAM Library",
Expand Down
13 changes: 4 additions & 9 deletions src/platforms/esp32/tools/mkimage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ do_main(Argv) ->
BootFile = BuildDir ++ "/libs/esp32boot/esp32boot.avm",
mkimage(
RootDir,
BuildDir,
maps:get(boot, Opts, BootFile),
maps:get(out, Opts, "atomvm.img"),
maps:get(segments, Config)
Expand Down Expand Up @@ -130,7 +129,7 @@ get_build_dir(Opts, RootDir) ->
end.

%% @private
mkimage(RootDir, BuildDir, BootFile, OutputFile, Segments) ->
mkimage(RootDir, BootFile, OutputFile, Segments) ->
io:format("Writing output to ~s~n", [OutputFile]),
io:format("boot file is ~s~n", [BootFile]),
io:format("=============================================~n"),
Expand Down Expand Up @@ -164,11 +163,7 @@ mkimage(RootDir, BuildDir, BootFile, OutputFile, Segments) ->
end,
SegmentPaths = [
replace(
"BUILD_DIR",
BuildDir,
replace(
"BOOT_FILE", BootFile, replace("ROOT_DIR", RootDir, SegmentPath)
)
"BOOT_FILE", BootFile, replace("ROOT_DIR", RootDir, SegmentPath)
)
|| SegmentPath <- maps:get(path, Segment)
],
Expand Down Expand Up @@ -213,5 +208,5 @@ from_hex([$0, $x | Bits]) ->

%% @private
replace(VariableName, Value, String) ->
string:replace(String, io_lib:format("${~s}", [VariableName]), Value),
string:replace(String, io_lib:format("$[~s]", [VariableName]), Value).
String0 = string:replace(String, io_lib:format("${~s}", [VariableName]), Value),
string:replace(String0, io_lib:format("$[~s]", [VariableName]), Value).
31 changes: 22 additions & 9 deletions src/platforms/esp32/tools/mkimage.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#

escript "@CMAKE_BINARY_DIR@/mkimage.erl" \
--root_dir "@CMAKE_BINARY_DIR@/../../../.." \
--config "@CMAKE_BINARY_DIR@/mkimage.config" \
--out "@CMAKE_BINARY_DIR@/atomvm-@CONFIG_IDF_TARGET@.img" \
"$@"
build_dir=$(CDPATH=; cd -- "$(dirname -- "$0")" && pwd -P)

echo "============================================="
report_success()
{
echo "============================================="
echo ""
echo "AtomVM @CONFIG_IDF_TARGET@ version @ATOMVM_VERSION@ image written to:"
echo "${build_dir}/atomvm-@CONFIG_IDF_TARGET@.img"
exit 0
}

fail()
{
echo ""
echo "Failed to build image."
exit 1
}

escript "${build_dir}/mkimage.erl" \
--root_dir "${build_dir}/../../../../" \
--config "${build_dir}/mkimage.config" \
--out "${build_dir}/atomvm-@CONFIG_IDF_TARGET@.img" \
"$@" && report_success || fail

echo ""
echo "AtomVM @CONFIG_IDF_TARGET@ version @ATOMVM_VERSION@ image written to:"
echo "@CMAKE_BINARY_DIR@/atomvm-@CONFIG_IDF_TARGET@.img"
Loading