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

46 Commits

Author SHA1 Message Date
Gunar Schorcht
32168da8d6 cpu/esp32: add flashpage support
f
2023-01-07 14:49:36 +01:00
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
Gunar Schorcht
f23b20f91f cpu/esp: use FLASHFILE_POS for image position in flash
Instead of using a fixed position of the image file in the flash, the variable `FLASHFILE_POS` is used which allows to override the default position of the image in the flash at 0x10000.
2022-12-31 14:10:57 +01:00
Gunar Schorcht
4f1b4ba0c9 cpu/esp_common: remove double defines from Makefile 2022-12-22 12:18:34 +01:00
Gunar Schorcht
b4fafef6e7 cpu/esp_common: replace FLASH_MODE_* by CONFIG_*FLASHMODE_* defines
The former FLASH_MODE_{DOUT,DIO,QOUT,QIO} defines are replaced by the corresponding CONFIG_FLASHMODE_{DOUT,DIO,QOUT,QIO} and CONFIG_ESPTOOLPY_FLASHMODE_{DOUT,DIO,QOUT,QIO} as used by the ESP-IDF. This is also needed for the migration of defining flash mode in Kconfig.
2022-08-01 15:17:33 +02:00
Gunar Schorcht
cd3c053d32 cpu/esp32: qout mode is no longer required for SPI RAM 2022-08-01 15:11:11 +02:00
Gunar Schorcht
fd67f1402f cpu/esp_common: use CPU_ARCH in Makefile for compile options
To support ESP32x families, CPU_ARCH is used instead of CPU in Makefiles to define architecture dependent compile options.
2022-07-18 13:05:21 +02:00
Gunar Schorcht
cdd1ec81a4 cpu/esp_common: ESP32 variant independent makefiles 2022-06-23 13:19:52 +02:00
Gunar Schorcht
99fa182fb4 cpu/esp_common/freertos: add required task functions 2022-06-20 21:23:47 +02:00
Gunar Schorcht
d2a4d6e3d3 cpu/esp32: compile bootloader from ESP-IDF v4.4 source 2022-06-01 13:31:00 +02:00
Gunar Schorcht
60bbe0fe49 cpu/esp_common/makefile: move linking of libhal.a to esp8266 makefile 2022-05-18 07:27:23 +02:00
Gunar Schorcht
cbbd02d520 dist/tools: rename esptool to esptools to use it for several tools
The directory `dist/tools/esptool` already contains a couple of ESP tools and not only esptool.py. As the location for a couple of ESP related tools, it is more clear to call it `esptools` instead of `esptool`.
2022-03-04 08:34:19 +01:00
Gunar Schorcht
d6c2926933 pkg/esp32_sdk: add ESP32 SDK without libraries as package
The vendor binary libraries of ESP-IDF are provided as a separate GIT repository. These libraries are defined as separate package for two reasons: 1. RIOT packages don't support to clone GIT repositories recursively; 2. ESP-IDF pulls a lot of other GIT repositories that are not needed when it is cloned recursively.
2022-01-04 16:34:31 +01:00
Leandro Lanzieri
01e01c4597
cpu/esp_common: move LINKFLAGS to Makefile.include 2021-12-10 18:54:28 +01:00
Gunar Schorcht
697c44811a
Merge pull request #16911 from yarrick/esp_jtag
cpu/esp32: Add openocd programming support
2021-10-26 01:24:27 +02:00
iosabi
7b1f083cd8 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-10-23 11:13:38 +00:00
Erik Ekman
3d7d211157 cpu/esp: Always create app.elf.bin and partitions.bin
Even if programmer is not esptool
2021-10-15 09:59:38 +02:00
Marian Buschsieweke
6c4f0da7a7
cpu/esp_common: fix bootloop on ESP8266 2021-07-13 20:48:01 +02:00
Marian Buschsieweke
a9dea12eb8
cpu/esp_common: add overflow detection to calloc
If esp_idf_heap is not used, implement calloc through a custom wrapper
function on top of malloc to add overflow detection, which is not
present in the newlib forks with xtensa support yet.
2021-05-10 15:29:48 +02:00
b5794c2a22
cpu/esp: set esptool as supported programmer 2021-02-24 13:29:56 +01:00
d527ab6994
cpu: boards: esp: use common esptool makefile 2020-12-01 10:36:42 +01:00
Jean Pierre Dudey
295a3665d2 cpu/esp: implement ESP SoftAP mode
This is an implementation of the ESP32 SoftAP mode using the
`esp_wifi_ap` pseudomodule.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2020-09-27 18:29:24 -05:00
Leandro Lanzieri
81cb769cad
makefiles: avoid building archives when compiling 2020-09-04 15:01:10 +02:00
Francisco Molina
e98341da93
Makefile: use normal conditionals 2020-06-29 22:40:29 +02:00
Gunar Schorcht
fef3c101b7 Revert "cpu/esp_common: fix dependency of flash target on ELF file"
This reverts commit d0cc955394.
2020-05-12 18:07:48 +02:00
Gunar Schorcht
d0cc955394 cpu/esp_common: fix dependency of flash target on ELF file
Flashing an ESP board first requires the creation of a flash image from the ELF file.  This is realized in the `preflash` target. However, the `preflash` target only depends on the variable `BUILD_BEFORE_FLASH` but on the ELF file. Therefore, the variable `BUILD_BEFORE_FLASH` must be set to the ELF file to ensure that when using multiple make processes, the compilation of the ELF file is completed before the flash image is created.
2020-05-08 11:03:39 +02:00
Marian Buschsieweke
bcaacc8fa5
cpu/esp_common: Use python3 instead python 2020-03-26 15:10:28 +01:00
Leandro Lanzieri
afc0ad4d57
cpu/esp_common: Set RIOT_TEST_TIMEOUT with conditional expansion 2020-03-24 09:27:40 +01:00
Leandro Lanzieri
56972af3b4
cpu/esp_common: Don't increase GNRC_NETIF_NUMOF on Makefile 2020-03-24 09:27:30 +01:00
Leandro Lanzieri
939a10813b
cpu/esp_common: Check for esp_spi_ram with conditional expansion 2020-03-24 09:21:23 +01:00
Leandro Lanzieri
fcfc15e199
cpu/esp: Move dependency resolution of esp_log_startup to Makefile.dep 2020-03-24 09:21:21 +01:00
Leandro Lanzieri
e61532efbe
cpu/esp: Move dependency resolution of esp_log_colored to Makefile.dep 2020-03-24 09:21:21 +01:00
Leandro Lanzieri
f918b97ec3
cpu/esp: Move dependency resolution of esp_gdb to Makefile.dep 2020-03-24 09:21:20 +01:00
Leandro Lanzieri
7a30795a8c
cpu/esp: Move esp_[wifi/now] dependency resolution to Makefile.dep 2020-03-24 09:21:20 +01:00
Leandro Lanzieri
ab1f88c69a
cpu/esp: Evaluate esp_[wifi/now] modules with conditional expansion 2020-03-24 09:21:20 +01:00
Leandro Lanzieri
48a62dcc8f
cpu/esp: Move common dependencies to Makefile.dep 2020-03-24 09:21:19 +01:00
Gunar Schorcht
ae647ed95f cpu/esp32/esp_wifi: Makefile integration for WPA2 Enterprise mode 2020-03-17 17:51:29 +01:00
Gunar Schorcht
3230326652 cpu/esp32: fix esp_spi_ram dependency and flash mode setting 2020-02-21 10:14:03 +01:00
Gunar Schorcht
ccae24c8b6 cpu/esp_common: enable esp_wifi as default for lwip 2020-02-21 09:09:34 +01:00
Gunar Schorcht
98ca108be5 cpu/esp8266: move esp_wifi to cpu/esp_common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
18659bdf26 cpu/esp*: move FreeRTOS headers to cpu/esp_common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
05faec7cf8 cpu/esp*: move periph/i2c_sw to esp/common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
0ef723c6f7 cpu/esp_common: add module esp_periph_common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
39ee806d3c cpu/esp*: move some vendor/esp code to cpu/esp_common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
7d701f6fa8 cpu/esp*: move common headers to cpu/esp_common 2020-02-21 09:09:34 +01:00
Gunar Schorcht
53a3756e0c cpu/esp*: common Makfile* added 2020-02-21 09:09:34 +01:00