Skip to content

Commit b51f3e7

Browse files
committed
repl_installer: Schedule reboot
This allows us to cleanly exit the script and disconnect before the hard reboot happens.
1 parent ef893cb commit b51f3e7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pybricksdev/repl_installer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,14 @@ async def install(self, firmware_archive_path):
141141
await self.exec_line("from _pybricks.install import install; install()")
142142

143143
# Remove installation files
144+
self.print_output = False
144145
await self.exec_line("import uos")
145146
await self.exec_line("uos.remove('_pybricks/__init__.py')")
146147
await self.exec_line("uos.remove('_pybricks/install.py')")
147148
await self.exec_line("uos.remove('_pybricks/firmware.bin')")
148149

150+
# Disconnect.
151+
await self.disconnect()
149152

150153

151154
if __name__ == "__main__":

pybricksdev/resources/install_pybricks.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import utime
1111
import uhashlib
1212
import uos
13+
import micropython
1314

1415

1516
FLASH_START = 0x8000000
@@ -196,4 +197,12 @@ def install():
196197
firmware.appl_image_store(overall_checksum.to_bytes(4, 'little'))
197198

198199
# Check result
199-
print(firmware.info())
200+
if firmware.info()["valid"]:
201+
print("Success! The firmware will be installed when it reboots.")
202+
else:
203+
print("Firmware image not accepted. It will not be installed.")
204+
205+
# Reboot soon, giving some time to softly disconnect.
206+
print("Rebooting soon! Please wait.")
207+
timer = umachine.Timer()
208+
timer.init(period=1500, mode=umachine.Timer.ONE_SHOT, callback=lambda x: umachine.reset())

0 commit comments

Comments
 (0)