Skip to content

[POC] Azure Integration in RIOT OS#20222

Closed
tanvirBsmrstu wants to merge 39 commits intoRIOT-OS:masterfrom
tanvirBsmrstu:az_clean_2023_04
Closed

[POC] Azure Integration in RIOT OS#20222
tanvirBsmrstu wants to merge 39 commits intoRIOT-OS:masterfrom
tanvirBsmrstu:az_clean_2023_04

Conversation

@tanvirBsmrstu
Copy link
Copy Markdown

Contribution description (3 modules, one package, one application)

  1. Zero-touch device provisioning with Device Provisioning Service using X.509 certificate.
  2. Cloud-to-Device and Device-to-Cloud messaging with Azure IoT Hub.
  3. Receiving and parsing Direct method invocation from Azure IoT Hub.
  4. Receiving and parsing Device Twins update notifications from Azure IoT Hub.
  • Azure IoT SDK for embedded C is integrated using a new RIOT package
  • "gnrc_wolfssl_tls" module uses wolfssl and gnrc to achieve TLS
  • "mqtts_riot_iface" module uses paho mqtt package and gnrc_wolfssl_tls module to achieve MQTTS
  • "az_riot_pnp_iface" module is a wrapper on top of MQTTS and azure SDK to provide a Plug-and-play flavour.
  • Scripts are provided to facilitate generating self signed certificates.
  • A demo application /examples/az_pnp_demo is provided with a reach Readme.md file.

Testing procedure

  • A demo application /examples/az_pnp_demo is provided with a reach Readme.md file.
    Please read carefully the Readme

Current Limitations

DNS is not integrated yet, please see the readme and use IP at the mentioned place for testing.
Error handling has to improve a lot.

Thanks,
Tanvir Hasan

dylad and others added 30 commits April 6, 2023 09:35
This function should not be called by the driver as USBUS will handle it already. So remove this call to prevent duplication

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
For the usbdev_fs peripheral, IN and OUT endpoints of the same index must have the same type.
For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous.
With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken.
Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect
This commit fixes all the access to these registers to prevent from modifying these bits when not needed

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
19462: cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport 2023.04] r=dylad a=dylad


### Contribution description

This backport PR provides two fixes for the usbdev_fs driver:

    Fix endpoints registration
    Fix assignment of toggleable bits in EP_REG(x) registers

These bugs were encountered with the USBUS MSC implementation.

Regarding the endpoints registration:

For the usbdev_fs peripheral, IN and OUT endpoints of the same index must have the same type.
For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous.
With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken.
Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP.

and for the second fix:

EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect
This commit fixes all the access to these registers to prevent from modifying these bits when not needed.
Without this patch, the endpoint status (VALID / NACK / STALL) can be erroneously modify because bits are not cleared when assigning the new content to the register and thus make the bits toggle and change values.

### Testing procedure
See RIOT-OS#19460


### Issues/PRs references

RIOT-OS#19460

Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
19456: usbus/msc: fixes for synopsys dwc2 [backport 2023.04] r=dylad a=dylad

### Contribution description
This is a backport PR containing two fixes for USBUS MSC driver so it can works with `usbdev_synopsys_dwc2` driver
See RIOT-OS#19455 for more context.


### Testing procedure
Same as RIOT-OS#19455 

### Issues/PRs references
See RIOT-OS#19455 


Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
(cherry picked from commit 2684870)
19472: drivers/usbus_synopsys_dwc2: fix interrupt handling in DMA mode [backport 2023.04] r=dylad a=MrKevinWeiss

# Backport of RIOT-OS#19459

### Contribution description

This PR fixes the interrupt handling for IN endpoints in DMA mode.

In DMA mode, both the `XFRC` (Transfer Complete) interrupt and the `TXFE` (TX FIFO Empty) interrupt for IN EP1 ... EPn were used to generate the `USBDEV_EVENT_TR_COMPLETE`. This led to problems with USBUS MSC. With this fix, the `TXFE` interrupt is used only in non-DMA mode or only for IN EP0 in DMA mode while the `XFRC` (Transfer Complete) is used only in DMA mode for IN EP1 ... EPn.

