1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 07:51:19 +01:00
bors[bot] c2d5c6b7d9
Merge #19409
19409: dist/tools/openocd: fix problems with riotboot caused by _flash_addr function for OpenOCD v0.12  r=maribu a=gschorcht

### Contribution description

This PR fixes the problem that OpenOCD v0.12 can't be used to flash application images for `riotboot`. Found when using OpenOCD v0.12 for GD32V and `riotboot`.

If `riotboot` is used, application images including their riotboot headers are flashed as binaries where the flash address has to be sepcified in `openocd` command. To determine the flash address, OpenOCD command `flash list` is used which returns a list of flash banks. With OpenOCD version v0.12, the format of the command output has been changed.

Until version OpenOCD version v0.11, command `flash list` returned something like (**without newlines**):
```
{name nrf51 base 0 size 0 bus_width 1 chip_width 1}
{name nrf51 base 268439552 size 0 bus_width 1 chip_width 1}
```
It was hard-coded in function `_flash_addr` to extract the 4th column of the according line instead of using the keyword `base`.
With OpenOCD version v0.12, the output format of the `flash list` command has been changed to:
```
{name nrf51.flash driver nrf51 base 0 size 0 bus_width 1 chip_width 1 target nrf51.cpu}
{name nrf51.uicr driver nrf51 base 268439552 size 0 bus_width 1 chip_width 1 target nrf51.cpu}
```
That is, with the hard-coded 4th column, function `_flash_addr` always returns `0x00000000` which doesn't matter for platforms that define `0x0` as base address but using `riotboot` on platforms that define a base address other than `0x0` no longer works.

For example, using `riotboot` on a `nucleo-f303ze` with OpenOCD v0.11 works as expected
```python
FEATURES_REQUIRED=riotboot BOARD=nucleo-f303ze make -j8 -C tests/shell flash
...
openocd.sh flashtests/shell/bin/nucleo-f303ze/riotboot_files/slot0-extended.bin
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08000000
...
Info : flash size = 512kbytes
auto erase enabled
wrote 266240 bytes from file /home/gs/src/RIOT-Xtensa-ESP.esp-idf-4.4/tests/shell/bin/nucleo-f303ze/riotboot_files/slot0-extended.bin in 11.100125s (23.423 KiB/s)

verified 265216 bytes in 3.802232s (68.118 KiB/s)
```
but fails when using OpenOCD v0.12 due to wrong image offset:
```python
openocd.sh flash tests/shell/bin/nucleo-f303ze/riotboot_files/slot0-extended.bin
### Flashing Target ###
Binfile detected, adding ROM base address: 0x00000000
Flashing with IMAGE_OFFSET: 0x00000000
...
Info : flash size = 512kbytes
Warn : no flash bank found for address 0x00000000
auto erase enabled
wrote 0 bytes from file tests/shell/bin/nucleo-f303ze/riotboot_files/slot0-extended.bin in 0.001248s (0.000 KiB/s)

Error: checksum mismatch - attempting binary compare
diff 0 address 0x00001004. Was 0xb9 instead of 0x49
diff 1 address 0x00001005. Was 0xf8 instead of 0xf9
```

This PR modifies the `_flash_address` function to use the base keyword to extract the flash address to use.

### Testing procedure

Use a board which provides the `riotboot` feature but for which `riotboot` doesn't work any longer, for example `nucleo-f303ze`:
```
FEATURES_PROVIDED=riotboot FEATURES_REQUIRED=riotboot BOARD=nucleo-f303ze make -j8 -C tests/shell flash
```
 Principally, also boards that don't yet provide the `riotboot` feature but work for testing, for example:
