@@ -42,9 +42,12 @@ do_main(Argv) ->
42
42
RootDir ->
43
43
try
44
44
Config = load_config (maps :get (config , Opts , " mkimage.config" )),
45
+ BuildDir = get_build_dir (Opts , RootDir ),
46
+ BootFile = BuildDir ++ " /libs/esp32boot/esp32boot.avm" ,
45
47
mkimage (
46
48
RootDir ,
47
- get_build_dir (Opts , RootDir ),
49
+ BuildDir ,
50
+ maps :get (boot , Opts , BootFile ),
48
51
maps :get (out , Opts , " atomvm.img" ),
49
52
maps :get (segments , Config )
50
53
),
@@ -65,6 +68,8 @@ parse_args(Argv) ->
65
68
% % @private
66
69
parse_args ([], {Opts , Args }) ->
67
70
{Opts , lists :reverse (Args )};
71
+ parse_args ([" --boot" , Path | T ], {Opts , Args }) ->
72
+ parse_args (T , {Opts #{boot => Path }, Args });
68
73
parse_args ([" --out" , Path | T ], {Opts , Args }) ->
69
74
parse_args (T , {Opts #{out => Path }, Args });
70
75
parse_args ([" --root_dir" , Path | T ], {Opts , Args }) ->
@@ -92,6 +97,7 @@ print_help() ->
92
97
" The following options are supported:"
93
98
" ~n "
94
99
" * --root_dir <path> Path to the root directory of the AtomVM git checkout~n "
100
+ " * --boot <path> Path to a esp32boot.avm file~n "
95
101
" * --build_dir <path> Path to the AtomVM build directory (defaults to root_dir/build, if unspecifeid)~n "
96
102
" * --out <path> Output path for AtomVM image file~n "
97
103
" * --config <path> Path to mkimage configuration file~n "
@@ -124,7 +130,7 @@ get_build_dir(Opts, RootDir) ->
124
130
end .
125
131
126
132
% % @private
127
- mkimage (RootDir , BuildDir , OutputFile , Segments ) ->
133
+ mkimage (RootDir , BuildDir , BootFile , OutputFile , Segments ) ->
128
134
io :format (" Writing output to ~s~n " , [OutputFile ]),
129
135
io :format (" =============================================~n " ),
130
136
case file :open (OutputFile , [write , binary ]) of
@@ -156,7 +162,7 @@ mkimage(RootDir, BuildDir, OutputFile, Segments) ->
156
162
end
157
163
end ,
158
164
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 ) ))
160
166
|| SegmentPath <- maps :get (path , Segment )
161
167
],
162
168
case try_read (SegmentPaths ) of
@@ -200,4 +206,5 @@ from_hex([$0, $x | Bits]) ->
200
206
201
207
% % @private
202
208
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