1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00
RIOT/cpu
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
..
arm7_common cpu/arm7_common: drop cyclic include 2022-12-13 15:55:17 +01:00
atmega32u4
atmega128rfa1
atmega256rfr2
atmega328p
atmega1281
atmega1284p
atmega2560
atmega_common cpu/atmega_common/periph_timer: fix spurious IRQs 2022-11-25 14:46:16 +01:00
atxmega
avr8_common cpu: always rely on stdio.inc.mk for default stdio selection 2022-11-09 10:42:47 +01:00
cc26x0_cc13x0
cc26x2_cc13x2
cc26xx_cc13xx cpu/cc26xx_cc13xx: remove broken HTML links and headings from doc 2022-10-28 08:57:17 -04:00
cc2538
cortexm_common cpu/cortexm_common: measure time spent with IRQ disabled 2022-11-24 21:27:20 +01:00
efm32 cpu/efm32: increase RIOTBOOT_LEN for riotboot_dfu 2022-12-07 16:38:51 +01:00
esp32 Merge #19078 2023-01-02 18:18:19 +00:00
esp8266 Merge #19074 2023-01-03 00:44:24 +00:00
esp_common Merge #19074 2023-01-03 00:44:24 +00:00
fe310
gd32v
kinetis
lm4f120 cpu/lm4f120: remove stdlib include 2022-12-14 00:22:02 +01:00
lpc23xx cpu/lpc23xx: core: replace RIOT_FILE_RELATIVE with __FILE__ 2022-11-19 01:48:42 +01:00
lpc1768
msp430_common
msp430fxyz
native native: Remove code used for __MACH__ target 2022-12-22 17:57:25 +01:00
nrf5x_common cpu/nrf5x_common: Implement timer_set() 2022-12-23 14:48:08 +01:00
nrf51
nrf52
nrf9160
qn908x cpu/qn908x: use bitarithm_test_and_clear() & fix cb 2022-11-28 16:43:24 +01:00
riscv_common riscv: Reduce reset trampoline code size by 2 bytes 2022-12-08 13:26:07 +01:00
rpx0xx
sam0_common sam0_common: use size_t len for I2C transfers, as declared (fixes #19008) 2022-12-04 16:57:00 +01:00
sam3
sam_common
samd5x
samd21 cpu/sam0/spi: generalize pm_layered interaction 2022-11-03 14:53:44 +01:00
saml1x
saml21 cpu/saml21: define required power modes 2022-11-03 14:53:45 +01:00
stellaris_common
stm32 cpu/stm32/periph_timer: fix spurious IRQs 2022-11-24 22:34:10 +01:00
doc.txt
Kconfig