You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/mix/tasks/esp32_flash.ex
+54Lines changed: 54 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,59 @@
1
1
defmoduleMix.Tasks.Atomvm.Esp32.Flashdo
2
2
useMix.Task
3
+
4
+
@shortdoc"Flash the application to an ESP32 micro-controller"
5
+
6
+
@moduledoc"""
7
+
Flashes the application to an ESP32 micro-controller.
8
+
9
+
> #### Info {: .info}
10
+
>
11
+
> Note. Before running this task, you must flash the AtomVM virtual machine to the target device.
12
+
>
13
+
> ### ESP32 Build Requirements
14
+
>
15
+
> This tasks depends on a host installation of the IDF_SDK and Espressif Xtensa tool chains, see [Building for ESP32](https://www.atomvm.net/doc/main/build-instructions.html#building-for-esp32)
16
+
>
17
+
> If the IDF_PATH environment variable is set, then the esptool.py from the IDF SDK installation will be used to flash the application to the ESP32 device.
18
+
> Otherwise, this plugin will attempt to use the esptool.py program from the user's PATH environment variable.
19
+
> The ESP Tool Python3 application can be installed from source or via many popular package managers. Consult your local OS documentation for more information.
20
+
21
+
## Usage example
22
+
23
+
Within your AtomVM mix project run
24
+
25
+
`
26
+
$ mix atomvm.esp32.flash
27
+
`
28
+
29
+
Or with optional flags (which will override the config in mix.exs)
Copy file name to clipboardExpand all lines: lib/mix/tasks/pico_flash.ex
+113-8Lines changed: 113 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,53 @@
1
1
defmoduleMix.Tasks.Atomvm.Pico.Flashdo
2
2
useMix.Task
3
+
4
+
@shortdoc"Flash the application to a pico micro-controller"
5
+
6
+
@moduledoc"""
7
+
Flashes the application to a Raspberry Pi RP2
8
+
9
+
You can build with all boards supported by Raspberry Pi pico SDK, including Pico, Pico-W and Pico2.
10
+
AtomVM also works with clones such as RP2040 Zero.
11
+
12
+
> #### Info {: .info}
13
+
>
14
+
> Note. Before running this task, you must flash the AtomVM virtual machine to the target device.
15
+
>
16
+
> This tasks depends on a host installation of pico supported tooling, see [Building for Raspberry Pi RP2](https://www.atomvm.net/doc/master/build-instructions.html#building-for-raspberry-pi-rp2)
17
+
18
+
## Usage example
19
+
20
+
Within your AtomVM mix project run
21
+
22
+
`
23
+
$ mix atomvm.pico.flash
24
+
`
25
+
26
+
Or with optional flags (which will override the config in mix.exs)
27
+
28
+
`
29
+
$ mix atomvm.pico.flash --picotool /some/path
30
+
`
31
+
32
+
## Configuration
33
+
34
+
ExAtomVM can be configured from the mix.ex file and supports the following settings for the
35
+
`atomvm.pico.flash` task.
36
+
37
+
* `:pico_path` - The full path to the pico mount point, defaults to `"/run/media/${USER}/RPI-RP2"` on linux; `"/Volumes/RPI-RP2"` on darwin (Mac)
38
+
39
+
* `:pico_reset` - The full path to the pico device to reset if required, default `"/dev/ttyACM*"` on linux; `"/dev/cu.usbmodem14*"` on darwin (Mac)
40
+
41
+
* `:picotool` - The full path to picotool executable (currently optional), default `undefined`
42
+
43
+
## Command line options
44
+
45
+
Properties in the mix.exs file may be over-ridden on the command line using long-style flags (prefixed by --) by the same name
46
+
as the supported properties key listed in .
47
+
48
+
For example, you can use the `--picotool` option to specify or override the `picotool` property.
49
+
"""
50
+
3
51
aliasMix.Project
4
52
aliasMix.Tasks.Atomvm.Uf2create
5
53
@@ -9,12 +57,38 @@ defmodule Mix.Tasks.Atomvm.Pico.Flash do
@@ -70,13 +144,16 @@ defmodule Mix.Tasks.Atomvm.Pico.Flash do
70
144
caseMap.get(filestat,:type)do
71
145
:directory->
72
146
:ok
147
+
73
148
_->
74
149
IO.puts("Object found at #{mount} is not a directory")
75
150
exit({:shutdown,1})
76
151
end
152
+
77
153
{:error,:enoent}->
78
154
Process.sleep(1000)
79
155
wait_for_mount(mount,count+1)
156
+
80
157
error->
81
158
IO.puts("unexpected error: #{error} while checking pico mount path.")
82
159
exit({:shutdown,1})
@@ -94,10 +171,12 @@ defmodule Mix.Tasks.Atomvm.Pico.Flash do
94
171
caseMap.get(info,:type)do
95
172
:directory->
96
173
:ok
174
+
97
175
_->
98
176
IO.puts("error: object at pico mount path not a directory. Abort!")
99
177
exit({:shutdown,1})
100
178
end
179
+
101
180
_->
102
181
IO.puts("error: Pico not mounted. Abort!")
103
182
exit({:shutdown,1})
@@ -123,16 +202,19 @@ defmodule Mix.Tasks.Atomvm.Pico.Flash do
123
202
casePath.wildcard(resetdev)do
124
203
[]->
125
204
false
205
+
126
206
[device|_t]->
127
207
caseFile.stat(device)do
128
208
{:ok,info}->
129
209
caseMap.get(info,:type)do
130
210
:device->{true,device}
131
211
_->false
132
212
end
213
+
133
214
_->
134
215
false
135
216
end
217
+
136
218
_->
137
219
false
138
220
end
@@ -146,25 +228,40 @@ defmodule Mix.Tasks.Atomvm.Pico.Flash do
146
228
{"",0}->
147
229
# Pause to let the device settle
148
230
Process.sleep(200)
231
+
149
232
error->
150
233
casepicotooldo
151
234
false->
152
-
IO.puts("Error: #{error}\nUnable to locate 'picotool', close the serial monitor before flashing, or install picotool for automatic disconnect and BOOTSEL mode.")
235
+
IO.puts(
236
+
"Error: #{error}\nUnable to locate 'picotool', close the serial monitor before flashing, or install picotool for automatic disconnect and BOOTSEL mode."
237
+
)
238
+
153
239
exit({:shutdown,1})
240
+
154
241
_->
155
-
IO.puts("Warning: #{error}\nFor faster flashing remember to disconnect serial monitor first.")
242
+
IO.puts(
243
+
"Warning: #{error}\nFor faster flashing remember to disconnect serial monitor first."
244
+
)
245
+
156
246
reset_args=["reboot","-f","-u"]
157
-
IO.puts("Disconnecting serial monitor with `picotool #{:lists.join(" ",reset_args)}` in 5 seconds...")
247
+
248
+
IO.puts(
249
+
"Disconnecting serial monitor with `picotool #{:lists.join(" ",reset_args)}` in 5 seconds..."
0 commit comments