mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 09:37:00 +08:00
feat(bootloader): Add startup function
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -75,7 +75,7 @@ SECTIONS
|
||||
{
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.UserEnter.text)
|
||||
LONG(_text_start)
|
||||
. = ALIGN(16);
|
||||
*(.DebugExceptionVector.text)
|
||||
. = ALIGN(16);
|
||||
|
Binary file not shown.
35
components/esp8266/source/startup.c
Normal file
35
components/esp8266/source/startup.c
Normal 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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user