Skip to content

Commit 10c660d

Browse files
committed
Update to v2.3.0
1 parent cf7cb1c commit 10c660d

157 files changed

Lines changed: 168445 additions & 117341 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Application/NUCLEO-N657X0-Q/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ SZ = $(PREFIX)size
151151
CP = $(PREFIX)objcopy
152152
READELF = $(PREFIX)readelf
153153
endif
154+
LD = $(CC)
154155
HEX = $(CP) -O ihex
155156
BIN = $(CP) -O binary
156157
FLASHER = STM32_Programmer_CLI
@@ -195,8 +196,6 @@ C_INCLUDES += -I../../Middlewares/stm32-mw-camera/sensors/ov5640
195196

196197
C_INCLUDES += -IInc
197198
C_INCLUDES += -I$(MODEL_DIR)
198-
C_INCLUDES += -I../../Middlewares/ai-postprocessing-wrapper
199-
C_INCLUDES += -I../../Middlewares/stm32-vision-models-postprocessing/lib_vision_models_pp/Inc
200199
C_INCLUDES += -I../../Middlewares/stedgeai-lib/Npu/ll_aton
201200
C_INCLUDES += -I../../STM32Cube_FW_N6/Drivers/STM32N6xx_HAL_Driver/Inc
202201
C_INCLUDES += -I../../STM32Cube_FW_N6/Drivers/STM32N6xx_HAL_Driver/Inc/Legacy
@@ -225,7 +224,7 @@ CFLAGS += -std=gnu11
225224
LDSCRIPT = STM32CubeIDE/STM32N657xx.ld
226225

227226
# libraries
228-
LIBS = -lc -lm -lnosys -l:NetworkRuntime1100_CM55_GCC.a
227+
LIBS = -lc -lm -lnosys -l:NetworkRuntime1200_CM55_GCC.a
229228
LIBDIR = -L../../Middlewares/stedgeai-lib/Lib/GCC/ARMCortexM55
230229
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
231230
# Uncomment to enable %f formatted output

Application/NUCLEO-N657X0-Q/STM32CubeIDE/.cproject

Lines changed: 273 additions & 4 deletions
Large diffs are not rendered by default.

Application/NUCLEO-N657X0-Q/STM32CubeIDE/STM32N657xx.ld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _Min_Stack_Size = 0x4000; /* required amount of stack */
1212
MEMORY
1313
{
1414
AXISRAM1_S (xrw) : ORIGIN = 0x34000400, LENGTH = 1647K
15+
FLASH (xrw) : ORIGIN = 0x71380000, LENGTH = 2M
1516
}
1617

1718
/* Sections */
@@ -147,6 +148,13 @@ SECTIONS
147148
. = ALIGN(8);
148149
} >AXISRAM1_S
149150