```
FEATURES_PROVIDED=riotboot FEATURES_REQUIRED=riotboot BOARD=nucleo-f103rb make -j8 -C tests/shell flash
FEATURES_PROVIDED=riotboot FEATURES_REQUIRED=riotboot BOARD=nucleo-f411re make -j8 -C tests/shell flash
```
Without the PR, flashing `tests/shell/bin/nucleo-f103rb/riotboot_files/slot0-extended.bin` fails, with the PR it should work.

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2023-03-19 18:34:14 +00:00
2023-03-17 13:02:20 +01:00
2023-03-10 02:22:17 +00:00
2023-03-10 14:32:59 +00:00
2023-03-13 11:49:39 +01:00
2023-03-17 13:06:11 +00:00
2023-03-17 13:06:11 +00:00
2020-04-28 11:58:44 +02:00
2021-10-22 10:21:57 +02:00
2017-12-08 09:10:01 +01:00
2023-03-02 11:31:07 +01:00
2022-08-23 09:46:56 +02:00
2023-02-28 02:46:35 +00:00
2022-11-14 14:28:28 +01:00

Nightly CI status master Nightly HiL CI overview GitHub release License API docs Wiki Stack Overflow questions Twitter Matrix

The friendly Operating System for IoT!

RIOT is a real-time multi-threading operating system that supports a range of devices that are typically found in the Internet of Things (IoT): 8-bit, 16-bit and 32-bit microcontrollers.

RIOT is based on the following design principles: energy-efficiency, real-time capabilities, small memory footprint, modularity, and uniform API access, independent of the underlying hardware (this API offers partial POSIX compliance).

RIOT is developed by an international open source community which is independent of specific vendors (e.g. similarly to the Linux community). RIOT is licensed with LGPLv2.1, a copyleft license which fosters indirect business models around the free open-source software platform provided by RIOT, e.g. it is possible to link closed-source code with the LGPL code.

FEATURES

RIOT provides features including, but not limited to:

  • a preemptive, tickless scheduler with priorities
  • flexible memory management
  • high resolution, long-term timers
  • MTD abstraction layer
  • File System integration
  • support 200+ boards based on AVR, MSP430, ESP8266, ESP32, RISC-V, ARM7 and ARM Cortex-M
  • the native port allows to run RIOT as-is on Linux and BSD. Multiple instances of RIOT running on a single machine can also be interconnected via a simple virtual Ethernet bridge or via a simulated IEEE 802.15.4 network (ZEP)
  • IPv6
  • 6LoWPAN (RFC4944, RFC6282, and RFC6775)
  • UDP
  • RPL (storing mode, P2P mode)
  • CoAP
  • OTA updates via SUIT
  • MQTT
  • USB (device mode)
  • Display / Touchscreen support
  • CCN-Lite
  • LoRaWAN
  • UWB
  • Bluetooth (BLE) via NimBLE

GETTING RIOT

The most convenient way to get RIOT is to clone it via Git

$ git clone https://github.com/RIOT-OS/RIOT

this will ensure that you get all the newest features and bug fixes with the caveat of an ever changing work environment.

If you prefer things more stable, you can download the source code of one of our quarter annual releases via Github as ZIP file or tarball. You can also checkout a release in a cloned Git repository using

$ git pull --tags
$ git checkout <YYYY.MM>

For more details on our release cycle, check our documentation.

GETTING STARTED

  • You want to start the RIOT? Just follow our quickstart guide or try this tutorial. For specific toolchain installation, follow instructions in the getting started page.
  • The RIOT API itself can be built from the code using doxygen. The latest version of the documentation is uploaded daily to doc.riot-os.org.

FORUM

Do you have a question, want to discuss a new feature, or just want to present your latest project using RIOT? Come over to our forum and post to your hearts content.

CONTRIBUTE

To contribute something to RIOT, please refer to our contributing document.

MAILING LISTS

LICENSE

  • Most of the code developed by the RIOT community is licensed under the GNU Lesser General Public License (LGPL) version 2.1 as published by the Free Software Foundation.
  • Some external sources, especially files developed by SICS are published under a separate license.

All code files contain licensing information.

For more information, see the RIOT website:

https://www.riot-os.org

Languages
C 92%
C++ 3%
Makefile 2.6%
Python 2.2%