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
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,62 @@
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
+
> #### Important {: .warning}
10
+
>
11
+
> Before running this task, you must flash the AtomVM virtual machine to the target device.
12
+
>
13
+
> This tasks depends on `esptool` and can be installed using package managers:
14
+
> - linux (debian): apt install esptool
15
+
> - macos: brew install esptool
16
+
> - or follow these [installation instructions](https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html#installation) when not available through a package manager.
17
+
18
+
## Usage example
19
+
20
+
Within your AtomVM mix project run
21
+
22
+
`
23
+
$ mix atomvm.esp32.flash
24
+
`
25
+
26
+
Or with optional flags (which will override the config in mix.exs)
Copy file name to clipboardExpand all lines: lib/mix/tasks/packbeam.ex
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,35 @@
1
1
defmoduleMix.Tasks.Atomvm.Packbeamdo
2
2
useMix.Task
3
+
4
+
@shortdoc"Bundle the application into an AVM file"
5
+
6
+
@moduledoc"""
7
+
Bundle an application into an AVM file that can be flashed to a micro-controller and (or directly on a unix host) executed by the AtomVM virtual machine.
8
+
9
+
10
+
## Usage example
11
+
12
+
Within your AtomVM mix project run
13
+
14
+
`
15
+
$ mix atomvm.packbeam
16
+
`
17
+
18
+
## Configuration
19
+
20
+
ExAtomVM can be configured from the mix.ex file and supports the following settings for the
21
+
`atomvm.packbeam` task.
22
+
23
+
* `:start` - The name of the module containing the start/0 entrypoint function. Only to be used to override the `:start` options defined in the the projects `mix.exs` This would not normally be needed, unless the user had an alternate mode of operation e.g like a client/server app that normally builds the client, but when building the server uses a different start module.
24
+
25
+
## Command line options
26
+
27
+
Properties in the mix.exs file may be over-ridden on the command line using long-style flags (prefixed by --) by the same name
28
+
as the [supported properties](#module-configuration)
29
+
30
+
For example, you can use the `--start` option to specify or override the `start` property.
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
+
> #### Important {: .warning}
13
+
>
14
+
> Before running this task, you must flash the AtomVM virtual machine to the target device.
15
+
>
16
+
> The pico provided partition is expected to be mounted. MacOS and most Linux desktop environments will do this automatically, for some it will need to be setup by the user.
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](#module-configuration)
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