Skip to content

Commit 77419d1

Browse files
committed
Added factory reset paragraph
1 parent 5088e6d commit 77419d1

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

docs/source/tutorials/standalone_mode.rst

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,54 @@ can start with flashing the pipeline. You can flash the pipeline with the follow
7575
After successfully flashing the pipeline, it will get started automatically when you power up the device.
7676
If you would like to change the flashed pipeline, simply re-flash it again.
7777

78-
..
79-
Clear flash
80-
###########
78+
Clear flash
79+
###########
8180

82-
Since pipeline will start when powering the device, this can lead to unnecesary heating. If you would like to clear
83-
the flashed pipeline, use the code snippet below.
81+
Since pipeline will start when powering the device, this can lead to unnecesary heating. If you would like to clear
82+
the flashed pipeline, use the code snippet below.
8483

85-
.. code-block:: python
84+
.. warning::
85+
Code below doesn't work yet. We will be adding "flashClear" helper function to the library.
8686

87-
import depthai as dai
88-
(ok, info) = dai.DeviceBootloader.getFirstAvailableDevice()
89-
if ok:
90-
print(f'Clearing flash of the OAK: {info.desc.name}');
91-
with dai.DeviceBootloader(info) as bl:
92-
(success, error) = bl.flashConfigClear()
93-
if error: print("Error:", error)
94-
else: print("Successfully cleared flash")
95-
else: print("No device found")
87+
.. code-block:: python
88+
89+
import depthai as dai
90+
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
91+
if not f:
92+
print('No devices found, exiting...')
93+
exit(-1)
94+
95+
with dai.DeviceBootloader(bl) as bootloader:
96+
bootloader.flashClear()
97+
98+
Factory reset
99+
#############
100+
101+
In case you have soft-bricked your device, or just want to clear everything (flashed pipeline/assets and bootloader config),
102+
we recommend running the factory reset script below. It will also flash the latest bootloader version.
103+
104+
.. code-block:: python
105+
106+
import depthai as dai
107+
import tempfile
108+
109+
blBinary = dai.DeviceBootloader.getEmbeddedBootloaderBinary(dai.DeviceBootloader.Type.NETWORK)
110+
blBinary = blBinary + ([0xFF] * ((8 * 1024 * 1024 + 512) - len(blBinary)))
111+
112+
with tempfile.NamedTemporaryFile() as tmpBlFw:
113+
tmpBlFw.write(bytes(blBinary))
114+
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
115+
if not f:
116+
print('No devices found, exiting...')
117+
exit(-1)
118+
119+
with dai.DeviceBootloader(bl, allowFlashingBootloader=True) as bootloader:
120+
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
121+
# Override SBR table, to prevent booting flashed application
122+
[success, msg] = bootloader.flashBootloader(progress, tmpBlFw.name)
123+
if success:
124+
print('Successfully overwritten SBR table. Device should be reacheable through PoE after switching the boot switches back to previous (0x3) value')
125+
else:
126+
print(f"Couldn't overwrite SBR table to unbrick the device. Error: {msg}")
96127
97128
.. include:: ../includes/footer-short.rst

0 commit comments

Comments
 (0)