CPU panic'ed when the function was used in the elf but not relocated in the main program
Closed this issue · 5 comments
Hi,
I'm trying this library.What a good library you have made!
But I found something wrong.As is said in the title,
I tried the program below,
#include <stdio.h>
#include <stdint.h>
int delay(size_t millsec);
uint32_t local_main(uint32_t arg) {
for(int i=0;i<20;i++){
printf("Hello world!\n");
printf("It works for %i times!\n",i);
delay(3000);
}
return 0;
}
As you can see,I used a external function "delay()",but when I do NOT add an implement to the relocate table,the CPU panic'ed.
The host program is below:
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include "loader.hpp"
#include "Program.h"
extern "C" void delay(size_t microsec){
TickType_t xDelay = microsec / portTICK_PERIOD_MS;
vTaskDelay(xDelay);
}
extern "C" void app_main() {
ElfLoader test((void*)Program, {
{"puts", (void*) puts},
{ "printf", (void*) printf },
{ "delay",(void*) delay }
});
test.parse();
if(test.relocate()==0){
((void (*) ())test.getEntryPoint())();
}else{
printf("Cannot load ELF file!\n");
}
}
Could anyone help me,please?
Thanks.
Hello, I have tested your program. I am sure that the problem is with the elf file loader. I will try to solve it as quickly as I can.
Note that the delay function is of different types. You have void type in one file and int type in another.
I found the reason for the panic. The entry point pointer is wrong. I have already solved the problem, but I need to run more tests before I post the solution
I have tested your program with the updated loader. The program works without errors.