Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: add support for init / esp32boot.avm #657

Merged
merged 7 commits into from
Aug 6, 2023

Conversation

bettio
Copy link
Collaborator

@bettio bettio commented Jul 1, 2023

Init takes care of launching startup module and eventually ALISP console and web server according to configuration / in case of failure.

Closes #654

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@bettio bettio changed the title Esp32kernel ESP32: add support for kernel app Jul 1, 2023
@bettio bettio force-pushed the esp32kernel branch 2 times, most recently from e305246 to 6cd8afc Compare July 3, 2023 17:53
src/libAtomVM/nifs.gperf Outdated Show resolved Hide resolved
src/libAtomVM/nifs.c Outdated Show resolved Hide resolved
@bettio bettio marked this pull request as ready for review July 6, 2023 23:37
libs/CMakeLists.txt Outdated Show resolved Hide resolved
@bettio bettio force-pushed the esp32kernel branch 2 times, most recently from d6f79f0 to f07cce5 Compare July 9, 2023 15:50
@bettio bettio force-pushed the esp32kernel branch 2 times, most recently from 13ec09f to b2f582b Compare July 22, 2023 12:35
src/libAtomVM/nifs.c Fixed Show fixed Hide fixed
src/libAtomVM/nifs.c Fixed Show fixed Hide fixed
@bettio bettio changed the title ESP32: add support for kernel app ESP32: add support for init / esp32boot.avm Jul 22, 2023
@bettio bettio force-pushed the esp32kernel branch 2 times, most recently from 7ef680e to 2b1aadc Compare July 22, 2023 14:03
Copy link
Collaborator

@fadushin fadushin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High level comments:

Breaking changes:

  1. The changes to the return value and looping in the esp32init:start/0 function significantly change the current behavior of AtomVM. Specifically, the VM will never terminate with this change. This needs to be discussed.
  2. The current change breaks images created in CI and even by default on the command line without changes to the image building process and the creation of an AVM file to populate the boot.avm partition that include the esp32boot contents and the libatomvm.avm contents.

Devops/style issues:

  1. This PR should be split into probably 3 PRs and reviewed separately
    • Addition of a new Nif (atomvm_get_start_beam_nif)
    • Change of the return type of an internal API (sys_open_avm_from_file)
    • The thrust of this PR -- the new esp32init module and support for it
  2. The esp32init module needs to be broken up into a core module that doesn't bring in any of the web server or networking logic. This adds code and atoms that do not need to be loaded in the majority of applications that are not using dev mode.
  3. Debugging code needs to be removed
  4. Dev mode probably needs to be documented in the Getting Started Guide.

src/platforms/esp32/main/main.c Show resolved Hide resolved
libs/esp32boot/esp32init.erl Outdated Show resolved Hide resolved
src/libAtomVM/nifs.c Outdated Show resolved Hide resolved
src/libAtomVM/sys.h Outdated Show resolved Hide resolved
libs/esp32boot/esp32init.erl Outdated Show resolved Hide resolved
src/platforms/esp32/partitions.csv Show resolved Hide resolved
libs/esp32boot/esp32init.erl Outdated Show resolved Hide resolved
libs/esp32boot/esp32init.erl Outdated Show resolved Hide resolved
libs/esp32boot/esp32init.erl Outdated Show resolved Hide resolved
libs/esp32boot/esp32init.erl Show resolved Hide resolved
@bettio bettio marked this pull request as draft July 22, 2023 22:31
bettio added a commit that referenced this pull request Jul 23, 2023
…type

Make atomvm:add_avm_pack_file/2 return a meaningful error

This change is required for #657.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
bettio added a commit that referenced this pull request Jul 24, 2023
NIFs: add atomvm:get_start_beam/1

This change is required in order to implement #657.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
@bettio
Copy link
Collaborator Author

bettio commented Jul 24, 2023

If we don't feel 100% sure about a number of choices we can also defer this as default (and hence the mkimage change), and iterate over this more and more until it is good enough for using it as default.

@bettio bettio marked this pull request as ready for review July 28, 2023 13:16
@bettio bettio added this to the v0.6 milestone Jul 28, 2023
libs/esp32devmode/src/esp32devmode.erl Outdated Show resolved Hide resolved
libs/esp32boot/esp32init.erl Show resolved Hide resolved
esp32init purpose is to load the application from an application
partition.

Signed-off-by: Davide Bettio <[email protected]>
Try to boot boot.avm partition first, which will take care of
application loading.

Signed-off-by: Davide Bettio <[email protected]>
Use atomvm:get_start_beam/1 for finding startup module instead of
relying on some static default.

Signed-off-by: Davide Bettio <[email protected]>
Do not enable it by default.

Signed-off-by: Davide Bettio <[email protected]>
Add (opt-in) NVS setting for enabling always ALISP console and web server.

Signed-off-by: Davide Bettio <[email protected]>
Keep esp32init as small as possible.

Signed-off-by: Davide Bettio <[email protected]>
@bettio bettio force-pushed the esp32kernel branch 2 times, most recently from d1bab7b to 98b88d4 Compare August 6, 2023 15:31
Copy link
Collaborator

@fadushin fadushin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev mode started even when you have flashed an application to main.app

Application is started inside of `try .. catch` block and
`timer:sleep(infinity)` is used after application exit according to
devmode settings.

Signed-off-by: Davide Bettio <[email protected]>
@bettio bettio merged commit 867592e into atomvm:master Aug 6, 2023
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESP32 partition schema and apps support
4 participants