-
Notifications
You must be signed in to change notification settings - Fork 5
Enhancements for the esp32_flash task #52
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
base: master
Are you sure you want to change the base?
Conversation
5685f2a to
91a5fc9
Compare
91a5fc9 to
783d3ad
Compare
586a1ef to
d334c12
Compare
pguyot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Partial review)
3a391b9 to
4d4e57e
Compare
9b7d519 to
fe79208
Compare
src/atomvm_esp32_flash_provider.erl
Outdated
| rebar_api:abort("Partition ~s not found!", [Partition]); | ||
| error:invalid_partition_table -> | ||
| rebar_api:abort( | ||
| "Error parsing partition table, possible line noise reading from device.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Port already open with minicom is more likely here than line noise ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it were an open port to minicom that would have caused a rebar_api:abort/2 sooner, but I was not catching it there, and it would have fallen through to a more generic error.
I did rework error reporting a bit and centralized the error decoding to clean up the logic, and because so many of the errors can occur in multiple call locations.
src/atomvm_esp32_flash_provider.erl
Outdated
|
|
||
| %% @private | ||
| get_part_tempfile(State) -> | ||
| OutDir = filename:absname(rebar_dir:base_dir(State)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should call mktemp(1) here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. When I was first implementing this I intended to look into OTP methods for using temp files, but by the time I got the tricky bits working I forget to go back and address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did use mktemp here, which prompted me to add atomvm_rebar3_plugin:external_command/3 for better re-usability (making the transition to replace use of os:cmd/1,2 with open_port/2 in other providers). I also added a temp logfile for esptool.py output. It turns out that the dumpfile created by mktemp causes esptool.py an error, so it needs to be deleted immediately, but the tempfile generated name is still used. Both the esptool.py output log and dumpfile are cleaned up before exiting successfully, but retained, and the full path to the logfile displayed if there is a failure.
src/esp_part_dump.erl
Outdated
| {Tool, {exit_status, Status}} -> | ||
| error({"esptool.py failure", Status}) | ||
| after 120000 -> | ||
| error("esptool.py failed (2 minute timeout exceeded)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tool is not closed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I did completely forget about that. Out of curiosity, how does the VM handle that close internally? Is a signal sent to the OS kill the external process?
885f434 to
db356bd
Compare
Changes error reporting for the esp32_flash task to include stack trace when rebar3 is executed with DIAGNOSTIC=1 or DEBUG=1. Signed-off-by: Winford <winford@object.stream>
c9ad99f to
5cfb5c7
Compare
3586f77 to
dbbf440
Compare
The `offset` for the beam application partition is now read from the partition table on the attached esp32 device. When a custom partition table is used that does not use `main.avm` for the beam app partition name the `app_partition` parameter should be used to specify the application partition to be flashed. Valid application partition sub-types (the type is `data`) are `phy` or `0xAA`. If the `offset` parameter is specified it will be used to verify that the offset address of the application partition matched the expected value. This may be used to prevent flashing to a standard build of AtomMV for application that require a custom partition table. The `port` that the ESP32 is attached to is now auto discovered by default. When more than one ESP32 device is plugged into USB the port should be specified to control which device is flashed. Error reporting has been improved with descriptive error messages. Dialyzer warnings for the esp32_flash task have been fixed when analyzing atomvm_rebar3_plugin. Signed-off-by: Winford <winford@object.stream>
dbbf440 to
54d23fd
Compare
Changes include automatic detection of the beam application partition (default
main.avm) to prevent overwriting the wrong flash sectors. This prevents overwriting Elixir library modules for Elixir supported builds, and assures that the application will be written to the same address that AtomVM will load and run. When flashing to a device with a custom partition table theapp_partitionparameter should be supplied if the app partition is not namedmain.avm.Other changes include: