2023-07-11 02:49 PM
Hello STM Community,
I am currently trying to upload a large model to my STM32H745I-DISCO. Given the size of the model, I chose the [Use external flash] option, which, as per the user manual, led to the generation of a separate network_data.bin file. As per my understanding, this network_data.bin file should contain the weight files that were split, although I invite corrections if my assumption is incorrect.
The user manual further emphasizes that the network_data.bin file must be manually programmed on the board's external Flash memory. Tools such as the STM32CubeProgrammer (STM32CubeProg) are recommended for this task. An interesting note I came across was that using automatic validation on the target leads to the network_data.bin file being automatically programmed on the external Flash memory on the board.
Given this information, I'm left with some uncertainty: if I don't manually code to explicitly utilize this network_data.bin file, will the model still be able to run inferences without these specific weights? Isn't this result totally garbage without explicitly using the network_data.bin file? I would greatly appreciate if anyone could shed some light on this issue and help me understand the system's behavior in this regard.
Thank you in advance for your help and time.
2023-07-12 02:06 AM - edited 2023-07-12 02:14 AM
Hi, both CubeIDE debugger and STM32 CubeProgrammer can put data into external flash of ST-made eval boards.
For this, you need to specify the suitable "external loader" in the debugger or CubeProgrammer settings. (These loaders are specific for the board and flash chip model).
The easiest and most straightforward is to use CubeProgrammer, specify the start address in the STM32 address space and the binary file will be burned there. If you have a J-LINK, its J-Flash software can do this too.
As for the STM32 firmware projects (of any kind, AI or not) - they can contain code and data both in internal and external flash. When you start running or debugging such project, the debugger writes everything to the board. Due to the large data size on the external flash and for more complete control, you may want to keep the external flash data separate from the firmware, and update it manually, as explained above.
Of course, your firmware can and should validate that the data on the flash is written correctly.
2023-07-12 06:43 AM
For the AI network to have the appropriate accuracy it must access to the correct weights.
Using STM32CubeMX and X-CUBE-AI, it will generate a project that access the external memories on the board (init done in app_x-cube-ai.c) with the proper declaration of the buffers.
For STM32 boards it will use the board BSP to access the external memory. If you have your own board you'll have to change that code for a proper initialization of the external memory in "memory mapped" mode.
Regards
Daniel