Lesept
Active member
Hi
I have a Teensy 4.1 with 8MB PSRAM and 256 MB Flash.
I have a large code that uses large arrays declared in .h files. I try to manage the storage between RAM1 & 2, PSRAM and Flash, depending on their size.
For example, the file classifier_2_weight.h contains:
I use this array in a function called model_forward, in a forward.cpp file, which declares and includes some arrays as well:
When I compile the code I get this error message:
These 2 arrays seem to have coliving problems. They interact here:
If I remove the PROGMEM statement in the .H file, keeping only:
then the compilation continues and I get another error:
This is more complex to understand.
I have read somewhere that if I don't declare arrays as PROGMEM, they are first stored in RAM1 then put in Flash. But if their size is larger than the RAM1 size, maybe this results in section `.bss' is not within region `DTCM' ?
Can anyone explain these error messages and help me fix them?
Thanks for your help.
I have a Teensy 4.1 with 8MB PSRAM and 256 MB Flash.
I have a large code that uses large arrays declared in .h files. I try to manage the storage between RAM1 & 2, PSRAM and Flash, depending on their size.
For example, the file classifier_2_weight.h contains:
Code:
#include <stdint.h>
PROGMEM const float classifier_2_weight_output_0[128000] =
{
-0.0524069182574749, -0.03734472393989563, -0.04629778116941452, -0.0400727204978466, -0.02280816249549389,
-0.02316550724208355, 0.002435319824144244, 0.0019113686867058277, -0.015797318890690804, -0.04310063645243645,
-0.011440770700573921, 0.03244912996888161, -0.008675714023411274, -0.022800328209996223, -0.010684050619602203,
...
};
I use this array in a function called model_forward, in a forward.cpp file, which declares and includes some arrays as well:
Code:
// Memory block
#include "..\include\parameters\onnx__Conv_95.h"
#include "..\include\parameters\onnx__Conv_98.h"
#include "..\include\parameters\onnx__Conv_101.h"
#include "..\include\parameters\onnx__Conv_104.h"
#include "..\include\parameters\onnx__Conv_107.h"
#include "..\include\parameters\onnx__Conv_110.h"
#include "..\include\parameters\onnx__Conv_113.h"
#include "..\include\parameters\classifier_2_weight.h" // <--- Here
EXTMEM float input[131072];
DMAMEM float input2[32768];
EXTMEM float output[131072];
DMAMEM float weightsRAM2[73728];
EXTMEM float weightsPSRAM[921600];
PROGMEM float weightsFlash[921600];
When I compile the code I get this error message:
Code:
In file included from C:\Users\fa125436\Documents\Arduino\Aidge_Teensy_ResNet\src\dnn\src\forward.cpp:54:
C:\Users\fa125436\Documents\Arduino\Aidge_Teensy_ResNet\src\dnn\include\parameters\classifier_2_weight.h: In function 'void model_forward(float**)':
C:\Users\fa125436\Documents\Arduino\Aidge_Teensy_ResNet\src\dnn\include\parameters\classifier_2_weight.h:3:21: error: 'classifier_2_weight_output_0' causes a section type conflict with 'weightsFlash'
3 | PROGMEM const float classifier_2_weight_output_0[128000] =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\fa125436\Documents\Arduino\Aidge_Teensy_ResNet\src\dnn\src\forward.cpp:60:15: note: 'weightsFlash' was declared here
60 | PROGMEM float weightsFlash[921600];
| ^~~~~~~~~~~~
exit status 1
Compilation error: 'classifier_2_weight_output_0' causes a section type conflict with 'weightsFlash'
These 2 arrays seem to have coliving problems. They interact here:
Code:
memcpy(weightsFlash, classifier_2_weight_output_0, 512000);
If I remove the PROGMEM statement in the .H file, keeping only:
Code:
#include <stdint.h>
const float classifier_2_weight_output_0[128000] =
Code:
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\fa125436\AppData\Local\arduino\sketches\EE9AC2D007C02D446B7F6F7B98C17DC1/Aidge_Teensy_ResNet.ino.elf section `.data' will not fit in region `DTCM'
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\fa125436\AppData\Local\arduino\sketches\EE9AC2D007C02D446B7F6F7B98C17DC1/Aidge_Teensy_ResNet.ino.elf section `.data' will not fit in region `FLASH'
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: address 0x20cf3de0 of C:\Users\fa125436\AppData\Local\arduino\sketches\EE9AC2D007C02D446B7F6F7B98C17DC1/Aidge_Teensy_ResNet.ino.elf section `.bss' is not within region `DTCM'
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: address 0x20cf3de0 of C:\Users\fa125436\AppData\Local\arduino\sketches\EE9AC2D007C02D446B7F6F7B98C17DC1/Aidge_Teensy_ResNet.ino.elf section `.bss' is not within region `DTCM'
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: section .bss.dma VMA [20200000,2026b07f] overlaps section .data VMA [20000000,20cf1ebf]
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: region `DTCM' overflowed by 13057504 bytes
c:/users/fa125436/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 9455616 bytes
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
I have read somewhere that if I don't declare arrays as PROGMEM, they are first stored in RAM1 then put in Flash. But if their size is larger than the RAM1 size, maybe this results in section `.bss' is not within region `DTCM' ?
Can anyone explain these error messages and help me fix them?
Thanks for your help.