Skip to content

Commit d1d5b40

Browse files
committed
esp32_flash: fix crash when -b/--baud is given
The legacy (non-namespaced) esp32_flash task typed baud as a string in its option spec while the atomvm-namespaced provider it delegates to types it as an integer; any explicit -b through the legacy task reached do_flash as a string and crashed integer_to_list/1 with badarg. Type the legacy option as integer, and also normalize baud in get_opts so string values from rebar.config keep working. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 9022349 commit d1d5b40

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/atomvm_esp32_flash_provider.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ get_opts(State) ->
107107
{ParsedArgs, _} = rebar_state:command_parsed_args(State),
108108
RebarOpts = atomvm_rebar3_plugin:get_atomvm_rebar_provider_config(State, ?PROVIDER),
109109
ParsedOpts = atomvm_rebar3_plugin:proplist_to_map(ParsedArgs),
110-
maps:merge(
110+
Opts = maps:merge(
111111
env_opts(),
112112
maps:merge(RebarOpts, ParsedOpts)
113-
).
113+
),
114+
% baud may arrive as a string from rebar.config or from the legacy
115+
% (non-namespaced) esp32_flash task, whose option spec used to type
116+
% it as a string; do_flash needs an integer.
117+
Opts#{baud := maybe_convert_string(maps:get(baud, Opts))}.
114118

115119
%% @private
116120
env_opts() ->

src/legacy_esp32_flash_provider.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{esptool, $e, "esptool", string, "Path to esptool.py"},
3232
{chip, $c, "chip", string, "ESP chip (default auto)"},
3333
{port, $p, "port", string, "Device port (default /dev/ttyUSB0)"},
34-
{baud, $b, "baud", string, "Baud rate (default 115200)"},
34+
{baud, $b, "baud", integer, "Baud rate (default 115200)"},
3535
{offset, $o, "offset", string, "Offset (default 0x210000)"}
3636
]).
3737

0 commit comments

Comments
 (0)