我的项目中有一个 4096 字节的数据数组,需要通过 I2C 传递给另一个元件。
这个数组是常量,因此我按以下方式声明,以便将其存储在flash中而非 RAM 中:
static const uint8_t myArray[4096] = {
0x80,0x40,0x00,0x11,
...
当我将该变量的指针传递给 HAL I2C 函数后,它突然被分配到了 RAM 中,编译器还报出了 RAM 溢出错误:
HAL_I2C_Slave_Sequential_Transmit_IT(&h_i2c, (uint8_t *)myArray, 4096, I2C_FIRST_AND_LAST_FRAME);
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-10.macos64_1.0.0.11181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: my-proj.elf section `._user_heap_stack' will not fit in region `RAM'
/Applications/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-10.macos64_1.0.0.11181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: region `RAM' overflowed by 16 bytes
collect2: error: ld returned 1 exit status
make: *** [makefile:87: stereo-slo-051.elf] Error 1
"make -j11 all" terminated with exit code 2. Build might be incomplete.
这该如何解决?
|
|