Skip to content

Can't properly run on esp32p4 #376

@kirillolenev-dm

Description

@kirillolenev-dm

Bug description

A simple HelloWorld panics during startup when targeting esp32p4 with ESP_IDF 5.3.x+/ 5.4.x+ versions.
(ESP32-P4-Function-EV-Board)

ESP-ROM:esp32p4-eco2-20240710
Build:Jul 10 2024
rst:0xc (SW_CPU_RESET),boot:0x30f (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4ff00c9a
0x4ff00c9a - esp_restart_noos
    at /Users/kirill/Desktop/tempp4/kiolp4/.embuild/espressif/esp-idf/v5.4.1/components/esp_system/port/soc/esp32p4/system_internal.c:197
Core1 Saved PC:0x4fc012cc
SPI mode:DIO, clock div:2
load:0x4ff33ce0,len:0x162c
load:0x4ff2abd0,len:0xd6c
load:0x4ff2cbd0,len:0x3308
entry 0x4ff2abda
I (33) boot: ESP-IDF v5.4.1 2nd stage bootloader
I (33) boot: compile time Apr 16 2025 21:55:19
I (33) boot: Multicore bootloader
I (34) boot: chip revision: v1.0
I (36) boot: efuse block revision: v0.3
I (40) boot.esp32p4: SPI Speed      : 40MHz
I (44) boot.esp32p4: SPI Mode       : DIO
I (47) boot.esp32p4: SPI Flash Size : 16MB
I (51) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (71) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (78) boot:  2 factory          factory app      00 00 00010000 00100000
I (85) boot: End of partition table
I (87) esp_image: segment 0: paddr=00010020 vaddr=40020020 size=09a40h ( 39488) map
I (104) esp_image: segment 1: paddr=00019a68 vaddr=30100000 size=00044h (    68) load
I (105) esp_image: segment 2: paddr=00019ab4 vaddr=4ff00000 size=06564h ( 25956) load
I (117) esp_image: segment 3: paddr=00020020 vaddr=40000020 size=16394h ( 91028) map
I (137) esp_image: segment 4: paddr=000363bc vaddr=4ff06564 size=05ce0h ( 23776) load
I (144) esp_image: segment 5: paddr=0003c0a4 vaddr=4ff0c280 size=01c00h (  7168) load
I (149) boot: Loaded app from partition at offset 0x10000
I (150) boot: Disabling RNG early entropy source...
I (162) cpu_start: Multicore app
Guru Meditation Error: Core  0 panic'ed (Instruction access fault). Exception was unhandled.

Core  0 register dump:
MEPC    : 0x00008082  RA      : 0x4000159e  SP      : 0x4ff3cb90  GP      : 0x4ff0ca80  
0x4000159e - do_global_ctors
    at /Users/kirill/Desktop/tempp4/kiolp4/.embuild/espressif/esp-idf/v5.4.1/components/esp_system/startup.c:102
0x4ff0ca80 - s_retention
    at ??:??
TP      : 0x00000000  T0      : 0x4fc00d56  T1      : 0x4ff0103c  T2      : 0x00000012  
0x4ff0103c - heap_caps_aligned_alloc_base
    at /Users/kirill/Desktop/tempp4/kiolp4/.embuild/espressif/esp-idf/v5.4.1/components/heap/heap_caps_base.c:108
S0/FP   : 0x40029a70  S1      : 0x4002a000  A0      : 0x00000000  A1      : 0x00000080  
A2      : 0x00000029  A3      : 0x0000001f  A4      : 0x00000001  A5      : 0x00008082  
A6      : 0xe0f1f000  A7      : 0x0000001c  S2      : 0x40020020  S3      : 0x00020020  
S4      : 0x4ff003e8  S5      : 0x00016394  S6      : 0x00010000  S7      : 0x00009a40  
0x4ff003e8 - rv_utils_dbgr_is_attached
    at /Users/kirill/Desktop/tempp4/kiolp4/.embuild/espressif/esp-idf/v5.4.1/components/riscv/include/riscv/rv_utils.h:325
S8      : 0x00010020  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x08000000  T5      : 0x04000000  T6      : 0x0c000000  
MSTATUS : 0x00001880  MTVEC   : 0x4ff00003  MCAUSE  : 0x00000001  MTVAL   : 0x00008082  
0x4ff00003 - _vector_table
    at ??:??
MHARTID : 0x00000000  

config.toml

[build]
target = "riscv32imafc-esp-espidf"

[target.riscv32imafc-esp-espidf]
linker = "ldproxy"
runner = "espflash flash --monitor"
rustflags = [ "--cfg",  "espidf_time64"]

[unstable]
build-std = ["std", "panic_abort"]

[env]
MCU="esp32p4"
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
ESP_IDF_VERSION = "v5.4"
#ESP_IDF_VERSION = "v5.3"

cargo.toml

[package]
name = "kiolp4"
version = "0.1.0"
authors = ["kirillolenev-dm <[email protected]>"]
edition = "2021"
resolver = "2"
rust-version = "1.77"

[[bin]]
name = "kiolp4"
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors

[profile.release]
opt-level = "s"

[profile.dev]
debug = true    # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
default = ["std", "esp-idf-sys/native"]

std = ["esp-idf-sys/std"]

[dependencies]
esp-idf-sys = { version = "0.36.1", default-features = false }

[build-dependencies]
embuild = "0.33"

fn main() {
    esp_idf_sys::link_patches();
    println!("Hello, world!1");
}

To Reproduce

  1. Build
  2. Flash

Expected behavior

Run normally

Environment

  • Crate (esp-idf-sys) version: [e.g. 0.36.1
  • ESP-IDF branch or tag: 5.3.x+/ 5.4.x+
  • Target device (MCU): [e.g. esp32p4]
  • OS: [macOs]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions