Hi!!
Thank you so so much for your help

i was able to finish it.I just added the file "return from panic" inside my custom panic handler hard-codded in my panic_handler.c. At least i have something to work on even though is hard-codded, im so grateful for that
However,the wrapper does not work for me , if i simulate the structure of the memprop_app and adding the linker in the outside CMakeFile
Code: Select all
main/
├── CMakeLists.txt
├── custom_panic.c
├── ecall_panic.c
├── main.c
├── program.s
├── return_from_panic.s
CMakeLists.txt
The outside CMake looks like this
Code: Select all
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
target_link_libraries(${project_elf} PRIVATE
"-Wl,--wrap=esp_panic_handler")
project(hello_world)
It gives me this problem
Code: Select all
/home/{myname}/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: esp-idf/esp_system/libesp_system.a(panic_handler.c.obj): in function panic_handler':
/home/{myname}/esp/v5.3/esp-idf/components/esp_system/port/panic_handler.c:220:(.text.panic_handler+0x42): undefined reference to __wrap_esp_panic_handler'
collect2: error: ld returned 1 exit status
I tried also to insert the wrapper in the inside CMakeFile, but it's kinda silly, the wrapper does not create.
It looks like this
Code: Select all
idf_component_register(
SRCS
"program.s"
"return_from_panic.S"
"custom_panic.c"
"ecall_panic.c"
INCLUDE_DIRS
"..")
# target_link_libraries(${project_elf} PRIVATE
# "-Wl,--wrap=esp_panic_handler"
# )
The wrapper code looks like this
Code: Select all
#include "riscv/rvruntime-frames.h"
#include "esp_private/panic_internal.h"
#include "esp_private/panic_reason.h"
#include "hal/wdt_hal.h"
#include "creator/custom_panic.h"
#include <stdio.h>
extern void esp_panic_handler(panic_info_t *info);
void return_from_panic_handler(RvExcFrame *frm) __attribute__((noreturn));
void __real_esp_panic_handler(panic_info_t *info);
void __wrap_esp_panic_handler(panic_info_t *info)
{
printf("Panic handler personalizado llamado\n");
RvExcFrame *frm = (RvExcFrame *)info->frame;
if ( frm->mcause == 8 || frm->mcause == 11 ) {
/* Return from exception to the return address that called the faulting function.*/
track_ecall(frm);
frm->mepc = frm->mepc + 4;
/* Restore the CPU state and return from the exception.*/
return_from_panic_handler(frm);
} else {
__real_esp_panic_handler(info);
}
}
What can be the cause of failing???