### Testing procedure

This PR should work together with PR RIOT-OS#19458 for SD Card interface for a board with USB HS port, for example:
```
USEMODULE='sdcard_spi mtd_sdcard_default periph_usbdev_hs_ulpi' \
CFLAGS='-DSDCARD_SPI_PARAM_CLK=GPIO_PIN\(PORT_I,1\) -DSDCARD_SPI_PARAM_MISO=GPIO_PIN\(PORT_B,14\) -DSDCARD_SPI_PARAM_MOSI=GPIO_PIN\(PORT_B,15\) -DSDCARD_SPI_PARAM_CS=GPIO_PIN\(PORT_A,8\)' \
BOARD=stm32f746g-disco make -j8 -C tests/usbus_msc flash
```
It should still work for CDC ECM for such a board:
```
USEMODULE='periph_usbdev_hs_ulpi stdio_cdc_acm' BOARD=stm32f746g-disco make -j8 -C tests/usbus_cdc_ecm flash
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
19473: drivers/at86rf2xx: fix default page being ignored [backport 2023.04] r=leandrolanzieri a=MrKevinWeiss

# Backport of RIOT-OS#19467



Co-authored-by: Jose Alamos <jose@alamos.cc>
19479: gnrc_netif/lorawan: fix setting nwkskey via NETOPT [backport 2023.04] r=leandrolanzieri a=MrKevinWeiss

# Backport of RIOT-OS#19475



Co-authored-by: Jose Alamos <jose@alamos.cc>
While testing examples/micropython I notice that the default of miniterm.py is actually miniterm.
To simplify user setups, this checks for miniterm.py first then falls back to miniterm.

(cherry picked from commit 6d72903)
19489: makefiles/tools/serial.inc.mk: Handle new miniterm versions [backport 2023.04] r=maribu a=MrKevinWeiss

# Backport of RIOT-OS#19444



### Contribution description

While testing examples/micropython I notice that the default of miniterm.py is actually miniterm. To simplify user setups, this checks for miniterm.py first then falls back to miniterm.

### Testing procedure

Take any board with any newish version of Ubuntu and run
```
make -C flash test examples/micropython
```

If you have `miniterm.py` in `PATH` or if it is `miniterm` both should work.

### Issues/PRs references



Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
gnrc_sixlowpan_iphc: check IPHC dispatch for truncation
gnrc_rpl_srh: check header fields consistency before substraction
19497: security fixes [backport 2023.04] r=kaspar030 a=MrKevinWeiss

### Contribution description

### Testing procedure

### Issues/PRs references

Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
This pulls in several fixes from these repositories:

* riot-sys:
    * Add `random` module to `riot-headers` (RIOT-OS/rust-riot-sys#26)
    * README: fix 2 typos (RIOT-OS/rust-riot-sys#31)
    * bindgen: Use 0.64 (RIOT-OS/rust-riot-sys#30)
    * wolfSSL support added (RIOT-OS/rust-riot-sys#28)
    * extern-types: Generate replacement types dynamically (RIOT-OS/rust-riot-sys#27)
    * Extern types: Add netq_t, make them large (RIOT-OS/rust-riot-sys#25)
    * doc: Suppress warnings about things C2Rust does not uphold (RIOT-OS/rust-riot-sys#23)
    * export macro_DAC_LINE (RIOT-OS/rust-riot-sys#22)
    * Add BINDGEN_OUTPUT_FILE export (RIOT-OS/rust-riot-sys#21)
* riot-wrappers:
    * DAC: Add wrapper around RIOTs DAC-interface (RIOT-OS/rust-riot-wrappers#36)
    * saul: Compatibly rename G* variants (RIOT-OS/rust-riot-wrappers#50)
    * tests: Add test for auto-init when auto-init debug is active (RIOT-OS/rust-riot-wrappers#48)
    * gcoap: Provide link encoder (RIOT-OS/rust-riot-wrappers#47)
    * Drop SUIT support in riot-wrappers (RIOT-OS/rust-riot-wrappers#44)
    * Add an auto init module (RIOT-OS/rust-riot-wrappers#45)
    * gcoap: Allow registration without scope for 'static listeners (RIOT-OS/rust-riot-wrappers#43)

Through direct dependency changes (the bindgen update), the number of
transitive dependencies could be reduced.

(cherry picked from commit de41031)
(cherry picked from commit 5f91bd8)
This helps remove duplicate code after previous updates.

(cherry picked from commit d630f00)
This fixes a regression by merging RIOT-OS/rust-riot-wrappers#55
(the "G" unit has been deprecated, but that deprecation was done wrong
in RIOT-OS/rust-riot-wrappers#50).

(cherry picked from commit 6724e85)
GCC 12 create a bogus array out of bounds warning as it assumes that
because there is special handling for `uart == 0` and `uart == 1`,
`uart` can indeed be `1`. There is an `assert(uart < UART_NUMOF)` above
that would blow up prior to any out of bounds access.

In any case, optimizing out the special handling of `uart == 1` for
when `UART_NUMOF == 1` likely improves the generated code and fixes
the warning.

    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:88:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
       88 |     ctx[uart].rx_cb = rx_cb;
          |     ~~~^~~~~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
       52 | static uart_isr_ctx_t ctx[UART_NUMOF];
          |                       ^~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:89:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
       89 |     ctx[uart].arg = arg;
          |     ~~~^~~~~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
       52 | static uart_isr_ctx_t ctx[UART_NUMOF];
          |                       ^~~

(cherry picked from commit d6499fa)
The OPENOCD_CMD_RESET_HALT was not longer correctly passed to the
script. This fixes the issue.

(cherry picked from commit f220c23)
19518: release-notes.txt: add 2023.04 release notes [backport 2023.04] r=MrKevinWeiss a=MrKevinWeiss

# Backport of RIOT-OS#19503



Co-authored-by: Jose Alamos <jose@alamos.cc>
19521: VERSION: add 2023.04 version file r=maribu a=MrKevinWeiss

### Contribution description

Adds the VERSION file for 2023.04.

### Testing procedure



Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
19505: Rust: Update dependencies [backport 2023.04] r=maribu a=maribu

# Backport of RIOT-OS#19495

### Contribution description

This updates both the RIOT-specific and generic dependencies of Rust examples and modules.

It also follows a deprecation from the G unit renaming originally done in RIOT-OS#19292.

### Testing procedure

* Green CI should do

### Issues/PRs references

Copying from one of the commits with some sed:

* riot-sys:
    * RIOT-OS/rust-riot-sys#26
    * RIOT-OS/rust-riot-sys#31
    * RIOT-OS/rust-riot-sys#30
    * RIOT-OS/rust-riot-sys#28
    * RIOT-OS/rust-riot-sys#27
    * RIOT-OS/rust-riot-sys#25
    * RIOT-OS/rust-riot-sys#23
    * RIOT-OS/rust-riot-sys#22
    * RIOT-OS/rust-riot-sys#21
* riot-wrappers:
    * RIOT-OS/rust-riot-wrappers#36
    * RIOT-OS/rust-riot-wrappers#50
    * RIOT-OS/rust-riot-wrappers#48
    * RIOT-OS/rust-riot-wrappers#47
    * RIOT-OS/rust-riot-wrappers#44
    * RIOT-OS/rust-riot-wrappers#45
    * RIOT-OS/rust-riot-wrappers#43
    * (later, when the mistake became apparent) RIOT-OS/rust-riot-wrappers#55

### How to do similar PRs

Updating the RIOT-related dependencies (which here also updated bindgen because the dependency of riot-sys changed):

```
$ for x in **/Cargo.lock; do cargo update --manifest-path=${x%.lock}.toml --package riot-sys --package riot-wrappers; done
```

Updating everything (should never really be needed, b/c if something has a concrete dependency change it'd say so, but dependencies generally get better over time):

```
$ for x in **/Cargo.lock; do cargo update --manifest-path=${x%.lock}.toml; done
```

Creating the commit message:

```
$ git log --first-parent --format='%s (%b)' 9c29faf55d4c14d2d7f55f8df5059c52af4e5317..e4973a6ee88427f702dac41b3dce4fd6b6b9689e | sed 's/Merges: //' | sed 's/^/    * /'
```

git shortlog unfortunately doesn't show the merges the way I prefer linking them. The versions in the command line can be taken from `git diff --text` and looking for the riot-sys or riot-wrappers line, respectively.

19509: cpu/cc26xx_cc13xx: Fix bogus array-bound warning [backport 2023.04] r=maribu a=maribu

# Backport of RIOT-OS#19504

### Contribution description

GCC 12 create a bogus array out of bounds warning as it assumes that because there is special handling for `uart == 0` and `uart == 1`, `uart` can indeed be `1`. There is an `assert(uart < UART_NUMOF)` above that would blow up prior to any out of bounds access.

In any case, optimizing out the special handling of `uart == 1` for when `UART_NUMOF == 1` likely improves the generated code and fixes the warning.

    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:88:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
       88 |     ctx[uart].rx_cb = rx_cb;
          |     ~~~^~~~~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
       52 | static uart_isr_ctx_t ctx[UART_NUMOF];
          |                       ^~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:89:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
       89 |     ctx[uart].arg = arg;
          |     ~~~^~~~~~
    /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
       52 | static uart_isr_ctx_t ctx[UART_NUMOF];
          |                       ^~~

### Testing procedure

The actual change is a pretty obvious one-liner, so that code review and a green CI should be sufficient. If not, running any UART example app without regression should do.

### Issues/PRs references

None

19510: tools/openocd: Fix handling of OPENOCD_CMD_RESET_HALT [backport 2023.04] r=maribu a=maribu

# Backport of RIOT-OS#19506

### Contribution description

The OPENOCD_CMD_RESET_HALT was not longer correctly passed to the script. This fixes the issue.

### Testing procedure

Flashing of e.g. the `cc2650-launchpad` with upstream OpenOCD should work again.

### Issues/PRs references

The change was added to RIOT-OS#19050 after testing the PR and before merging. I'm not sure if the fix never worked because of this, or if behavior of `target-export-variables` or GNU Make changed.

Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
@github-actions github-actions bot added Platform: native Platform: This PR/issue effects the native platform Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: network Area: Networking Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Area: timers Area: timer subsystems Area: tools Area: Supplementary tools Area: boards Area: Board ports Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports Area: USB Area: Universal Serial Bus Area: sys Area: System Area: examples Area: Example Applications labels Jan 3, 2024
@maribu
Copy link
Copy Markdown
Member

maribu commented Jan 3, 2024

Thanks for your pull request. Cloud integration is an area in which RIOT is indeed pretty lacking, despite often voiced interest in this from users. So work in this area is more than welcome 😄

Would you mind to rebase the PR against current HEAD? Github doesn't perform that well with figuring out what changes are indeed intended part of the PR when the history of the branch of the PR is to different; especially when merging upstream back into the feature branch. It eases the web based review process a lot when only the actual changes show up. Thanks 😄

@tanvirBsmrstu
Copy link
Copy Markdown
Author

Another pull request #20223 is created

@tanvirBsmrstu
Copy link
Copy Markdown
Author

Thanks @maribu for your appreciation.

Actually, I was working on 23.04 till now; I have been cleaning the project since last night and was a bit tired. Therefore I did not notice the huge amount of file changes. When I noticed it, I started creating another PR; and was late to see your message.
Sorry for creating two different PRs.

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: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: network Area: Networking Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework Area: timers Area: timer subsystems Area: tools Area: Supplementary tools Area: USB Area: Universal Serial Bus Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: ESP Platform: This PR/issue effects ESP-based platforms Platform: native Platform: This PR/issue effects the native platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants