1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/esp8266_sdk/Makefile.include

34 lines
1.3 KiB
Makefile
Raw Normal View History

cpu/esp8266: Build the SDK bootloader from source. We had four versions of pre-built bootloaders for the esp8266 with different settings of logging and color logging. These bootloaders were manually built from the SDK and shipped with RIOT-OS source code. However there are more settings that affect the bootloader build that are relevant to the app or final board that uses this bootloader. In particular, flash size and flash speed is important for the bootloader to be able to load an app from a large partition table at the fastest speed supported by the board layout and flash chip. Another example is the UART baudrate of the logging output from the bootloader. The boot ROM will normally start at a baud rate of 74880 (depending on the crystal installed), so it might make sense to keep the UART output at the same speed so we can debug boot modes and bootloader with the same terminal. This patch builds the bootloader.bin file from the ESP8266 SDK source code. The code is built as a module (esp8266_bootloader) which at the moment doesn't generate any object code for the application and only produces a bootloader.bin file set to the BOOTLOADER_BIN make variable for the esptool.inc.mk to flash. The code needs to be compiled and linked with custom rules defined in the module's Makefile since the bootloader.bin is its own separate application. The `BOOTLOADER_BIN` variable is changed from a path relative to the `$(RIOTCPU)/$(CPU)/bin/` directory to be full path. This makes it easier for applications or board to provide their own bootloader binary if needed. As a result of building the bootloader from source we fixed the issue of having a large partition table. Fixes #16402.
2021-05-06 03:00:04 +02:00
PSEUDOMODULES += esp8266_sdk
esp8266: Download Espressif RTOS SDK as a new RIOT PKG RIOT-OS uses part of Espressif ESP8266 RTOS SDK to build support for this CPU. The SDK includes some vendor-provided closed source pre-compiled libraries that we need to modify to adapt to RIOT-OS usage. This library modifications was done once and uploaded to a fork of the vendor repository and was provided as an environment variable. This patch changes two things: 1. It installs the SDK as a RIOT PKG from the new pkg/esp8266_sdk directory instead of requiring the user to download it separately. 2. It performs the library modifications (symbol renames) on the pkg Makefile removing the need to use a fork with the modifications applied and simplifying the SDK update and future modifications. This change sets the SDK package version (git SHA) to the same one that our fork was using as a parent in the vendor repository, meaning that the output libraries are exactly the same as before. Tested with ``` ESP8266_RTOS_SDK_DIR=/dev/null USEMODULE=esp_log_startup make -C tests/shell BOARD=esp8266-esp-12x flash ``` and verified that the program works. The boot message now includes: ``` ESP8266-RTOS-SDK Version v3.1-51-g913a06a9 ``` confirming the SDK version used. `/dev/null` in the test is just to make sure that no evaluation of `ESP8266_RTOS_SDK_DIR` in make is affected by the environment variable value which would be set to the SDK for people who followed the set up instructions before this change. Tested the checkout size: ```bash $ du -hs build/pkg/esp8266_sdk/ 124M build/pkg/esp8266_sdk/ ```
2021-05-01 15:39:25 +02:00
# Directory with the SDK source checkout. Some modules in the cpu/esp8266 use
# internal parts of the SDK and for that they need access to the
# ESP8266_RTOS_SDK_DIR path.
export ESP8266_RTOS_SDK_DIR = $(PKGDIRBASE)/esp8266_sdk
# Directory where we built the modified libraries and headers.
ESP8266_SDK_BUILD_DIR ?= $(ESP8266_RTOS_SDK_DIR)/build-libs
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/bootloader_support/include/
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/esp8266/include
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/esp8266/include/esp8266
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/heap/include
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/heap/port/esp8266/include
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/nvs_flash/include
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/spi_flash/include
INCLUDES += -I$(ESP8266_SDK_BUILD_DIR)
# Modified binary libraries are built here in the Makefile.
LINKFLAGS += -L$(ESP8266_SDK_BUILD_DIR)
cpu/esp8266: Build the SDK bootloader from source. We had four versions of pre-built bootloaders for the esp8266 with different settings of logging and color logging. These bootloaders were manually built from the SDK and shipped with RIOT-OS source code. However there are more settings that affect the bootloader build that are relevant to the app or final board that uses this bootloader. In particular, flash size and flash speed is important for the bootloader to be able to load an app from a large partition table at the fastest speed supported by the board layout and flash chip. Another example is the UART baudrate of the logging output from the bootloader. The boot ROM will normally start at a baud rate of 74880 (depending on the crystal installed), so it might make sense to keep the UART output at the same speed so we can debug boot modes and bootloader with the same terminal. This patch builds the bootloader.bin file from the ESP8266 SDK source code. The code is built as a module (esp8266_bootloader) which at the moment doesn't generate any object code for the application and only produces a bootloader.bin file set to the BOOTLOADER_BIN make variable for the esptool.inc.mk to flash. The code needs to be compiled and linked with custom rules defined in the module's Makefile since the bootloader.bin is its own separate application. The `BOOTLOADER_BIN` variable is changed from a path relative to the `$(RIOTCPU)/$(CPU)/bin/` directory to be full path. This makes it easier for applications or board to provide their own bootloader binary if needed. As a result of building the bootloader from source we fixed the issue of having a large partition table. Fixes #16402.
2021-05-06 03:00:04 +02:00
# Bootloader module built from the SDK.
DIRS += $(RIOTBASE)/pkg/esp8266_sdk/bootloader
PSEUDOMODULES += esp_bootloader
ifneq (,$(filter esp_bootloader,$(USEMODULE)))
# Bootloader file used by esptool.inc.mk
BOOTLOADER_BIN ?= $(BINDIR)/esp_bootloader/bootloader.bin
endif
$(BOOTLOADER_BIN):