19211: cpu/gd32v: move board dependent RTT configs to board config r=maribu a=gschorcht
### Contribution description
This PR fixes the problem that the RTT frequency is defined to be 40.0 kHz instead of 32.768 kHz if `TEST_KCONFIG=1` is not defined.
The problem was caused by the order in which the headers were included. In `cpu/gd32v/include/periph_cpu.h` the RTT frequency was defined to be 32.768 kHz or 40.0 kHz, depending on the `CONFIG_BOARD_HAS_LXTAL` configuration of the board. If `TEST_KCONFIG=1` is used, it is defined in `autoconfig.h` and is always known, but without `TEST_KCONFIG=1` it is defined in the `periph_conf.h` of the board. If `periph_cpu.h` is included but not `periph_conf.h`, `CONFIG_BOARD_HAS_LXTAL` is not defined without `TEST_KCONFIG=1` and the RTT frequency is defined to be 40.0 kHz.
The solution is to move board dependent RTT configurations to `periph_common.conf`.
### Testing procedure
```
BOARD=sipeed-longan-nano make -C tests/periph_rtt flash
```
should still work.
### Issues/PRs references
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
19206: doc/porting-boards.md: fix code snippets in md view r=benpicco a=krzysztof-cabaj
### Contribution description
Current version of the file [`porting-boards.md`](https://github.com/RIOT-OS/RIOT/blob/master/doc/doxygen/src/porting-boards.md) did not present correctly in the github preview two snippets, presented in the sections: `doc.txt` and `Using Common code`.
This PR fix this issue.
### Testing procedure
Check if these changes do not corrupt generated doxygen.
### Issues/PRs references
None
Co-authored-by: krzysztof-cabaj <kcabaj@gmail.com>
19209: cpu/gd32v: add periph_pwm support r=benpicco a=gschorcht
### Contribution description
This PR provides the `periph_pwm` support for GD32VF103.
It includes a bug fix (2c6e527339) of `periph_timer` which clears pending interrupts on setting the timer before the interrupt is enabled. This avoids that a pending interrupt is triggered immediately when the timer is set. The bug caused `tests/periph_timer` and `tests/periph_timer_periodic` to crash. (I could split-off this bug fix if necessary).
Furthermore, the default timer configuration has been extended and reordered. `TIMER0` can be used now as timer device (0dfbdebaf7). The default timer configuration has been changed (377b5b321c) so that `TIMER0` and `TIMER1` are always timer devices. `TIMER2` can only be used as timer device if it is not used for PWM devices. `TIMER3` and `TIMER4` are only available as timer devices if they are supported by the CPU model and not used for PWM devices.
### Testing procedure
- `tests/periph_timer` and `tests/periph_timer_periodic` should work now. Without the PR, these tests lead to kernel panic.
- `tests/periph_pwm` should work on any GD32VF103 board. Command `osci` should also let LED1 and LED2 oscillate.
### Issues/PRs references
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
The default timer configuration has been changed so that `TIMER0` and `TIMER1` are always timer devices. `TIMER2` can only be used as timer device if it is not used for PWM devices. `TIMER3` and `TIMER4` are only available as timer devices if they are supported by the CPU model and not used for PWM devices.
When a timer is set, any pending interrupts must be cleared before the interrupt is enabled for the channel. Otherwise the interrupt would be triggered immediately when the timer is set.
19199: sys/suit: Ensure previous thread is stopped before reusing its stack r=benpicco a=chrysn
### Contribution description
Closes: https://github.com/RIOT-OS/RIOT/issues/19195
If the thread has released the mutex but the thread has not terminated (which happens in the situation that would previously have overwritten a still active thread's state), then a warning is shown and the trigger is ignored.
### Testing procedure
This should work before and after:
* `make -C examples/suit_update BOARD=native all term`
* `aiocoap-client coap://'[fe80::3c63:beff:fe85:ca96%tapbr0]'/suit/trigger -m POST --payload 'coap://[2001:db8::]/foo'`
* In parallel, on the RIOT shell, run `suit fetch coap://[2001:db8::]/foo`
* After the first download fails, the second one starts right away ("suit_worker: update failed, hdr invalid" / "suit_worker: started").
Run again with the worker thread on low priority:
```patch
diff --git a/sys/suit/transport/worker.c b/sys/suit/transport/worker.c
index a54022fb28..e26701a64c 100644
--- a/sys/suit/transport/worker.c
+++ b/sys/suit/transport/worker.c
`@@` -70 +70 `@@`
-#define SUIT_COAP_WORKER_PRIO THREAD_PRIORITY_MAIN - 1
+#define SUIT_COAP_WORKER_PRIO THREAD_PRIORITY_MAIN + 1
```
Before, this runs the download once silently (no clue why it doesn't run it twice, but then again, I claim there's concurrent memory access from two thread, so who knows what happens). After, it runs a single download and shows an error message for the second one once the first is complete ("Ignoring SUIT trigger: worker is still busy.").
### Issues/PRs references
This may be made incrementally easier by https://github.com/RIOT-OS/RIOT/pull/19197 -- that PR as it is now would spare us the zombification (because returning would do that), and having a `wait` function would allow us to turn the new error case into a success.
19205: boards/common: add common timer config for GD32VF103 boards r=benpicco a=benpicco
19207: examples/gnrc_border_router: static: use router from advertisements by default r=benpicco a=benpicco
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
19202: cpu/gd32v: add periph_rtt support r=benpicco a=gschorcht
### Contribution description
This PR provides the `periph_rtt` support and is one of a bunch of PRs that complete the peripheral drivers for GD32VF103.
### Testing procedure
`tests/periph_rtt` should work and give the following results:
```
Help: Press s to start test, r to print it is ready
START
main(): This is RIOT! (Version: 2023.04-devel-199-g2d429-cpu/gd32v/periph_rtt)
RIOT RTT low-level driver test
RTT configuration:
RTT_MAX_VALUE: 0xffffffff
RTT_FREQUENCY: 32768
Testing the tick conversion
Trying to convert 1 to seconds and back
Trying to convert 256 to seconds and back
Trying to convert 65536 to seconds and back
Trying to convert 16777216 to seconds and back
Trying to convert 2147483648 to seconds and back
All ok
Initializing the RTT driver
This test will now display 'Hello' every 5 seconds
RTT now: 148
Setting initial alarm to now + 5 s (163988)
rtt_get_alarm() PASSED
Done setting up the RTT, wait for many Hellos
{ "threads": [{ "name": "idle", "stack_size": 256, "stack_used": 216 }]}
{ "threads": [{ "name": "main", "stack_size": 1280, "stack_used": 480 }]}
Hello
Hello
Hello
Hello
```
### Issues/PRs references
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
19204: boards/sipeed-longan-nano: default to flashing via DFU r=gschorcht a=benpicco
Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
19200: blobs: include documentation in doxygen r=kaspar030 a=bergzand
### Contribution description
This PR changes the blob makefile documentation to be included in the doxygen output. I ~~didn't~~ slightly change the documentation itself to satisfy doxygen, just added another # and the doxygen boiler plating .
### Testing procedure
Take a look at the docs
### Issues/PRs references
None
Co-authored-by: Koen Zandberg <koen@bergzand.net>
19192: cpu/esp32: fixes for boot issues and crashes on ESP32 r=kaspar030 a=Flole998
### Contribution description
In syscalls_init() there is a call to malloc(), which will return NULL if the heap is not initialized before, causing the entire board to fail booting if MODULE_ESP_IDF_HEAP is used.
API of [vTaskDelete()](https://www.freertos.org/a00126.html) says, that if NULL is passed to vTaskDelete the calling task should be deleted.
This PR needs a backport to 2023.01.
### Testing procedure
Just compiling on the ESP32S2 and running it with WiFi caused it to not start anymore, no output, nothing. When Null is written to that null-pointer it hangs.
The second commit fixed an issue/assertion fail that happens when the WiFi connection drops/disconnects.
### Issues/PRs references
Issue was introduced with PR #19146
Co-authored-by: Flole998 <Flole998@users.noreply.github.com>
In syscalls_init() there is a call to malloc(), which will return NULL if the heap is not initialized before, causing the entire board to fail booting if MODULE_ESP_IDF_HEAP is used.
19185: cpu/gd32v: add periph_gpio_irq support r=gschorcht a=gschorcht
### Contribution description
This PR provides the `periph_gpio_irq` support and is one of a bunch of follow up PRs that complete the peripheral drivers for GD32VF103.
### Testing procedure
Use a GD32VF103 board and flash `tests/periph_gpio`. Note: The Sipeed Longan Nano works also with `seeedstudio-gd32` board defintion and could be used for testing.
```
BOARD=seeedstudio-gd32 make -C tests/periph_gpio flash (until PR #19170 is merged only `seeedstudio
```
With the GPIO PB8 and PB9 connected, the following test sequence should work:
```
> init_out 1 8
> init_int 1 9 2 0
GPIO_PIN(1, 9) successfully initialized as ext int
> set 1 8
INT: external interrupt from pin 9
> clear 1 8
INT: external interrupt from pin 9
```
### Issues/PRs references
19187: cpu/gd32v: add pm_layered support in periph_pm r=gschorcht a=gschorcht
### Contribution description
This PR provides the `pm_layered` support and is one of a bunch of follow up PRs that complete the peripheral drivers for GD32VF103.
Since the configuration of the deep sleep and the standby mode require the access CSR (control and status registers) of the MCU, the Nuclei-SDK NMSIS is added as package which provides a low-level interface for Nuclei-based RISC-V MCUs.
### Testing procedure
The best way to test it is to rebase this PR onto PR #19186 and to flash `tests/periph_pm` to any GD32VF103 board. Note: The Sipeed Longan Nano works also with `seeedstudio-gd32` board definition and could be used for testing.
```
BOARD=seeedstudio-gd32 make -C tests/periph_pm flash
```
The test output should be:
```
main(): This is RIOT! (Version: 2023.04-devel-174-g7dc91-cpu/gd32v/periph_pm_test)
...
mode 0 blockers: 1
mode 1 blockers: 2
mode 2 blockers: 0
Lowest allowed mode: 2
```
Using command the `set_rtc 1 5` command should let the MCU deep sleep for 5 seconds
```
> set_rtc 1 5
Setting power mode 1 for 5 seconds.
␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀>
```
while command `set_rtc 1 5` should set the MCU into the standby mode which is left with restart.
```
> set_rtc 0 5
Setting power mode 0 for 5 seconds.
main(): This is RIOT! (Version: 2023.04-devel-174-g7dc91-cpu/gd32v/periph_pm_test)
...
mode 0 blockers: 1
mode 1 blockers: 2
mode 2 blockers: 0
Lowest allowed mode: 2
>
```
The garbage on UART interface after deep sleep is caused by the clock synchronisation that becomes necessary after deep sleep and is the same as for other boards.
### Issues/PRs references
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
19170: boards/sipeed-longan-nano: add definition for the Sipeed Longan Nano GD32VF103 board r=benpicco a=gschorcht
### Contribution description
This PR add the support for the [Sipeed Longan Nano](https://longan.sipeed.com/en) board, a GD32VF103 development board with the GigaDevice GD32VF103CBT8 RISC-V MCU. This includes moving the common board definitions for GDV32F103 boards from `boards/seeedstudio-gd32` to `boards/common/gd32v`.
**[Update]** At first glance, the existing peripheral definition for `seeedstudio-gd32` seems to fit exactly for `sipeed-longan-nano`. But at second glance it becomes clear that `seeedstudio-gd32` which is using the GD32VF103VBT6 instead of the GD32VF103CBT6 has more peripherals and much more peripheral pins are broken out. This allows a more extensive and flexible peripheral definition (more timers, more ADC pins, more UART interfaces, ...). So it doesn't seem to be a good idea to share the peripheral definitions between these boards.
This PR depends on PR #19166 and includes this PR for the moment.
### Testing procedure
t.b.d.
### Issues/PRs references
Depends on PR #19166
19190: pkg/wolfssl: Fix memory leaks in wolfSSL sock_tls r=benpicco a=Flole998
When sk->ssl is NULL it doesn't need to be free()d, otherwise it may be free()d
19191: Fix SX126X-STM32WL module in Kconfig r=MrKevinWeiss a=MrKevinWeiss
### Contribution description
Master is broken due to kconfig mismatch for the `nucleo-wl55jc`. The radio was just not declared.
This fixes the board and cleans up some of the SX126X kconfig.
### Testing procedure
Murdock should pass
### Issues/PRs references
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Flole998 <Flole998@users.noreply.github.com>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>