ESP32: Wi-Fi using SPIRAM #99028
-
|
Hi, I am using Zephyr v4.2.1 and using custom board based on ESP32-WROVER-E-N4R8. I see exception when trying to run samples/net/wifi/shell with following $ cat boards/my_custom_board_procpu.conf
CONFIG_ESP_SPIRAM=y
CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM=y
CONFIG_NET_IF_MAX_IPV4_COUNT=2
$ cat boards/my_custom_board_procpu.overlay
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
aliases {
wdog = &wdt0;
sw0 = &button0;
led0 = &led0;
led1 = &led1;
led2 = &led2;
ledg = &led0;
ledr = &led1;
ledb = &led2;
bn-spi = &spi2;
bn-irq = &bn_irq_pin;
uart-api = &uart0;
bn-cs = &bn_cs_pin;
bn-cs-ext = &bn_cs_ext;
gmac = ð
wifi0 = &wifi;
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio1 7 GPIO_PULL_UP>;
label = "BOOT Button 0";
zephyr,code = <INPUT_KEY_0>;
};
button1: button_1 {
gpios = <&gpio1 2 GPIO_PULL_UP>;
label = "USR Button 2";
zephyr,code = <INPUT_KEY_1>;
};
bn_irq_pin: bn_irq_pin {
status = "okay";
gpios = <&gpio1 4 0>;
label = "SPI slave IRQ pin";
};
bn_cs_pin: bn_cs_pin {
status = "okay";
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
label = "SPI slave CS 0 pin";
};
bn_cs_ext: bn_cs_ext {
status = "okay";
gpios = <&gpio1 1 GPIO_PULL_UP>;
label = "SPI slave CS 1 pin";
};
};
generic-gpios {
compatible = "gpio-generic";
};
leds {
compatible = "gpio-leds";
led0: led_1 {
gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
label = "User LD1 GREEN";
status = "okay";
};
led1: led_2 {
gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
label = "User LD2 RED";
status = "okay";
};
led2: led_3 {
gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
label = "User LD3 BLUE";
status = "okay";
};
};
};
&gpio0 {
status = "okay";
label = "gpio0";
};
&gpio1 {
status = "okay";
label = "gpio1";
};
&uart1 {
status = "okay";
};
&wdt0 {
status = "okay";
label = "wdt0";
};
&spi3 {
status = "okay";
};
&spi2 {
status = "okay";
};
ð {
status = "okay";
};
&phy {
status = "disabled";
};
&mdio {
status = "okay";
};
&wifi {
status = "ok";
};
/* 8MB psram */
&psram0 {
status = "okay";
};
$ west espressif monitor
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting......
Detecting chip type... ESP32
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffb0000,len:32364
ho 0 tail 12 room 4
load:0x40080000,len:69072
1150 mmu set 00010000, pos 00010000
entry 0x4008a8f0
I (57) soc_init: ESP Simple boot
I (57) soc_init: compile time Nov 6 2025 19:32:35
W (58) soc_init: Unicore bootloader
I (58) soc_init: chip revision: v3.1
I (61) flash_init: SPI Speed : 40MHz
I (65) flash_init: SPI Mode : DIO
I (68) flash_init: SPI Flash Size : 4MB
I (72) boot: DRAM: lma 0x00001020 vma 0x3ffb0000 len 0x7e6c (32364)
I (78) boot: IRAM: lma 0x00008e94 vma 0x40080000 len 0x10dd0 (69072)
I (84) boot: IRAM: lma 0x00019c78 vma 0x00000000 len 0x6380 (25472)
I (90) boot: IMAP: lma 0x00020000 vma 0x400d0000 len 0x63e98 (409240)
I (97) boot: IRAM: lma 0x00083ea0 vma 0x00000000 len 0xc158 (49496)
I (103) boot: DMAP: lma 0x00090000 vma 0x3f400000 len 0x17834 (96308)
I (109) boot: Image with 6 segments
I (112) boot: IROM segment: paddr=00020000h, vaddr=400d0000h, size=63E98h (409240) map
I (120) boot: DROM segment: paddr=00090000h, vaddr=3f400000h, size=17834h ( 96308) map
I (139) boot: libc heap size 65 kB.
I (139) spi_flash: detected chip: generic
I (139) spi_flash: flash io: dio
I (139) quad_psram: This chip is ESP32-D0WD
I (144) esp_psram: Found 8MB PSRAM device
I (147) esp_psram: Speed: 40MHz
I (150) esp_psram: PSRAM initialized, cache is in normal (1-core) mode.
W (157) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped
I (1042) esp_psram: SPI SRAM memory test OK
[00:00:01.119,000] <inf> phy_mii: PHY (1) ID 221430
[00:00:01.170,000] <inf> phy_mii: PHY (2) ID 221430
*** Booting Zephyr OS build 600b189b68c8 ***
uart:~$ wifi scan
[00:00:02.929,000] <inf> phy_mii: PHY (1) Link speed 100 Mb, full duplex
[00:00:03.861,000] <err> os: ** FATAL EXCEPTION
[00:00:03.861,000] <err> os: ** CPU 0 EXCCAUSE 28 (load prohibited)
[00:00:03.861,000] <err> os: ** PC 0x400862a0 VADDR 0xbbbbbbab
[00:00:03.861,000] <err> os: ** PS 0x60a20
[00:00:03.861,000] <err> os: ** (INTLEVEL:0 EXCM: 0 UM:1 RING:0 WOE:1 OWB:10 CALLINC:2)
[00:00:03.861,000] <err> os: ** A0 0x400862cc SP 0x3f8006d4 A2 0xbbbbbbab A3 0xbbbbbbbb
[00:00:03.861,000] <err> os: ** A4 0 A5 0x1 A6 0 A7 0x3ffcf930
[00:00:03.861,000] <err> os: ** A8 0x8008893f A9 0x3ffcf920 A10 0 A11 0x60a23
[00:00:03.861,000] <err> os: ** A12 0 A13 0x60e20 A14 0 A15 0x3ffcf900
[00:00:03.861,000] <err> os: ** LBEG 0x4000c2e0 LEND 0x4000c2f6 LCOUNT 0
[00:00:03.861,000] <err> os: ** SAR 0xe
[00:00:03.861,000] <err> os: ** THREADPTR 0xbbbbbbbb
0
[00:00:03.861,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:03.861,000] <err> os: Current thread: 0x3ffc6d70 (net_mgmt)
[00:00:03.973,000] <err> os: Halting systemWhen I disable the SPIRAM $ cat boards/my_custom_board_procpu.conf
CONFIG_ESP_SPIRAM=n
CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM=n
CONFIG_NET_IF_MAX_IPV4_COUNT=2
The example runs as expected. I am able to scan WiFi networks and connect to it. $ west espressif monitor
Serial port /dev/ttyUSB0
Connecting.....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
--- idf_monitor on /dev/ttyUSB0 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffb0000,len:31972
load:0x40080000,len:63872
1150 mmu set 00010000, pos 00010000
entry 0x40089980
I (55) soc_init: ESP Simple boot
I (55) soc_init: compile time Nov 6 2025 19:13:12
W (55) soc_init: Unicore bootloader
I (55) soc_init: chip revision: v3.1
I (58) flash_init: SPI Speed : 40MHz
I (62) flash_init: SPI Mode : DIO
I (66) flash_init: SPI Flash Size : 4MB
I (69) boot: DRAM: lma 0x00001020 vma 0x3ffb0000 len 0x7ce4 (31972)
I (75) boot: IRAM: lma 0x00008d0c vma 0x40080000 len 0xf980 (63872)
I (82) boot: IRAM: lma 0x00018698 vma 0x00000000 len 0x7960 (31072)
I (88) boot: IMAP: lma 0x00020000 vma 0x400d0000 len 0x62e1c (405020)
I (94) boot: IRAM: lma 0x00082e24 vma 0x00000000 len 0xd1d4 (53716)
I (100) boot: DMAP: lma 0x00090000 vma 0x3f400000 len 0x1710c (94476)
I (106) boot: Image with 6 segments
I (110) boot: IROM segment: paddr=00020000h, vaddr=400d0000h, size=62E1Ch (405020) map
I (117) boot: DROM segment: paddr=00090000h, vaddr=3f400000h, size=1710Ch ( 94476) map
I (136) boot: libc heap size 45 kB.
I (136) spi_flash: detected chip: generic
I (136) spi_flash: flash io: dio
[00:00:00.221,000] <inf> phy_mii: PHY (1) ID 221430
[00:00:00.826,000] <err> phy_mii: Failed to reset PHY (0): -116
[00:00:00.877,000] <inf> phy_mii: PHY (2) ID 221430
[00:00:00.893,000] <wrn> net_if: You have 1 IPv4 net_if addresses but 2 network interfaces
[00:00:00.893,000] <wrn> net_if: Consider increasing CONFIG_NET_IF_MAX_IPV4_COUNT value.
*** Booting Zephyr OS build 600b189b68c8 ***
[00:00:02.032,000] <inf> phy_mii: PHY (1) Link speed 100 Mb, full duplex
uart:~$ wifi scan
Scan requested
Num | SSID (len) | Chan (Band) | RSSI | Security | BSSID | MFP
1 | (<>|<>) 7 | 12 (2.4GHz) | -36 | WPA2-PSK | 78:9A:18:C8:1D:00 | Disable
2 | DIRECT-2B-HP Smart Tank 510 27 | 7 (2.4GHz) | -38 | WPA2-PSK | 5E:60:BA:26:C8:2B | Disable
Scan request done
uart:~$ wifi connect --key-mgmt 1 --ssid (<>|<>) --passphrase My.Awesome.Pass
Connection requested
[00:01:30.202,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:01:33.219,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:01:42.195,000] <inf> net_dhcpv4: Received: 192.168.101.31
uart:~$ net allocs
Set CONFIG_NET_DEBUG_NET_PKT_ALLOC to enable net_pkt allocation support.
[00:01:58.206,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:03.208,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:11.209,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:26.221,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:31.224,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:40.225,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:02:57.241,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:02.244,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:11.245,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:27.261,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:31.264,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:38.272,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:54.286,000] <inf> net_dhcpv4: Received: 192.168.101.31
[00:03:57.288,000] <inf> net_dhcpv4: Received: 192.168.101.31
uart:~$
Based on this article https://developer.espressif.com/blog/2024/12/zephyr-how-to-use-psram/, I have moved to zephyr 4.2.1. Hoping I can use SPIRAM support. Any help is welcome. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
@Ajno, thanks for your report. May I ask you to move to the latest |
Beta Was this translation helpful? Give feedback.
-
|
Hi @marekmatej, I figured that out. There was a mistake in my device tree enabling UART1 which shares GPIO with SPIRAM. After fixing that, It works as expected. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
@Ajno, thanks for your report. May I ask you to move to the latest
main? Since you are using a custom board, make sure SPIRAM is properly connected and you are using a supported chip.