mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
components/esp32: add inter-processor call API and implement spi_flash through it
With this change, flash operations can run on both cores. NVS and WiFi stack can also run in dual core mode now.
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#include "esp_spi_flash.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_ipc.h"
|
||||
|
||||
static void IRAM_ATTR user_start_cpu0(void);
|
||||
static void IRAM_ATTR call_user_start_cpu1();
|
||||
@@ -180,37 +182,39 @@ void IRAM_ATTR call_user_start_cpu1() {
|
||||
user_start_cpu1();
|
||||
}
|
||||
|
||||
extern volatile int port_xSchedulerRunning;
|
||||
extern int xPortStartScheduler();
|
||||
extern volatile int port_xSchedulerRunning[2];
|
||||
|
||||
void user_start_cpu1(void) {
|
||||
//Wait for the freertos initialization is finished on CPU0
|
||||
while (port_xSchedulerRunning == 0) ;
|
||||
ets_printf("Core0 started initializing FreeRTOS. Jumping to scheduler.\n");
|
||||
//Okay, start the scheduler!
|
||||
void IRAM_ATTR user_start_cpu1(void) {
|
||||
// Wait for FreeRTOS initialization to finish on PRO CPU
|
||||
while (port_xSchedulerRunning[0] == 0) {
|
||||
;
|
||||
}
|
||||
ets_printf("Starting scheduler on APP CPU.\n");
|
||||
// Start the scheduler on APP CPU
|
||||
xPortStartScheduler();
|
||||
}
|
||||
|
||||
extern void (*__init_array_start)(void);
|
||||
extern void (*__init_array_end)(void);
|
||||
|
||||
extern esp_err_t app_main();
|
||||
static void do_global_ctors(void) {
|
||||
void (**p)(void);
|
||||
for(p = &__init_array_start; p != &__init_array_end; ++p)
|
||||
(*p)();
|
||||
}
|
||||
|
||||
extern esp_err_t app_main();
|
||||
|
||||
void user_start_cpu0(void) {
|
||||
ets_setup_syscalls();
|
||||
do_global_ctors();
|
||||
esp_ipc_init();
|
||||
spi_flash_init();
|
||||
|
||||
#if CONFIG_WIFI_ENABLED
|
||||
ets_printf("nvs_flash_init\n");
|
||||
esp_err_t ret = nvs_flash_init(5, 3);
|
||||
if (ret != ESP_OK) {
|
||||
ets_printf("nvs_flash_init fail, ret=%d\n", ret);
|
||||
printf("nvs_flash_init failed, ret=%d\n", ret);
|
||||
}
|
||||
|
||||
system_init();
|
||||
@@ -227,6 +231,7 @@ void user_start_cpu0(void) {
|
||||
app_main();
|
||||
#endif
|
||||
|
||||
ets_printf("Starting scheduler on PRO CPU.\n");
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user