cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use external flash and ram with X-Cube-AI on the STMH747XI-DISCO board?

ZachB
Associate II

I want to run some AI models on the STMH747XI-DISCO board that are too large for the onboard flash and ram. I have absolutely no problem setting up the project with Cube AI and getting the model loaded. In the network Advanced Settings, I have external flash and external ram checked to be used, the correct start addresses, use activation buffer set, and use activation buffer for both input and output buffers.

When the project is generated, it does not compile with error ".elf section `.bss' will not fit in region `RAM' ". Looking into what is filling up so much ram in the map file, I can see that the activations array was taking almost 541KB of the 512KB in that ram section. I find this very strange, since I checked the option to put the activation buffer in external ram. (As a note, this array is defined on line 87 in app_x-cube-ai.c)

I manually added the section and linker attribute to put the activations array 16MB into the external ram, since 16MB is plenty for everything else. With that, the project compiled. However, when I try to download the project to the board, it fails immediately. The error is not helpful: 0693W00000D02SnQAJ.pngWhen trying to download the .elf file to the board in the STM32CubeProgrammer, I get a different error that is similarly not helpful:

" 16:01:58 : Error: failed to download Segment[3]

 16:01:58 : Error: failed to download the File"

So my question is, how do I get AI models to properly run/load on external flash and ram?

4 REPLIES 4

Well pretty sure it doesn't download into SDRAM directly, code in startup.s should bring that up and copy content.

To program the External QSPI memory you'll want to specify that it needs to use the appropriate External Loader

ie MT25TL01G_STM32H747I-DISCO.stldr

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Do you by chance have a working project you'd be willing to share that both uses external ram/flash and uses the latest model runtime? I would love to examine one.

I'm a Keil guy, not doing AI, ..

There should be some SDRAM and QSPI examples under the CubeH7 trees for the STM32H747I-DISCO, along with sample linker scripts (.LD), or CubeMX/IDE should be able to manifest something out of thin air or boiler plate.

STM32Cube_FW_H7_V1.8.0\Projects\STM32H747I-DISCO\Examples\BSP

STM32Cube_FW_H7_V1.8.0\Projects\STM32H747I-DISCO\Examples\JPEG\JPEG_MJPEG_VideoDecodingFromQSPI

STM32Cube_FW_H7_V1.8.0\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_sdram.c

STM32Cube_FW_H7_V1.8.0\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_qspi.c

Looks like you're building code, might want to look at .MAP or .ELF to understand where "Segment[3]" is situated, but guessing 0x90000000 for QSPI, for the tools to download'n'debug you'd need to specify the External Loader in the CubeIDE user interface

https://community.st.com/s/question/0D53W000004JXkf/how-can-i-use-my-own-external-loader-for-debugging-in-stm32cubeide

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The BSP example does not seem to work. It immediately hits a "Break at address "0xa05f0000" with no debug information available, or outside of program code."

The Video Decoding project is interesting, but it does not seem to include any way to write to the qspi flash.

I have both those drivers set up for my project.

I am left with no further information on how to actually write to the qspi flash. I really don't understand how I am supposed to do it. I figured the download tool in the IDE should be able to handle it no problem. Do you have any more insights or recommendations?