From 58c8f72d54070e4061bb879ce0818c89b45c8b8a Mon Sep 17 00:00:00 2001 From: Erol444 Date: Sat, 28 May 2022 13:47:40 +0200 Subject: [PATCH 1/2] Updated standalone mode, suggested using Device Manager --- docs/source/tutorials/standalone_mode.rst | 104 +++++----------------- 1 file changed, 22 insertions(+), 82 deletions(-) diff --git a/docs/source/tutorials/standalone_mode.rst b/docs/source/tutorials/standalone_mode.rst index 0ddddcef8..c4eb4f189 100644 --- a/docs/source/tutorials/standalone_mode.rst +++ b/docs/source/tutorials/standalone_mode.rst @@ -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 ` and then :ref:`flashing the pipeline ` +be achieved by first :ref:`flashing the bootloader ` and then :ref:`flashing 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 @@ -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 @@ -75,83 +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() - device_info.state = dai.XLinkDeviceState.X_LINK_BOOTLOADER - device_info.desc.protocol = dai.XLinkProtocol.X_LINK_TCP_IP - device_info.desc.name = "192.168.34.110" # Set IP here + 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 From 7cc9273320e02d400619ca164a2222430acc9638 Mon Sep 17 00:00:00 2001 From: Erol444 Date: Mon, 30 May 2022 13:41:37 +0200 Subject: [PATCH 2/2] Fixed number of mib to erase on factory reset --- utilities/device_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utilities/device_manager.py b/utilities/device_manager.py index aa408a01b..6f0f410e3 100644 --- a/utilities/device_manager.py +++ b/utilities/device_manager.py @@ -242,7 +242,9 @@ def factoryReset(device): 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))