1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/makefiles
bors[bot] f7ef90d213
Merge #19074
19074: cpu/esp8266: build the SDK bootloader from source r=benpicco a=gschorcht

### Contribution description

This PR is a takeover of PR #17043, which is rebased to the current master and includes some corrections that became necessary after rebasing.

**Copied from description of PR #17043:**

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.

### Testing procedure

Use following command to flash the application with STDIO UART baudrate of 115200 baud.
```
BAUD=74880 USEMODULE=esp_log_startup make -C tests/shell BOARD=esp8266-esp-12x flash
```
Connect with a terminal programm of your choice (unfortunatly `picocom` and `socat` don't support a baudrate close to 74880), for example:
```
python -m serial.tools.miniterm /dev/ttyUSB0 74880
```
On reset, the `esp8266-esp-12x` node shows the ROM bootloader log output
```
 ets Jan  8 2013,rst cause:2, boot mode:(3,7) 

load 0x40100000, len 6152, room 16 
tail 8
chksum 0x6f
load 0x3ffe8008, len 24, room 0 
tail 8
chksum 0x86
load 0x3ffe8020, len 3408, room 0 
tail 0
chksum 0x79
```
as well as the second-stage bootloader built by this PR (`ESP-IDF v3.1-51-g913a06a9ac3`) at 74880 baudrate.
```
I (42) boot: ESP-IDF v3.1-51-g913a06a9ac3 2nd stage bootloader
I (42) boot: compile time 11:25:03
I (42) boot: SPI Speed      : 26.7MHz
...
I (151) boot: Loaded app from partition at offset 0x10000
```
The application output is seen as garbage since the `esp8266-esp-12x` uses 115200 as baurate by default.

To see all output at a baudrate of 74880 baud, you can use the following command:
```
CFLAGS='-DSTDIO_UART_BAUDRATE=74880' BAUD=74880 USEMODULE=esp_log_startup make -C tests/shell BOARD=esp8266-esp-12x flash
```

If the application is built without options, the ROOM bootloader output will be 74880 baud and the second stage bootloader and application output will be 115200 baud.

### Issues/PRs references

Fixes issue #16402

Co-authored-by: iosabi <iosabi@protonmail.com>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2023-01-03 00:44:24 +00:00
..
arch makefiles/gnu.inc.mk: set flags based on compiler version 2022-11-19 23:14:54 +01:00
boards makefiles/boards/stm32.inc.mk: improve stm32flash support 2022-08-16 22:00:06 +02:00
boot makefiles: add riotboot_dfu-util.mk to override board's dfu-util config 2022-11-30 19:28:14 +01:00
libc makefiles/libc/picolibc.mk: fix compilation with modern binutils 2022-11-12 17:09:11 +01:00
pkg makefiles/pkg/nimble.adv.mk: add utility to assign adv instance 2022-04-27 08:22:58 +02:00
tests build-system: add capability to execute scripts with custom executor 2022-10-19 13:58:19 +02:00
toolchain makefiles/gnu.inc.mk: fix "extraneous text after 'ifneq' directive" 2022-11-20 14:53:34 +01:00
tools Merge #19074 2023-01-03 00:44:24 +00:00
utils makefiles/utils/ansi: Refactor ansi codes into their own file. 2021-05-04 10:52:50 +02:00
app_dirs.inc.mk make: use $(MAKE) instead of direct make call 2020-07-03 12:03:06 +02:00
application.inc.mk core: split out library code 2022-03-09 21:43:05 +01:00
auto_init.inc.mk makefiles: add common makefile for auto_init modules 2020-06-08 10:27:35 +02:00
bindist.inc.mk makefiles/bindist: copy object files and use .bin to compare 2020-09-04 15:01:15 +02:00
blob.inc.mk makefiles/blob.inc.mk: introduce blob -> hdr utility makefile 2019-11-18 17:53:47 +01:00
boards.inc.mk make: add info-emulated-boards helper target 2021-10-12 10:39:57 +02:00
buildtests.inc.mk many typo fixes 2019-11-23 22:39:07 +01:00
cargo-settings.inc.mk Rust: Add crates-to-module adapter 2022-07-09 21:15:29 +02:00
cargo-targets.inc.mk makefiles: Use grep -q rather than --quiet 2022-11-14 09:51:19 +01:00
cflags.inc.mk makefiles/cflags.inc.mk: don't include absolute path in __FILE__ macro 2022-11-15 15:28:54 +01:00
clang_tidy.inc.mk makefiles/clang-tidy: initial support 2021-05-28 11:57:20 +02:00
color.inc.mk makefiles/color: Add color functions. 2021-05-04 10:57:47 +02:00
default-radio-settings.inc.mk drivers/cc110x : Add CONFIG_ 2020-04-17 23:27:01 +05:30
defaultmodules_deps.inc.mk sys/preprocessor: add preprocessor module 2022-10-17 10:38:14 +02:00
defaultmodules_no_recursive_deps.inc.mk buildsystem: split default modules include early and late 2022-06-02 12:56:59 +02:00
defaultmodules_regular.inc.mk libc: add to default modules 2022-09-26 19:06:46 +02:00
dependencies_debug.inc.mk makefiles/dependencies_debug.inc.mk: add TOOLCHAIN 2021-01-27 11:11:43 +01:00
dependency_resolution.inc.mk buildsystem: split default modules include early and late 2022-06-02 12:56:59 +02:00
deprecated_boards.inc.mk cpu/mips: Remove all mips 2022-09-27 13:42:37 +02:00
deprecated_cpus.inc.mk cpu/mips: Remove all mips 2022-09-27 13:42:37 +02:00
deprecated_modules.inc.mk sys/shell/cmds: fix shell_cmd_netif LoRaWAN integration 2022-10-04 23:06:03 +02:00
docker.inc.mk makefiles/docker.inc.mk: add support for podman 2022-09-29 20:59:42 +02:00
driver_with_disp_dev.mk make: introduce makefile to optimize driver with disp/touch_dev build 2022-01-06 12:07:07 +01:00
driver_with_saul.mk make: introduce makefile to optimize driver with saul build 2022-01-06 12:07:06 +01:00
driver_with_touch_dev.mk make: introduce makefile to optimize driver with disp/touch_dev build 2022-01-06 12:07:07 +01:00
eclipse.inc.mk eclipse.inc.mk: Split eclipse support into it's own file. 2018-12-05 15:22:42 +01:00
features_check.inc.mk build_system: don't optionally use conflicting features 2021-02-22 12:06:27 +01:00
features_modules.inc.mk makefiles/features_modules: ignore non-init periphs 2022-08-17 14:37:24 +02:00
git_version.inc.mk makefiles/git_version.inc.mk: deferred GIT_VERSION definition 2019-07-22 12:00:45 +02:00
info-global.inc.mk makefiles: undefine BOARD_VERSION in info-global.inc.mk 2022-08-30 15:08:39 +02:00
info-nproc.inc.mk make: replace curly braces with parenthesis 2018-03-22 20:43:15 +01:00
info.inc.mk makefiles: Add make info-rust target 2022-09-23 02:03:50 +02:00
kconfig.mk boards: Use BOARD.config pattern for kconfig 2022-02-14 13:10:09 +01:00
mcuboot.mk Merge pull request #11130 from cladmi/pr/make/flashfile/jlink 2019-03-14 12:01:02 +01:00
modules.inc.mk makefile: add a check for real modules 2020-09-04 15:01:16 +02:00
murdock.inc.mk makefiles/murdock.inc.mk: change policy to run tests by default 2019-08-21 12:49:26 +02:00
periph.mk Makefile: remove usage of SUBMODULES_NOFORCE 2020-04-15 12:11:44 +02:00
pseudomodules.inc.mk sys/malloc_tracing: add module to trace dyn memory management 2022-11-15 12:59:46 +01:00
scan-build.inc.mk makefiles: avoid building archives when compiling 2020-09-04 15:01:10 +02:00
stdio.inc.mk pkg/tinyusb: implement stdio via CDC ACM 2022-11-09 12:06:36 +01:00
suit.base.inc.mk makefiles/suit: avoid unwanted key creation trigger 2022-07-20 12:35:33 +02:00
suit.inc.mk makefiles/suit: allow to overwrite SUIT_VENDOR_DOMAIN 2022-06-01 13:18:00 +02:00
tests.inc.mk make: run static_tests.sh directly with static-tests target 2020-12-17 15:16:36 +01:00
ubsan.inc.mk make: add initial ubsan support 2022-02-16 12:20:45 +01:00
usb-codes.inc.mk makefile: Fix usage error with busybox grep 2020-10-06 17:16:26 +00:00
vars.inc.mk makefiles: Add openocd-rtt 2022-08-30 09:34:22 +02:00