Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/gd32v: add riotboot support #19411

Merged
merged 13 commits into from
Apr 19, 2023
Merged

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Mar 19, 2023

Contribution description

This PR provides riotboot support for GD32V.

Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:

PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash

Flash slot 0 and set RIOT_VERSION to 1

USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
> main(): This is RIOT! (Version: 1)
test_shell.

Flash slot 1 and set RIOT_VERSION to 2

USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
> main(): This is RIOT! (Version: 2)
test_shell.

Issues/PRs references

@github-actions github-actions bot added Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: sys Area: System Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms labels Mar 19, 2023
@gschorcht gschorcht added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 19, 2023
@riot-ci
Copy link

riot-ci commented Mar 19, 2023

Murdock results

✔️ PASSED

373b10e tests/riotboot_flashwrite: blacklist GD32V boards

Success Failures Total Runtime
6882 0 6882 08m:51s

Artifacts

@gschorcht
Copy link
Contributor Author

I had to push further commits that improve/fix gd32vf103_clock_init. This fix is required for riotboot if the application uses the USB peripheral. In this case, the core clock has to be changed from 108 MHz (riotboot) to 96 MHz (application).

@github-actions github-actions bot added the Platform: ARM Platform: This PR/issue effects ARM-based platforms label Mar 20, 2023
@gschorcht
Copy link
Contributor Author

Commit 53db2ba changes SLOT1_OFFSET to hex format because for better readability and compatibility with other address and offset numbers.

-DSLOT0_LEN=0xe000 -DSLOT0_OFFSET=0x4000 -DSLOT1_LEN=0xe000 -DSLOT1_OFFSET=73728 

vs

-DSLOT0_LEN=0xe000 -DSLOT0_OFFSET=0x4000 -DSLOT1_LEN=0xe000 -DSLOT1_OFFSET=0x12000

@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Apr 12, 2023
19411: cpu/gd32v: add riotboot support r=benpicco a=gschorcht

### Contribution description

This PR provides `riotboot` support for GD32V.

### Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:
```python
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash
```
Flash slot 0 and set `RIOT_VERSION` to 1
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
```
```python
> main(): This is RIOT! (Version: 1)
test_shell.
```
Flash slot 1 and set `RIOT_VERSION` to 2
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
```
```python
> main(): This is RIOT! (Version: 2)
test_shell.
```

### Issues/PRs references


19432: boards/esp32: deduplication in common ESP32x board definitions r=benpicco a=gschorcht

### Contribution description

The PR reduced code duplication in `boards/common/esp32*`.

The PR moves the header files from `boards/common/esp32s3/include` that can be used for all types of ESP32x SoCs to a new common ESP32x board definition which is then included by all common ESP32x board definitions.

### Testing procedure

Green CI.

### Issues/PRs references


19461: drivers/enc28j60: fix ISR routine and bth r=benpicco a=peteut



Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Alain Péteut <alain.peteut@yahoo.com>
@bors
Copy link
Contributor

bors bot commented Apr 12, 2023

Build failed (retrying...):

bors bot added a commit that referenced this pull request Apr 12, 2023
19411: cpu/gd32v: add riotboot support r=benpicco a=gschorcht

### Contribution description

This PR provides `riotboot` support for GD32V.

### Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:
```python
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash
```
Flash slot 0 and set `RIOT_VERSION` to 1
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
```
```python
> main(): This is RIOT! (Version: 1)
test_shell.
```
Flash slot 1 and set `RIOT_VERSION` to 2
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
```
```python
> main(): This is RIOT! (Version: 2)
test_shell.
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 12, 2023

Ah, riotboot_serial requires also commit a3b3ec9 from my riotboot-dfu branch.

@bors
Copy link
Contributor

bors bot commented Apr 12, 2023

Build failed:

@gschorcht gschorcht added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 12, 2023
@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Apr 16, 2023
19411: cpu/gd32v: add riotboot support r=benpicco a=gschorcht

### Contribution description

This PR provides `riotboot` support for GD32V.

### Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:
```python
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash
```
Flash slot 0 and set `RIOT_VERSION` to 1
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
```
```python
> main(): This is RIOT! (Version: 1)
test_shell.
```
Flash slot 1 and set `RIOT_VERSION` to 2
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
```
```python
> main(): This is RIOT! (Version: 2)
test_shell.
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@bors
Copy link
Contributor

bors bot commented Apr 16, 2023

Build failed:

@github-actions github-actions bot added the Area: examples Area: Example Applications label Apr 17, 2023
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Apr 18, 2023
`riotboot_slot` uses `ARRAY_SIZE` which is defined in `container.h` but not yet included on some plattforms.
To allow CPU specific definitions in `cpu.h`, `riscv_common/cpu.h` is renamed to ``riscv_common/cpu_common.h` and included in new `cpu.h` files for FE310 and GD32V.
To be able to reconfigure the PLL multiplier in clock configuration, the existing value has to be reset first. This becomes necessary when changing the core clock, e.g. when booting with riotboot an application that uses USB.
Using hex number for addresses and address offsets improves the readability.
Some platforms such as RISC-V don't support numbers given with unit (32K)
@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Apr 18, 2023
19411: cpu/gd32v: add riotboot support r=benpicco a=gschorcht

### Contribution description

This PR provides `riotboot` support for GD32V.

### Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:
```python
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash
```
Flash slot 0 and set `RIOT_VERSION` to 1
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
```
```python
> main(): This is RIOT! (Version: 1)
test_shell.
```
Flash slot 1 and set `RIOT_VERSION` to 2
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
```
```python
> main(): This is RIOT! (Version: 2)
test_shell.
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@bors
Copy link
Contributor

bors bot commented Apr 18, 2023

Build failed:

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Apr 19, 2023
@gschorcht
Copy link
Contributor Author

I had to blacklist GD32V boards. I hope that CI is now happy.

@benpicco
Copy link
Contributor

benpicco commented Apr 19, 2023

The board has 128k Flash, why does riotboot_flashwrite overflow it by 10k?
Almost feels like something got messed up with the linker script.

nvm those tests all use two slots which leave less than 64k for the app

@benpicco
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented Apr 19, 2023

Build succeeded:

@bors bors bot merged commit 88d1d2e into RIOT-OS:master Apr 19, 2023
@gschorcht
Copy link
Contributor Author

Thanks.

@gschorcht gschorcht deleted the cpu/gd32v/riotboot branch April 26, 2023 09:25
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants