編譯LVGL + WIFI 時遇到的問題

各位大大好,

最近在使用LVGL v8 + WIFI 的聯網運用

LVGL v8 起來的時候Code Size 約 25%
單獨 WIFI AP 編譯起來約 Code Size 約 34 %

但是兩個加在一起編譯的時候,卻出現下列狀況

c:/users/allen/appdata/local/arduino15/packages/realtek/tools/ameba_d_asdk_toolchain/1.0.1/bin/../lib/gcc/arm-none-eabi/6.5.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\allen\AppData\Local\Temp\arduino_build_407547/application.axf section `.ram_heap.data' will not fit in region `BD_RAM_NS'
c:/users/allen/appdata/local/arduino15/packages/realtek/tools/ameba_d_asdk_toolchain/1.0.1/bin/../lib/gcc/arm-none-eabi/6.5.0/../../../../arm-none-eabi/bin/ld.exe: region `BD_RAM_NS' overflowed by 45536 bytes
collect2.exe: error: ld returned 1 exit status

是RAM 不夠用嗎?

去看了amebad_img2_is_arduino.ld 之後發現也還是看不懂,所以要上來請教一下各位前輩,感謝。

1 Like

我爬了一下之前的文,我也不太相信SRAM 會被上數量個 驅動吃光光。

以前開發其他板子的經驗,這種 link 錯誤是記憶空間不足導致,可以分析 map 檔案,裡面會有所有函數和變數占用記憶空間的情況。編譯錯誤訊息顯示 .ram_heap.data 放不進去,看看 heap size 宣告了多少? 處理這類問題,以我個人經驗,提供幾個方向

  1. 調整 compile 參數: 最佳化的等級,或者 optimize by Size / Time …
  2. 優化自己的程式碼: 移除無用的變數,修改邏輯設計
  3. 如果記憶空間僅僅不足一小部分,用上述方式或能度過,另外就是硬體再外掛RAM
1 Like

感謝您的回覆,看了兩個個別的 MAP 檔發現一些事情

  1. 原裝 WIFI lib 很肥大
  2. 確實是RAM (SRAM) 不夠

另外這是AMB23在 Arduino環境下的LD File,這樣的宣告是否可以讓使用者直接指到PSRAM 去? 看來還是得做點功課。

INCLUDE "rom_symbol_ns.txt"

MEMORY
{
	IROM (rx) : 				ORIGIN = 0x10100000, LENGTH = 0x1010A000 - 0x10100000	/* ROM: 40k */
	IROM_NS (rx) : 				ORIGIN = 0x1010A000, LENGTH = 0x10140000 - 0x1010A000	/* ROM: 216k */
	DROM_NS (rx) : 				ORIGIN = 0x101C0000, LENGTH = 0x101D4000 - 0x101C0000	/* ROM: 80k */
	DROM (rx) : 				ORIGIN = 0x101D4000, LENGTH = 0x101D8000 - 0x101D4000	/* ROM: 16k */
	ROMBSS_RAM_COM (rw) : 		ORIGIN = 0x10000000, LENGTH = 0x10001000 - 0x10000000	/* ROM BSS COMMON(S & NS both used) RAM: 4K */
	ROMBSS_RAM_NS (rw) : 		ORIGIN = 0x10001000, LENGTH = 0x10002000 - 0x10001000	/* ROM BSS NS RAM: 4K */
	RSVD_RAM_NS (rw) : 			ORIGIN = 0x10002000, LENGTH = 0x10004000 - 0x10002000	/* RSVD RAM: 8K */
	MSP_RAM_NS (rw) : 			ORIGIN = 0x10004000, LENGTH = 0x10005000 - 0x10004000	/* MSP_NS RAM: 4K */

	BD_RAM_NS (rwx) : 			ORIGIN = 0x10005000, LENGTH = 0x1007C000 - 0x10005000	/* MAIN RAM NS: 456K */
	ROMBSS_RAM_S (rwx)  : 		ORIGIN = 0x1007C000, LENGTH = 0x1007D000 - 0x1007C000	/* ROM BSS RAM S: 4K */
	BOOTLOADER_RAM_S (rwx)  : 	ORIGIN = 0x1007D000, LENGTH = 0x1007F000 - 0x1007D000	/* BOOT Loader RAM: 8K */
	MSP_RAM_S (rwx)  : 		ORIGIN = 0x1007F000, LENGTH = 0x10080000 - 0x1007F000	/* MSP_S RAM: 4k */
	EXTENTION_SRAM (rwx)  : 		ORIGIN = 0x100E0000, LENGTH = 0x10100000 - 0x100E0000	/* EXTENTION SRAM: 128k */

	PSRAM_NS (rwx)  : 		ORIGIN = 0x02000000 + 0x20, LENGTH = 0x02400000 - 0x02000000 - 0x20	/* PSRAM_NS: 4M */

	/* Flash */
	KM0_BOOT (rx)  :		ORIGIN = 0x08000000+0x20, LENGTH = 0x02000-0x20	/* XIPBOOT: 8k, 32 Bytes resvd for header*/
	BACKUP (r) :			ORIGIN = 0x08002000, LENGTH = 0x1000	/* BACKUP: 4K system data in flash */
	XIPSYS (r) :				ORIGIN = 0x08003000, LENGTH = 0x1000	/* XIPSYS: 4K system data in flash */
	KM4_BOOT (rx) :				ORIGIN = 0x08004000+0x20, LENGTH = 0x02000-0x20	/* XIPBOOT: 8k, 32 Bytes resvd for header*/
	KM0_IMG2 (rx) : 			ORIGIN = 0x0C000000+0x20, LENGTH = 0x02000000-0x20	/* KM0_IMG2: 32MB, 32 Bytes resvd for header, virtual address */
	KM4_IMG2 (rx) : 			ORIGIN = 0x0E000000+0x20, LENGTH = 0x02000000-0x20	/* KM4_IMG2 OTA1: 32MB, 32 Bytes resvd for header,  virtual address */
	BTRACE (rx) :				ORIGIN = 0x00800000, LENGTH = 0x00C00000 -0x00800000	/* Bluetooth Trace */

	/* KM0 RAM*/
	KM0_SRAM (rwx) : 			ORIGIN = 0x00080000, LENGTH = 0x00090000 - 0x00080000	/* KM0 SRAM: 64k */
	RETENTION_RAM (rwx) : 		ORIGIN = 0x000C0000, LENGTH = 0x000C0400 - 0x000C0000	/* KM0 Retention SRAM: 1k */
}

目前想法是看看有沒有辦法把LVGL 的RAM 定址到PSRAM 那邊去,應該還有很多地方要努力。

1 Like

因為要在LVGL V8 環境下使用Wifi ,如果沒有特別的設定編譯的時候RAM 就會報掉,所以目前的作法是把AMB23 的 PSRAM 打開來用