Unverified Commit e7415b55 authored by David Brown's avatar David Brown Committed by GitHub
Browse files

Merge pull request #79 from nvlsianpu/fixes/cherry-pick-pr1362

cherry-pick fix for zephyr 3.1.0-rc3
parents e58ea98a df6249a6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -6,4 +6,9 @@

#pragma once

void start_cpu0_image(int image_index, int slot, unsigned int hdr_offset);
#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
void start_cpu1_image(int image_index, int slot, unsigned int hdr_offset);
#endif

void esp_app_image_load(int image_index, int slot, unsigned int hdr_offset, unsigned int *entry_addr);
+2 −10
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@
#ifdef CONFIG_SECURE_FLASH_ENC_ENABLED
#include "esp_flash_encrypt.h"
#endif
#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
#include "app_cpu_start.h"
#endif

#include "esp_loader.h"
#include "os/os_malloc.h"
@@ -41,13 +38,10 @@ extern esp_err_t check_and_generate_secure_boot_keys(void);

void do_boot(struct boot_rsp *rsp)
{
    unsigned int entry_addr;
    BOOT_LOG_INF("br_image_off = 0x%x", rsp->br_image_off);
    BOOT_LOG_INF("ih_hdr_size = 0x%x", rsp->br_hdr->ih_hdr_size);
    int slot = (rsp->br_image_off == CONFIG_ESP_IMAGE0_PRIMARY_START_ADDRESS) ? PRIMARY_SLOT : SECONDARY_SLOT;
    esp_app_image_load(IMAGE_INDEX_0, slot, rsp->br_hdr->ih_hdr_size, &entry_addr);
    ((void (*)(void))entry_addr)(); /* Call to application entry address should not return */
    FIH_PANIC; /* It should not get here */
    start_cpu0_image(IMAGE_INDEX_0, slot, rsp->br_hdr->ih_hdr_size);
}

#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
@@ -79,15 +73,13 @@ done:

void do_boot_appcpu(uint32_t img_index, uint32_t slot)
{
    unsigned int entry_addr;
    struct image_header img_header;

    if (read_image_header(img_index, slot, &img_header) != 0) {
        FIH_PANIC;
    }

    esp_app_image_load(img_index, slot, img_header.ih_hdr_size, &entry_addr);
    appcpu_start(entry_addr);
    start_cpu1_image(img_index, slot, img_header.ih_hdr_size);
}
#endif

+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ SECTIONS
    *libhal.a:esp_efuse_api.*(.literal .text .literal.* .text.*)
    *libhal.a:esp_efuse_utility.*(.literal .text .literal.* .text.*)
    *libhal.a:esp_efuse_api_key_esp32.*(.literal .text .literal.* .text.*)
    *libhal.a:app_cpu_start.*(.literal .text .literal.* .text.*)
    *esp_mcuboot.*(.literal .text .literal.* .text.*)
    *esp_loader.*(.literal .text .literal.* .text.*)
    *(.fini.literal)
+21 −0
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@
#include "esp_loader.h"
#include "flash_map_backend/flash_map_backend.h"

#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
#include "app_cpu_start.h"
#endif

static int load_segment(const struct flash_area *fap, uint32_t data_addr, uint32_t data_len, uint32_t load_addr)
{
    const uint32_t *data = (const uint32_t *)bootloader_mmap((fap->fa_off + data_addr), data_len);
@@ -90,3 +94,20 @@ void esp_app_image_load(int image_index, int slot, unsigned int hdr_offset, unsi
    assert(entry_addr != NULL);
    *entry_addr = load_header.entry_addr;
}

void start_cpu0_image(int image_index, int slot, unsigned int hdr_offset)
{
    unsigned int entry_addr;
    esp_app_image_load(image_index, slot, hdr_offset, &entry_addr);
    ((void (*)(void))entry_addr)(); /* Call to application entry address should not return */
    FIH_PANIC; /* It should not get here */
}

#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
void start_cpu1_image(int image_index, int slot, unsigned int hdr_offset)
{
    unsigned int entry_addr;
    esp_app_image_load(image_index, slot, hdr_offset, &entry_addr);
    appcpu_start(entry_addr);
}
#endif