feat(bootloader): Add startup function

This commit is contained in:
Dong Heng
2018-06-19 17:02:34 +08:00
parent c7c96e0066
commit 1cde2f5f81
9 changed files with 129 additions and 65 deletions

View File

@ -4,11 +4,11 @@ BOOTLOADER_FIRMWARE_DIR := $(abspath $(COMPONENT_PATH))/firmware
ESPTOOLPY_FLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
ifeq ($(ESPTOOLPY_FLASHSIZE), "2MB-c1")
ifeq ($(ESPTOOLPY_FLASHSIZE), "2MB")
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x1FC000
endif
ifeq ($(ESPTOOLPY_FLASHSIZE), "4MB-c1")
ifeq ($(ESPTOOLPY_FLASHSIZE), "4MB")
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x3FC000
endif

View File

@ -75,7 +75,7 @@ SECTIONS
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.UserEnter.text)
LONG(_text_start)
. = ALIGN(16);
*(.DebugExceptionVector.text)
. = ALIGN(16);

Binary file not shown.

View File

@ -0,0 +1,35 @@
#include "sdkconfig.h"
#include <stdint.h>
#include <stdarg.h>
#include "esp_image_format.h"
#define FLASH_MAP_ADDR 0x40200000
void call_user_start(void)
{
int i;
extern void user_start(void);
esp_image_header_t *head = (esp_image_header_t *)(FLASH_MAP_ADDR + CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET);
esp_image_segment_header_t *segment = (esp_image_segment_header_t *)((uintptr_t)head + sizeof(esp_image_header_t));
for (i = 0; i < 3; i++) {
segment = (esp_image_segment_header_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t) + segment->data_len);
uint32_t *dest = (uint32_t *)segment->load_addr;
uint32_t *src = (uint32_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t));
uint32_t size = segment->data_len / sizeof(uint32_t);
while (size--)
*dest++ = *src++;
}
__asm__ __volatile__(
"movi a2, 0x40100000\n"
"wsr a2, vecbase\n");
user_start();
}