-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support PROVES Flight Control Board v5e (SX1262 radio) #18
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
base: main
Are you sure you want to change the base?
Changes from all commits
55eef15
e5d1b37
3d87c61
8665bc9
fcfff6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_PROVES_FLIGHT_CONTROL_BOARD_V5E | ||
| select SOC_RP2350A_M33 if BOARD_PROVES_FLIGHT_CONTROL_BOARD_V5E_RP2350A_M33 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # PROVES Flight Control Board v5e — DTS = upstream Pico 2 base + proves_flight_control_board_v5e_hardware.dtsi. | ||
|
|
||
| board: | ||
| name: proves_flight_control_board_v5e | ||
| full_name: PROVES Flight Control Board v5e | ||
| vendor: PROVES | ||
| socs: | ||
| - name: rp2350a |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Project-specific hardware for PROVES Flight Control Board v5e. | ||
| * Same wiring intent as the v5 port, but the v5e carries an SX126x-based | ||
| * LoRa module (E22-400M30S) instead of the v5's SX1276. | ||
| */ | ||
|
|
||
| #include <zephyr/dt-bindings/lora/sx126x.h> | ||
|
|
||
| &zephyr_udc0 { | ||
| /* Control port */ | ||
| cdc_acm_uart0: cdc_acm_uart0 { | ||
| compatible = "zephyr,cdc-acm-uart"; | ||
| }; | ||
| /* Data port */ | ||
| cdc_acm_uart1: cdc_acm_uart1 { | ||
| compatible = "zephyr,cdc-acm-uart"; | ||
| }; | ||
| }; | ||
|
|
||
| &pinctrl { | ||
| spi1_default: spi1_default { | ||
| group1 { | ||
| pinmux = <SPI1_SCK_P10>, <SPI1_TX_P11>; | ||
| }; | ||
|
|
||
| group2 { | ||
| pinmux = <SPI1_RX_P12>; | ||
| input-enable; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &spi1 { | ||
| status = "okay"; | ||
| cs-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; | ||
| pinctrl-0 = <&spi1_default>; | ||
| pinctrl-names = "default"; | ||
|
|
||
| lora0: sx1262@0 { | ||
| compatible = "semtech,sx1262"; | ||
| reg = <0>; | ||
| spi-max-frequency = <125000>; | ||
| reset-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; | ||
| busy-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; | ||
| dio1-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; | ||
| tx-enable-gpios = <&gpio0 21 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; | ||
| rx-enable-gpios = <&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; | ||
| dio3-tcxo-voltage = <SX126X_DIO3_TCXO_1V8>; | ||
| tcxo-power-startup-delay-ms = <10>; | ||
| rx-boosted; | ||
| label = "E22-400M30S"; | ||
| }; | ||
| }; | ||
|
|
||
| / { | ||
| chosen { | ||
| zephyr,console = &cdc_acm_uart0; | ||
| }; | ||
|
|
||
| fstab { | ||
| compatible = "zephyr,fstab"; | ||
| ffs1: ffs1 { | ||
| compatible = "zephyr,fstab,fatfs"; | ||
| disk-access; | ||
| automount; | ||
| mount-point = "/"; | ||
| }; | ||
| }; | ||
|
|
||
| ramdisk0 { | ||
| compatible = "zephyr,ram-disk"; | ||
| disk-name = "RAM"; | ||
| sector-size = <512>; | ||
| sector-count = <128>; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Same composition as Zephyr upstream rpi_pico2_rp2350a_m33.dts, plus | ||
| * proves_flight_control_board_v5e_hardware.dtsi (project-specific nodes only). | ||
| */ | ||
|
|
||
| /dts-v1/; | ||
|
|
||
| #include <raspberrypi/rpi_pico/rp2350a.dtsi> | ||
| #include <raspberrypi/rpi_pico/m33.dtsi> | ||
| #include <../boards/raspberrypi/rpi_pico2/rpi_pico2.dtsi> | ||
| #include <../boards/raspberrypi/common/rpi_pico-led.dtsi> | ||
| #include "proves_flight_control_board_v5e_hardware.dtsi" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| identifier: proves_flight_control_board_v5e/rp2350a/m33 | ||
| name: PROVES Flight Control Board v5e (RP2350, Cortex-M33) | ||
| type: mcu | ||
| arch: arm | ||
| flash: 4096 | ||
| ram: 520 | ||
| toolchain: | ||
| - zephyr | ||
| - gnuarmemb | ||
| supported: | ||
| - adc | ||
| - clock | ||
| - counter | ||
| - dma | ||
| - gpio | ||
| - hwinfo | ||
| - i2c | ||
| - pwm | ||
| - spi | ||
| - uart | ||
| - usbd | ||
| - watchdog |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Minimal defaults — same baseline as upstream rpi_pico2_rp2350a_m33_defconfig. | ||
| # Application merges prj.conf on top. | ||
|
|
||
| CONFIG_BUILD_OUTPUT_HEX=y | ||
| CONFIG_BUILD_OUTPUT_UF2=y | ||
| CONFIG_CLOCK_CONTROL=y | ||
| CONFIG_CONSOLE=y | ||
| CONFIG_GPIO=y | ||
| CONFIG_RESET=y | ||
| CONFIG_SERIAL=y | ||
| CONFIG_UART_CONSOLE=y | ||
| CONFIG_UART_INTERRUPT_DRIVEN=y | ||
| CONFIG_USE_DT_CODE_PARTITION=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Patches | ||
|
|
||
| Local patches for submodules that cannot carry the change directly (the | ||
| `lib/zephyr-workspace/zephyr` submodule points at upstream | ||
| `zephyrproject-rtos/zephyr`). | ||
|
|
||
| ## zephyr-sx126x-wakeup-busy-delay.patch | ||
|
|
||
| **Required for SX126x-based boards (`proves_flight_control_board_v5e`).** | ||
|
|
||
| The Zephyr SX126x driver polls the BUSY line immediately after the wake-up | ||
| SPI transaction. The chip needs up to ~340us (datasheet warm-start time) | ||
| after the wake-up NSS edge before it is ready, and there is a window where | ||
| BUSY has not yet been asserted. When the poll wins that race, the next SPI | ||
| command is clocked into a chip that is still starting up and is silently | ||
| ignored. Since the driver re-enters sleep after every operation and the | ||
| first command after wake is always `SetRfFrequency`, the practical symptom | ||
| is that `SET_FREQ` intermittently does not retune the radio (~40% of | ||
| attempts measured on a Flight Control Board v5e in release builds; debug | ||
| builds mask the race because logging adds delay). | ||
|
|
||
| Apply with: | ||
|
|
||
| ``` | ||
| cd lib/zephyr-workspace/zephyr | ||
| git apply ../../../patches/zephyr-sx126x-wakeup-busy-delay.patch | ||
| ``` | ||
|
|
||
| This should be submitted to upstream Zephyr; the patch can be dropped once | ||
| the submodule advances past a release containing the fix. SX127x-based | ||
| boards (`ground_radio_controller`, v5) do not compile this file and are | ||
| unaffected. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| diff --git a/drivers/lora/loramac_node/sx126x.c b/drivers/lora/loramac_node/sx126x.c | ||
| index 6221943f5..d4ac247b9 100644 | ||
| --- a/drivers/lora/loramac_node/sx126x.c | ||
| +++ b/drivers/lora/loramac_node/sx126x.c | ||
| @@ -394,6 +394,14 @@ void SX126xWakeup(void) | ||
| return; | ||
| } | ||
|
|
||
| + /* The chip takes up to ~340us (datasheet t_woff, warm start) after | ||
| + * the wake-up NSS edge before it is ready. Polling BUSY immediately | ||
| + * can sample it before the chip has asserted it, in which case the | ||
| + * next command is clocked into a device still starting up and is | ||
| + * silently ignored. Wait out the startup window before polling. | ||
| + */ | ||
| + k_busy_wait(500); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit confused about this patch. We're not sleeping the radio as far as I know. And in any case the datasheet doesn't say "wait after wake" to send commands, it says "wait after sleep". It is possible the delay just changed the timing of things so as to disguise a race condition causing the intermittent SET_FREQ failures the new README mentions. |
||
| + | ||
| LOG_DBG("Waiting for device..."); | ||
| SX126xWaitOnBusy(); | ||
| LOG_DBG("Device ready"); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Label the shell command block.
Line 24 should use
```bashso Markdown linting can identify the command language.🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 24-24: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Source: Linters/SAST tools