|
STM32N6 NPU Deployment — Politecnico di Milano
1.0
Documentation for Neural Network Deployment on STM32N6 NPU - Politecnico di Milano 2024-2025
|
Dynamic C source code modification for external memory activation buffer management. More...
Go to the source code of this file.
Namespaces | |
| external_memory_mgt | |
Functions | |
| None | external_memory_mgt.update_activation_c_code (str c_project_path, str path_network_c_info, int available_AXIRAM, cfg=None, Dict custom_objects=None) |
Dynamic C source code modification for external memory activation buffer management.
This module contains a single function, update_activation_c_code(), which performs in-place modification of generated C firmware source files to correctly configure activation buffer placement across the STM32's AXIRAM and SDRAM memory regions.
Why this file exists: When ST Edge AI Core generates the C code for a neural network, it produces generic activation buffer declarations. However, the STM32H747I-DISCO board (and similar targets) has a complex memory hierarchy where different activation buffers must be placed in specific SRAM banks for optimal performance. This file patches the generated C source to add the correct GCC section attributes and linker directives.
Key operations performed:
main.h with the correct camera resolution macrosmain.c to declare activation buffers with explicit memory section attributes, distributing them across AXIRAM and SDRAM based on available spaceai_interface.h with the correct input buffer index and sizeNote on project applicability: This function targets the STM32H747I-DISCO board. For the STM32N6570-DK used in this project, the memory management is handled differently by the Neural-ART toolchain. This file is documented for completeness as part of the common deployment module.
Definition in file external_memory_mgt.py.