Issue while trying to build application for DFU bluetooth on nrf7002DK board

Currently I'm working on a nrf7002DK board and I'm trying to deploy tflite example on the device with bluetooth DFU funtionality. But I got many errors on the way and frustated a bit, it would be really helpful if someone from the Nordic SDK team to help me out on this. This is research project and i want this to be happening for my paper.

SDK version: nrd connect SDK 2.7.0

Window 11

Parents
  • Hi

    Its a bit unclear to me, you are building from the image the peripheral_lbs sample. It should be enough to add the following

    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

    But you are also mentioning tflite. My general recommendation when asking about bootloaders is to have a look at our lesson regarding bootloaders and DFU here

    Regards

    Runar

  • Hi Runar,

    Thank you for your response and suggestions. I wanted to provide more context to clarify my issue and highlight the steps I’ve already taken:

    1. Objective:
      My goal is to deploy a TensorFlow Lite Micro (TFLite Micro) model (the code for the TFlite based application) on the nRF7002DK board. I also want to add Bluetooth DFU functionality to allow over-the-air updates of the firmware, including updates to the TFLite model, so that when I make changes to my model I can update it through Bluetooth DFU FOTA on my nrf7002DK.

    2. Current Status:

      • I have successfully deployed the bluetooth_lbs example with DFU functionality on the board. The Bluetooth functionality works perfectly, and I can perform DFU updates without any issues.
      • Separately, I have also deployed the TFLite Micro model on the board, and it runs inference as expected.
    3. The Problem:
      When I attempt to integrate the TFLite Micro application into the bluetooth_lbs example to combine the functionalities, I encounter multiple issues:

      • Build-Time Issues: Initially, I faced linker errors such as undefined reference to setup and undefined reference to loop functions. I resolved these by ensuring proper function declarations and linking.
      • Runtime Issues: After resolving the build issues, the application crashes at runtime with errors like unaligned memory access and usage faults.
      • Devicetree Conflicts: I noticed errors related to spi_nor (this is also a main headache) and flash memory configurations during the build process, specifically when enabling DFU functionality with the TinyML integration.
    4. Steps Taken to Debug:

      • I ensured that the CONFIG_BOOTLOADER_MCUBOOT=y and CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y configurations are included.
      • I carefully reviewed and adjusted memory regions in the Devicetree to allocate space for both the TFLite Micro model and DFU functionality.
      • I debugged the runtime issues using logs and stack traces, identifying problems like memory misalignment during TFLite interpreter setup.
    5. Current Challenge:
      The functionalities (TinyML and Bluetooth DFU) work perfectly when deployed separately. However, integrating both functionalities into a single application is causing issues. It seems to be related to memory allocation, resource conflicts, or compatibility between the TFLite interpreter and the DFU configurations.

    6. Request for Guidance:

      • How can I resolve these memory allocation issues and avoid runtime faults like unaligned memory access?
      • Take a look at both application codes (I shared the links to both the applications code)?
      • Provide guidance on how these can be merged?
      • Are there specific best practices for integrating TinyML inference with Bluetooth DFU functionality on the nRF7002DK?
      • Could you suggest a step-by-step approach to ensure proper integration of these features without resource conflicts?

    I hope this explanation makes my challenges clearer. If needed, I can share more detailed logs or configurations to assist further.

    Thank you so much for your time and guidance!

    Best regards,
    Gowtham Raj

  • Hi Gowtham

    I will need a bit of time to look into this. 

    Gowtham Raj said:
      • Devicetree Conflicts: I noticed errors related to spi_nor (this is also a main headache) and flash memory configurations during the build process, specifically when enabling DFU functionality with the TinyML integration.

    I suspect the issue here is that the 7002dk uses QSPI for communicating with the nRF7002 and QSPi is enabled instead for SPI. So we would need to overwrite the QSPI enabling for the SPI for external flash to work as intended. I'm working on a example application for this. When this is finished I would suggest trying to add the ML model for this sample. If this is not working then we can have a look at it again. 

    Regards

    Runar

  • Update: 

    You can try this sample with the build target nRF7002dk/nrf5340/app 

    This sample uses sysbuild so make sure to select it in your build configuration

    6153.peripheral_lbs_ble_fota.zip

    Regards

    Runar

  • Hi Runar,

    Thanks again for your continued help and the 6153.peripheral_lbs_ble_fota.zip sample. I’m making progress but have hit a critical roadblock that I need your expertise on.

    I’m trying to combine my working TinyML CIFAR-10 image classification project with your DFU-capable BLE peripheral (6153.peripheral_lbs_ble_fota) on the nRF7002DK board. The idea is to run ML inference on-device and also allow firmware or model updates over Bluetooth using DFU.

    Individually, both applications work perfectly. TinyML inference runs as expected when deployed alone, and the BLE DFU project allows firmware updates via the nRF Connect mobile app without any issues. However, once I integrate the TFLite-based TinyML application into the DFU BLE sample, the application builds and flashes successfully but crashes at runtime during the model setup phase with a usage fault related to unaligned memory access. The error occurs during the interpreter initialization and tensor arena usage. I’ve already replaced malloc with a statically allocated buffer using alignas(16), tried placing the tensor_arena in the .noinit section, increased stack sizes in prj.conf, and confirmed all includes and CMake paths are correct.

    I moved the entire TinyML logic, including model, interpreter, and inference loop, into src folder and called setup() and loop() after BLE initialization. The BLE DFU functionality remains intact, but the crash still happens when the model is set up. I’ve also tried printing memory layout and reducing arena size, but the fault persists.

    The image I’ve attached here shows the exact error output in the serial monitor. It confirms that the system crashes during the TensorFlow Lite Micro setup with an “unaligned memory access” usage fault, followed by a Zephyr fatal error and system reset.

    Could you please take a look at my TinyML project (TinyML-CIFAR-10_Object_Detection_nrf7002DK) and try to combine it properly with the 6153.peripheral_lbs_ble_fota.zip? The goal is to get both functionalities working together without memory conflicts. I suspect there might be SPI/QSPI conflicts, flash layout or RAM pressure issues, or something related to memory sections and the TF-M runtime. If possible, it would be really helpful if you could provide a working integrated sample or guidance on which regions need to be adjusted to avoid these faults.

    This project is important to me as it is part of my university research, and I’m trying to demonstrate full firmware update capability with on-device TinyML inference. Your support would mean a lot and help me move forward with the paper. Please let me know if you need more logs, source files, or a zipped version of the project. I’ve attached a screenshot of the crash for reference.

    links: /cfs-file/__key/communityserver-discussions-components-files/4/6153.peripheral_5F00_lbs_5F00_ble_5F00_fota.zip

    https://github.com/gowtham323/TinyML-CIFAR-10_Object_Detection_nrf7002DK/tree/main

    Thanks and regards,

    Gowtham Raj
    j

