Merge branch 'feature/speed_up_system_startup' into 'master'

feat(startup): add fast boot and fast restart function

See merge request sdk/ESP8266_RTOS_SDK!1302
This commit is contained in:
Dong Heng
2020-08-05 11:21:00 +08:00
19 changed files with 428 additions and 43 deletions

View File

@ -205,6 +205,9 @@
#define CACHE_READ_EN_BIT BIT8
//}}
#define ESP_CACHE1_ADDR_MAX (0x100000)
#define ESP_CACHE2_ADDR_MAX (0x200000)
#define DRAM_BASE (0x3FFE8000)
#define DRAM_SIZE (96 * 1024)

View File

@ -1,9 +1,16 @@
#ifndef _ROM_FUNCTIONS_H
#define _ROM_FUNCTIONS_H
#include "sdkconfig.h"
#include <stdint.h>
#include <stdarg.h>
#ifdef CONFIG_SOC_FULL_ICACHE
#define SOC_CACHE_SIZE 1 // 32KB
#else
#define SOC_CACHE_SIZE 0 // 16KB
#endif
#define ROM_FLASH_BUF_DECLARE(__name, __size) uint8_t __name[__size] __attribute__((aligned(4)))
typedef struct {

View File

@ -0,0 +1,87 @@
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#ifndef BOOTLOADER_BUILD
#include "esp_partition.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef BOOTLOADER_BUILD
/**
* @brief Setting target partition as fast boot partition and enable fast boot function.
*
* @param partition partition which has image to be booted
*
* @return
* - 0 on success
* - -EINVAL parameter error
* - -EIO read flash error
*/
int esp_fast_boot_enable_partition(const esp_partition_t *partition);
/**
* @brief Setting current running partition as fast boot partition and enable fast boot function.
*
* @return
* - 0 on success
* - -EINVAL current running partition information error
* - -EIO read flash error
*/
int esp_fast_boot_enable(void);
/**
* @brief Directly running the image which is to be booted after restart.
*
* @note It is just like jumping directly from one APP to another one without running ROM bootloader and level 2 bootloader.
* Using this API, system starting up is fastest.
*
* @return
* - 0 on success
* - -EINVAL booted partition information error
* - -EIO read flash error
*/
int esp_fast_boot_restart(void);
#endif
/**
* @brief Disabling fast boot function and bootloader will not boot fast.
*/
void esp_fast_boot_disable(void);
/**
* @brief Getting fast boot information.
*
* @param image_start image startting address in the SPI Flash
* @param image_size image max size in the SPI Flash
* @param image_entry image entry address in the SPI Flash
*
* @return
* - 0 on success
* - -EINVAL fast boot information error
*/
int esp_fast_boot_get_info(uint32_t *image_start, uint32_t *image_size, uint32_t *image_entry);
/**
* @brief Printing fast boot information.
*/
void esp_fast_boot_print_info(void);
#ifdef __cplusplus
}
#endif

View File

@ -50,6 +50,7 @@ typedef enum {
ESP_RST_DEEPSLEEP, //!< Reset after exiting deep sleep mode
ESP_RST_BROWNOUT, //!< Brownout reset (software or hardware)
ESP_RST_SDIO, //!< Reset over SDIO
ESP_RST_FAST_SW, //!< Fast reboot
} esp_reset_reason_t;
/**
@ -187,6 +188,13 @@ uint32_t esp_random(void);
*/
void esp_fill_random(void *buf, size_t len);
/**
* @brief Initialize MAC address
*
* @return 0 if sucess or others failed
*/
esp_err_t esp_mac_init(void);
typedef enum {
FLASH_SIZE_4M_MAP_256_256 = 0, /**< Flash size : 4Mbits. Map : 256KBytes + 256KBytes */
FLASH_SIZE_2M, /**< Flash size : 2Mbits. Map : 256KBytes */

View File

@ -22,6 +22,7 @@ extern "C" {
#endif
#define RTC_SYS_RAM_SIZE 256
#define ESP_SYSTEM_FAST_BOOT_IMAGE 0x5aa5a55a
/**
* @brief Station's AP base information of old SDK
@ -50,6 +51,13 @@ struct _rtc_sys_info {
uint32_t hint; // software reset reason
uint32_t old_sysconf_addr; /*<! old SDK system configuration parameters base address,
if your bootloader is older than v3.2, please don't use this */
struct {
uint32_t magic;
uint32_t image_start;
uint32_t image_size;
uint32_t image_entry;
uint32_t crc32;
} fast_boot;
};
/**

View File

@ -101,6 +101,11 @@ static inline STATUS UartRxString(uint8_t *pString, uint8_t MaxStrlen)
return OK;
}
/**
* @brief Disable UART0 I/O swap and don't care about if TX FIFO is empty
*/
void uart_disable_swap_io(void);
/**
* @}
*/