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
Make pico_flash provider picotool path configurable
Changes the pico_flash provider to allow setting the full path to picotool as an environment
variable, in rebar.config, or from cli parameters when exacuting the task.
Closes#40
Signed-off-by: Winford <winford@object.stream>
Any setting specified on the command line take precedence over entries in `rebar.config`, which in turn take precedence over environment variable settings, which in turn take precedence over the default values specified above.
Copy file name to clipboardExpand all lines: src/atomvm_pico_flash_provider.erl
+27-13Lines changed: 27 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,8 @@
34
34
{path, $p, "path", string,
35
35
"Path to pico device (Defaults Linux: /run/media/${USER}/RPI-RP2, MacOS: /Volumes/RPI-RP2)"},
36
36
{reset, $r, "reset", string,
37
-
"Path to serial device to reset before flashing (Defaults Linux: /dev/ttyACM0, MacOS: /dev/cu.usbmodem14*)"}
37
+
"Path to serial device to reset before flashing (Defaults Linux: /dev/ttyACM0, MacOS: /dev/cu.usbmodem14*)"},
38
+
{picotool, $t, "picotool", string, "Path to picotool utility (Default is to search in PATH)"}
38
39
]).
39
40
40
41
%%
@@ -72,7 +73,8 @@ do(State) ->
72
73
ok=do_flash(
73
74
rebar_state:project_apps(State),
74
75
maps:get(path, Opts),
75
-
maps:get(reset, Opts)
76
+
maps:get(reset, Opts),
77
+
maps:get(picotool, Opts)
76
78
),
77
79
{ok, State}
78
80
catch
@@ -109,9 +111,22 @@ env_opts() ->
109
111
reset=>os:getenv(
110
112
"ATOMVM_REBAR3_PLUGIN_PICO_RESET_DEV",
111
113
get_reset_dev()
114
+
),
115
+
picotool=>os:getenv(
116
+
"ATOMVM_REBAR3_PLUGIN_PICOTOOL",
117
+
os:getenv("ATOMVM_PICOTOOL", find_picotool())
112
118
)
113
119
}.
114
120
121
+
%% @private
122
+
find_picotool() ->
123
+
caseos:find_executable("picotool") of
124
+
false ->
125
+
"";
126
+
Picotool ->
127
+
Picotool
128
+
end.
129
+
115
130
%% @private
116
131
get_stty_file_flag() ->
117
132
{_Fam, System} =os:type(),
@@ -228,7 +243,7 @@ needs_reset(ResetDev) ->
228
243
end.
229
244
230
245
%% @private
231
-
do_reset(ResetPort) ->
246
+
do_reset(ResetPort, Picotool) ->
232
247
Flag=get_stty_file_flag(),
233
248
BootselMode=lists:join("", [
234
249
"stty", Flag, ResetPort, "1200"
@@ -239,20 +254,19 @@ do_reset(ResetPort) ->
239
254
"" ->
240
255
ok;
241
256
Error ->
242
-
caseos:find_executable(picotool)of
243
-
false ->
244
-
rebar_api:error(
245
-
"Warning: ~s~nUnable to locate 'picotool', close the serial monitor before flashing, or install picotool for automatic disconnect and BOOTSEL mode.",
257
+
casePicotoolof
258
+
"" ->
259
+
rebar_api:abort(
260
+
"Warning: ~s~nUnable to locate 'picotool', close the serial monitor before flashing, or supply the path to picotool if it is not installed in your PATH for automatic disconnect and BOOTSEL mode.",
246
261
[Error]
247
-
),
248
-
erlang:throw(reset_error);
249
-
Picotool ->
262
+
);
263
+
RP2tool ->
250
264
rebar_api:warn(
251
265
"Warning: ~s~nFor faster flashing remember to disconnect serial monitor first.",
252
266
[Error]
253
267
),
254
268
DevReset=lists:join("", [
255
-
Picotool, "reboot", "-f", "-u"
269
+
RP2tool, "reboot", "-f", "-u"
256
270
]),
257
271
rebar_api:warn("Disconnecting serial monitor with: `~s' in 5 seconds...", [
0 commit comments