mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 00:56:38 +08:00
Merge branch 'feature/add_bootloader_support' into 'master'
Add bootloader support See merge request sdk/ESP8266_RTOS_SDK!216
This commit is contained in:
16
Kconfig
16
Kconfig
@ -4,11 +4,23 @@
|
|||||||
#
|
#
|
||||||
mainmenu "Espressif IoT Development Framework Configuration"
|
mainmenu "Espressif IoT Development Framework Configuration"
|
||||||
|
|
||||||
|
choice TARGET_PLATFORM
|
||||||
|
bool "Espressif target platform choose"
|
||||||
|
default TARGET_PLATFORM_ESP8266
|
||||||
|
help
|
||||||
|
Choose the specific target platform which you will use.
|
||||||
|
|
||||||
|
config TARGET_PLATFORM_ESP32
|
||||||
|
bool "esp32"
|
||||||
|
config TARGET_PLATFORM_ESP8266
|
||||||
|
bool "esp8266"
|
||||||
|
endchoice
|
||||||
|
|
||||||
menu "SDK tool configuration"
|
menu "SDK tool configuration"
|
||||||
config TOOLPREFIX
|
config TOOLPREFIX
|
||||||
string "Compiler toolchain path/prefix"
|
string
|
||||||
default "xtensa-lx106-elf-"
|
default "xtensa-esp32-elf-" if TARGET_PLATFORM_ESP32
|
||||||
|
default "xtensa-lx106-elf-" if TARGET_PLATFORM_ESP8266
|
||||||
help
|
help
|
||||||
The prefix/path that is used to call the toolchain. The default setting assumes
|
The prefix/path that is used to call the toolchain. The default setting assumes
|
||||||
a crosstool-ng gcc setup that is in your PATH.
|
a crosstool-ng gcc setup that is in your PATH.
|
||||||
|
323
components/bootloader/Kconfig.projbuild
Normal file
323
components/bootloader/Kconfig.projbuild
Normal file
@ -0,0 +1,323 @@
|
|||||||
|
menu "Bootloader config"
|
||||||
|
choice LOG_BOOTLOADER_LEVEL
|
||||||
|
bool "Bootloader log verbosity"
|
||||||
|
default LOG_BOOTLOADER_LEVEL_INFO
|
||||||
|
help
|
||||||
|
Specify how much output to see in bootloader logs.
|
||||||
|
|
||||||
|
config LOG_BOOTLOADER_LEVEL_NONE
|
||||||
|
bool "No output"
|
||||||
|
config LOG_BOOTLOADER_LEVEL_ERROR
|
||||||
|
bool "Error"
|
||||||
|
config LOG_BOOTLOADER_LEVEL_WARN
|
||||||
|
bool "Warning"
|
||||||
|
config LOG_BOOTLOADER_LEVEL_INFO
|
||||||
|
bool "Info"
|
||||||
|
config LOG_BOOTLOADER_LEVEL_DEBUG
|
||||||
|
bool "Debug"
|
||||||
|
config LOG_BOOTLOADER_LEVEL_VERBOSE
|
||||||
|
bool "Verbose"
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config LOG_BOOTLOADER_LEVEL
|
||||||
|
int
|
||||||
|
default 0 if LOG_BOOTLOADER_LEVEL_NONE
|
||||||
|
default 1 if LOG_BOOTLOADER_LEVEL_ERROR
|
||||||
|
default 2 if LOG_BOOTLOADER_LEVEL_WARN
|
||||||
|
default 3 if LOG_BOOTLOADER_LEVEL_INFO
|
||||||
|
default 4 if LOG_BOOTLOADER_LEVEL_DEBUG
|
||||||
|
default 5 if LOG_BOOTLOADER_LEVEL_VERBOSE
|
||||||
|
|
||||||
|
config BOOTLOADER_SPI_WP_PIN
|
||||||
|
int "SPI Flash WP Pin when customising pins via efuse (read help)"
|
||||||
|
range 0 33
|
||||||
|
default 7
|
||||||
|
depends on (FLASHMODE_QIO || FLASHMODE_QOUT) && TARGET_PLATFORM_ESP32
|
||||||
|
help
|
||||||
|
This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
|
||||||
|
overriden by setting the efuses SPI_PAD_CONFIG_xxx.
|
||||||
|
|
||||||
|
When this is the case, the Efuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
|
||||||
|
pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in Efuse. That pin number is compiled into the bootloader
|
||||||
|
instead.
|
||||||
|
|
||||||
|
The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
|
||||||
|
|
||||||
|
choice BOOTLOADER_VDDSDIO_BOOST
|
||||||
|
bool "VDDSDIO LDO voltage"
|
||||||
|
default BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||||
|
depends on TARGET_PLATFORM_ESP32
|
||||||
|
help
|
||||||
|
If this option is enabled, and VDDSDIO LDO is set to 1.8V (using EFUSE
|
||||||
|
or MTDI bootstrapping pin), bootloader will change LDO settings to
|
||||||
|
output 1.9V instead. This helps prevent flash chip from browning out
|
||||||
|
during flash programming operations.
|
||||||
|
|
||||||
|
This option has no effect if VDDSDIO is set to 3.3V, or if the internal
|
||||||
|
VDDSDIO regulator is disabled via efuse.
|
||||||
|
|
||||||
|
config BOOTLOADER_VDDSDIO_BOOST_1_8V
|
||||||
|
bool "1.8V"
|
||||||
|
depends on !ESPTOOLPY_FLASHFREQ_80M && TARGET_PLATFORM_ESP32
|
||||||
|
config BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||||
|
bool "1.9V"
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config BOOTLOADER_FACTORY_RESET
|
||||||
|
bool "GPIO triggers factory reset"
|
||||||
|
default N
|
||||||
|
depends on TARGET_PLATFORM_ESP32
|
||||||
|
help
|
||||||
|
Allows to reset the device to factory settings:
|
||||||
|
- clear one or more data partitions;
|
||||||
|
- boot from "factory" partition.
|
||||||
|
The factory reset will occur if there is a GPIO input pulled low while device starts up.
|
||||||
|
See settings below.
|
||||||
|
|
||||||
|
config BOOTLOADER_NUM_PIN_FACTORY_RESET
|
||||||
|
int "Number of the GPIO input for factory reset"
|
||||||
|
depends on BOOTLOADER_FACTORY_RESET && TARGET_PLATFORM_ESP32
|
||||||
|
range 0 39
|
||||||
|
default 4
|
||||||
|
help
|
||||||
|
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||||
|
To trigger a factory reset, this GPIO must be pulled low on reset.
|
||||||
|
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||||
|
|
||||||
|
config BOOTLOADER_OTA_DATA_ERASE
|
||||||
|
bool "Clear OTA data on factory reset (select factory partition)"
|
||||||
|
depends on BOOTLOADER_FACTORY_RESET
|
||||||
|
help
|
||||||
|
The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a factory reset.
|
||||||
|
|
||||||
|
config BOOTLOADER_DATA_FACTORY_RESET
|
||||||
|
string "Comma-separated names of partitions to clear on factory reset"
|
||||||
|
depends on BOOTLOADER_FACTORY_RESET
|
||||||
|
default "nvs"
|
||||||
|
help
|
||||||
|
Allows customers to select which data partitions will be erased while factory reset.
|
||||||
|
|
||||||
|
Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this: "nvs, phy_init, ...")
|
||||||
|
Make sure that the name specified in the partition table and here are the same.
|
||||||
|
Partitions of type "app" cannot be specified here.
|
||||||
|
|
||||||
|
config BOOTLOADER_APP_TEST
|
||||||
|
bool "GPIO triggers boot from test app partition"
|
||||||
|
default N
|
||||||
|
depends on TARGET_PLATFORM_ESP32
|
||||||
|
help
|
||||||
|
Allows to run the test app from "TEST" partition.
|
||||||
|
A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
|
||||||
|
See settings below.
|
||||||
|
|
||||||
|
config BOOTLOADER_NUM_PIN_APP_TEST
|
||||||
|
int "Number of the GPIO input to boot TEST partition"
|
||||||
|
depends on BOOTLOADER_APP_TEST
|
||||||
|
range 0 39
|
||||||
|
default 18
|
||||||
|
help
|
||||||
|
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||||
|
To trigger a test app, this GPIO must be pulled low on reset.
|
||||||
|
After the GPIO input is deactivated and the device reboots, the old application will boot.
|
||||||
|
(factory or OTA[x]).
|
||||||
|
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||||
|
|
||||||
|
config BOOTLOADER_HOLD_TIME_GPIO
|
||||||
|
int "Hold time of GPIO for reset/test mode (seconds)"
|
||||||
|
depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
|
||||||
|
default 5
|
||||||
|
help
|
||||||
|
The GPIO must be held low continuously for this period of time after reset
|
||||||
|
before a factory reset or test partition boot (as applicable) is performed.
|
||||||
|
|
||||||
|
endmenu # Bootloader
|
||||||
|
|
||||||
|
|
||||||
|
menu "Security features"
|
||||||
|
depends on TARGET_PLATFORM_ESP32
|
||||||
|
|
||||||
|
config SECURE_BOOT_ENABLED
|
||||||
|
bool "Enable secure boot in bootloader (READ DOCS FIRST)"
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
Build a bootloader which enables secure boot on first boot.
|
||||||
|
|
||||||
|
Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition table or boot an app if the data has a verified digital signature. There are implications for reflashing updated apps once secure boot is enabled.
|
||||||
|
|
||||||
|
When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
|
||||||
|
|
||||||
|
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||||
|
|
||||||
|
choice SECURE_BOOTLOADER_MODE
|
||||||
|
bool "Secure bootloader mode"
|
||||||
|
depends on SECURE_BOOT_ENABLED
|
||||||
|
default SECURE_BOOTLOADER_ONE_TIME_FLASH
|
||||||
|
|
||||||
|
config SECURE_BOOTLOADER_ONE_TIME_FLASH
|
||||||
|
bool "One-time flash"
|
||||||
|
help
|
||||||
|
On first boot, the bootloader will generate a key which is not readable externally or by software. A digest is generated from the bootloader image itself. This digest will be verified on each subsequent boot.
|
||||||
|
|
||||||
|
Enabling this option means that the bootloader cannot be changed after the first time it is booted.
|
||||||
|
|
||||||
|
config SECURE_BOOTLOADER_REFLASHABLE
|
||||||
|
bool "Reflashable"
|
||||||
|
help
|
||||||
|
Generate a reusable secure bootloader key, derived (via SHA-256) from the secure boot signing key.
|
||||||
|
|
||||||
|
This allows the secure bootloader to be re-flashed by anyone with access to the secure boot signing key.
|
||||||
|
|
||||||
|
This option is less secure than one-time flash, because a leak of the digest key from one device allows reflashing of any device that uses it.
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||||
|
bool "Sign binaries during build"
|
||||||
|
depends on SECURE_BOOT_ENABLED
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
|
||||||
|
|
||||||
|
If enabled, these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
|
||||||
|
|
||||||
|
If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py (for example, on a remote signing server.)
|
||||||
|
|
||||||
|
config SECURE_BOOT_SIGNING_KEY
|
||||||
|
string "Secure boot private signing key"
|
||||||
|
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||||
|
default secure_boot_signing_key.pem
|
||||||
|
help
|
||||||
|
Path to the key file used to sign partition tables and app images for secure boot. Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
|
||||||
|
|
||||||
|
Key file is an ECDSA private key (NIST256p curve) in PEM format.
|
||||||
|
|
||||||
|
Path is evaluated relative to the project directory.
|
||||||
|
|
||||||
|
You can generate a new signing key by running the following command:
|
||||||
|
espsecure.py generate_signing_key secure_boot_signing_key.pem
|
||||||
|
|
||||||
|
See docs/security/secure-boot.rst for details.
|
||||||
|
|
||||||
|
config SECURE_BOOT_VERIFICATION_KEY
|
||||||
|
string "Secure boot public signature verification key"
|
||||||
|
depends on SECURE_BOOT_ENABLED && !SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||||
|
default signature_verification_key.bin
|
||||||
|
help
|
||||||
|
Path to a public key file used to verify signed images. This key is compiled into the bootloader,
|
||||||
|
and may also be used to verify signatures on OTA images after download.
|
||||||
|
|
||||||
|
Key file is in raw binary format, and can be extracted from a
|
||||||
|
PEM formatted private key using the espsecure.py
|
||||||
|
extract_public_key command.
|
||||||
|
|
||||||
|
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||||
|
|
||||||
|
config SECURE_BOOT_INSECURE
|
||||||
|
bool "Allow potentially insecure options"
|
||||||
|
depends on SECURE_BOOT_ENABLED
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
You can disable some of the default protections offered by secure boot, in order to enable testing or a custom combination of security features.
|
||||||
|
|
||||||
|
Only enable these options if you are very sure.
|
||||||
|
|
||||||
|
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||||
|
|
||||||
|
config FLASH_ENCRYPTION_ENABLED
|
||||||
|
bool "Enable flash encryption on boot (READ DOCS FIRST)"
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If this option is set, flash contents will be encrypted by the bootloader on first boot.
|
||||||
|
|
||||||
|
Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
|
||||||
|
system is complicated and not always possible.
|
||||||
|
|
||||||
|
Read https://esp-idf.readthedocs.io/en/latest/security/flash-encryption.html before enabling.
|
||||||
|
|
||||||
|
config FLASH_ENCRYPTION_INSECURE
|
||||||
|
bool "Allow potentially insecure options"
|
||||||
|
depends on FLASH_ENCRYPTION_ENABLED
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
You can disable some of the default protections offered by flash encryption, in order to enable testing or a custom combination of security features.
|
||||||
|
|
||||||
|
Only enable these options if you are very sure.
|
||||||
|
|
||||||
|
Refer to docs/security/secure-boot.rst and docs/security/flash-encryption.rst for details.
|
||||||
|
|
||||||
|
menu "Potentially insecure options"
|
||||||
|
visible if FLASH_ENCRYPTION_INSECURE || SECURE_BOOT_INSECURE
|
||||||
|
|
||||||
|
# NOTE: Options in this menu NEED to have SECURE_BOOT_INSECURE
|
||||||
|
# and/or FLASH_ENCRYPTION_INSECURE in "depends on", as the menu
|
||||||
|
# itself doesn't enable/disable its children (if it's not set,
|
||||||
|
# it's possible for the insecure menu to be disabled but the insecure option
|
||||||
|
# to remain on which is very bad.)
|
||||||
|
|
||||||
|
config SECURE_BOOT_ALLOW_ROM_BASIC
|
||||||
|
bool "Leave ROM BASIC Interpreter available on reset"
|
||||||
|
depends on SECURE_BOOT_INSECURE || FLASH_ENCRYPTION_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
By default, the BASIC ROM Console starts on reset if no valid bootloader is
|
||||||
|
read from the flash.
|
||||||
|
|
||||||
|
When either flash encryption or secure boot are enabled, the default is to
|
||||||
|
disable this BASIC fallback mode permanently via efuse.
|
||||||
|
|
||||||
|
If this option is set, this efuse is not burned and the BASIC ROM Console may
|
||||||
|
remain accessible. Only set this option in testing environments.
|
||||||
|
|
||||||
|
config SECURE_BOOT_ALLOW_JTAG
|
||||||
|
bool "Allow JTAG Debugging"
|
||||||
|
depends on SECURE_BOOT_INSECURE || FLASH_ENCRYPTION_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If not set (default), the bootloader will permanently disable JTAG (across entire chip) on first boot when either secure boot or flash encryption is enabled.
|
||||||
|
|
||||||
|
Setting this option leaves JTAG on for debugging, which negates all protections of flash encryption and some of the protections of secure boot.
|
||||||
|
|
||||||
|
Only set this option in testing environments.
|
||||||
|
|
||||||
|
|
||||||
|
config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_ENCRYPT
|
||||||
|
bool "Leave UART bootloader encryption enabled"
|
||||||
|
depends on FLASH_ENCRYPTION_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If not set (default), the bootloader will permanently disable UART bootloader encryption access on first boot. If set, the UART bootloader will still be able to access hardware encryption.
|
||||||
|
|
||||||
|
It is recommended to only set this option in testing environments.
|
||||||
|
|
||||||
|
config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_DECRYPT
|
||||||
|
bool "Leave UART bootloader decryption enabled"
|
||||||
|
depends on FLASH_ENCRYPTION_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If not set (default), the bootloader will permanently disable UART bootloader decryption access on first boot. If set, the UART bootloader will still be able to access hardware decryption.
|
||||||
|
|
||||||
|
Only set this option in testing environments. Setting this option allows complete bypass of flash encryption.
|
||||||
|
|
||||||
|
config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_CACHE
|
||||||
|
bool "Leave UART bootloader flash cache enabled"
|
||||||
|
depends on FLASH_ENCRYPTION_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If not set (default), the bootloader will permanently disable UART bootloader flash cache access on first boot. If set, the UART bootloader will still be able to access the flash cache.
|
||||||
|
|
||||||
|
Only set this option in testing environments.
|
||||||
|
|
||||||
|
config SECURE_BOOT_TEST_MODE
|
||||||
|
bool "Secure boot test mode: don't permanently set any efuses"
|
||||||
|
depends on SECURE_BOOT_INSECURE
|
||||||
|
default N
|
||||||
|
help
|
||||||
|
If this option is set, all permanent secure boot changes (via Efuse) are disabled.
|
||||||
|
|
||||||
|
Log output will state changes which would be applied, but they will not be.
|
||||||
|
|
||||||
|
This option is for testing purposes only - it completely disables secure boot protection.
|
||||||
|
|
||||||
|
|
||||||
|
endmenu # Potentially Insecure
|
||||||
|
endmenu # Security features
|
126
components/bootloader/Makefile.projbuild
Normal file
126
components/bootloader/Makefile.projbuild
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# Bootloader component (top-level project parts)
|
||||||
|
#
|
||||||
|
# The bootloader is not a real component that gets linked into the project.
|
||||||
|
# Instead it is an entire standalone project (in subproject/) that gets
|
||||||
|
# built in the upper project's build directory. This Makefile.projbuild provides
|
||||||
|
# the glue to build the bootloader project from the original project. It
|
||||||
|
# basically runs Make in the subproject/ directory but it needs to
|
||||||
|
# zero some variables the ESP-IDF project.mk makefile exports first, to not
|
||||||
|
# let them interfere.
|
||||||
|
#
|
||||||
|
BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
|
||||||
|
BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
|
||||||
|
BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
|
||||||
|
|
||||||
|
# signing key path is resolved relative to the project directory
|
||||||
|
CONFIG_SECURE_BOOT_SIGNING_KEY ?=
|
||||||
|
SECURE_BOOT_SIGNING_KEY=$(abspath $(call dequote,$(CONFIG_SECURE_BOOT_SIGNING_KEY)))
|
||||||
|
export SECURE_BOOT_SIGNING_KEY # used by bootloader_support component
|
||||||
|
|
||||||
|
# Has a matching value in bootloader_support esp_flash_partitions.h
|
||||||
|
BOOTLOADER_OFFSET := 0x0000
|
||||||
|
|
||||||
|
# Custom recursive make for bootloader sub-project
|
||||||
|
#
|
||||||
|
# NB: Some variables are cleared in the environment, not
|
||||||
|
# overriden, because they need to be re-defined in the child
|
||||||
|
# project.
|
||||||
|
BOOTLOADER_MAKE= +\
|
||||||
|
PROJECT_PATH= \
|
||||||
|
COMPONENT_DIRS= \
|
||||||
|
$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/subproject \
|
||||||
|
V=$(V) \
|
||||||
|
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
||||||
|
TEST_COMPONENTS= \
|
||||||
|
TESTS_ALL=
|
||||||
|
|
||||||
|
.PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
|
||||||
|
|
||||||
|
$(BOOTLOADER_BIN): $(SDKCONFIG_MAKEFILE)
|
||||||
|
$(BOOTLOADER_MAKE) $@
|
||||||
|
|
||||||
|
clean: bootloader-clean
|
||||||
|
|
||||||
|
bootloader-list-components:
|
||||||
|
$(BOOTLOADER_MAKE) list-components
|
||||||
|
|
||||||
|
ifndef CONFIG_SECURE_BOOT_ENABLED
|
||||||
|
# If secure boot disabled, bootloader flashing is integrated
|
||||||
|
# with 'make flash' and no warnings are printed.
|
||||||
|
|
||||||
|
bootloader: $(BOOTLOADER_BIN)
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "Bootloader built. Default flash command is:"
|
||||||
|
@echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $^"
|
||||||
|
|
||||||
|
ESPTOOL_ALL_FLASH_ARGS += $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)
|
||||||
|
|
||||||
|
bootloader-flash: $(BOOTLOADER_BIN) $(call prereq_if_explicit,erase_flash)
|
||||||
|
$(ESPTOOLPY_WRITE_FLASH) 0x0000 $^
|
||||||
|
|
||||||
|
else ifdef CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
|
||||||
|
|
||||||
|
# One time flashing requires user to run esptool.py command themselves,
|
||||||
|
# and warning is printed about inability to reflash.
|
||||||
|
#
|
||||||
|
# The flashing command is deliberately printed without an auto-reset
|
||||||
|
# step, so the device doesn't immediately reset to flash itself.
|
||||||
|
|
||||||
|
bootloader: $(BOOTLOADER_BIN)
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "Bootloader built. One-time flash command is:"
|
||||||
|
@echo "$(subst hard_reset,no_reset,$(ESPTOOLPY_WRITE_FLASH)) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "* IMPORTANT: After first boot, BOOTLOADER CANNOT BE RE-FLASHED on same device"
|
||||||
|
|
||||||
|
else ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
|
||||||
|
# Reflashable secure bootloader
|
||||||
|
# generates a digest binary (bootloader + digest)
|
||||||
|
|
||||||
|
BOOTLOADER_DIGEST_BIN := $(BOOTLOADER_BUILD_DIR)/bootloader-reflash-digest.bin
|
||||||
|
SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key.bin
|
||||||
|
|
||||||
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||||
|
$(SECURE_BOOTLOADER_KEY): $(SECURE_BOOT_SIGNING_KEY)
|
||||||
|
$(ESPSECUREPY) digest_private_key -k $< $@
|
||||||
|
else
|
||||||
|
$(SECURE_BOOTLOADER_KEY):
|
||||||
|
@echo "No pre-generated key for a reflashable secure bootloader is available, due to signing configuration."
|
||||||
|
@echo "To generate one, you can use this command:"
|
||||||
|
@echo "espsecure.py generate_flash_encryption_key $@"
|
||||||
|
@echo "then re-run make."
|
||||||
|
exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
bootloader: $(BOOTLOADER_DIGEST_BIN)
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "Bootloader built and secure digest generated. First time flash command is:"
|
||||||
|
@echo "$(ESPEFUSEPY) burn_key secure_boot $(SECURE_BOOTLOADER_KEY)"
|
||||||
|
@echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "To reflash the bootloader after initial flash:"
|
||||||
|
@echo "$(ESPTOOLPY_WRITE_FLASH) 0x0 $(BOOTLOADER_DIGEST_BIN)"
|
||||||
|
@echo $(SEPARATOR)
|
||||||
|
@echo "* After first boot, only re-flashes of this kind (with same key) will be accepted."
|
||||||
|
@echo "* Not recommended to re-use the same secure boot keyfile on multiple production devices."
|
||||||
|
|
||||||
|
$(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY)
|
||||||
|
@echo "DIGEST $(notdir $@)"
|
||||||
|
$(Q) $(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
|
||||||
|
|
||||||
|
else # CONFIG_SECURE_BOOT_ENABLED && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE && !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
|
||||||
|
bootloader:
|
||||||
|
@echo "Invalid bootloader target: bad sdkconfig?"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef CONFIG_SECURE_BOOT_ENABLED
|
||||||
|
# don't build bootloader by default is secure boot is enabled
|
||||||
|
all_binaries: $(BOOTLOADER_BIN)
|
||||||
|
endif
|
||||||
|
|
||||||
|
bootloader-clean: $(SDKCONFIG_MAKEFILE)
|
||||||
|
$(BOOTLOADER_MAKE) app-clean
|
||||||
|
ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
|
||||||
|
rm -f $(SECURE_BOOTLOADER_KEY) $(BOOTLOADER_DIGEST_BIN)
|
||||||
|
endif
|
7
components/bootloader/component.mk
Normal file
7
components/bootloader/component.mk
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# bootloader component is special, as bootloader is also a project.
|
||||||
|
#
|
||||||
|
# This top-level component is only configuration files for the IDF project.
|
||||||
|
#
|
||||||
|
# See Makefile.projbuild for the targets which actually build the bootloader.
|
||||||
|
COMPONENT_CONFIG_ONLY := 1
|
||||||
|
|
2
components/bootloader/subproject/.gitignore
vendored
Normal file
2
components/bootloader/subproject/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build
|
||||||
|
sdkconfig
|
32
components/bootloader/subproject/Makefile
Normal file
32
components/bootloader/subproject/Makefile
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
|
||||||
|
# project subdirectory.
|
||||||
|
#
|
||||||
|
ifeq ("$(MAKELEVEL)","0")
|
||||||
|
$(error Bootloader makefile expects to be run as part of 'make bootloader' from a top-level project.)
|
||||||
|
endif
|
||||||
|
|
||||||
|
PROJECT_NAME := bootloader
|
||||||
|
|
||||||
|
COMPONENTS := esptool_py main
|
||||||
|
|
||||||
|
# Clear C and CXX from top level project
|
||||||
|
CFLAGS =
|
||||||
|
CXXFLAGS =
|
||||||
|
|
||||||
|
#We cannot include the esp8266 component directly but we need its includes.
|
||||||
|
CFLAGS += -I $(IDF_PATH)/components/esp8266/include
|
||||||
|
|
||||||
|
# The bootloader pseudo-component is also included in this build, for its Kconfig.projbuild to be included.
|
||||||
|
#
|
||||||
|
# IS_BOOTLOADER_BUILD tells the component Makefile.projbuild to be a no-op
|
||||||
|
IS_BOOTLOADER_BUILD := 1
|
||||||
|
export IS_BOOTLOADER_BUILD
|
||||||
|
|
||||||
|
# BOOTLOADER_BUILD macro is the same, for source file changes
|
||||||
|
CFLAGS += -D BOOTLOADER_BUILD=1
|
||||||
|
|
||||||
|
# include the top-level "project" include directory, for sdkconfig.h
|
||||||
|
CFLAGS += -I$(BUILD_DIR_BASE)/../include
|
||||||
|
|
||||||
|
include $(IDF_PATH)/make/project.mk
|
312
components/bootloader/subproject/main/bootloader_start.c
Normal file
312
components/bootloader/subproject/main/bootloader_start.c
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
// Copyright 2015-2016 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.
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "load_flash_bin.h"
|
||||||
|
|
||||||
|
#include "esp8266/eagle_soc.h"
|
||||||
|
|
||||||
|
//#define BOOT_DEBUG
|
||||||
|
|
||||||
|
#ifdef BOOT_DEBUG
|
||||||
|
#define BDEBUG ets_printf
|
||||||
|
#else
|
||||||
|
#define BDEBUG(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOOT_VERSION 0x06
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SPI_FLASH_QIO_MODE = 0,
|
||||||
|
SPI_FLASH_QOUT_MODE,
|
||||||
|
SPI_FLASH_DIO_MODE,
|
||||||
|
SPI_FLASH_DOUT_MODE,
|
||||||
|
SPI_FLASH_FASTRD_MODE,
|
||||||
|
SPI_FLASH_SLOWRD_MODE
|
||||||
|
} SpiFlashRdMode;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPI_MODE_QIO,
|
||||||
|
SPI_MODE_QOUT,
|
||||||
|
SPI_MODE_DIO,
|
||||||
|
SPI_MODE_DOUT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPI_SPEED_40M,
|
||||||
|
SPI_SPEED_26M,
|
||||||
|
SPI_SPEED_20M,
|
||||||
|
SPI_SPEED_80M = 0xF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPI_SIZE_4M_256_256 = 0,
|
||||||
|
SPI_SIZE_2M,
|
||||||
|
SPI_SIZE_8M_512_512,
|
||||||
|
SPI_SIZE_16M_512_512,
|
||||||
|
SPI_SIZE_32M_512_512,
|
||||||
|
SPI_SIZE_16M_1024_1024,
|
||||||
|
SPI_SIZE_32M_1024_1024
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
USER_BIN1,
|
||||||
|
USER_BIN2
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SPI_SEC_SIZE 0x1000
|
||||||
|
|
||||||
|
struct save_hdr {
|
||||||
|
char flag;
|
||||||
|
char pad[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct boot_hdr {
|
||||||
|
char use_bin: 2; // low bit
|
||||||
|
char boot_status: 1;
|
||||||
|
char reverse: 5;
|
||||||
|
char version: 5; // low bit
|
||||||
|
char test_pass_flag: 1;
|
||||||
|
char test_start_flag: 1;
|
||||||
|
char enhance_boot_flag: 1;
|
||||||
|
char test_bin_addr[3];
|
||||||
|
char user_bin_addr[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct boot_hdr_1 {
|
||||||
|
char use_bin: 4;
|
||||||
|
char flag: 4;
|
||||||
|
char pad[7];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct boot_hdr_2 {
|
||||||
|
char use_bin: 4;
|
||||||
|
char flag: 4;
|
||||||
|
char version;
|
||||||
|
char pad[6];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct flash_hdr {
|
||||||
|
char magic;
|
||||||
|
char blocks;
|
||||||
|
char spi_mode; //flag of flash read mode in unpackage and usage in future
|
||||||
|
char spi_speed: 4; // low bit
|
||||||
|
char spi_size_map: 4;
|
||||||
|
unsigned int entry_addr;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
struct block_hdr {
|
||||||
|
unsigned int load_addr;
|
||||||
|
unsigned int data_len;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#define WIFI_PARAM_RF 0
|
||||||
|
#define WIFI_PARAM_SAVE_0 1
|
||||||
|
#define WIFI_PARAM_SAVE_1 2
|
||||||
|
#define WIFI_PARAM_FLAG 3
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SPI_FLASH_RESULT_OK = 0,
|
||||||
|
SPI_FLASH_RESULT_ERR = 1,
|
||||||
|
SPI_FLASH_RESULT_TIMEOUT = 2
|
||||||
|
} SpiFlashOpResult;
|
||||||
|
|
||||||
|
extern SpiFlashOpResult SPIRead(uint32_t addr, void *dst, uint32_t size);
|
||||||
|
extern int ets_printf(const char* fmt, ...);
|
||||||
|
extern void *ets_memcpy(void *restrict to, const void *restrict from, size_t size);
|
||||||
|
|
||||||
|
signed int get_flash_bin_addr(unsigned int bin_addr)
|
||||||
|
{
|
||||||
|
char buf[16];
|
||||||
|
struct flash_hdr* fhdr;
|
||||||
|
struct block_hdr* bhdr;
|
||||||
|
|
||||||
|
SPIRead(bin_addr, (unsigned int*)buf, 16);
|
||||||
|
|
||||||
|
fhdr = (struct flash_hdr*)buf;
|
||||||
|
|
||||||
|
if (fhdr->magic == 0xE9) {
|
||||||
|
return 0;
|
||||||
|
} else if (fhdr->magic == 0xEA && fhdr->blocks == 0x04) {
|
||||||
|
bhdr = (struct block_hdr*)(buf + sizeof(struct flash_hdr));
|
||||||
|
return bhdr->data_len;
|
||||||
|
} else {
|
||||||
|
ets_printf("error magic!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0---OK, 1---FAIL
|
||||||
|
char jump_to_run_addr(unsigned int bin_addr)
|
||||||
|
{
|
||||||
|
unsigned int flash_addr;
|
||||||
|
char ret = 1;
|
||||||
|
char(*jump_to_load_flash_code)(unsigned int addr);
|
||||||
|
|
||||||
|
ets_printf(" @ %x\n\n", bin_addr);
|
||||||
|
|
||||||
|
jump_to_load_flash_code = (void*)(0x4010FC08);
|
||||||
|
flash_addr = get_flash_bin_addr(bin_addr);
|
||||||
|
|
||||||
|
if (flash_addr != -1) {
|
||||||
|
if (flash_addr == 0) {
|
||||||
|
ret = jump_to_load_flash_code(bin_addr);
|
||||||
|
} else {
|
||||||
|
ret = jump_to_load_flash_code(bin_addr + 16 + flash_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int gen_bin_addr(unsigned char* buf)
|
||||||
|
{
|
||||||
|
unsigned int ret;
|
||||||
|
|
||||||
|
ret = buf[2] << 16 | buf[1] << 8 | buf[0];
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void call_start_cpu(void)
|
||||||
|
{
|
||||||
|
struct save_hdr shdr;
|
||||||
|
struct boot_hdr bhdr;
|
||||||
|
struct flash_hdr fhdr;
|
||||||
|
|
||||||
|
unsigned int sys_start;
|
||||||
|
|
||||||
|
ets_printf("\n2nd boot version : 2.0\n");
|
||||||
|
|
||||||
|
SPIRead(0, (unsigned int*)&fhdr, sizeof(struct flash_hdr));
|
||||||
|
|
||||||
|
BDEBUG("[D]: magic %02x\n", fhdr.magic);
|
||||||
|
BDEBUG("[D]: blocks %02x\n", fhdr.blocks);
|
||||||
|
BDEBUG("[D]: spi_mode %02x\n", fhdr.spi_mode);
|
||||||
|
BDEBUG("[D]: spi_speed %02x\n", fhdr.spi_speed);
|
||||||
|
BDEBUG("[D]: spi_size_map %02x\n", fhdr.spi_size_map);
|
||||||
|
|
||||||
|
ets_printf(" SPI Speed : ");
|
||||||
|
|
||||||
|
switch (fhdr.spi_speed) {
|
||||||
|
case SPI_SPEED_40M:
|
||||||
|
ets_printf("40MHz\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SPEED_26M:
|
||||||
|
ets_printf("26.7MHz\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SPEED_20M:
|
||||||
|
ets_printf("20MHz\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SPEED_80M:
|
||||||
|
ets_printf("80MHz\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ets_printf(" SPI Mode : ");
|
||||||
|
|
||||||
|
switch (fhdr.spi_mode) {
|
||||||
|
case SPI_MODE_QIO:
|
||||||
|
ets_printf("QIO\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_MODE_QOUT:
|
||||||
|
ets_printf("QOUT\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_MODE_DIO:
|
||||||
|
ets_printf("DIO\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_MODE_DOUT:
|
||||||
|
ets_printf("DOUT\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fhdr.spi_mode = SPI_MODE_QIO;
|
||||||
|
ets_printf("QIO\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ets_printf(" SPI Flash Size & Map: ");
|
||||||
|
|
||||||
|
switch (fhdr.spi_size_map) {
|
||||||
|
case SPI_SIZE_4M_256_256:
|
||||||
|
sys_start = 124;
|
||||||
|
ets_printf("4Mbit(256KB+256KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_2M:
|
||||||
|
sys_start = 60;
|
||||||
|
ets_printf("2Mbit\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_8M_512_512:
|
||||||
|
sys_start = 252;
|
||||||
|
ets_printf("8Mbit(512KB+512KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_16M_512_512:
|
||||||
|
sys_start = 508;
|
||||||
|
ets_printf("16Mbit(512KB+512KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_32M_512_512:
|
||||||
|
sys_start = 1020;
|
||||||
|
ets_printf("32Mbit(512KB+512KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_16M_1024_1024:
|
||||||
|
sys_start = 508;
|
||||||
|
ets_printf("16Mbit(1024KB+1024KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPI_SIZE_32M_1024_1024:
|
||||||
|
sys_start = 1020;
|
||||||
|
ets_printf("32Mbit(1024KB+1024KB)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sys_start = 124;
|
||||||
|
ets_printf("4Mbit\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPIRead((sys_start + WIFI_PARAM_FLAG) * SPI_SEC_SIZE,
|
||||||
|
(unsigned int*)&shdr, sizeof(struct save_hdr));
|
||||||
|
|
||||||
|
SPIRead((sys_start + ((shdr.flag == 0) ? WIFI_PARAM_SAVE_0 : WIFI_PARAM_SAVE_1)) * SPI_SEC_SIZE,
|
||||||
|
(unsigned int*)&bhdr, sizeof(struct boot_hdr));
|
||||||
|
|
||||||
|
BDEBUG("[D]: use_bin %02x\n", bhdr.use_bin);
|
||||||
|
BDEBUG("[D]: boot_status %02x\n", bhdr.boot_status);
|
||||||
|
BDEBUG("[D]: reverse %02x\n", bhdr.reverse);
|
||||||
|
BDEBUG("[D]: version %02x\n", bhdr.version);
|
||||||
|
BDEBUG("[D]: test_pass_flag %02x\n", bhdr.test_pass_flag);
|
||||||
|
BDEBUG("[D]: test_start_flag %02x\n", bhdr.test_start_flag);
|
||||||
|
BDEBUG("[D]: enhance_boot_flag %02x\n", bhdr.enhance_boot_flag);
|
||||||
|
BDEBUG("[D]: test_bin_addr %02x %02x %02x\n", bhdr.test_bin_addr[0], bhdr.test_bin_addr[1], bhdr.test_bin_addr[2]);
|
||||||
|
BDEBUG("[D]: user_bin_addr %02x %02x %02x\n", bhdr.user_bin_addr[0], bhdr.user_bin_addr[1], bhdr.user_bin_addr[2]);
|
||||||
|
|
||||||
|
ets_memcpy((void *)0x4010FC00, load_bin, load_bin_len);
|
||||||
|
|
||||||
|
ets_printf("jump to run");
|
||||||
|
|
||||||
|
jump_to_run_addr(0x1000);
|
||||||
|
}
|
15
components/bootloader/subproject/main/component.mk
Normal file
15
components/bootloader/subproject/main/component.mk
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#
|
||||||
|
# Main bootloader Makefile.
|
||||||
|
#
|
||||||
|
# This is basically the same as a component makefile, but in the case of the bootloader
|
||||||
|
# we pull in bootloader-specific linker arguments.
|
||||||
|
#
|
||||||
|
|
||||||
|
LINKER_SCRIPTS := \
|
||||||
|
esp8266.bootloader.ld \
|
||||||
|
$(IDF_PATH)/components/esp8266/ld/esp8266.rom.ld \
|
||||||
|
esp8266.bootloader.rom.ld
|
||||||
|
|
||||||
|
COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH) $(addprefix -T ,$(LINKER_SCRIPTS))
|
||||||
|
|
||||||
|
COMPONENT_ADD_LINKER_DEPS := $(LINKER_SCRIPTS)
|
130
components/bootloader/subproject/main/esp8266.bootloader.ld
Normal file
130
components/bootloader/subproject/main/esp8266.bootloader.ld
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
Linker file used to link the bootloader.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Simplified memory map for the bootloader
|
||||||
|
|
||||||
|
The main purpose is to make sure the bootloader can load into main memory
|
||||||
|
without overwriting itself.
|
||||||
|
*/
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
dport0_seg : org = 0x3FF00000, len = 0x10
|
||||||
|
|
||||||
|
/* All .data/.bss/heap are in this segment. */
|
||||||
|
dram_seg : org = 0x3FFE8000, len = 0x18000
|
||||||
|
|
||||||
|
/* Functions which are critical should be put in this segment. */
|
||||||
|
iram_seg : org = 0x40108000, len = 0x8000
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Default entry point: */
|
||||||
|
ENTRY(call_start_cpu);
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.iram1.text :
|
||||||
|
{
|
||||||
|
. = ALIGN (16);
|
||||||
|
*(.entry.text)
|
||||||
|
*(.init.literal)
|
||||||
|
*(.init)
|
||||||
|
} > iram_seg
|
||||||
|
|
||||||
|
.iram.text :
|
||||||
|
{
|
||||||
|
_stext = .;
|
||||||
|
_text_start = ABSOLUTE(.);
|
||||||
|
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||||
|
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||||
|
*(.fini.literal)
|
||||||
|
*(.fini)
|
||||||
|
*(.gnu.version)
|
||||||
|
_text_end = ABSOLUTE(.);
|
||||||
|
_etext = .;
|
||||||
|
} > iram_seg
|
||||||
|
|
||||||
|
/* Shared RAM */
|
||||||
|
.dram0.bss (NOLOAD) :
|
||||||
|
{
|
||||||
|
. = ALIGN (8);
|
||||||
|
_bss_start = ABSOLUTE(.);
|
||||||
|
*(.dynsbss)
|
||||||
|
*(.sbss)
|
||||||
|
*(.sbss.*)
|
||||||
|
*(.gnu.linkonce.sb.*)
|
||||||
|
*(.scommon)
|
||||||
|
*(.sbss2)
|
||||||
|
*(.sbss2.*)
|
||||||
|
*(.gnu.linkonce.sb2.*)
|
||||||
|
*(.dynbss)
|
||||||
|
*(.bss)
|
||||||
|
*(.bss.*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN (8);
|
||||||
|
_bss_end = ABSOLUTE(.);
|
||||||
|
} >dram_seg
|
||||||
|
|
||||||
|
.dram0.data :
|
||||||
|
{
|
||||||
|
_data_start = ABSOLUTE(.);
|
||||||
|
*(.data)
|
||||||
|
*(.data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
*(.data1)
|
||||||
|
*(.sdata)
|
||||||
|
*(.sdata.*)
|
||||||
|
*(.gnu.linkonce.s.*)
|
||||||
|
*(.sdata2)
|
||||||
|
*(.sdata2.*)
|
||||||
|
*(.gnu.linkonce.s2.*)
|
||||||
|
*(.jcr)
|
||||||
|
_data_end = ABSOLUTE(.);
|
||||||
|
} >dram_seg
|
||||||
|
|
||||||
|
.dram0.rodata :
|
||||||
|
{
|
||||||
|
_rodata_start = ABSOLUTE(.);
|
||||||
|
*(.rodata)
|
||||||
|
*(.rodata.*)
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
*(.rodata1)
|
||||||
|
__XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
|
||||||
|
*(.xt_except_table)
|
||||||
|
*(.gcc_except_table)
|
||||||
|
*(.gnu.linkonce.e.*)
|
||||||
|
*(.gnu.version_r)
|
||||||
|
*(.eh_frame)
|
||||||
|
. = (. + 3) & ~ 3;
|
||||||
|
/* C++ constructor and destructor tables, properly ordered: */
|
||||||
|
__init_array_start = ABSOLUTE(.);
|
||||||
|
KEEP (*crtbegin.o(.ctors))
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||||
|
KEEP (*(SORT(.ctors.*)))
|
||||||
|
KEEP (*(.ctors))
|
||||||
|
__init_array_end = ABSOLUTE(.);
|
||||||
|
KEEP (*crtbegin.o(.dtors))
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||||
|
KEEP (*(SORT(.dtors.*)))
|
||||||
|
KEEP (*(.dtors))
|
||||||
|
/* C++ exception handlers table: */
|
||||||
|
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
|
||||||
|
*(.xt_except_desc)
|
||||||
|
*(.gnu.linkonce.h.*)
|
||||||
|
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
||||||
|
*(.xt_except_desc_end)
|
||||||
|
*(.dynamic)
|
||||||
|
*(.gnu.version_d)
|
||||||
|
_rodata_end = ABSOLUTE(.);
|
||||||
|
/* Literals are also RO data. */
|
||||||
|
_lit4_start = ABSOLUTE(.);
|
||||||
|
*(*.lit4)
|
||||||
|
*(.lit4.*)
|
||||||
|
*(.gnu.linkonce.lit4.*)
|
||||||
|
_lit4_end = ABSOLUTE(.);
|
||||||
|
. = ALIGN(4);
|
||||||
|
_heap_start = ABSOLUTE(.);
|
||||||
|
} >dram_seg
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
PROVIDE ( ets_memcpy = 0x400018b4 );
|
||||||
|
PROVIDE ( ets_printf = 0x400024cc );
|
||||||
|
|
||||||
|
PROVIDE ( SPIRead = 0x40004b1c );
|
68
components/bootloader/subproject/main/load_flash_bin.h
Normal file
68
components/bootloader/subproject/main/load_flash_bin.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
unsigned char load_bin[] = {
|
||||||
|
0x1c, 0x4b, 0x00, 0x40, 0xb4, 0x18, 0x00, 0x40, 0x1c, 0x04, 0x12, 0xc1,
|
||||||
|
0xa0, 0xd9, 0xd1, 0xe9, 0xe1, 0xf9, 0xf1, 0x3d, 0x01, 0xc9, 0xc1, 0x09,
|
||||||
|
0xb1, 0x01, 0xf9, 0xff, 0xcd, 0x02, 0xc0, 0x00, 0x00, 0x56, 0x72, 0x1c,
|
||||||
|
0x32, 0xa0, 0xe9, 0x22, 0x01, 0x00, 0xf8, 0x11, 0x30, 0x22, 0xc0, 0x32,
|
||||||
|
0x01, 0x01, 0x39, 0xa1, 0x56, 0x42, 0x1b, 0x3d, 0x01, 0x1c, 0x04, 0x02,
|
||||||
|
0x01, 0x08, 0x22, 0x01, 0x0a, 0xe2, 0x01, 0x0b, 0xd2, 0x01, 0x0f, 0x80,
|
||||||
|
0xee, 0x11, 0x80, 0xdd, 0x11, 0x20, 0xee, 0x20, 0x22, 0x01, 0x09, 0x80,
|
||||||
|
0xee, 0x11, 0x20, 0xee, 0x20, 0x22, 0x01, 0x0e, 0x80, 0xee, 0x11, 0x00,
|
||||||
|
0xee, 0x20, 0x20, 0xdd, 0x20, 0x02, 0x01, 0x0c, 0x22, 0x01, 0x0d, 0x80,
|
||||||
|
0xdd, 0x11, 0x20, 0xdd, 0x20, 0x80, 0xdd, 0x11, 0x00, 0xdd, 0x20, 0x01,
|
||||||
|
0xe2, 0xff, 0x22, 0xcc, 0x10, 0xc0, 0x00, 0x00, 0x56, 0x82, 0x16, 0xf9,
|
||||||
|
0x91, 0xe2, 0x61, 0x13, 0x22, 0xcc, 0x20, 0x08, 0xa1, 0x22, 0x61, 0x12,
|
||||||
|
0x16, 0x50, 0x21, 0xfd, 0x01, 0xc2, 0xa0, 0xef, 0x1c, 0x0a, 0xd2, 0x61,
|
||||||
|
0x14, 0x2d, 0x0e, 0x0c, 0x07, 0x72, 0x61, 0x11, 0xed, 0x01, 0x0d, 0x02,
|
||||||
|
0x0c, 0x17, 0x62, 0x21, 0x11, 0x82, 0x21, 0x14, 0x60, 0x6a, 0xc0, 0x60,
|
||||||
|
0x60, 0x74, 0x67, 0xb8, 0x01, 0x0c, 0x07, 0x16, 0x47, 0x1f, 0x0c, 0x39,
|
||||||
|
0x67, 0x09, 0x1c, 0xa6, 0x16, 0x4f, 0x0c, 0x0d, 0x1b, 0xdd, 0x22, 0x0f,
|
||||||
|
0x00, 0x22, 0x40, 0x00, 0x1b, 0xff, 0x1b, 0x00, 0xc0, 0xc2, 0x30, 0xc0,
|
||||||
|
0xc0, 0x74, 0x67, 0x9d, 0xea, 0x46, 0x0d, 0x00, 0xbc, 0x26, 0x2d, 0x00,
|
||||||
|
0x60, 0x92, 0x41, 0xa6, 0x19, 0x29, 0x0c, 0x0d, 0x1b, 0xdd, 0x42, 0x0f,
|
||||||
|
0x01, 0x02, 0x0f, 0x03, 0x32, 0x0f, 0x00, 0xc0, 0x00, 0x30, 0xc2, 0x0f,
|
||||||
|
0x02, 0x40, 0x33, 0x30, 0x30, 0xcc, 0x30, 0x00, 0xcc, 0x30, 0xc0, 0xc0,
|
||||||
|
0x74, 0x08, 0x0f, 0x09, 0x02, 0x4b, 0xff, 0x4b, 0x22, 0x97, 0x9d, 0xd7,
|
||||||
|
0x0d, 0x02, 0x16, 0x97, 0x19, 0x60, 0x28, 0xc0, 0x20, 0x24, 0x41, 0x22,
|
||||||
|
0x61, 0x10, 0x79, 0x71, 0x32, 0x21, 0x10, 0x42, 0x21, 0x11, 0x0c, 0x05,
|
||||||
|
0x4a, 0x68, 0x40, 0x40, 0x74, 0x62, 0xc6, 0xf0, 0x60, 0x60, 0x34, 0x70,
|
||||||
|
0x45, 0x93, 0x42, 0x61, 0x11, 0x70, 0x68, 0x83, 0x69, 0x81, 0xa6, 0x13,
|
||||||
|
0x4c, 0x0c, 0x0d, 0x09, 0x61, 0x22, 0x21, 0x12, 0x3d, 0x01, 0x01, 0xac,
|
||||||
|
0xff, 0x1c, 0x04, 0xc0, 0x00, 0x00, 0x56, 0x22, 0x09, 0x22, 0x21, 0x12,
|
||||||
|
0x0c, 0x00, 0x22, 0xc2, 0x10, 0x22, 0x61, 0x12, 0x1b, 0x30, 0xea, 0x20,
|
||||||
|
0x22, 0x02, 0x00, 0x30, 0x00, 0x74, 0xc0, 0xc2, 0x30, 0xc0, 0xc0, 0x74,
|
||||||
|
0x66, 0xb0, 0xec, 0x28, 0x61, 0x3d, 0x01, 0x01, 0xa2, 0xff, 0x1c, 0x04,
|
||||||
|
0xc0, 0x00, 0x00, 0x1b, 0xdd, 0x08, 0x61, 0x22, 0x21, 0x10, 0x02, 0xc0,
|
||||||
|
0x10, 0x09, 0x61, 0xd7, 0x92, 0xb6, 0x38, 0x71, 0x09, 0x61, 0x9c, 0xb3,
|
||||||
|
0x22, 0x21, 0x12, 0x3d, 0x01, 0x01, 0x98, 0xff, 0x1c, 0x04, 0xc0, 0x00,
|
||||||
|
0x00, 0x08, 0x61, 0x56, 0x12, 0x04, 0x22, 0x21, 0x12, 0xfd, 0x01, 0x22,
|
||||||
|
0xc2, 0x10, 0x22, 0x61, 0x12, 0x68, 0x81, 0x0c, 0x33, 0x60, 0x60, 0x74,
|
||||||
|
0x67, 0x83, 0x02, 0x06, 0x3e, 0x00, 0xa6, 0x16, 0x16, 0x0c, 0x0d, 0x1b,
|
||||||
|
0xdd, 0x22, 0x0f, 0x00, 0x22, 0x40, 0x00, 0x1b, 0xff, 0x1b, 0x00, 0xc0,
|
||||||
|
0xc2, 0x30, 0xc0, 0xc0, 0x74, 0x67, 0x9d, 0xea, 0x38, 0xa1, 0x1c, 0x0a,
|
||||||
|
0x66, 0x13, 0x19, 0x42, 0x01, 0x0f, 0xc0, 0x44, 0xc0, 0x16, 0xc4, 0x0b,
|
||||||
|
0x0c, 0x12, 0xc8, 0xc1, 0xd8, 0xd1, 0xe8, 0xe1, 0xf8, 0xf1, 0x08, 0xb1,
|
||||||
|
0x12, 0xc1, 0x60, 0x0d, 0xf0, 0x02, 0x21, 0x11, 0x0a, 0x06, 0x00, 0xda,
|
||||||
|
0xc0, 0xd0, 0xd0, 0x74, 0xb6, 0x8d, 0x46, 0x92, 0x0f, 0x06, 0x32, 0x0f,
|
||||||
|
0x02, 0x82, 0x0f, 0x07, 0x22, 0x0f, 0x03, 0x80, 0x88, 0x11, 0x80, 0x22,
|
||||||
|
0x11, 0x30, 0x22, 0x20, 0x90, 0x88, 0x20, 0x32, 0x0f, 0x01, 0x80, 0x22,
|
||||||
|
0x11, 0x92, 0x0f, 0x05, 0x80, 0x88, 0x11, 0x90, 0x88, 0x20, 0x30, 0x22,
|
||||||
|
0x20, 0x92, 0x0f, 0x04, 0x80, 0x88, 0x11, 0x32, 0x0f, 0x00, 0x80, 0x22,
|
||||||
|
0x11, 0x30, 0x22, 0x20, 0x90, 0x88, 0x20, 0x8b, 0x30, 0x30, 0x30, 0x74,
|
||||||
|
0x32, 0x61, 0x11, 0x06, 0x10, 0x00, 0x22, 0xc1, 0x10, 0xea, 0x30, 0x01,
|
||||||
|
0x6b, 0xff, 0x4d, 0x0d, 0xc0, 0x00, 0x00, 0x22, 0x21, 0x12, 0x3d, 0x01,
|
||||||
|
0x01, 0x67, 0xff, 0x1c, 0x04, 0xc0, 0x00, 0x00, 0xfc, 0x92, 0x01, 0x65,
|
||||||
|
0xff, 0x32, 0x21, 0x12, 0x0c, 0x84, 0x22, 0xc1, 0x10, 0x2a, 0x2d, 0xd0,
|
||||||
|
0x44, 0xc0, 0x40, 0x40, 0x74, 0x32, 0xc3, 0x10, 0x32, 0x61, 0x12, 0x42,
|
||||||
|
0x61, 0x11, 0x3d, 0x01, 0xc0, 0x00, 0x00, 0x28, 0x41, 0x88, 0x51, 0x1c,
|
||||||
|
0x0a, 0x82, 0x61, 0x14, 0xf2, 0x21, 0x11, 0x48, 0xa1, 0xea, 0xff, 0x0b,
|
||||||
|
0x04, 0x00, 0x40, 0x74, 0x49, 0xa1, 0x56, 0xc4, 0xdf, 0x08, 0x91, 0xc0,
|
||||||
|
0x00, 0x00, 0x0c, 0x02, 0x86, 0xce, 0xff, 0x0c, 0x02, 0x22, 0x61, 0x10,
|
||||||
|
0x86, 0x99, 0xff, 0x16, 0xd6, 0xf1, 0x2d, 0x00, 0x60, 0x72, 0x41, 0xe6,
|
||||||
|
0x17, 0x02, 0x86, 0xc4, 0xff, 0x0c, 0x0d, 0x1b, 0xdd, 0x42, 0x0f, 0x01,
|
||||||
|
0x02, 0x0f, 0x03, 0x32, 0x0f, 0x00, 0xc0, 0x00, 0x30, 0xc2, 0x0f, 0x02,
|
||||||
|
0x40, 0x33, 0x30, 0x30, 0xcc, 0x30, 0x00, 0xcc, 0x30, 0xc0, 0xc0, 0x74,
|
||||||
|
0x08, 0x0f, 0x09, 0x02, 0x4b, 0xff, 0x4b, 0x22, 0x77, 0x9d, 0xd7, 0x46,
|
||||||
|
0xb9, 0xff, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int load_bin_len = 760;
|
7
components/esp8266/Kconfig
Normal file
7
components/esp8266/Kconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
menu "ESP8266-specific"
|
||||||
|
|
||||||
|
config APP_OFFSET
|
||||||
|
hex
|
||||||
|
default 0x1000
|
||||||
|
|
||||||
|
endmenu
|
@ -1,176 +1,26 @@
|
|||||||
|
|
||||||
BOOTLOADER_FIRMWARE_DIR := $(abspath $(COMPONENT_PATH))/firmware
|
BOOTLOADER_FIRMWARE_DIR := $(abspath $(COMPONENT_PATH))/firmware
|
||||||
|
|
||||||
#configurate downloading parameters
|
|
||||||
ESPTOOLPY_FLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
ESPTOOLPY_FLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
||||||
ESPTOOLPY_FLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
|
||||||
ESPTOOLPY_FLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "512KB")
|
|
||||||
BLANK_BIN_OFFSET1 := 0x7B000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x7E000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x7C000
|
|
||||||
ESP8266_SIZEMAP := 0
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "1MB")
|
|
||||||
BLANK_BIN_OFFSET1 := 0xFB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0xFE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0xFC000
|
|
||||||
ESP8266_SIZEMAP := 2
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "2MB")
|
|
||||||
BLANK_BIN_OFFSET1 := 0x1FB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x1FE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x1FC000
|
|
||||||
ESP8266_SIZEMAP := 3
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "2MB-c1")
|
ifeq ($(ESPTOOLPY_FLASHSIZE), "2MB-c1")
|
||||||
BLANK_BIN_OFFSET1 := 0x1FB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x1FE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x1FC000
|
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x1FC000
|
||||||
ESP8266_SIZEMAP := 5
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "4MB")
|
|
||||||
BLANK_BIN_OFFSET1 := 0x3FB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x3FE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x3FC000
|
|
||||||
ESP8266_SIZEMAP := 4
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "4MB-c1")
|
ifeq ($(ESPTOOLPY_FLASHSIZE), "4MB-c1")
|
||||||
BLANK_BIN_OFFSET1 := 0x3FB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x3FE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x3FC000
|
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x3FC000
|
||||||
ESP8266_SIZEMAP := 6
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "8MB")
|
ifeq ($(ESPTOOLPY_FLASHSIZE), "8MB")
|
||||||
BLANK_BIN_OFFSET1 := 0x7FB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0x7FE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x7FC000
|
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0x7FC000
|
||||||
ESP8266_SIZEMAP := 8
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHSIZE), "16MB")
|
ifeq ($(ESPTOOLPY_FLASHSIZE), "16MB")
|
||||||
BLANK_BIN_OFFSET1 := 0xFFB000
|
|
||||||
BLANK_BIN_OFFSET2 := 0xFFE000
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0xFFC000
|
ESP_INIT_DATA_DEFAULT_BIN_OFFSET := 0xFFC000
|
||||||
ESP8266_SIZEMAP := 9
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BOOTLOADER_BIN_OFFSET := 0
|
|
||||||
APP_OFFSET := 0x1000
|
|
||||||
|
|
||||||
ESP8266_BOOTMODE ?= 2 # always be 2
|
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHMODE),"qio")
|
|
||||||
ESP8266_FLASHMODE ?= 0
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHMODE),"qout")
|
|
||||||
ESP8266_FLASHMODE ?= 1
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHMODE),"dio")
|
|
||||||
ESP8266_FLASHMODE ?= 2
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHMODE),"dout")
|
|
||||||
ESP8266_FLASHMODE ?= 3
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHFREQ),"20m")
|
|
||||||
ESP8266_FREQDIV ?= 2
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHFREQ),"26m")
|
|
||||||
ESP8266_FREQDIV ?= 1
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHFREQ),"40m")
|
|
||||||
ESP8266_FREQDIV ?= 0
|
|
||||||
endif
|
|
||||||
ifeq ($(ESPTOOLPY_FLASHFREQ),"80m")
|
|
||||||
ESP8266_FREQDIV ?= 15
|
|
||||||
endif
|
|
||||||
|
|
||||||
PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
|
|
||||||
|
|
||||||
ESP8266_BINSCRIPT ?= $(PYTHON) $(IDF_PATH)/tools/gen_appbin.py
|
|
||||||
|
|
||||||
ifdef DEBUG_BIN_PARAM
|
|
||||||
$(info mode:$(ESP8266_BOOTMODE) flash:$(ESP8266_FLASHMODE) freqdiv:$(ESP8266_FREQDIV), size_map:$(ESP8266_SIZEMAP))
|
|
||||||
$(info BLANK:$(BLANK_BIN_OFFSET1)/$(BLANK_BIN_OFFSET2) data:$(ESP_INIT_DATA_DEFAULT_BIN_OFFSET) script:$(ESP8266_LINKER_SCRIPTS))
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(APP_BIN): $(APP_ELF)
|
|
||||||
@$(OBJCOPY) --only-section .text -O binary $< eagle.app.v6.text.bin
|
|
||||||
@$(OBJCOPY) --only-section .data -O binary $< eagle.app.v6.data.bin
|
|
||||||
@$(OBJCOPY) --only-section .rodata -O binary $< eagle.app.v6.rodata.bin
|
|
||||||
@$(OBJCOPY) --only-section .irom0.text -O binary $< eagle.app.v6.irom0text.bin
|
|
||||||
@$(ESP8266_BINSCRIPT) $< $(ESP8266_BOOTMODE) $(ESP8266_FLASHMODE) $(ESP8266_FREQDIV) $(ESP8266_SIZEMAP)
|
|
||||||
@mv eagle.app.flash.bin $@
|
|
||||||
@rm eagle.app.v6.*
|
|
||||||
|
|
||||||
BLANK_BIN := $(BOOTLOADER_FIRMWARE_DIR)/blank.bin
|
|
||||||
ESP_INIT_DATA_DEFAULT_BIN := $(BOOTLOADER_FIRMWARE_DIR)/esp_init_data_default.bin
|
ESP_INIT_DATA_DEFAULT_BIN := $(BOOTLOADER_FIRMWARE_DIR)/esp_init_data_default.bin
|
||||||
BOOTLOADER_BIN := $(BOOTLOADER_FIRMWARE_DIR)/boot_v1.7.bin
|
|
||||||
|
|
||||||
CONFIG_ESPTOOLPY_COMPRESSED ?= y
|
ESPTOOL_ALL_FLASH_ARGS += $(ESP_INIT_DATA_DEFAULT_BIN_OFFSET) $(ESP_INIT_DATA_DEFAULT_BIN)
|
||||||
CONFIG_ESPTOOLPY_BEFORE_RESET ?=y
|
|
||||||
CONFIG_ESPTOOLPY_AFTER_RESET ?=y
|
|
||||||
|
|
||||||
ESPTOOLPY_SRC := $(IDF_PATH)/components/esptool_py/esptool/esptool.py
|
|
||||||
|
|
||||||
CHIP ?= esp8266
|
|
||||||
ESPPORT ?= $(CONFIG_ESPTOOLPY_PORT)
|
|
||||||
ESPBAUD ?= $(CONFIG_ESPTOOLPY_BAUD)
|
|
||||||
ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
|
||||||
ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
|
||||||
ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
|
||||||
ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip $(CHIP)
|
|
||||||
|
|
||||||
ESPTOOL_WRITE_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
|
|
||||||
|
|
||||||
ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
|
|
||||||
|
|
||||||
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS)
|
|
||||||
|
|
||||||
ESPTOOL_ALL_FLASH_ARGS += $(BOOTLOADER_BIN_OFFSET) $(BOOTLOADER_BIN) \
|
|
||||||
$(APP_OFFSET) $(APP_BIN) \
|
|
||||||
$(ESP_INIT_DATA_DEFAULT_BIN_OFFSET) $(ESP_INIT_DATA_DEFAULT_BIN) \
|
|
||||||
$(BLANK_BIN_OFFSET1) $(BLANK_BIN) \
|
|
||||||
$(BLANK_BIN_OFFSET2) $(BLANK_BIN)
|
|
||||||
|
|
||||||
flash: all_binaries $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
|
||||||
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(APP_OFFSET))..."
|
|
||||||
$(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
|
|
||||||
|
|
||||||
app-flash: $(APP_BIN) $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
|
||||||
@echo "Flashing app to serial port $(ESPPORT), offset $(APP_OFFSET)..."
|
|
||||||
$(ESPTOOLPY_WRITE_FLASH) $(APP_OFFSET) $(APP_BIN)
|
|
||||||
|
|
||||||
erase_flash:
|
|
||||||
@echo "Erasing entire flash..."
|
|
||||||
$(ESPTOOLPY_SERIAL) erase_flash
|
|
||||||
|
|
||||||
MONITORBAUD ?= $(CONFIG_MONITOR_BAUD)
|
|
||||||
|
|
||||||
MONITOR_PYTHON := $(PYTHON)
|
|
||||||
|
|
||||||
ifeq ("$(OS)","Windows_NT")
|
|
||||||
# miniterm and idf_monitor both need a Windows Console PTY in order
|
|
||||||
# to correctly handle user input
|
|
||||||
MONITOR_PYTHON := winpty $(PYTHON)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# note: if you want to run miniterm from command line, can simply run
|
|
||||||
# miniterm.py on the console. The '$(PYTHON) -m serial.tools.miniterm'
|
|
||||||
# is to allow for the $(PYTHON) variable overriding the python path.
|
|
||||||
simple_monitor: $(call prereq_if_explicit,%flash)
|
|
||||||
$(MONITOR_PYTHON) -m serial.tools.miniterm --rts 0 --dtr 0 --raw $(ESPPORT) $(MONITORBAUD)
|
|
||||||
|
|
||||||
MONITOR_OPTS := --baud $(MONITORBAUD) --port $(ESPPORT) --toolchain-prefix $(CONFIG_TOOLPREFIX) --make "$(MAKE)"
|
|
||||||
|
|
||||||
monitor: $(call prereq_if_explicit,%flash)
|
|
||||||
$(summary) MONITOR
|
|
||||||
[ -f $(APP_ELF) ] || echo "*** 'make monitor' target requires an app to be compiled and flashed first."
|
|
||||||
[ -f $(APP_ELF) ] || echo "*** Run 'make flash monitor' to build, flash and monitor"
|
|
||||||
[ -f $(APP_ELF) ] || echo "*** Or alternatively 'make simple_monitor' to view the serial port as-is."
|
|
||||||
[ -f $(APP_ELF) ] || exit 1
|
|
||||||
$(MONITOR_PYTHON) $(IDF_PATH)/tools/idf_monitor.py $(MONITOR_OPTS) $(APP_ELF)
|
|
||||||
|
|
||||||
# global CFLAGS for ESP8266
|
# global CFLAGS for ESP8266
|
||||||
CFLAGS += -DMEMLEAK_DEBUG -DICACHE_FLASH
|
CFLAGS += -DMEMLEAK_DEBUG -DICACHE_FLASH
|
||||||
@ -180,5 +30,3 @@ CFLAGS += -Wno-error=char-subscripts -Wno-error=unknown-pragmas -Wno-error=impli
|
|||||||
-Wno-error=pointer-sign -Wno-error=switch -Wno-error=maybe-uninitialized -Wno-error=format= \
|
-Wno-error=pointer-sign -Wno-error=switch -Wno-error=maybe-uninitialized -Wno-error=format= \
|
||||||
-Wno-error=unused-value -Wno-error=address -Wno-error=return-type -Wno-error=format-extra-args \
|
-Wno-error=unused-value -Wno-error=address -Wno-error=return-type -Wno-error=format-extra-args \
|
||||||
-Wno-error=format-zero-length -Wno-error=unused-label -Wno-error=sizeof-pointer-memaccess
|
-Wno-error=format-zero-length -Wno-error=unused-label -Wno-error=sizeof-pointer-memaccess
|
||||||
|
|
||||||
.PHONY: erase_flash
|
|
||||||
|
105
components/esptool_py/Makefile.projbuild
Normal file
105
components/esptool_py/Makefile.projbuild
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
# Component support for esptool.py. Doesn't do much by itself,
|
||||||
|
# components have their own flash targets that can use these variables.
|
||||||
|
ESPPORT ?= $(CONFIG_ESPTOOLPY_PORT)
|
||||||
|
ESPBAUD ?= $(CONFIG_ESPTOOLPY_BAUD)
|
||||||
|
ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
||||||
|
ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
||||||
|
ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
||||||
|
|
||||||
|
CONFIG_ESPTOOLPY_COMPRESSED ?=
|
||||||
|
|
||||||
|
PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
|
||||||
|
|
||||||
|
# two commands that can be used from other components
|
||||||
|
# to invoke esptool.py (with or without serial port args)
|
||||||
|
#
|
||||||
|
ESPTOOLPY_SRC := $(COMPONENT_PATH)/esptool/esptool.py
|
||||||
|
ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip esp8266
|
||||||
|
ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD) --before $(CONFIG_ESPTOOLPY_BEFORE) --after $(CONFIG_ESPTOOLPY_AFTER)
|
||||||
|
|
||||||
|
# Supporting esptool command line tools
|
||||||
|
ESPEFUSEPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espefuse.py
|
||||||
|
ESPSECUREPY := $(PYTHON) $(COMPONENT_PATH)/esptool/espsecure.py
|
||||||
|
export ESPSECUREPY # is used in bootloader_support component
|
||||||
|
|
||||||
|
ESPTOOL_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
|
||||||
|
ifdef CONFIG_ESPTOOLPY_FLASHSIZE_DETECT
|
||||||
|
ESPTOOL_WRITE_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size detect
|
||||||
|
else
|
||||||
|
ESPTOOL_WRITE_FLASH_OPTIONS := $(ESPTOOL_FLASH_OPTIONS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef IS_BOOTLOADER_BUILD
|
||||||
|
ESPTOOL_ELF2IMAGE_OPTIONS := --version=2
|
||||||
|
else
|
||||||
|
ESPTOOL_ELF2IMAGE_OPTIONS :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z,-u) $(ESPTOOL_WRITE_FLASH_OPTIONS)
|
||||||
|
|
||||||
|
ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN)
|
||||||
|
|
||||||
|
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||||
|
ifndef IS_BOOTLOADER_BUILD
|
||||||
|
# for locally signed secure boot image, add a signing step to get from unsigned app to signed app
|
||||||
|
APP_BIN_UNSIGNED := $(APP_BIN:.bin=-unsigned.bin)
|
||||||
|
|
||||||
|
$(APP_BIN): $(APP_BIN_UNSIGNED) $(SECURE_BOOT_SIGNING_KEY) $(SDKCONFIG_MAKEFILE)
|
||||||
|
$(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) -o $@ $<
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
# non-secure boot (or bootloader), both these files are the same
|
||||||
|
APP_BIN_UNSIGNED ?= $(APP_BIN)
|
||||||
|
|
||||||
|
$(APP_BIN_UNSIGNED): $(APP_ELF) $(ESPTOOLPY_SRC)
|
||||||
|
$(ESPTOOLPY) elf2image $(ESPTOOL_FLASH_OPTIONS) $(ESPTOOL_ELF2IMAGE_OPTIONS) -o $@ $<
|
||||||
|
ifdef IS_BOOTLOADER_BUILD
|
||||||
|
@mv $@0x00000.bin $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
flash: all_binaries $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
||||||
|
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(CONFIG_APP_OFFSET))..."
|
||||||
|
ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||||
|
@echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
|
||||||
|
endif
|
||||||
|
$(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
|
||||||
|
|
||||||
|
app-flash: $(APP_BIN) $(ESPTOOLPY_SRC) $(call prereq_if_explicit,erase_flash)
|
||||||
|
@echo "Flashing app to serial port $(ESPPORT), offset $(CONFIG_APP_OFFSET)..."
|
||||||
|
$(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
|
||||||
|
|
||||||
|
# Submodules normally added in component.mk, but can be added
|
||||||
|
# at the project level as long as qualified path
|
||||||
|
COMPONENT_SUBMODULES += $(COMPONENT_PATH)/esptool
|
||||||
|
|
||||||
|
erase_flash:
|
||||||
|
@echo "Erasing entire flash..."
|
||||||
|
$(ESPTOOLPY_SERIAL) erase_flash
|
||||||
|
|
||||||
|
MONITORBAUD ?= $(CONFIG_MONITOR_BAUD)
|
||||||
|
|
||||||
|
MONITOR_PYTHON := $(PYTHON)
|
||||||
|
|
||||||
|
ifeq ("$(OS)","Windows_NT")
|
||||||
|
# miniterm and idf_monitor both need a Windows Console PTY in order
|
||||||
|
# to correctly handle user input
|
||||||
|
MONITOR_PYTHON := winpty $(PYTHON)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# note: if you want to run miniterm from command line, can simply run
|
||||||
|
# miniterm.py on the console. The '$(PYTHON) -m serial.tools.miniterm'
|
||||||
|
# is to allow for the $(PYTHON) variable overriding the python path.
|
||||||
|
simple_monitor: $(call prereq_if_explicit,%flash)
|
||||||
|
$(MONITOR_PYTHON) -m serial.tools.miniterm --rts 0 --dtr 0 --raw $(ESPPORT) $(MONITORBAUD)
|
||||||
|
|
||||||
|
MONITOR_OPTS := --baud $(MONITORBAUD) --port $(ESPPORT) --toolchain-prefix $(CONFIG_TOOLPREFIX) --make "$(MAKE)"
|
||||||
|
|
||||||
|
monitor: $(call prereq_if_explicit,%flash)
|
||||||
|
$(summary) MONITOR
|
||||||
|
[ -f $(APP_ELF) ] || echo "*** 'make monitor' target requires an app to be compiled and flashed first."
|
||||||
|
[ -f $(APP_ELF) ] || echo "*** Run 'make flash monitor' to build, flash and monitor"
|
||||||
|
[ -f $(APP_ELF) ] || echo "*** Or alternatively 'make simple_monitor' to view the serial port as-is."
|
||||||
|
[ -f $(APP_ELF) ] || exit 1
|
||||||
|
$(MONITOR_PYTHON) $(IDF_PATH)/tools/idf_monitor.py $(MONITOR_OPTS) $(APP_ELF)
|
||||||
|
|
||||||
|
.PHONY: erase_flash
|
Reference in New Issue
Block a user