Reply
  • Hi Runar,

    Thanks again for your continued help and the 6153.peripheral_lbs_ble_fota.zip sample. I’m making progress but have hit a critical roadblock that I need your expertise on.

    I’m trying to combine my working TinyML CIFAR-10 image classification project with your DFU-capable BLE peripheral (6153.peripheral_lbs_ble_fota) on the nRF7002DK board. The idea is to run ML inference on-device and also allow firmware or model updates over Bluetooth using DFU.

    Individually, both applications work perfectly. TinyML inference runs as expected when deployed alone, and the BLE DFU project allows firmware updates via the nRF Connect mobile app without any issues. However, once I integrate the TFLite-based TinyML application into the DFU BLE sample, the application builds and flashes successfully but crashes at runtime during the model setup phase with a usage fault related to unaligned memory access. The error occurs during the interpreter initialization and tensor arena usage. I’ve already replaced malloc with a statically allocated buffer using alignas(16), tried placing the tensor_arena in the .noinit section, increased stack sizes in prj.conf, and confirmed all includes and CMake paths are correct.

    I moved the entire TinyML logic, including model, interpreter, and inference loop, into src folder and called setup() and loop() after BLE initialization. The BLE DFU functionality remains intact, but the crash still happens when the model is set up. I’ve also tried printing memory layout and reducing arena size, but the fault persists.

    The image I’ve attached here shows the exact error output in the serial monitor. It confirms that the system crashes during the TensorFlow Lite Micro setup with an “unaligned memory access” usage fault, followed by a Zephyr fatal error and system reset.

    Could you please take a look at my TinyML project (TinyML-CIFAR-10_Object_Detection_nrf7002DK) and try to combine it properly with the 6153.peripheral_lbs_ble_fota.zip? The goal is to get both functionalities working together without memory conflicts. I suspect there might be SPI/QSPI conflicts, flash layout or RAM pressure issues, or something related to memory sections and the TF-M runtime. If possible, it would be really helpful if you could provide a working integrated sample or guidance on which regions need to be adjusted to avoid these faults.

    This project is important to me as it is part of my university research, and I’m trying to demonstrate full firmware update capability with on-device TinyML inference. Your support would mean a lot and help me move forward with the paper. Please let me know if you need more logs, source files, or a zipped version of the project. I’ve attached a screenshot of the crash for reference.

    links: /cfs-file/__key/communityserver-discussions-components-files/4/6153.peripheral_5F00_lbs_5F00_ble_5F00_fota.zip

    https://github.com/gowtham323/TinyML-CIFAR-10_Object_Detection_nrf7002DK/tree/main

    Thanks and regards,

    Gowtham Raj
    j

Children
No Data
Related