Skip to content

Commit

Permalink
Merge branch 'main' into release_2.16.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Jun 6, 2022
2 parents d9ad60c + 425d01a commit 4c289a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 82 deletions.
103 changes: 22 additions & 81 deletions docs/source/tutorials/standalone_mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Standalone mode
===============

**Standalone / Hostless / On-The-Edge mode** means that the OAK camera isn't connected to a host computer. This can
be achieved by first :ref:`flashing the bootloader <Flash bootloader>` and then :ref:`flashing the pipeline <Flash the pipeline>`
be achieved by first :ref:`flashing the bootloader <Flash the bootloader>` and then :ref:`flashing the pipeline <Flash the pipeline>`
and assets (NN models) to the OAK's flash memory.

Standalone mode is **only possible on OAKs that have on-board flash** memory, which are currently
Expand Down Expand Up @@ -37,23 +37,15 @@ or script node, as mentioned above.
Flash the bootloader
####################

Execute the code below to flash the :ref:`Bootloader` to the device. The bootloader is packaged together with the
depthai, so if you have the latest depthai version, you will flash the latest bootloader version. This step
is required only once.

.. code-block:: python
import depthai as dai
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
bootloader = dai.DeviceBootloader(bl)
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
bootloader.flashBootloader(progress)
The :ref:`Bootloader` is packaged together with the depthai, so if you have the latest depthai version, you can flash the
latest bootloader version. To flash the bootloader, we suggest using the :ref:`Device Manager`. To view the API code behind
it, see :ref:`Flash Bootloader` example code.

Flash the pipeline
##################

After you have standalone :ref:`Pipeline` definition and :ref:`Bootloader` already flashed on the device, you
can start with flashing the pipeline. You can flash the pipeline with the following snippet:
After you have standalone :ref:`Pipeline` defined and :ref:`Bootloader` already flashed on the device, you
can flash the pipeline to the device, along with its assests (eg. AI models). You can flash the pipeline with the following snippet:

.. code-block:: python
Expand All @@ -75,82 +67,31 @@ can start with flashing the pipeline. You can flash the pipeline with the follow
After successfully flashing the pipeline, it will get started automatically when you power up the device.
If you would like to change the flashed pipeline, simply re-flash it again.

Clear flash
###########

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

.. warning::
Code below doesn't work yet. We will be adding "flashClear" helper function to the library.

.. code-block:: python
import depthai as dai
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
if not f:
print('No devices found, exiting...')
exit(-1)
with dai.DeviceBootloader(bl) as bootloader:
bootloader.flashClear()
Factory reset
#############

In case you have soft-bricked your device, or just want to clear everything (flashed pipeline/assets and bootloader config),
we recommend running the factory reset script below. It will also flash the latest bootloader version.

.. code-block:: python
..
Clear flash
###########
import depthai as dai
import tempfile
Since pipeline will start when powering the device, this can lead to unnecesary heating. If you would like to clear
the flashed pipeline, use the code snippet below.

blBinary = dai.DeviceBootloader.getEmbeddedBootloaderBinary(dai.DeviceBootloader.Type.NETWORK)
blBinary = blBinary + ([0xFF] * ((8 * 1024 * 1024 + 512) - len(blBinary)))
.. warning::
Code below doesn't work yet. We will be adding "flashClear" helper function to the library.

with tempfile.NamedTemporaryFile() as tmpBlFw:
tmpBlFw.write(bytes(blBinary))
.. code-block:: python
(f, device_info) = dai.DeviceBootloader.getFirstAvailableDevice()
import depthai as dai
(f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
if not f:
print('No devices found, exiting...')
exit(-1)
with dai.DeviceBootloader(device_info, allowFlashingBootloader=True) as bootloader:
progress = lambda p : print(f'Factory reset progress: {p*100:.1f}%')
# Override SBR table, to prevent booting flashed application
[success, msg] = bootloader.flashBootloader(progress, tmpBlFw.name)
if success:
print('Successfully overwritten SBR table. Device should now be reacheable through PoE')
else:
print(f"Couldn't overwrite SBR table to unbrick the device. Error: {msg}")
You can also **factory reset OAK POE at specific IP** if it's not reachable (not in same LAN).

.. code-block:: python
import depthai as dai
import tempfile
blBinary = dai.DeviceBootloader.getEmbeddedBootloaderBinary(dai.DeviceBootloader.Type.NETWORK)
blBinary = blBinary + ([0xFF] * ((8 * 1024 * 1024 + 512) - len(blBinary)))
with tempfile.NamedTemporaryFile() as tmpBlFw:
tmpBlFw.write(bytes(blBinary))
device_info = dai.DeviceInfo("192.168.34.110") # Set IP here
device_info.state = dai.XLinkDeviceState.X_LINK_BOOTLOADER
device_info.protocol = dai.XLinkProtocol.X_LINK_TCP_IP
with dai.DeviceBootloader(bl) as bootloader:
bootloader.flashClear()
with dai.DeviceBootloader(device_info, allowFlashingBootloader=True) as bootloader:
progress = lambda p : print(f'Factory reset progress: {p*100:.1f}%')
# Override SBR table, to prevent booting flashed application
[success, msg] = bootloader.flashBootloader(progress, tmpBlFw.name)
if success:
print('Successfully overwritten SBR table. Device should now be reacheable through PoE')
else:
print(f"Couldn't overwrite SBR table to unbrick the device. Error: {msg}")
Factory reset
#############

In case you have soft-bricked your device, or just want to clear everything (flashed pipeline/assets and bootloader config),
we recommend using the :ref:`Device Manager`. Factory reset will also flash the latest bootloader.

.. include:: ../includes/footer-short.rst
4 changes: 3 additions & 1 deletion utilities/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ def factoryReset(device: dai.DeviceInfo):

try:
blBinary = dai.DeviceBootloader.getEmbeddedBootloaderBinary(type)
blBinary = blBinary + ([0xFF] * ((8 * 1024 * 1024 + 512) - len(blBinary)))
# Clear 1 MiB for USB BL and 8 MiB for NETWORK BL
mib = 1 if type == dai.DeviceBootloader.Type.USB else 8
blBinary = blBinary + ([0xFF] * ((mib * 1024 * 1024 + 512) - len(blBinary)))
bl = dai.DeviceBootloader(device, True)
tmpBlFw = tempfile.NamedTemporaryFile(delete=False)
tmpBlFw.write(bytes(blBinary))
Expand Down

0 comments on commit 4c289a5

Please sign in to comment.