151+
.flash_section :
152+
{
153+
. = ALIGN(32);
154+
*(.flash_blob)
155+
. = ALIGN(32);
156+
} >FLASH
157+
150158
/* Remove information from the compiler libraries */
151159
/DISCARD/ :
152160
{

Application/NUCLEO-N657X0-Q/Src/main.c

Lines changed: 37 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ float nn_top1_output_class_proba;
9696

9797
#define ALIGN_TO_16(value) (((value) + 15) & ~15)
9898

99-
/* for models not multiple of 16; needs a working buffer */
99+
/* When NN input dimensions are not a multiple of 16, the DCMIPP output needs cropping */
100100
#if (STAI_NETWORK_IN_1_WIDTH * STAI_NETWORK_IN_1_CHANNEL) != ALIGN_TO_16(STAI_NETWORK_IN_1_WIDTH * STAI_NETWORK_IN_1_CHANNEL)
101+
#define DCMIPP_NN_NEEDS_CROP 1
101102
#define DCMIPP_OUT_NN_LEN (ALIGN_TO_16(STAI_NETWORK_IN_1_WIDTH * STAI_NETWORK_IN_1_CHANNEL) * STAI_NETWORK_IN_1_HEIGHT)
102103
#define DCMIPP_OUT_NN_BUFF_LEN (DCMIPP_OUT_NN_LEN + 32 - DCMIPP_OUT_NN_LEN%32)
103104

104105
__attribute__ ((aligned (32)))
105-
uint8_t dcmipp_out_nn[DCMIPP_OUT_NN_BUFF_LEN];
106+
static uint8_t dcmipp_out_nn[DCMIPP_OUT_NN_BUFF_LEN];
106107
#else
107-
uint8_t *dcmipp_out_nn;
108+
#define DCMIPP_NN_NEEDS_CROP 0
108109
#endif
109110

110111
/* model */
@@ -133,7 +134,6 @@ static void set_clk_sleep_mode(void);
133134
static void IAC_Config(void);
134135
static void Display_WelcomeScreen(void);
135136
static void Hardware_init(void);
136-
static void Run_Inference(stai_network *network_instance);
137137
static void NeuralNetwork_init(uint32_t *nn_in_length, stai_ptr *nn_out, stai_size *number_output, int32_t nn_out_len[]);
138138

139139

@@ -146,24 +146,7 @@ int main(void)
146146
{
147147
Hardware_init();
148148

149-
/*** App header *************************************************************/
150-
printf("========================================\n");
151-
printf("STM32N6-GettingStarted-ImageClassification %s (%s)\n", APP_VERSION_STRING, APP_GIT_SHA1_STRING);
152-
printf("Build date & time: %s %s\n", __DATE__, __TIME__);
153-
#if defined(__GNUC__)
154-
printf("Compiler: GCC %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
155-
#elif defined(__ICCARM__)
156-
printf("Compiler: IAR EWARM %d.%d.%d\n", __VER__ / 1000000, (__VER__ / 1000) % 1000 ,__VER__ % 1000);
157-
#else
158-
printf("Compiler: Unknown\n");
159-
#endif
160-
printf("HAL: %lu.%lu.%lu\n", __STM32N6xx_HAL_VERSION_MAIN, __STM32N6xx_HAL_VERSION_SUB1, __STM32N6xx_HAL_VERSION_SUB2);
161-
printf("STEdgeAI Tools: %d.%d.%d\n", STAI_TOOLS_VERSION_MAJOR, STAI_TOOLS_VERSION_MINOR, STAI_TOOLS_VERSION_MICRO);
162-
printf("NN model: %s\n", STAI_NETWORK_ORIGIN_MODEL_NAME);
163-
printf("========================================\n");
164-
165149
/*** NN Init ****************************************************************/
166-
uint32_t pitch_nn = 0;
167150
uint32_t nn_in_len = 0;
168151
stai_size number_output = 0;
169152
stai_ptr nn_out[STAI_NETWORK_OUT_NUM] = {0};
@@ -180,49 +163,62 @@ int main(void)
180163
pp_input = nn_out[0];
181164

182165
/*** Camera Init ************************************************************/
166+
uint32_t pitch_nn = 0;
183167
CameraPipeline_Init((uint32_t *[2]) {&lcd_bg_area.XSize, &lcd_fg_area.XSize}, (uint32_t *[2]) {&lcd_bg_area.YSize, &lcd_fg_area.YSize}, &pitch_nn);
184168

185169
Display_init();
186170

187171
/* Start LCD Display camera pipe stream */
188172
CameraPipeline_DisplayPipe_Start(lcd_bg_buffer, CMW_MODE_CONTINUOUS);
189173

174+
/*** App header *************************************************************/
175+
printf("========================================\n");
176+
printf("STM32N6-GettingStarted-ImageClassification %s (%s)\n", APP_VERSION_STRING, APP_GIT_SHA1_STRING);
177+
printf("Build date & time: %s %s\n", __DATE__, __TIME__);
178+
#if defined(__GNUC__)
179+
printf("Compiler: GCC %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
180+
#elif defined(__ICCARM__)
181+
printf("Compiler: IAR EWARM %d.%d.%d\n", __VER__ / 1000000, (__VER__ / 1000) % 1000 ,__VER__ % 1000);
182+
#else
183+
printf("Compiler: Unknown\n");
184+
#endif
185+
printf("HAL: %lu.%lu.%lu\n", __STM32N6xx_HAL_VERSION_MAIN, __STM32N6xx_HAL_VERSION_SUB1, __STM32N6xx_HAL_VERSION_SUB2);
186+
printf("STEdgeAI Tools: %d.%d.%d\n", STAI_TOOLS_VERSION_MAJOR, STAI_TOOLS_VERSION_MINOR, STAI_TOOLS_VERSION_MICRO);
187+
printf("NN model: %s\n", STAI_NETWORK_ORIGIN_MODEL_NAME);
188+
printf("========================================\n");
189+
190190
/*** App Loop ***************************************************************/
191191
while (1)
192192
{
193193
CameraPipeline_IspUpdate();
194194

195-
if (pitch_nn != (STAI_NETWORK_IN_1_WIDTH * STAI_NETWORK_IN_1_CHANNEL))
196-
{
197-
/* Start NN camera single capture Snapshot */
198-
CameraPipeline_NNPipe_Start(dcmipp_out_nn, CMW_MODE_SNAPSHOT);
199-
}
200-
else
201-
{
202-
/* Start NN camera single capture Snapshot */
203-
CameraPipeline_NNPipe_Start(nn_in, CMW_MODE_SNAPSHOT);
204-
}
195+
#if DCMIPP_NN_NEEDS_CROP
196+
/* Start NN camera single capture Snapshot into intermediate buffer */
197+
CameraPipeline_NNPipe_Start(dcmipp_out_nn, CMW_MODE_SNAPSHOT);
198+
#else
199+
/* Start NN camera single capture Snapshot directly into NN input */
200+
CameraPipeline_NNPipe_Start(nn_in, CMW_MODE_SNAPSHOT);
201+
#endif
205202

206203
while (cameraFrameReceived == 0) {};
207204
cameraFrameReceived = 0;
208205

209206
uint32_t ts[2] = { 0 };
210207

211-
if (pitch_nn != (STAI_NETWORK_IN_1_WIDTH * STAI_NETWORK_IN_1_CHANNEL))
212-
{
213-
SCB_InvalidateDCache_by_Addr(dcmipp_out_nn, sizeof(dcmipp_out_nn));
208+
#if DCMIPP_NN_NEEDS_CROP
214209
/*
215-
* Crop the image if the neural network (NN) input dimensions are not a multiple of 16.
216-
* The DCMIPP hardware requires the output image dimensions to be multiples of 16.
217-
* This ensures compatibility with the NN input dimensions.
210+
* Crop the image: the DCMIPP hardware requires output dimensions to be
211+
* multiples of 16, so we crop the padded buffer into the NN input buffer.
218212
*/
219-
img_crop(dcmipp_out_nn, nn_in, pitch_nn, STAI_NETWORK_IN_1_WIDTH, STAI_NETWORK_IN_1_HEIGHT, STAI_NETWORK_IN_1_CHANNEL);
220-
SCB_CleanInvalidateDCache_by_Addr(nn_in, nn_in_len);
221-
}
213+
SCB_InvalidateDCache_by_Addr(dcmipp_out_nn, sizeof(dcmipp_out_nn));
214+
img_crop(dcmipp_out_nn, nn_in, pitch_nn, STAI_NETWORK_IN_1_WIDTH, STAI_NETWORK_IN_1_HEIGHT, STAI_NETWORK_IN_1_CHANNEL);
215+
SCB_CleanInvalidateDCache_by_Addr(nn_in, nn_in_len);
216+
#endif
222217

223218
ts[0] = HAL_GetTick();
224219
/* run ATON inference */
225-
Run_Inference(network_context);
220+
ret = stai_network_run(network_context, STAI_MODE_SYNC);
221+
assert(ret == 0);
226222
ts[1] = HAL_GetTick();
227223

228224
Network_Postprocess();
@@ -282,19 +278,6 @@ static void Hardware_init(void)
282278

283279
}
284280

285-
static void Run_Inference(stai_network *network_instance) {
286-
stai_return_code ret;
287-
288-
do {
289-
ret = stai_network_run(network_instance, STAI_MODE_ASYNC);
290-
if (ret == STAI_RUNNING_WFE)
291-
LL_ATON_OSAL_WFE();
292-
} while (ret == STAI_RUNNING_WFE || ret == STAI_RUNNING_NO_WFE);
293-
294-
ret = stai_ext_network_new_inference(network_instance);
295-
assert(ret == STAI_SUCCESS);
296-
}
297-
298281
static void NeuralNetwork_init(uint32_t *nn_in_length, stai_ptr *nn_out, stai_size *number_output, int32_t nn_out_len[])
299282
{
300283
stai_network_info info;

Application/STM32N6570-DK/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ SZ = $(PREFIX)size
143143
CP = $(PREFIX)objcopy
144144
READELF = $(PREFIX)readelf
145145
endif
146+
LD = $(CC)
146147
HEX = $(CP) -O ihex
147148
BIN = $(CP) -O binary
148149
FLASHER = STM32_Programmer_CLI
@@ -183,8 +184,6 @@ C_INCLUDES += -I../../Middlewares/stm32-mw-camera/sensors/ov5640
183184

184185
C_INCLUDES += -IInc
185186
C_INCLUDES += -I$(MODEL_DIR)
186-
C_INCLUDES += -I../../Middlewares/ai-postprocessing-wrapper
187-
C_INCLUDES += -I../../Middlewares/stm32-vision-models-postprocessing/lib_vision_models_pp/Inc
188187
C_INCLUDES += -I../../Middlewares/stedgeai-lib/Npu/ll_aton
189188
C_INCLUDES += -I../../STM32Cube_FW_N6/Drivers/STM32N6xx_HAL_Driver/Inc
190189
C_INCLUDES += -I../../STM32Cube_FW_N6/Drivers/STM32N6xx_HAL_Driver/Inc/Legacy
@@ -213,7 +212,7 @@ CFLAGS += -std=gnu11
213212
LDSCRIPT = STM32CubeIDE/STM32N657xx.ld
214213

215214
# libraries
216-
LIBS = -lc -lm -lnosys -l:NetworkRuntime1100_CM55_GCC.a
215+
LIBS = -lc -lm -lnosys -l:NetworkRuntime1200_CM55_GCC.a
217216
LIBDIR = -L../../Middlewares/stedgeai-lib/Lib/GCC/ARMCortexM55
218217
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
219218
# Uncomment to enable %f formatted output

0 commit comments

Comments
 (0)