1
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_cpu.h"
|
||||
|
||||
typedef int (*func_t)(void);
|
||||
|
||||
void run_app_from_iram(void)
|
||||
{
|
||||
uint8_t code[] = {
|
||||
0x36, 0x41, 0x00, 0x2c, 0xa2, 0x1d, 0xf0
|
||||
};
|
||||
|
||||
void *exec = heap_caps_malloc(sizeof(code),
|
||||
MALLOC_CAP_EXEC | MALLOC_CAP_8BIT);
|
||||
|
||||
memcpy(exec, code, sizeof(code));
|
||||
|
||||
//esp_cpu_invalidate_icache_all();
|
||||
|
||||
func_t f = (func_t)exec;
|
||||
|
||||
int result = f();
|
||||
|
||||
printf("Result = %d\n", result); // Должно быть 42
|
||||
|
||||
heap_caps_free(exec);
|
||||
}
|
||||
Reference in New Issue
Block a user