-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootloader: Integrate rboot directly as 'bootloader' component
Currently using unpatched upstream rboot, but modified to build without esptool2.
- Loading branch information
1 parent
f38bb74
commit a3956af
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This is a wrapper around the rboot makefile, which gives us the parameters | ||
# we need to use rboot with esp-open-rtos | ||
# | ||
# The wrapper means we don't require esptool2 in the build process, so we can just use | ||
# esptool.py (still need xxd, grep, sed to generate the header - see below.) | ||
|
||
BUILD_DIR ?= build | ||
FIRMWARE_DIR ?= firmware | ||
|
||
# RBOOT configuration parameters. | ||
# RBOOT_BIG_FLASH is required for esp-open-rtos. | ||
export RBOOT_BIG_FLASH = 1 | ||
|
||
export RBOOT_BUILD_BASE=$(abspath $(BUILD_DIR)) | ||
|
||
# Default ESPTOOL params, all the same as when using normal esp-open-rtos makefiles | ||
ESPTOOL ?= esptool.py | ||
ESPPORT ?= /dev/ttyUSB0 | ||
ESPBAUD ?= 115200 | ||
|
||
FLASH_SIZE ?= 16 | ||
FLASH_MODE ?= qio | ||
FLASH_SPEED ?= 40 | ||
|
||
ESPTOOL_ARGS=-fs $(FLASH_SIZE)m -fm $(FLASH_MODE) -ff $(FLASH_SPEED)m | ||
|
||
ifeq ("$(V)","1") | ||
Q := | ||
else | ||
Q := @ | ||
endif | ||
|
||
all: $(FIRMWARE_DIR)/rboot.bin | ||
|
||
rboot/Makefile: | ||
$(error rboot git submodule is not checkedo out. Try running 'git submodule update --init --recursive') | ||
|
||
$(FIRMWARE_DIR)/rboot.bin: $(BUILD_DIR)/rboot.elf $(FIRMWARE_DIR) | ||
@echo "FW rboot.bin" | ||
$(Q) $(ESPTOOL) elf2image $(ESPTOOL_ARGS) $< -o $(BUILD_DIR)/ | ||
$(Q) mv $(BUILD_DIR)/0x00000.bin $@ | ||
|
||
# rboot generates this header using the 'esptool2 -header' option. To try and avoid | ||
# esptool2 as a dependency, we try it here using grep, sed, xxd (all fairly common Unix tools) | ||
$(BUILD_DIR)/rboot-hex2a.h: $(BUILD_DIR)/rboot-stage2a.elf $(BUILD_DIR) | ||
@echo "Extracting stub image header..." | ||
$(Q) xtensa-lx106-elf-objcopy $< --only-section .text -Obinary $(BUILD_DIR)/rboot-hex2a.bin | ||
$(Q) xxd -i $(BUILD_DIR)/rboot-hex2a.bin > $@.in | ||
$(Q) sed -i "s/unsigned char .\+\[\]/const uint8 _text_data[]/" $@.in | ||
$(Q) sed -i "s/unsigned int .\+_len/const uint32 _text_len/" $@.in | ||
$(Q) echo "const uint32 entry_addr = $$(xtensa-lx106-elf-objdump -f $< | grep 'start address' | grep -o '0x.\+');" >> $@.in | ||
$(Q) echo "const uint32 _text_addr = 0x$$(xtensa-lx106-elf-objdump -h -j .text $< | grep ".text" | grep -o '401.....' | head -n1);" >> $@.in | ||
$(Q) mv $@.in $@ | ||
|
||
$(BUILD_DIR)/rboot-stage2a.elf: $(BUILD_DIR) | ||
$(Q) $(MAKE) -C rboot $(RBOOT_BUILD_BASE)/rboot-stage2a.elf | ||
|
||
$(BUILD_DIR)/rboot.elf: $(BUILD_DIR)/rboot-hex2a.h | ||
$(Q) $(MAKE) -C rboot $(RBOOT_BUILD_BASE)/rboot.elf | ||
|
||
$(BUILD_DIR) $(FIRMWARE_DIR): | ||
$(Q) mkdir -p "$@" | ||
|
||
flash: $(FIRMWARE_DIR)/rboot.bin | ||
$(Q) $(ESPTOOL) -p $(ESPPORT) -b $(ESPBAUD) write_flash $(ESPTOOL_ARGS) 0x0 $< | ||
|
||
clean: | ||
$(Q) rm -rf $(BUILD_DIR) | ||
$(Q) rm -rf $(FIRMWARE_DIR) | ||
|
||
.PHONY: all clean flash erase_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
OTA Bootloader (rboot) source module and support files. | ||
|
||
Can be used to build an esp-open-rtos compatible rboot bootloader, for use when OTA=1. | ||
|
||
It is also possible to use the upstream rboot verbatim, but *ensure that the `RBOOT_BIG_FLASH` option is enabled or images in slots other than 0 won't work correctly. | ||
|
||
rboot is an open source bootloader by Richard Burton: | ||
https://github.com/raburton/rboot | ||
|
||
See the contents of the 'rboot' directory for more information. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters