-
Notifications
You must be signed in to change notification settings - Fork 89
Make it easier to build and flash with jag #3025
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -314,18 +314,18 @@ in `build/esp32/firmware.envelope`: | |
| make esp32 | ||
| ``` | ||
|
|
||
| For other chip variants use the corresponding make target. For example, for the ESP32-C6 which would generate in `build/esp32c6/firmware.envelope`: | ||
|
|
||
| ``` sh | ||
| make esp32c6 | ||
| ``` | ||
|
|
||
| If you want to flash the generated firmware on your device, you can use the `firmware` | ||
| too. Internally, the `firmware` tool calls out to | ||
| [esptool](https://github.com/espressif/esptool) | ||
| so you need to install that one first. | ||
| You can also set the environment variable `ESPTOOL_PATH` to point | ||
| to a valid esptool (for example the one in the shipped esp-idf: | ||
| `export ESPTOOL_PATH=$PWD/third_party/esp-idf/components/esptool_py/esptool/esptool.py`). | ||
| Assuming your device is connected through `/dev/ttyUSB0` | ||
| you can then flash a device as follows: | ||
| tool. Internally it calls the bundled esptool from the esp-idf submodule. | ||
| You can override this with the `ESPTOOL_PATH` environment variable if you want to use a different version of esptool. | ||
|
|
||
| ``` sh | ||
| build/host/sdk/lib/toit/tool firmware -e build/esp32/firmware.envelope \ | ||
| build/host/sdk/bin/toit tool firmware -e build/esp32/firmware.envelope \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good change. thanks. |
||
| flash --port /dev/ttyUSB0 --baud 921600 | ||
| ``` | ||
|
|
||
|
|
@@ -340,6 +340,39 @@ build/host/sdk/bin/toit tool firmware -e build/esp32/firmware.envelope \ | |
| flash --port /dev/ttyUSB0 --baud 921600 | ||
| ``` | ||
|
|
||
| ### Flashing with Jaguar (live reloading) | ||
|
|
||
| To run Jaguar on your locally built firmware, compile the Jaguar service snapshot | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally I use |
||
| using your SDK (so the versions match) and install it as a container before flashing. | ||
| The Jaguar source lives in [toitlang/jaguar](https://github.com/toitlang/jaguar). | ||
| Set `JAG_PATH` to its location, or leave it unset to default to `../jaguar` | ||
| (i.e. checked out alongside this repo): | ||
|
|
||
| ``` sh | ||
| JAG_PATH=${JAG_PATH:-../jaguar} | ||
|
|
||
| # Install jaguar's dependencies and compile its service snapshot | ||
| build/host/sdk/bin/toit pkg --project-root="$JAG_PATH" install | ||
| build/host/sdk/bin/toit compile -O2 --snapshot \ | ||
| -o /tmp/jaguar.snapshot "$JAG_PATH/src/jaguar.toit" | ||
|
|
||
| # Add jaguar to the firmware envelope | ||
| build/host/sdk/bin/toit tool firmware \ | ||
| -e build/esp32c6/firmware.envelope \ | ||
| container install -o /tmp/firmware-jaguar.envelope \ | ||
| jaguar /tmp/jaguar.snapshot | ||
|
|
||
| # Flash with WiFi credentials | ||
| # echo '{ "wifi": { "wifi.ssid": "YourSSID", "wifi.password": "YourPassword" } }' > wifi.json | ||
| build/host/sdk/bin/toit tool firmware \ | ||
| -e /tmp/firmware-jaguar.envelope \ | ||
| flash --config wifi.json --port /dev/ttyACM0 --baud 921600 | ||
| ``` | ||
|
|
||
| > **Note:** The jaguar snapshot must be compiled with the same SDK version as the | ||
| > firmware envelope. `jag flash` alone uses jag's pre-built snapshot which is pinned | ||
| > to a release tag and will not match a local dev build's version suffix. | ||
|
|
||
| ### Adding multiple containers | ||
|
|
||
| You can add more containers before you flash, so you firmware | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1116,29 +1116,17 @@ flash invocation/cli.Invocation -> none: | |
|
|
||
| esptool := find-esptool_ | ||
|
|
||
| // The new esptool has deprecated underscores in some arguments. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of unconditionally removing the replacements. Compromise: |
||
| // TODO(floitsch): remove these replacements when the esp-idf has been updated | ||
| // to a version that uses the new arguments. | ||
| before-args := flashing["extra_esptool_args"]["before"] | ||
| after-args := flashing["extra_esptool_args"]["after"] | ||
| write-flash-args := flashing["write_flash_args"] | ||
| before-args = before-args.replace --all "default_reset" "default-reset" | ||
| before-args = before-args.replace --all "no_reset" "no-reset" | ||
| after-args = after-args.replace --all "hard_reset" "hard-reset" | ||
| after-args = after-args.replace --all "no_reset" "no-reset" | ||
| write-flash-args.map --in-place: | ||
| if it == "--flash_mode": "--flash-mode" | ||
| else if it == "--flash_size": "--flash-size" | ||
| else if it == "--flash_freq": "--flash-freq" | ||
| else: it | ||
|
|
||
| code := pipe.run-program esptool + [ | ||
| "--port", port, | ||
| "--baud", "$baud", | ||
| "--chip", chip, | ||
| "--before", before-args, | ||
| "--after", after-args | ||
| ] + [ "write-flash" ] + write-flash-args + partition-args | ||
| ] + [ "write_flash" ] + write-flash-args + partition-args | ||
| if code != 0: exit 1 | ||
| finally: | ||
| directory.rmdir --recursive tmp | ||
|
|
||
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.
That only works if one has sourced the
export.sh. Otherwise it doesn't. (I didn't know that until today...)