Skip to content

Commit

Permalink
ESP32/kernel: use atomvm:get_entry_point/1
Browse files Browse the repository at this point in the history
Use atomvm:get_entry_point/1 for finding startup module instead of
relying on some static default.

Signed-off-by: Davide Bettio <[email protected]>
  • Loading branch information
bettio committed Jul 7, 2023
1 parent af6f470 commit 179709e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libs/esp32kernel/esp32kernel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ loop() ->

boot() ->
BootPath = get_boot_path(),
atomvm:add_avm_pack_file(BootPath, []),
atomvm:add_avm_pack_file(BootPath, [{name, app}]),

StartModule = get_start_module(),
StartModule:start().
Expand All @@ -91,7 +91,14 @@ get_boot_path() ->
get_start_module() ->
case esp:nvs_get_binary(atomvm, start_module) of
undefined ->
main;
case atomvm:get_entry_point(app) of
undefined ->
main;
ModuleNameWithExt when is_binary(ModuleNameWithExt) ->
Len = byte_size(ModuleNameWithExt) - byte_size(<<".beam">>),
ModuleName = binary:part(ModuleNameWithExt, 0, Len),
erlang:binary_to_atom(ModuleName, latin1)
end;
Module ->
erlang:binary_to_atom(Module, latin1)
end.
Expand Down

0 comments on commit 179709e

Please sign in to comment.