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
> Warning: There is currently a known bug that occurs when the VM is compiled with the `-DAVM_WAIT_FOR_USB_CONNECT` cmake option. If you have previously connected to the tty serial port with `screen`, `minicom`, or similar and have disconnected or closed the session, the device will take unusually long to reset and fail to mount the FAT partition within 30 seconds and `pico_flash` will fail. This can be worked around by unplugging the pico from usb and plug it back in again, before repeating the flash procedure.
433
+
> Note: If you use the `pico_flash` task while you are still connected to a serial monitoring application such as `minicom` or `screen` the `pico_flash` task will attempt to locate [`picotool`](https://github.com/raspberrypi/picotool) in the users PATH. If `picotool` is found it will be used to reboot the pico, disconnecting the serial monitor in the process, and the device will be put into `BOOTSEL` mode after it is rebooted. If `picotool` is not available the user will be informed, and reminded that manually closing the serial monitor is necessary before using `pico_flash`.
434
+
435
+
> Warning: There is currently a known bug that occurs when the VM has exited, the processor is left in as hung state. The device will take unusually long attempting to reset, and fail to mount the FAT partition within 30 seconds and `pico_flash` will fail. There is work under way to fix this bug, but in the meantime it can be worked around by unplugging the pico from usb and plug it back in again, before repeating the flash procedure.
434
436
435
437
The following table enumerates the properties that may be defined in your project's `rebar.config` file for this task. Use `pico_flash` as the key for any properties defined for this task.
rebar_api:info("Resetting device at path ~s", [ResetPort]),
209
-
ResetStatus=os:cmd(Reset),
209
+
ResetStatus=os:cmd(BootselMode),
210
210
caseResetStatusof
211
211
"" ->
212
212
ok;
213
-
_Any ->
214
-
rebar_api:error("Reset ~s failed. Is tty console attached?", [ResetPort]),
215
-
rebar_api:abort()
213
+
Error ->
214
+
caseos:find_executable(picotool) of
215
+
false ->
216
+
rebar_api:error("Warning: ~s~nUnable to locate 'picotool', close the serial monitor before flashing, or install picotool for automatic disconnect and BOOTSEL mode.", [Error]),
217
+
erlang:throw(reset_error);
218
+
_Path ->
219
+
rebar_api:warn("Warning: ~s~nFor faster flashing remember to disconnect serial monitor first.", [Error]),
220
+
DevReset=lists:join("", [
221
+
"picotool", "reboot", "-f", "-u"
222
+
]),
223
+
rebar_api:warn("Disconnecting serial monitor with: `~s' in 5 seconds...", [DevReset]),
224
+
timer:sleep(5000),
225
+
RebootReturn=os:cmd(DevReset),
226
+
RebootStatus=string:trim(RebootReturn),
227
+
caseRebootStatusof
228
+
"The device was asked to reboot into BOOTSEL mode." ->
229
+
ok;
230
+
BootError ->
231
+
rebar_api:error("Failed to prepare pico for flashing: ~s", [BootError]),
232
+
erlang:throw(picoflash_reboot_error)
233
+
end
234
+
end
216
235
end,
217
-
rebar_api:info("Waiting for the device at path ~s to settle and mount...", [PicoPath]),
236
+
PrettyPath=lists:join("", [
237
+
"echo", PicoPath
238
+
]),
239
+
rebar_api:info("Waiting for the device at path ~s to settle and mount...", [string:trim(os:cmd(PrettyPath))]),
218
240
wait_for_mount(PicoPath, 0)
219
241
end,
220
242
check_pico_mount(PicoPath),
221
243
TargetUF2=get_uf2_file(ProjectApps),
222
244
Cmd=lists:join("", [
223
245
"cp", "-v", TargetUF2, PicoPath
224
246
]),
225
-
rebar_api:info("Copying ~s to ~s...~n", [TargetUF2, PicoPath]),
0 commit comments