diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4afe61..7cca0c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,23 +17,22 @@ jobs: fail-fast: false matrix: include: + - manifest: ncs-serial-modem/west.yml + target: thingy91x/nrf9151/ns + app: ncs-serial-modem + sysbuild: true - manifest: west-ncs.yml - target: nrf9160dk/nrf9160/ns + target: thingy91x/nrf5340/cpuapp app: gateway sysbuild: true + - manifest: ncs-serial-modem/west.yml + target: nrf9160dk/nrf9160/ns + app: ncs-serial-modem + sysbuild: true - manifest: west-ncs.yml target: nrf9160dk/nrf52840 - app: controller - sysbuild: false - - manifest: west-ncs.yml - target: thingy91x/nrf9151/ns app: gateway sysbuild: true - - manifest: west-thingy91x-controller.yml - target: thingy91x/nrf5340/cpunet - app: controller - sysbuild: true - extra_args: -DSB_CONF_FILE=sysbuild/nrf5340_cpuapp.conf - manifest: west-zephyr.yml target: frdm_rw612 artifact_suffix: -ethernet @@ -74,11 +73,6 @@ jobs: git config --global user.name "Git User" west patch apply || true - - name: Manual Patch - if: ${{ matrix.manifest == 'west-thingy91x-controller.yml' }} - run: | - west forall zephyr -c "git am $GITHUB_WORKSPACE/pouch-gateway/zephyr/patches/thingy91x-controller/zephyr/*.patch" - - name: Install pip packages run: | uv pip install \ @@ -121,8 +115,5 @@ jobs: build/${{ matrix.sysbuild && matrix.app || '' }}/zephyr/zephyr.hex build/${{ matrix.sysbuild && matrix.app || '' }}/zephyr/zephyr.elf build/${{ matrix.sysbuild && matrix.app || '' }}/zephyr/zephyr.map - ${{ ((matrix.manifest == 'west-ncs.yml') && 'build/merged.hex') || '' }} - ${{ ((matrix.manifest == 'west-thingy91x-controller.yml') && 'build/merged.hex') || '' }} - ${{ ((matrix.manifest == 'west-thingy91x-controller.yml') && 'build/merged_CPUAPP.hex') || '' }} - ${{ ((matrix.manifest == 'west-thingy91x-controller.yml') && 'build/empty_app_core/zephyr/zephyr.elf') || '' }} - ${{ (matrix.sysbuild && (matrix.manifest == 'west-ncs.yml') && 'build/dfu_application.zip') || '' }} + ${{ ((matrix.manifest != 'west-zephyr.yml') && 'build/merged.hex') || '' }} + ${{ (matrix.sysbuild && (matrix.manifest != 'west-zephyr.yml') && 'build/dfu_application.zip') || '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9257681..1fc791e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,28 +26,24 @@ jobs: run: | mkdir -p release - mv artifacts/gateway-nrf9160dk-nrf9160-ns/merged.hex \ + mv artifacts/ncs-serial-modem-thingy91x-nrf9151-ns/merged.hex \ + release/thingy91x_nrf9151.hex + mv artifacts/ncs-serial-modem-thingy91x-nrf9151-ns/ncs-serial-modem/zephyr/zephyr.elf \ + release/thingy91x_nrf9151.elf + mv artifacts/gateway-thingy91x-nrf5340-cpuapp/merged.hex \ + release/thingy91x_nrf5340.hex + mv artifacts/gateway-thingy91x-nrf5340-cpuapp/gateway/zephyr/zephyr.elf \ + release/thingy91x_nrf5340.elf + + mv artifacts/ncs-serial-modem-nrf9160dk-nrf9160-ns/merged.hex \ release/nrf9160dk_nrf9160.hex - mv artifacts/gateway-nrf9160dk-nrf9160-ns/gateway/zephyr/zephyr.elf \ - release/nrf9160dk_nrf9160_ns.elf - mv artifacts/controller-nrf9160dk-nrf52840/zephyr/zephyr.hex \ + mv artifacts/ncs-serial-modem-nrf9160dk-nrf9160-ns/ncs-serial-modem/zephyr/zephyr.elf \ + release/nrf9160dk_nrf9160.elf + mv artifacts/gateway-nrf9160dk-nrf52840/merged.hex \ release/nrf9160dk_nrf52840.hex - mv artifacts/controller-nrf9160dk-nrf52840/zephyr/zephyr.elf \ + mv artifacts/gateway-nrf9160dk-nrf52840/gateway/zephyr/zephyr.elf \ release/nrf9160dk_nrf52840.elf - mv artifacts/gateway-thingy91x-nrf9151-ns/merged.hex \ - release/thingy91x_nrf9151.hex - mv artifacts/gateway-thingy91x-nrf9151-ns/gateway/zephyr/zephyr.elf \ - release/thingy91x_nrf9151_ns.elf - mv artifacts/controller-thingy91x-nrf5340-cpunet/merged_CPUAPP.hex \ - release/thingy91x_nrf5340_cpuapp.hex - mv artifacts/controller-thingy91x-nrf5340-cpunet/empty_app_core/zephyr/zephyr.elf \ - release/thingy91x_nrf5340_cpuapp.elf - mv artifacts/controller-thingy91x-nrf5340-cpunet/merged.hex \ - release/thingy91x_nrf5340_cpunet.hex - mv artifacts/controller-thingy91x-nrf5340-cpunet/controller/zephyr/zephyr.elf \ - release/thingy91x_nrf5340_cpunet.elf - mv artifacts/gateway-frdm_rw612-ethernet/zephyr.hex \ release/frdm_rw612-ethernet.hex mv artifacts/gateway-frdm_rw612-ethernet/zephyr.elf \ diff --git a/README.md b/README.md index 3431117..6a3473b 100644 --- a/README.md +++ b/README.md @@ -76,25 +76,23 @@ recommend using these binaries as the fastest way to get started. 1. Install the [`nrfutil`](https://www.nordicsemi.com/Products/Development-tools/nRF-Util) CLI tool. -2. Program the nRF5340 Bluetooth Controller Firmware +2. Program the nRF9151 Serial Modem Firmware - a. Position the SWD selection switch (`SW2`) to `nRF53` + a. Position the SWD selection switch (`SW2`) to `nRF91` - b. Issue the following command to program the `app` core: - ``` - nrfutil device program --firmware thingy91x_nrf5340_cpuapp.hex --x-family nrf53 --core application + b. Issue the following command: ``` - c. Issue the following command to program the `net` core: + nrfutil device program --firmware thingy91x_nrf9151.hex --x-family nrf91 ``` - nrfutil device program --firmware thingy91x_nrf5340_cpunet.hex --x-family nrf53 --core network -3. Program the nRF9151 Gateway Firmware + +3. Program the nRF5340 Gateway Firmware a. Power cycle the device and position the SWD selection switch (`SW2`) to - `nRF91` + `nRF53` b. Issue the following command: ``` - nrfutil device program --firmware thingy91x_nrf9151.hex --x-family nrf91 + nrfutil device program --firmware thingy91x_nrf5340.hex --x-family nrf53 --core application ``` @@ -106,22 +104,23 @@ CLI tool. 1. Install the [`nrfutil`](https://www.nordicsemi.com/Products/Development-tools/nRF-Util) CLI tool. -2. Program the nRF52840 Bluetooth Controller Firmware +2. Program the nRF9160 Serial Modem Firmware - a. Position the SWD selection switch (`SW10`) to `nRF52` + a. Position the SWD selection switch (`SW10`) to `nRF91` b. Issue the following command: ``` - nrfutil device program --firmware nrf9160dk_nrf52840.hex --x-family nrf52 + nrfutil device program --firmware nrf9160dk_nrf9160.hex --x-family nrf91 ``` -3. Program the nRF9160 Gateway Firmware + +3. Program the nRF52840 Gateway Firmware a. Power cycle the device and position the SWD selection switch (`SW10`) to - `nRF91` + `nRF52` b. Issue the following command: ``` - nrfutil device program --firmware nrf9160dk_nrf9160.hex --x-family nrf91 + nrfutil device program --firmware nrf9160dk_nrf52840.hex --x-family nrf52 ``` @@ -179,57 +178,55 @@ west patch apply #### Thingy:91 X -Controller on nRF5340 NET core does not work yet with newest NCS -version (for unknown reason yet), so it is required to use older version -of NCS which is specified in `west-thingy91x-controller.yml`. In order -to checkout proper revision and apply required patches type: - -``` -west config manifest.file west-thingy91x-controller.yml && west update -west forall zephyr -c "git am $(west topdir)/pouch-gateway/zephyr/patches/thingy91x-controller/zephyr/*.patch" -``` - -Bluetooth controller is running on the nRF5340 NET core. This means that proper -firmware needs to be flashed (HCI controller over UART) in order to -access Bluetooth from nRF9151 chip. - -This is done by by changing `SWD` switch (`SW2`) from `nRF91` to `nRF53` -on Thingy, then building and flashing firmware with: +Serial modem firmware runs on the nRF9151 chip, providing LTE +connectivity to the gateway over UART. Switch to serial modem manifest, +build and flash by changing the `SWD` switch (`SW2`) to `nRF91`, then: ``` -west build -p -b thingy91x/nrf5340/cpunet pouch-gateway/controller --sysbuild -- -DSB_CONF_FILE=sysbuild/nrf5340_cpuapp.conf +west config manifest.file ncs-serial-modem/west.yml +west update +west patch apply +west build -p -b thingy91x/nrf9151/ns pouch-gateway/ncs-serial-modem/ west flash ``` -Gateway firmware runs on nRF9151 chip. There is direct access to LTE -modem and also Bluetooth Host stack, which communicates with Bluetooth -Controller over UART. Build and flash it with: +Gateway firmware runs on the nRF5340 chip. It runs the Bluetooth Host +stack and communicates with the nRF9151 serial modem over UART for +Internet access. Switch back to NCS manifest, build and flash by +changing the `SWD` switch (`SW2`) to `nRF53`, then: ``` -west build -p -b thingy91x/nrf9151/ns pouch-gateway/gateway --sysbuild +west config manifest.file west-ncs.yml +west update +west patch apply +west build -p -b thingy91x/nrf5340/cpuapp --sysbuild pouch-gateway/gateway/ west flash ``` #### nRF9160 DK -Bluetooth controller is running on nRF52840. This means that proper -firmware needs to be flashed (HCI controller over UART) in order to -access Bluetooth from nRF9160 chip. - -This is done by by changing `SWD` switch (`SW10`) from `nRF91` to -`nRF52` on development kit, then building and flashing firmware with: +Serial modem firmware runs on the nRF9160 chip, providing LTE +connectivity to the gateway over UART. Switch to serial modem manifest, +build and flash by changing the `SWD` switch (`SW10`) to `nRF91`, then: ``` -west build -p -b nrf9160dk/nrf52840 pouch-gateway/controller +west config manifest.file ncs-serial-modem/west.yml +west update +west patch apply +west build -p -b nrf9160dk/nrf9160/ns pouch-gateway/ncs-serial-modem/ west flash ``` -Gateway firmware runs on nRF9160 chip. There is direct access to LTE -modem and also Bluetooth Host stack, which communicats with Bluetooth -Controller over UART. Build and flash it with: +Gateway firmware runs on the nRF52840 chip. It runs the Bluetooth Host +stack and communicates with the nRF9160 serial modem over UART for +Internet access. Switch back to NCS manifest, build and flash by +changing the `SWD` switch (`SW10`) to `nRF52`, then: ``` -west build -p -b nrf9160dk/nrf9160/ns pouch-gateway/gateway --sysbuild +west config manifest.file west-ncs.yml +west update +west patch apply +west build -p -b nrf9160dk/nrf52840 --sysbuild pouch-gateway/gateway/ west flash ``` diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt deleted file mode 100644 index 4851186..0000000 --- a/controller/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -project(pouch_gateway_controller) - -if(CONFIG_UART_ASYNC_API AND NOT CONFIG_NRF_SW_LPUART) - target_sources(app PRIVATE - ${ZEPHYR_BASE}/samples/bluetooth/hci_uart_async/src/hci_uart_async.c - ${ZEPHYR_BASE}/samples/bluetooth/hci_uart_async/src/main.c - ) -else() - target_sources(app PRIVATE - ${ZEPHYR_BASE}/samples/bluetooth/hci_uart/src/main.c - ) -endif() diff --git a/controller/boards/nrf52840dongle_nrf52840.conf b/controller/boards/nrf52840dongle_nrf52840.conf deleted file mode 100644 index 60c8520..0000000 --- a/controller/boards/nrf52840dongle_nrf52840.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_CONSOLE=n -CONFIG_STDOUT_CONSOLE=n -CONFIG_UART_CONSOLE=n - -CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Zephyr HCI UART sample" -CONFIG_USB_CDC_ACM=y -CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n diff --git a/controller/boards/nrf9160dk_nrf52840.conf b/controller/boards/nrf9160dk_nrf52840.conf deleted file mode 100644 index 27b0b19..0000000 --- a/controller/boards/nrf9160dk_nrf52840.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_GPIO=y -CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_BT_CTLR_ASSERT_HANDLER=y - -CONFIG_UART_1_ASYNC=y -CONFIG_UART_1_INTERRUPT_DRIVEN=n -CONFIG_NRF_SW_LPUART=y -CONFIG_NRF_SW_LPUART_INT_DRIVEN=y diff --git a/controller/boards/nrf9160dk_nrf52840.overlay b/controller/boards/nrf9160dk_nrf52840.overlay deleted file mode 100644 index f97eb90..0000000 --- a/controller/boards/nrf9160dk_nrf52840.overlay +++ /dev/null @@ -1,67 +0,0 @@ -/* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - -#include -#include - -&pinctrl { - uart0_default_alt: uart0_default_alt { - group1 { - psels = ; - }; - }; - - uart0_sleep_alt: uart0_sleep_alt { - group1 { - psels = ; - low-power-enable; - }; - }; - - uart1_default_alt: uart1_default_alt { - group1 { - psels = , - ; - }; - }; - - uart1_sleep_alt: uart1_sleep_alt { - group1 { - psels = , - ; - low-power-enable; - }; - }; - -}; - -&uart1 { - current-speed = <1000000>; - pinctrl-0 = <&uart1_default_alt>; - pinctrl-1 = <&uart1_sleep_alt>; - pinctrl-names = "default", "sleep"; - - lpuart: nrf-sw-lpuart { - compatible = "nordic,nrf-sw-lpuart"; - status = "okay"; - req-pin = <15>; /* <&interface_to_nrf9160 2 0>; */ - rdy-pin = <22>; /* <&interface_to_nrf9160 3 0>; */ - }; -}; - -/ { - chosen { - zephyr,bt-c2h-uart = &lpuart; - }; -}; - -&gpiote { - interrupts = <6 NRF_DEFAULT_IRQ_PRIORITY>; -}; - -/* Disabling uart rx pin to get low power */ -&uart0 { - pinctrl-0 = <&uart0_default_alt>; - pinctrl-1 = <&uart0_sleep_alt>; - pinctrl-names = "default", "sleep"; - disable-rx; -}; diff --git a/controller/boards/nrf9160dk_nrf52840_0_14_0.overlay b/controller/boards/nrf9160dk_nrf52840_0_14_0.overlay deleted file mode 100644 index f045e55..0000000 --- a/controller/boards/nrf9160dk_nrf52840_0_14_0.overlay +++ /dev/null @@ -1,4 +0,0 @@ -/* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - -/* Use the reset line that is available starting from v0.14.0 of the DK. */ -#include diff --git a/controller/boards/thingy91x_nrf5340_cpunet.conf b/controller/boards/thingy91x_nrf5340_cpunet.conf deleted file mode 100644 index f03b479..0000000 --- a/controller/boards/thingy91x_nrf5340_cpunet.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_UART_ASYNC_API=y -CONFIG_UART_CONSOLE=n -CONFIG_RTT_CONSOLE=y -CONFIG_USE_SEGGER_RTT=y -CONFIG_SHELL_BACKEND_RTT=y diff --git a/controller/boards/thingy91x_nrf5340_cpunet.overlay b/controller/boards/thingy91x_nrf5340_cpunet.overlay deleted file mode 100644 index 417b884..0000000 --- a/controller/boards/thingy91x_nrf5340_cpunet.overlay +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2025 Golioth, Inc. - * SPDX-License-Identifier: Apache-2.0 - */ - -&pinctrl { - uart0_default: uart0_default { - group1 { - psels = , - ; - }; - group2 { - psels = , - ; - bias-pull-up; - }; - }; - - uart0_sleep: uart0_sleep { - group1 { - psels = , - , - , - ; - low-power-enable; - }; - }; -}; - -&uart0_sleep { - group1 { - psels = , - , - , - ; - low-power-enable; - }; -}; - -&uart0 { - status = "okay"; - current-speed = <1000000>; - pinctrl-0 = <&uart0_default>; - pinctrl-1 = <&uart0_sleep>; - pinctrl-names = "default", "sleep"; - hw-flow-control; -}; diff --git a/controller/prj.conf b/controller/prj.conf deleted file mode 100644 index 92123d6..0000000 --- a/controller/prj.conf +++ /dev/null @@ -1,16 +0,0 @@ -# hci_uart_async -CONFIG_SERIAL=y - -# hci_raw (dependency of hci_uart) -CONFIG_BT=y -CONFIG_BT_HCI_RAW=y -CONFIG_BT_HCI_RAW_H4=y -CONFIG_BT_HCI_RAW_H4_ENABLE=y - -CONFIG_BT_MAX_CONN=16 -CONFIG_BT_BUF_ACL_TX_SIZE=255 -CONFIG_BT_BUF_ACL_RX_SIZE=255 -CONFIG_BT_BUF_CMD_TX_SIZE=255 -CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255 - -CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 diff --git a/controller/sample.yaml b/controller/sample.yaml deleted file mode 100644 index 8dcf503..0000000 --- a/controller/sample.yaml +++ /dev/null @@ -1,10 +0,0 @@ -sample: - name: Bluetooth HCI UART controller for gateway -tests: - sample.golioth.pouch_gateway.controller: - harness: bluetooth - platform_allow: - - nrf9160dk/nrf52840 - tags: - - uart - - bluetooth diff --git a/controller/sysbuild/nrf5340_cpuapp.conf b/controller/sysbuild/nrf5340_cpuapp.conf deleted file mode 100644 index 3752b81..0000000 --- a/controller/sysbuild/nrf5340_cpuapp.conf +++ /dev/null @@ -1,2 +0,0 @@ -SB_CONFIG_APPCORE_EMPTY=y # Add empty app core image on nRF5340 builds -SB_CONFIG_THINGY91X_NO_PREDEFINED_LAYOUT=y diff --git a/doc/simulator_or_usb_dongle.md b/doc/simulator_or_usb_dongle.md index 2a6ec60..0c8b2ee 100644 --- a/doc/simulator_or_usb_dongle.md +++ b/doc/simulator_or_usb_dongle.md @@ -106,7 +106,7 @@ Build Bluetooth Controller firmware with HCI UART over USB CDC-ACM for nRF52840 Dongle: ``` -west build -p -b nrf52840dongle/nrf52840 pouch-gateway/controller +west build -p -b nrf52840dongle/nrf52840 zephyr/samples/bluetooth/hci_uart ``` See [Programming and diff --git a/gateway/Kconfig b/gateway/Kconfig index aab1aa6..b7a5323 100644 --- a/gateway/Kconfig +++ b/gateway/Kconfig @@ -17,11 +17,13 @@ configdefault BT_CTLR_DATA_LENGTH_MAX config SAMPLE_POUCH_GATEWAY_BT_AUTO_BOND bool default y if BOARD_NRF52_BSIM_NATIVE + default y if BOARD_NRF9160DK_NRF52840 # This option is used only for automated tests config SAMPLE_POUCH_GATEWAY_BT_AUTO_CONFIRM bool default y if BOARD_NRF52_BSIM_NATIVE + default y if BOARD_NRF9160DK_NRF52840 source "${ZEPHYR_GOLIOTH_FIRMWARE_SDK_MODULE_DIR}/examples/zephyr/common/Kconfig.defconfig" diff --git a/gateway/Kconfig.sysbuild b/gateway/Kconfig.sysbuild index 0c31f8c..404836a 100644 --- a/gateway/Kconfig.sysbuild +++ b/gateway/Kconfig.sysbuild @@ -1,6 +1,8 @@ # Copyright (c) 2025 Golioth, Inc. # SPDX-License-Identifier: Apache-2.0 +rsource "Kconfig.sysbuild.defconfig" + menu "Gateway configuration" config POUCH_GATEWAY_CLOUD @@ -69,8 +71,4 @@ config PERIPHERAL_MOUNT_CREDS help Mount credentials located ${BUILD_DIR}/creds under /creds mountpoint in Zephyr. -choice BOOTLOADER - default BOOTLOADER_MCUBOOT if SOC != "native" -endchoice - source "share/sysbuild/Kconfig" diff --git a/gateway/Kconfig.sysbuild.defconfig b/gateway/Kconfig.sysbuild.defconfig new file mode 100644 index 0000000..94cf03f --- /dev/null +++ b/gateway/Kconfig.sysbuild.defconfig @@ -0,0 +1,39 @@ +# Copyright (c) 2026 Golioth, Inc. +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_THINGY91X_NRF5340_CPUAPP || BOARD_THINGY91X_NRF5340_CPUAPP_NS + +choice NETCORE + prompt "Netcore image" + default NETCORE_HCI_IPC + +config NETCORE_HCI_IPC + bool "hci_ipc" + +endchoice + +choice THINGY91X_LAYOUT + prompt "Pre-defined Thingy:91 X partition layout" + default THINGY91X_NO_PREDEFINED_LAYOUT + +config THINGY91X_NO_PREDEFINED_LAYOUT + bool "None [EXPERIMENTAL]" +endchoice + +configdefault SECURE_BOOT_NETCORE + bool + default n + +configdefault SECURE_BOOT_APPCORE + bool + default n + +configdefault NETCORE_APP_UPDATE + bool + default n + +configdefault NRF_DEFAULT_EMPTY + bool + default n + +endif # BOARD_THINGY91X_NRF5340_CPUAPP || BOARD_THINGY91X_NRF5340_CPUAPP_NS diff --git a/gateway/boards/nrf9160dk_nrf52840.conf b/gateway/boards/nrf9160dk_nrf52840.conf new file mode 100644 index 0000000..6476a9f --- /dev/null +++ b/gateway/boards/nrf9160dk_nrf52840.conf @@ -0,0 +1,26 @@ +# PPP +CONFIG_NET_L2_PPP=y +CONFIG_NET_L2_PPP_OPTION_DNS_USE=y + +# Network management +CONFIG_NET_MGMT=y +CONFIG_NET_MGMT_EVENT=y +CONFIG_NET_CONNECTION_MANAGER=y + +# Modem driver +CONFIG_MODEM=y +CONFIG_MODEM_CELLULAR=y + +# Align with the Serial LTE Modem (SLM) application. +CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=6000 + +# CMUX configuration +# MTU must accommodate PPP frames (up to 1500 bytes for IP packets) +CONFIG_MODEM_CMUX_MTU=1500 +CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=1024 + +# NB-IoT latency can reach 10s; use greater timeouts +CONFIG_NET_SOCKETS_DNS_TIMEOUT=15000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +CONFIG_COAP_INIT_ACK_TIMEOUT_MS=15000 +CONFIG_NET_SOCKETS_DTLS_TIMEOUT=15000 diff --git a/gateway/boards/nrf9160dk_nrf52840.overlay b/gateway/boards/nrf9160dk_nrf52840.overlay new file mode 100644 index 0000000..24d6f56 --- /dev/null +++ b/gateway/boards/nrf9160dk_nrf52840.overlay @@ -0,0 +1,20 @@ +#include + +/ { + aliases { + modem = &modem; + }; +}; + +&uart1 { + current-speed = <115200>; + hw-flow-control; + + modem: modem { + compatible = "nordic,nrf91-slm"; + status = "okay"; + autostarts; + mdm-dtr-gpios = <&interface_to_nrf9160 4 GPIO_ACTIVE_LOW>; + mdm-ring-gpios = <&interface_to_nrf9160 5 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>; + }; +}; diff --git a/gateway/boards/nrf9160dk_nrf9160_ns.conf b/gateway/boards/nrf9160dk_nrf9160_ns.conf deleted file mode 100644 index 7b60ef6..0000000 --- a/gateway/boards/nrf9160dk_nrf9160_ns.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_NRF_SW_LPUART=y -CONFIG_NRF_SW_LPUART_INT_DRIVEN=y - -CONFIG_UART_2_ASYNC=y -CONFIG_UART_2_INTERRUPT_DRIVEN=n diff --git a/gateway/boards/nrf9160dk_nrf9160_ns.overlay b/gateway/boards/nrf9160dk_nrf9160_ns.overlay deleted file mode 100644 index b35036e..0000000 --- a/gateway/boards/nrf9160dk_nrf9160_ns.overlay +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -/ { - chosen { - zephyr,bt-hci = &bt_hci_uart; - }; -}; - -&gpiote { - interrupts = <49 NRF_DEFAULT_IRQ_PRIORITY>; -}; - -&uart2 { - current-speed = <1000000>; - status = "okay"; - /delete-property/ hw-flow-control; - - pinctrl-0 = <&uart2_default_alt>; - pinctrl-1 = <&uart2_sleep_alt>; - lpuart: nrf-sw-lpuart { - compatible = "nordic,nrf-sw-lpuart"; - status = "okay"; - req-pin = <21>; /* <&interface_to_nrf52840 3 0>; */ - rdy-pin = <19>; /* <&interface_to_nrf52840 2 0>; */ - - bt_hci_uart: bt_hci_uart { - compatible = "zephyr,bt-hci-uart"; - status = "okay"; - }; - }; -}; -&uart1 { - status = "disabled"; -}; - -&pinctrl { - uart2_default_alt: uart2_default_alt { - group1 { - psels = , - ; - }; - }; - - uart2_sleep_alt: uart2_sleep_alt { - group1 { - psels = , - ; - low-power-enable; - }; - }; -}; diff --git a/gateway/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay b/gateway/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay deleted file mode 100644 index 4b403f1..0000000 --- a/gateway/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay +++ /dev/null @@ -1,2 +0,0 @@ -/* Use the reset line that is available starting from v0.14.0 of the DK. */ -#include diff --git a/gateway/boards/thingy91x_nrf5340_cpuapp.conf b/gateway/boards/thingy91x_nrf5340_cpuapp.conf new file mode 100644 index 0000000..b4b13c2 --- /dev/null +++ b/gateway/boards/thingy91x_nrf5340_cpuapp.conf @@ -0,0 +1,44 @@ +# PPP networking over Serial Modem +CONFIG_NET_L2_PPP=y +CONFIG_NET_L2_PPP_OPTION_DNS_USE=y + +# Network management +CONFIG_NET_MGMT=y +CONFIG_NET_MGMT_EVENT=y +CONFIG_NET_CONNECTION_MANAGER=y + +# Modem driver +CONFIG_MODEM=y +CONFIG_MODEM_CELLULAR=y + +# CMUX and buffer configuration +# MTU must accommodate PPP frames (up to 1500 bytes for IP packets) +CONFIG_MODEM_CMUX_MTU=1500 +CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=6000 +CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=1024 + +# UART configuration for nRF5340 +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_ASYNC_API=n + +# GPIO +CONFIG_GPIO=y + +# Console on RTT (UART0 is used for the modem) +CONFIG_UART_CONSOLE=n +CONFIG_RTT_CONSOLE=y +CONFIG_SHELL_BACKEND_RTT=y +CONFIG_LOG_BACKEND_UART=n +CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=2048 + +# Debug logging +CONFIG_LOG_DEFAULT_LEVEL=3 + +# NB-IoT latency can reach 10s; use greater timeouts +CONFIG_NET_SOCKETS_DNS_TIMEOUT=15000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +CONFIG_COAP_INIT_ACK_TIMEOUT_MS=15000 +CONFIG_NET_SOCKETS_DTLS_TIMEOUT=15000 + +# Increase default BT ACL TX count +CONFIG_BT_BUF_ACL_TX_COUNT=7 diff --git a/gateway/boards/thingy91x_nrf5340_cpuapp.overlay b/gateway/boards/thingy91x_nrf5340_cpuapp.overlay new file mode 100644 index 0000000..6777978 --- /dev/null +++ b/gateway/boards/thingy91x_nrf5340_cpuapp.overlay @@ -0,0 +1,59 @@ +/* + * Thingy:91 X overlay for Serial Modem communication with on-board nRF9151 + * + * UART0 is used for Serial Modem communication with 4-wire UART (HW flow control). + * Pin assignment matches the pouch-gateway BT HCI UART wiring: + * TX = P0.29 <-> nRF9151 P0.00 (RX) + * RX = P1.04 <-> nRF9151 P0.01 (TX) + * RTS = P1.06 <-> nRF9151 P0.05 (CTS) + * CTS = P1.08 <-> nRF9151 P0.04 (RTS) + * DTR = P1.15 <-> nRF9151 P0.26 (Power/DTR) + * + * Console is on RTT since UART0 is used for the modem. + */ + +/ { + aliases { + modem = &modem; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + hw-flow-control; + pinctrl-0 = <&uart_vcom0_vcom1_default>; + pinctrl-1 = <&uart_vcom0_vcom1_sleep>; + pinctrl-names = "default", "sleep"; + + /* Nordic nRF91 Serial Modem configuration */ + modem: modem { + compatible = "nordic,nrf91-slm"; + status = "okay"; + mdm-dtr-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>; + mdm-ring-gpios = <&gpio0 31 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>; + mdm-reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + }; +}; + +&pinctrl { + /* UART0 with HW flow control using pouch-gateway BT HCI pin assignment */ + uart_vcom0_vcom1_default: uart_vcom0_vcom1_default { + group1 { + psels = , + , + , + ; + }; + }; + + uart_vcom0_vcom1_sleep: uart_vcom0_vcom1_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; diff --git a/gateway/boards/thingy91x_nrf9151_ns.conf b/gateway/boards/thingy91x_nrf9151_ns.conf deleted file mode 100644 index c4b9b7d..0000000 --- a/gateway/boards/thingy91x_nrf9151_ns.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_UART_CONSOLE=n -CONFIG_RTT_CONSOLE=y -CONFIG_USE_SEGGER_RTT=y -CONFIG_SHELL_BACKEND_RTT=y diff --git a/gateway/boards/thingy91x_nrf9151_ns.overlay b/gateway/boards/thingy91x_nrf9151_ns.overlay deleted file mode 100644 index 9af2016..0000000 --- a/gateway/boards/thingy91x_nrf9151_ns.overlay +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Golioth, Inc. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/ { - chosen { - zephyr,bt-hci = &bt_hci_uart; - /delete-property/ zephyr,console; - /delete-property/ zephyr,shell-uart; - /delete-property/ zephyr,uart-mcumgr; - }; -}; - -&uart0_default { - group1 { - psels = , - , - , - ; - }; -}; - -&uart0_sleep { - group1 { - psels = , - , - , - ; - low-power-enable; - }; -}; - -&uart0 { - compatible = "nordic,nrf-uarte"; - status = "okay"; - current-speed = <1000000>; - hw-flow-control; - - bt_hci_uart: bt_hci_uart { - compatible = "zephyr,bt-hci-uart"; - status = "okay"; - }; -}; diff --git a/gateway/socs/native.conf b/gateway/socs/native.conf index dbac087..effef39 100644 --- a/gateway/socs/native.conf +++ b/gateway/socs/native.conf @@ -5,7 +5,6 @@ CONFIG_NET_DRIVERS=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_NATIVE_OFFLOADED_SOCKETS=y -CONFIG_HEAP_MEM_POOL_SIZE=1024 # Use embedded libc to use Zephyr's eventfd instead of host eventfd CONFIG_PICOLIBC=y diff --git a/gateway/socs/native_64.conf b/gateway/socs/native_64.conf index dbac087..effef39 100644 --- a/gateway/socs/native_64.conf +++ b/gateway/socs/native_64.conf @@ -5,7 +5,6 @@ CONFIG_NET_DRIVERS=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_NATIVE_OFFLOADED_SOCKETS=y -CONFIG_HEAP_MEM_POOL_SIZE=1024 # Use embedded libc to use Zephyr's eventfd instead of host eventfd CONFIG_PICOLIBC=y diff --git a/gateway/socs/nrf9151_ns.conf b/gateway/socs/nrf9151_ns.conf deleted file mode 100644 index ee91af1..0000000 --- a/gateway/socs/nrf9151_ns.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2025 Golioth, Inc. -# SPDX-License-Identifier: Apache-2.0 - -# General config -CONFIG_HEAP_MEM_POOL_SIZE=65536 -CONFIG_NEWLIB_LIBC=y - -# Networking -CONFIG_NET_SOCKETS_OFFLOAD=y -CONFIG_NET_IPV6=y -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -# Increase native TLS socket implementation, so that it is chosen instead of -# offloaded nRF91 sockets -CONFIG_NET_SOCKETS_TLS_PRIORITY=35 - -# Modem library -CONFIG_NRF_MODEM_LIB=y - -# LTE connectivity with network connection manager -CONFIG_NRF_MODEM_LIB_NET_IF=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n -CONFIG_NET_CONNECTION_MANAGER=y -CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 - -# Add Logs for LTE Link Handler -CONFIG_GOLIOTH_SAMPLE_NRF91_LTE_MONITOR=y - -# Disable options y-selected by NCS for no good reason -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n -CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=n - -# MbedTLS configuration to support p-384 curve. These options -# enable using the MbedTLS built-in support for operations not -# supported by the default nRF Oberon crypto backend -CONFIG_NORDIC_SECURITY_BACKEND=n -CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y - -# Add Network Info Support -CONFIG_MODEM_INFO=y - -# Generate MCUboot compatible images -CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/gateway/socs/nrf9160_ns.conf b/gateway/socs/nrf9160_ns.conf deleted file mode 100644 index ee91af1..0000000 --- a/gateway/socs/nrf9160_ns.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2025 Golioth, Inc. -# SPDX-License-Identifier: Apache-2.0 - -# General config -CONFIG_HEAP_MEM_POOL_SIZE=65536 -CONFIG_NEWLIB_LIBC=y - -# Networking -CONFIG_NET_SOCKETS_OFFLOAD=y -CONFIG_NET_IPV6=y -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -# Increase native TLS socket implementation, so that it is chosen instead of -# offloaded nRF91 sockets -CONFIG_NET_SOCKETS_TLS_PRIORITY=35 - -# Modem library -CONFIG_NRF_MODEM_LIB=y - -# LTE connectivity with network connection manager -CONFIG_NRF_MODEM_LIB_NET_IF=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n -CONFIG_NET_CONNECTION_MANAGER=y -CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 - -# Add Logs for LTE Link Handler -CONFIG_GOLIOTH_SAMPLE_NRF91_LTE_MONITOR=y - -# Disable options y-selected by NCS for no good reason -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n -CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=n - -# MbedTLS configuration to support p-384 curve. These options -# enable using the MbedTLS built-in support for operations not -# supported by the default nRF Oberon crypto backend -CONFIG_NORDIC_SECURITY_BACKEND=n -CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y - -# Add Network Info Support -CONFIG_MODEM_INFO=y - -# Generate MCUboot compatible images -CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/gateway/src/main.c b/gateway/src/main.c index 9039228..25fd213 100644 --- a/gateway/src/main.c +++ b/gateway/src/main.c @@ -31,6 +31,12 @@ LOG_MODULE_REGISTER(main); struct golioth_client *client; +struct net_wait_data +{ + struct k_sem sem; + struct net_mgmt_event_callback cb; +}; + static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw0), gpios, {}); static struct gpio_callback button_cb_data; static struct bt_conn *default_conn; @@ -91,75 +97,61 @@ static void connect_golioth_client(void) golioth_client_register_event_callback(client, on_client_event, NULL); } -#ifdef CONFIG_NRF_MODEM -#include -static void lte_handler(const struct lte_lc_evt *const evt) +static void event_cb_handler(struct net_mgmt_event_callback *cb, + uint64_t mgmt_event, + struct net_if *iface) { - if (evt->type == LTE_LC_EVT_NW_REG_STATUS) - { + struct net_wait_data *wait = CONTAINER_OF(cb, struct net_wait_data, cb); - if ((evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME) - || (evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_ROAMING)) - { - - if (!client) - { - connect_golioth_client(); - } - } + if (mgmt_event == cb->event_mask) + { + k_sem_give(&wait->sem); } } -#endif /* CONFIG_NRF_MODEM */ - -#ifdef CONFIG_MODEM_HL7800 -#define NET_MGMT_MASK (NET_EVENT_DNS_SERVER_ADD | NET_EVENT_L4_DISCONNECTED) -#include -#include -#include -static K_SEM_DEFINE(network_connected, 0, 1); +static void wait_for_net_event(struct net_if *iface, uint64_t event) +{ + struct net_wait_data wait; -static struct net_mgmt_event_callback cb; + wait.cb.handler = event_cb_handler; + wait.cb.event_mask = event; -static void net_mgmt_cb(struct net_mgmt_event_callback *cb, uint64_t event, struct net_if *iface) -{ - switch (event) - { - case NET_EVENT_DNS_SERVER_ADD: - LOG_INF("Network connectivity established and IP address assigned"); - k_sem_give(&network_connected); - break; - case NET_EVENT_L4_DISCONNECTED: - break; - default: - break; - } -} + k_sem_init(&wait.sem, 0, 1); + net_mgmt_add_event_callback(&wait.cb); -void wait_for_network(void) -{ - net_mgmt_init_event_callback(&cb, net_mgmt_cb, NET_MGMT_MASK); - net_mgmt_add_event_callback(&cb); - conn_mgr_mon_resend_status(); + k_sem_take(&wait.sem, K_FOREVER); - LOG_INF("Waiting for network connection..."); - k_sem_take(&network_connected, K_FOREVER); + net_mgmt_del_event_callback(&wait.cb); } -#endif /* CONFIG_MODEM_HL7800 */ static void connect_to_cloud(void) { -#if defined(CONFIG_NRF_MODEM) - LOG_INF("Connecting to LTE, this may take some time..."); - lte_lc_connect_async(lte_handler); -#else -#if defined(CONFIG_NET_L2_ETHERNET) && defined(CONFIG_NET_DHCPV4) - net_dhcpv4_start(net_if_get_default()); -#elif defined(CONFIG_MODEM_HL7800) - wait_for_network(); -#endif + struct net_if *iface = net_if_get_default(); + + if (!net_if_is_up(iface)) + { + LOG_INF("Bringing up network interface (%p)", (void *) iface); + int ret = net_if_up(iface); + if ((ret < 0) && (ret != -EALREADY)) + { + LOG_ERR("Failed to bring up network interface: %d", ret); + return; + } + } + + if (IS_ENABLED(CONFIG_NET_L2_ETHERNET) && IS_ENABLED(CONFIG_NET_DHCPV4)) + { + net_dhcpv4_start(net_if_get_default()); + } + else if (IS_ENABLED(CONFIG_MODEM)) + { + LOG_INF("Waiting to obtain IP address"); + wait_for_net_event(iface, + IS_ENABLED(DNS_SERVER_IP_ADDRESSES) ? NET_EVENT_DNS_SERVER_ADD + : NET_EVENT_IPV4_ADDR_ADD); + } + connect_golioth_client(); -#endif k_sem_take(&connected, K_FOREVER); } diff --git a/lib/cert.c b/lib/cert.c index ecf991e..2460929 100644 --- a/lib/cert.c +++ b/lib/cert.c @@ -75,18 +75,52 @@ void pouch_gateway_device_cert_abort(struct pouch_gateway_device_cert_context *c free(context); } +struct device_cert_set_ctx +{ + struct k_sem sem; + enum golioth_status status; +}; + +static void device_cert_set_callback(struct golioth_client *client, + enum golioth_status status, + const struct golioth_coap_rsp_code *coap_rsp_code, + const char *path, + void *arg) +{ + struct device_cert_set_ctx *ctx = arg; + + ctx->status = status; + k_sem_give(&ctx->sem); +} + int pouch_gateway_device_cert_finish(struct pouch_gateway_device_cert_context *context) { + struct device_cert_set_ctx ctx = {}; enum golioth_status status; + k_sem_init(&ctx.sem, 0, 1); + if (IS_ENABLED(CONFIG_POUCH_GATEWAY_CLOUD)) { - status = golioth_gateway_device_cert_set(_client, context->buf, context->len, 5); + status = golioth_gateway_device_cert_set(_client, + context->buf, + context->len, + device_cert_set_callback, + &ctx, + 5); if (status != GOLIOTH_OK) { LOG_ERR("Failed to finish device cert: %d", status); return -EIO; } + + k_sem_take(&ctx.sem, K_FOREVER); + + if (ctx.status != GOLIOTH_OK) + { + LOG_ERR("Failed to set cert: %d", ctx.status); + return -EIO; + } } pouch_gateway_device_cert_abort(context); diff --git a/ncs-serial-modem/CMakeLists.txt b/ncs-serial-modem/CMakeLists.txt new file mode 100644 index 0000000..4174f09 --- /dev/null +++ b/ncs-serial-modem/CMakeLists.txt @@ -0,0 +1,37 @@ +# +# Copyright (c) 2026 Golioth, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(serial_modem) + +# NORDIC SDK APP START +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/main.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_util.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_ctrl_pin.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_settings.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_host.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_commands.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_socket.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_icmp.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_fota.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_dfu.c) +target_sources(app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_uart_handler.c) +# NORDIC SDK APP END +target_sources_ifdef(CONFIG_SM_SMS app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_sms.c) +target_sources_ifdef(CONFIG_SM_PPP app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_ppp.c) +target_sources_ifdef(CONFIG_SM_CMUX app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_cmux.c) +target_sources_ifdef(CONFIG_SM_GNSS app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_gnss.c) +target_sources_ifdef(CONFIG_SM_NRF_CLOUD app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_nrfcloud.c) +target_sources_ifdef(CONFIG_SM_MQTTC app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_at_mqtt.c) +target_sources_ifdef(CONFIG_SM_MODEM_TRACE_BACKEND_CMUX app PRIVATE ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/sm_trace_backend_cmux.c) + +add_subdirectory_ifdef(CONFIG_SM_CARRIER ${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src/lwm2m_carrier) + +zephyr_include_directories(${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/src) + +include(${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/cmake/sm_version.cmake) diff --git a/ncs-serial-modem/Kconfig b/ncs-serial-modem/Kconfig new file mode 100644 index 0000000..dd8db50 --- /dev/null +++ b/ncs-serial-modem/Kconfig @@ -0,0 +1,4 @@ +# Copyright (c) 2026 Golioth, Inc. +# SPDX-License-Identifier: Apache-2.0 + +source "${ZEPHYR_NCS_SERIAL_MODEM_MODULE_DIR}/app/Kconfig" diff --git a/ncs-serial-modem/Kconfig.sysbuild b/ncs-serial-modem/Kconfig.sysbuild new file mode 100644 index 0000000..fdf0aaa --- /dev/null +++ b/ncs-serial-modem/Kconfig.sysbuild @@ -0,0 +1,6 @@ +# Copyright (c) 2026 Golioth, Inc. +# SPDX-License-Identifier: Apache-2.0 + +rsource "Kconfig.sysbuild.defconfig" + +source "share/sysbuild/Kconfig" diff --git a/ncs-serial-modem/Kconfig.sysbuild.defconfig b/ncs-serial-modem/Kconfig.sysbuild.defconfig new file mode 100644 index 0000000..cafb76f --- /dev/null +++ b/ncs-serial-modem/Kconfig.sysbuild.defconfig @@ -0,0 +1,20 @@ +# Copyright (c) 2026 Golioth, Inc. +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_THINGY91X_NRF9151 || BOARD_THINGY91X_NRF9151_NS + +choice THINGY91X_LAYOUT + prompt "Pre-defined Thingy:91 X partition layout" + default THINGY91X_NO_PREDEFINED_LAYOUT + +config THINGY91X_NO_PREDEFINED_LAYOUT + bool "None [EXPERIMENTAL]" +endchoice + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default n + +config PM_OVERRIDE_EXTERNAL_DRIVER_CHECK + default n + +endif # BOARD_THINGY91X_NRF9151 || BOARD_THINGY91X_NRF9151_NS diff --git a/ncs-serial-modem/boards/nrf9160dk_nrf9160_ns.overlay b/ncs-serial-modem/boards/nrf9160dk_nrf9160_ns.overlay new file mode 100644 index 0000000..240bb08 --- /dev/null +++ b/ncs-serial-modem/boards/nrf9160dk_nrf9160_ns.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2026 Golioth, Inc. + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +/ { + chosen { + ncs,sm-uart = &dtr_uart1; + }; +}; + +&uart1 { + compatible = "nordic,nrf-uarte"; + current-speed = <115200>; + hw-flow-control; + status = "okay"; + + dtr_uart1: dtr-uart { + compatible = "nordic,dtr-uart"; + dtr-gpios = <&interface_to_nrf52840 4 (GPIO_PULL_DOWN | GPIO_ACTIVE_LOW)>; + ri-gpios = <&interface_to_nrf52840 5 (GPIO_ACTIVE_LOW)>; + status = "okay"; + }; +}; + +&gpio0 { + status = "okay"; + /* Use PORT event for DTR (22) pin to save power */ + sense-edge-mask = <0x00400000>; +}; diff --git a/ncs-serial-modem/boards/thingy91x_nrf9151_ns.overlay b/ncs-serial-modem/boards/thingy91x_nrf9151_ns.overlay new file mode 100644 index 0000000..451d2b9 --- /dev/null +++ b/ncs-serial-modem/boards/thingy91x_nrf9151_ns.overlay @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2026 Golioth, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + ncs,sm-uart = &dtr_uart1; + }; +}; + +&uart1 { + pinctrl-0 = <&uart_vcom0_vcom1_default>; + pinctrl-1 = <&uart_vcom0_vcom1_sleep>; + current-speed = <115200>; + hw-flow-control; + status = "okay"; + + dtr_uart1: dtr-uart { + compatible = "nordic,dtr-uart"; + dtr-gpios = <&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_LOW)>; + ri-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>; + status = "okay"; + }; +}; + +&pinctrl { + uart_vcom0_vcom1_default: uart_vcom0_vcom1_default { + group1 { + psels = , + , + , + ; + }; + }; + + uart_vcom0_vcom1_sleep: uart_vcom0_vcom1_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; + +&gpio0 { + status = "okay"; + /* Use PORT event for DTR (22) pin to save power */ + sense-edge-mask = <0x00400000>; +}; diff --git a/ncs-serial-modem/cmake/write_sm_version_header.cmake b/ncs-serial-modem/cmake/write_sm_version_header.cmake new file mode 100644 index 0000000..cf5c74d --- /dev/null +++ b/ncs-serial-modem/cmake/write_sm_version_header.cmake @@ -0,0 +1,44 @@ +# +# Copyright (c) 2025 Nordic Semiconductor +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Extract git describe string +execute_process( + COMMAND git describe --tags --always --dirty + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE GIT_RESULT + ERROR_QUIET +) + +# Fallback if git command fails +if(NOT GIT_RESULT EQUAL 0) + set(GIT_DESCRIBE "unknown") +endif() + +# Validate OUTPUT_FILE variable is set +if(NOT DEFINED OUTPUT_FILE) + message(FATAL_ERROR "OUTPUT_FILE must be defined") +endif() + +# Prepare header content +set(HEADER_TEXT +"/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef SM_VERSION_H +#define SM_VERSION_H + +#define SM_VERSION \"${GIT_DESCRIBE}\" + +#endif /* SM_VERSION_H */ + +") + +# Write to output file +file(WRITE "${OUTPUT_FILE}" "${HEADER_TEXT}") diff --git a/ncs-serial-modem/prj.conf b/ncs-serial-modem/prj.conf new file mode 100644 index 0000000..9330e77 --- /dev/null +++ b/ncs-serial-modem/prj.conf @@ -0,0 +1,184 @@ +# +# Copyright (c) 2020 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +# General config +CONFIG_LOG=y +CONFIG_ASSERT=y +CONFIG_ASSERT_VERBOSE=n +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_STACK_SENTINEL=y +CONFIG_PICOLIBC_IO_FLOAT=y +CONFIG_RING_BUFFER=y +CONFIG_REBOOT=y +CONFIG_EVENTFD=y + +# Segger RTT +CONFIG_USE_SEGGER_RTT=y +# Where console messages (printk) are output. +# By itself, SM does not output any. +CONFIG_RTT_CONSOLE=y +CONFIG_UART_CONSOLE=y +# Where logs are output. +CONFIG_LOG_BACKEND_RTT=y +CONFIG_LOG_BACKEND_UART=y +# Increase the buffer so that all Serial Modem boot logs fit into the buffer. +# Because J-Link RTT Viewer has to be connected after the bootup, +# only logs that fit into the buffer are shown. This is especially useful in showing +# errors if Serial Modem does not start properly. +CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=2048 + +# Network +CONFIG_NETWORKING=y +CONFIG_NET_SOCKETS=y +CONFIG_NET_NATIVE=n +CONFIG_NET_IPV4=y +CONFIG_NET_IPV6=y + +# Modem library +CONFIG_NRF_MODEM_LIB=y +CONFIG_AT_CMD_CUSTOM=y +# Align the max FD entry to NRF_MODEM_MAX_SOCKET_COUNT(8) +CONFIG_ZVFS_OPEN_MAX=8 + +# Handle modem fault +CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y + +# Use GPIO +CONFIG_GPIO=y +CONFIG_GPIO_NRFX=y + +# UART interface +CONFIG_SERIAL=y +CONFIG_UART_USE_RUNTIME_CONFIGURE=y +CONFIG_UART_ASYNC_API=y +CONFIG_UART_INTERRUPT_DRIVEN=n + +# Stacks and heaps +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=16384 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 +CONFIG_AT_MONITOR_HEAP_SIZE=4096 + +# Device power management +CONFIG_PM_DEVICE=y +CONFIG_PM_DEVICE_RUNTIME=n + +# FOTA +CONFIG_HTTP_PARSER_URL=y +CONFIG_FOTA_DOWNLOAD=y +CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y +CONFIG_DFU_TARGET=y +CONFIG_DOWNLOADER=y +CONFIG_DOWNLOADER_STACK_SIZE=4096 +CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=2048 +CONFIG_BOOTLOADER_MCUBOOT=y +CONFIG_IMG_MANAGER=y + +# FLASH +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y +CONFIG_STREAM_FLASH=y +CONFIG_MPU_ALLOW_FLASH_WRITE=y +CONFIG_IMG_ERASE_PROGRESSIVELY=y + +# Settings +CONFIG_SETTINGS=y +CONFIG_SETTINGS_NVS=y +CONFIG_NVS=y + +# UUID and JWT +CONFIG_MODEM_JWT=y + +# AT command helper libraries +CONFIG_AT_PARSER=y +CONFIG_AT_MONITOR=y + +# Eventfd's to use with AT-commands. +CONFIG_ZVFS_EVENTFD_MAX=2 + +# Disable TF-M logging. +# TF-M log sending will block until remote end is ready, when HWFC is used on UART1. +CONFIG_TFM_LOG_LEVEL_SILENCE=y + +# +# SM-specific configurations +# +CONFIG_SM_CUSTOMER_VERSION="" +CONFIG_SM_EXTERNAL_XTAL=n + +# debug options +#CONFIG_LOG_BUFFER_SIZE=16384 +#CONFIG_SM_LOG_LEVEL_DBG=y +#CONFIG_LOG_PRINTK=n +#CONFIG_LOG_MODE_IMMEDIATE=y +#CONFIG_DEBUG_OPTIMIZATIONS=y +#CONFIG_DTR_UART_LOG_LEVEL_DBG=y + +# For using external GNSS antenna +#CONFIG_MODEM_ANTENNA=y +#CONFIG_MODEM_ANTENNA_GNSS_EXTERNAL=y + +# +# CMUX settings +# +CONFIG_SM_CMUX=y + +# Zephyr modem subsystem +CONFIG_MODEM_MODULES=y +CONFIG_MODEM_CMUX=y + +# CMUX MTU for full PPP/IP frames (must match Zephyr modem driver) +CONFIG_MODEM_CMUX_MTU=1500 +CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=1024 + +# UART buffers sized for larger CMUX frames +CONFIG_SM_UART_RX_BUF_COUNT=3 +CONFIG_SM_UART_RX_BUF_SIZE=2048 +CONFIG_SM_UART_TX_BUF_SIZE=2048 + +# +# PPP +# +CONFIG_SM_PPP=y + +# NCS modem libraries +CONFIG_AT_CMD_CUSTOM=y + +CONFIG_NRF_MODEM_LIB_SHMEM_TX_SIZE=22528 + +# Zephyr PPP support +CONFIG_NET_NATIVE=y +CONFIG_NET_L2_PPP=y +CONFIG_MODEM_MODULES=y +CONFIG_MODEM_PPP=y + +# L2 protocol +CONFIG_NET_L2_PPP_MGMT=y +CONFIG_NET_L2_PPP_OPTION_MRU=y +CONFIG_NET_L2_PPP_OPTION_SERVE_IP=y +CONFIG_NET_L2_PPP_OPTION_SERVE_DNS=y +CONFIG_NET_L2_PPP_TIMEOUT=5000 +CONFIG_NET_L2_PPP_MAX_CONFIGURE_REQ_RETRANSMITS=20 + +# IP stack +CONFIG_NET_IP_ADDR_CHECK=n +CONFIG_NET_SOCKETS_PACKET=y + +# network buffering +CONFIG_NET_BUF=y +CONFIG_NET_BUF_POOL_USAGE=y +CONFIG_NET_PKT_RX_COUNT=44 +CONFIG_NET_BUF_RX_COUNT=88 +CONFIG_NET_PKT_TX_COUNT=44 +CONFIG_NET_BUF_TX_COUNT=88 +CONFIG_NET_TC_RX_COUNT=0 +CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT=1000 + +# +# Override unused defaults +# +CONFIG_SM_NRF_CLOUD=n +CONFIG_SM_MQTTC=n diff --git a/ncs-serial-modem/sysbuild.conf b/ncs-serial-modem/sysbuild.conf new file mode 100644 index 0000000..cb39011 --- /dev/null +++ b/ncs-serial-modem/sysbuild.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2023 Nordic Semiconductor +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +SB_CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/ncs-serial-modem/sysbuild/mcuboot/app.overlay b/ncs-serial-modem/sysbuild/mcuboot/app.overlay new file mode 100644 index 0000000..e888755 --- /dev/null +++ b/ncs-serial-modem/sysbuild/mcuboot/app.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,code-partition = &boot_partition; + }; +}; diff --git a/ncs-serial-modem/sysbuild/mcuboot/boards/thingy91x_nrf9151.conf b/ncs-serial-modem/sysbuild/mcuboot/boards/thingy91x_nrf9151.conf new file mode 100644 index 0000000..e6cdaf2 --- /dev/null +++ b/ncs-serial-modem/sysbuild/mcuboot/boards/thingy91x_nrf9151.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2026 Golioth, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Disable Zephyr console +CONFIG_CONSOLE=n +CONFIG_CONSOLE_HANDLER=n +CONFIG_UART_CONSOLE=n diff --git a/ncs-serial-modem/sysbuild/mcuboot/prj.conf b/ncs-serial-modem/sysbuild/mcuboot/prj.conf new file mode 100644 index 0000000..60610ac --- /dev/null +++ b/ncs-serial-modem/sysbuild/mcuboot/prj.conf @@ -0,0 +1,44 @@ +# +# Copyright (c) 2026 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_PM=n + +CONFIG_MAIN_STACK_SIZE=10240 + +CONFIG_BOOT_SWAP_SAVE_ENCTLV=n +CONFIG_BOOT_ENCRYPT_IMAGE=n + +CONFIG_BOOT_UPGRADE_ONLY=n +CONFIG_BOOT_BOOTSTRAP=n + +### mbedTLS has its own heap +# CONFIG_HEAP_MEM_POOL_SIZE is not set + +CONFIG_FLASH=y +CONFIG_FPROTECT=y + +### Various Zephyr boards enable features that we don't want. +# CONFIG_BT is not set +# CONFIG_I2C is not set + +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y +### Ensure Zephyr logging changes don't use more resources +CONFIG_LOG_DEFAULT_LEVEL=0 +### Use info log level by default +CONFIG_MCUBOOT_LOG_LEVEL_INF=y +### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y +CONFIG_CBPRINTF_NANO=y +CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0 + +### Serial Modem +# Do not use UART, for power saving +CONFIG_CONSOLE=y +CONFIG_MCUBOOT_SERIAL=n +CONFIG_BOOT_SERIAL_UART=n +CONFIG_UART_CONSOLE=n +CONFIG_LOG_BACKEND_UART=n +CONFIG_CONSOLE_HANDLER=n diff --git a/ncs-serial-modem/west.yml b/ncs-serial-modem/west.yml new file mode 100644 index 0000000..e5fbf1a --- /dev/null +++ b/ncs-serial-modem/west.yml @@ -0,0 +1,11 @@ +manifest: + projects: + - name: ncs-serial-modem + path: ncs-serial-modem + revision: v1.0.0 + url: https://github.com/nrfconnect/ncs-serial-modem.git + import: true + + self: + path: pouch-gateway/ncs-serial-modem + west-commands: scripts/west-commands.yml diff --git a/samples/custom_connect/boards/nrf9160dk_nrf52840.conf b/samples/custom_connect/boards/nrf9160dk_nrf52840.conf new file mode 100644 index 0000000..6476a9f --- /dev/null +++ b/samples/custom_connect/boards/nrf9160dk_nrf52840.conf @@ -0,0 +1,26 @@ +# PPP +CONFIG_NET_L2_PPP=y +CONFIG_NET_L2_PPP_OPTION_DNS_USE=y + +# Network management +CONFIG_NET_MGMT=y +CONFIG_NET_MGMT_EVENT=y +CONFIG_NET_CONNECTION_MANAGER=y + +# Modem driver +CONFIG_MODEM=y +CONFIG_MODEM_CELLULAR=y + +# Align with the Serial LTE Modem (SLM) application. +CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=6000 + +# CMUX configuration +# MTU must accommodate PPP frames (up to 1500 bytes for IP packets) +CONFIG_MODEM_CMUX_MTU=1500 +CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=1024 + +# NB-IoT latency can reach 10s; use greater timeouts +CONFIG_NET_SOCKETS_DNS_TIMEOUT=15000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +CONFIG_COAP_INIT_ACK_TIMEOUT_MS=15000 +CONFIG_NET_SOCKETS_DTLS_TIMEOUT=15000 diff --git a/samples/custom_connect/boards/nrf9160dk_nrf52840.overlay b/samples/custom_connect/boards/nrf9160dk_nrf52840.overlay new file mode 100644 index 0000000..24d6f56 --- /dev/null +++ b/samples/custom_connect/boards/nrf9160dk_nrf52840.overlay @@ -0,0 +1,20 @@ +#include + +/ { + aliases { + modem = &modem; + }; +}; + +&uart1 { + current-speed = <115200>; + hw-flow-control; + + modem: modem { + compatible = "nordic,nrf91-slm"; + status = "okay"; + autostarts; + mdm-dtr-gpios = <&interface_to_nrf9160 4 GPIO_ACTIVE_LOW>; + mdm-ring-gpios = <&interface_to_nrf9160 5 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>; + }; +}; diff --git a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.conf b/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.conf deleted file mode 100644 index 7b60ef6..0000000 --- a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_NRF_SW_LPUART=y -CONFIG_NRF_SW_LPUART_INT_DRIVEN=y - -CONFIG_UART_2_ASYNC=y -CONFIG_UART_2_INTERRUPT_DRIVEN=n diff --git a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.overlay b/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.overlay deleted file mode 100644 index b35036e..0000000 --- a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns.overlay +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -/ { - chosen { - zephyr,bt-hci = &bt_hci_uart; - }; -}; - -&gpiote { - interrupts = <49 NRF_DEFAULT_IRQ_PRIORITY>; -}; - -&uart2 { - current-speed = <1000000>; - status = "okay"; - /delete-property/ hw-flow-control; - - pinctrl-0 = <&uart2_default_alt>; - pinctrl-1 = <&uart2_sleep_alt>; - lpuart: nrf-sw-lpuart { - compatible = "nordic,nrf-sw-lpuart"; - status = "okay"; - req-pin = <21>; /* <&interface_to_nrf52840 3 0>; */ - rdy-pin = <19>; /* <&interface_to_nrf52840 2 0>; */ - - bt_hci_uart: bt_hci_uart { - compatible = "zephyr,bt-hci-uart"; - status = "okay"; - }; - }; -}; -&uart1 { - status = "disabled"; -}; - -&pinctrl { - uart2_default_alt: uart2_default_alt { - group1 { - psels = , - ; - }; - }; - - uart2_sleep_alt: uart2_sleep_alt { - group1 { - psels = , - ; - low-power-enable; - }; - }; -}; diff --git a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay b/samples/custom_connect/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay deleted file mode 100644 index 4b403f1..0000000 --- a/samples/custom_connect/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay +++ /dev/null @@ -1,2 +0,0 @@ -/* Use the reset line that is available starting from v0.14.0 of the DK. */ -#include diff --git a/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.conf b/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.conf new file mode 100644 index 0000000..b4b13c2 --- /dev/null +++ b/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.conf @@ -0,0 +1,44 @@ +# PPP networking over Serial Modem +CONFIG_NET_L2_PPP=y +CONFIG_NET_L2_PPP_OPTION_DNS_USE=y + +# Network management +CONFIG_NET_MGMT=y +CONFIG_NET_MGMT_EVENT=y +CONFIG_NET_CONNECTION_MANAGER=y + +# Modem driver +CONFIG_MODEM=y +CONFIG_MODEM_CELLULAR=y + +# CMUX and buffer configuration +# MTU must accommodate PPP frames (up to 1500 bytes for IP packets) +CONFIG_MODEM_CMUX_MTU=1500 +CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=6000 +CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE_EXTRA=1024 + +# UART configuration for nRF5340 +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_ASYNC_API=n + +# GPIO +CONFIG_GPIO=y + +# Console on RTT (UART0 is used for the modem) +CONFIG_UART_CONSOLE=n +CONFIG_RTT_CONSOLE=y +CONFIG_SHELL_BACKEND_RTT=y +CONFIG_LOG_BACKEND_UART=n +CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=2048 + +# Debug logging +CONFIG_LOG_DEFAULT_LEVEL=3 + +# NB-IoT latency can reach 10s; use greater timeouts +CONFIG_NET_SOCKETS_DNS_TIMEOUT=15000 +CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=15000 +CONFIG_COAP_INIT_ACK_TIMEOUT_MS=15000 +CONFIG_NET_SOCKETS_DTLS_TIMEOUT=15000 + +# Increase default BT ACL TX count +CONFIG_BT_BUF_ACL_TX_COUNT=7 diff --git a/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.overlay b/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.overlay new file mode 100644 index 0000000..6777978 --- /dev/null +++ b/samples/custom_connect/boards/thingy91x_nrf5340_cpuapp.overlay @@ -0,0 +1,59 @@ +/* + * Thingy:91 X overlay for Serial Modem communication with on-board nRF9151 + * + * UART0 is used for Serial Modem communication with 4-wire UART (HW flow control). + * Pin assignment matches the pouch-gateway BT HCI UART wiring: + * TX = P0.29 <-> nRF9151 P0.00 (RX) + * RX = P1.04 <-> nRF9151 P0.01 (TX) + * RTS = P1.06 <-> nRF9151 P0.05 (CTS) + * CTS = P1.08 <-> nRF9151 P0.04 (RTS) + * DTR = P1.15 <-> nRF9151 P0.26 (Power/DTR) + * + * Console is on RTT since UART0 is used for the modem. + */ + +/ { + aliases { + modem = &modem; + }; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + hw-flow-control; + pinctrl-0 = <&uart_vcom0_vcom1_default>; + pinctrl-1 = <&uart_vcom0_vcom1_sleep>; + pinctrl-names = "default", "sleep"; + + /* Nordic nRF91 Serial Modem configuration */ + modem: modem { + compatible = "nordic,nrf91-slm"; + status = "okay"; + mdm-dtr-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>; + mdm-ring-gpios = <&gpio0 31 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>; + mdm-reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + }; +}; + +&pinctrl { + /* UART0 with HW flow control using pouch-gateway BT HCI pin assignment */ + uart_vcom0_vcom1_default: uart_vcom0_vcom1_default { + group1 { + psels = , + , + , + ; + }; + }; + + uart_vcom0_vcom1_sleep: uart_vcom0_vcom1_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; diff --git a/samples/custom_connect/boards/thingy91x_nrf9151_ns.conf b/samples/custom_connect/boards/thingy91x_nrf9151_ns.conf deleted file mode 100644 index c4b9b7d..0000000 --- a/samples/custom_connect/boards/thingy91x_nrf9151_ns.conf +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_UART_CONSOLE=n -CONFIG_RTT_CONSOLE=y -CONFIG_USE_SEGGER_RTT=y -CONFIG_SHELL_BACKEND_RTT=y diff --git a/samples/custom_connect/boards/thingy91x_nrf9151_ns.overlay b/samples/custom_connect/boards/thingy91x_nrf9151_ns.overlay deleted file mode 100644 index 9af2016..0000000 --- a/samples/custom_connect/boards/thingy91x_nrf9151_ns.overlay +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Golioth, Inc. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/ { - chosen { - zephyr,bt-hci = &bt_hci_uart; - /delete-property/ zephyr,console; - /delete-property/ zephyr,shell-uart; - /delete-property/ zephyr,uart-mcumgr; - }; -}; - -&uart0_default { - group1 { - psels = , - , - , - ; - }; -}; - -&uart0_sleep { - group1 { - psels = , - , - , - ; - low-power-enable; - }; -}; - -&uart0 { - compatible = "nordic,nrf-uarte"; - status = "okay"; - current-speed = <1000000>; - hw-flow-control; - - bt_hci_uart: bt_hci_uart { - compatible = "zephyr,bt-hci-uart"; - status = "okay"; - }; -}; diff --git a/samples/custom_connect/socs/native.conf b/samples/custom_connect/socs/native.conf index dbac087..effef39 100644 --- a/samples/custom_connect/socs/native.conf +++ b/samples/custom_connect/socs/native.conf @@ -5,7 +5,6 @@ CONFIG_NET_DRIVERS=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_NATIVE_OFFLOADED_SOCKETS=y -CONFIG_HEAP_MEM_POOL_SIZE=1024 # Use embedded libc to use Zephyr's eventfd instead of host eventfd CONFIG_PICOLIBC=y diff --git a/samples/custom_connect/socs/native_64.conf b/samples/custom_connect/socs/native_64.conf index dbac087..effef39 100644 --- a/samples/custom_connect/socs/native_64.conf +++ b/samples/custom_connect/socs/native_64.conf @@ -5,7 +5,6 @@ CONFIG_NET_DRIVERS=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_NATIVE_OFFLOADED_SOCKETS=y -CONFIG_HEAP_MEM_POOL_SIZE=1024 # Use embedded libc to use Zephyr's eventfd instead of host eventfd CONFIG_PICOLIBC=y diff --git a/samples/custom_connect/socs/nrf9151_ns.conf b/samples/custom_connect/socs/nrf9151_ns.conf deleted file mode 100644 index ee91af1..0000000 --- a/samples/custom_connect/socs/nrf9151_ns.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2025 Golioth, Inc. -# SPDX-License-Identifier: Apache-2.0 - -# General config -CONFIG_HEAP_MEM_POOL_SIZE=65536 -CONFIG_NEWLIB_LIBC=y - -# Networking -CONFIG_NET_SOCKETS_OFFLOAD=y -CONFIG_NET_IPV6=y -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -# Increase native TLS socket implementation, so that it is chosen instead of -# offloaded nRF91 sockets -CONFIG_NET_SOCKETS_TLS_PRIORITY=35 - -# Modem library -CONFIG_NRF_MODEM_LIB=y - -# LTE connectivity with network connection manager -CONFIG_NRF_MODEM_LIB_NET_IF=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n -CONFIG_NET_CONNECTION_MANAGER=y -CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 - -# Add Logs for LTE Link Handler -CONFIG_GOLIOTH_SAMPLE_NRF91_LTE_MONITOR=y - -# Disable options y-selected by NCS for no good reason -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n -CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=n - -# MbedTLS configuration to support p-384 curve. These options -# enable using the MbedTLS built-in support for operations not -# supported by the default nRF Oberon crypto backend -CONFIG_NORDIC_SECURITY_BACKEND=n -CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y - -# Add Network Info Support -CONFIG_MODEM_INFO=y - -# Generate MCUboot compatible images -CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/custom_connect/socs/nrf9160_ns.conf b/samples/custom_connect/socs/nrf9160_ns.conf deleted file mode 100644 index ee91af1..0000000 --- a/samples/custom_connect/socs/nrf9160_ns.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2025 Golioth, Inc. -# SPDX-License-Identifier: Apache-2.0 - -# General config -CONFIG_HEAP_MEM_POOL_SIZE=65536 -CONFIG_NEWLIB_LIBC=y - -# Networking -CONFIG_NET_SOCKETS_OFFLOAD=y -CONFIG_NET_IPV6=y -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -# Increase native TLS socket implementation, so that it is chosen instead of -# offloaded nRF91 sockets -CONFIG_NET_SOCKETS_TLS_PRIORITY=35 - -# Modem library -CONFIG_NRF_MODEM_LIB=y - -# LTE connectivity with network connection manager -CONFIG_NRF_MODEM_LIB_NET_IF=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=y -CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n -CONFIG_NET_CONNECTION_MANAGER=y -CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 - -# Add Logs for LTE Link Handler -CONFIG_GOLIOTH_SAMPLE_NRF91_LTE_MONITOR=y - -# Disable options y-selected by NCS for no good reason -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=n -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED=n -CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=n - -# MbedTLS configuration to support p-384 curve. These options -# enable using the MbedTLS built-in support for operations not -# supported by the default nRF Oberon crypto backend -CONFIG_NORDIC_SECURITY_BACKEND=n -CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y - -# Add Network Info Support -CONFIG_MODEM_INFO=y - -# Generate MCUboot compatible images -CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/custom_connect/src/main.c b/samples/custom_connect/src/main.c index 68151e6..47bec52 100644 --- a/samples/custom_connect/src/main.c +++ b/samples/custom_connect/src/main.c @@ -39,6 +39,12 @@ static struct sync_data sync_data; struct golioth_client *client; +struct net_wait_data +{ + struct k_sem sem; + struct net_mgmt_event_callback cb; +}; + static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw0), gpios, {}); static struct gpio_callback button_cb_data; static struct bt_conn *default_conn; @@ -99,39 +105,61 @@ static void connect_golioth_client(void) golioth_client_register_event_callback(client, on_client_event, NULL); } -#ifdef CONFIG_NRF_MODEM -#include -static void lte_handler(const struct lte_lc_evt *const evt) +static void event_cb_handler(struct net_mgmt_event_callback *cb, + uint64_t mgmt_event, + struct net_if *iface) { - if (evt->type == LTE_LC_EVT_NW_REG_STATUS) + struct net_wait_data *wait = CONTAINER_OF(cb, struct net_wait_data, cb); + + if (mgmt_event == cb->event_mask) { + k_sem_give(&wait->sem); + } +} - if ((evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME) - || (evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_ROAMING)) - { +static void wait_for_net_event(struct net_if *iface, uint64_t event) +{ + struct net_wait_data wait; - if (!client) - { - connect_golioth_client(); - } - } - } + wait.cb.handler = event_cb_handler; + wait.cb.event_mask = event; + + k_sem_init(&wait.sem, 0, 1); + net_mgmt_add_event_callback(&wait.cb); + + k_sem_take(&wait.sem, K_FOREVER); + + net_mgmt_del_event_callback(&wait.cb); } -#endif /* CONFIG_NRF_MODEM */ static void connect_to_cloud(void) { -#if defined(CONFIG_NRF_MODEM) - LOG_INF("Connecting to LTE, this may take some time..."); - lte_lc_connect_async(lte_handler); -#else -#if defined(CONFIG_NET_L2_ETHERNET) && defined(CONFIG_NET_DHCPV4) - net_dhcpv4_start(net_if_get_default()); -#endif - connect_golioth_client(); -#endif + struct net_if *iface = net_if_get_default(); + + if (!net_if_is_up(iface)) + { + LOG_INF("Bringing up network interface (%p)", (void *) iface); + int ret = net_if_up(iface); + if ((ret < 0) && (ret != -EALREADY)) + { + LOG_ERR("Failed to bring up network interface: %d", ret); + return; + } + } - LOG_INF("Waiting for network connection"); + if (IS_ENABLED(CONFIG_NET_L2_ETHERNET) && IS_ENABLED(CONFIG_NET_DHCPV4)) + { + net_dhcpv4_start(net_if_get_default()); + } + else if (IS_ENABLED(CONFIG_MODEM)) + { + LOG_INF("Waiting to obtain IP address"); + wait_for_net_event(iface, + IS_ENABLED(DNS_SERVER_IP_ADDRESSES) ? NET_EVENT_DNS_SERVER_ADD + : NET_EVENT_IPV4_ADDR_ADD); + } + + connect_golioth_client(); k_sem_take(&connected, K_FOREVER); } diff --git a/scripts/runners/__init__.py b/scripts/runners/__init__.py index cf953a4..ebf704f 100644 --- a/scripts/runners/__init__.py +++ b/scripts/runners/__init__.py @@ -1,3 +1,7 @@ -from .bsim_device import BsimDeviceBinaryRunner -from .bsim_phy import BsimPhyBinaryRunner -from .bsim_zephyr import BsimZephyrBinaryRunner +import os +import sys + +sys.path.insert(0, os.path.dirname(__file__)) +from bsim_device import BsimDeviceBinaryRunner +from bsim_phy import BsimPhyBinaryRunner +from bsim_zephyr import BsimZephyrBinaryRunner diff --git a/scripts/runners/bsim_device.py b/scripts/runners/bsim_device.py index b0951a5..375c5e5 100644 --- a/scripts/runners/bsim_device.py +++ b/scripts/runners/bsim_device.py @@ -6,7 +6,7 @@ from pathlib import Path -from .bsim_base import BsimBinaryRunnerBase +from bsim_base import BsimBinaryRunnerBase class BsimDeviceBinaryRunner(BsimBinaryRunnerBase): """Runs the BabbleSim arbitrary application.""" diff --git a/scripts/runners/bsim_phy.py b/scripts/runners/bsim_phy.py index 4c81a0c..71278ef 100644 --- a/scripts/runners/bsim_phy.py +++ b/scripts/runners/bsim_phy.py @@ -6,7 +6,7 @@ from pathlib import Path -from .bsim_base import BsimBinaryRunnerBase +from bsim_base import BsimBinaryRunnerBase class BsimPhyBinaryRunner(BsimBinaryRunnerBase): """Runs the BabbleSim 2G4 Phy binary.""" diff --git a/scripts/runners/bsim_zephyr.py b/scripts/runners/bsim_zephyr.py index 750e784..35a0be6 100644 --- a/scripts/runners/bsim_zephyr.py +++ b/scripts/runners/bsim_zephyr.py @@ -4,7 +4,7 @@ """This file provides a ZephyrBinaryRunner that enables flashing (running) a BabbleSim Zephyr application.""" -from .bsim_base import BsimBinaryRunnerBase +from bsim_base import BsimBinaryRunnerBase class BsimZephyrBinaryRunner(BsimBinaryRunnerBase): """Runs the BabbleSim Zephyr application.""" diff --git a/west-ncs.yml b/west-ncs.yml index 13f2350..0e88925 100644 --- a/west-ncs.yml +++ b/west-ncs.yml @@ -4,19 +4,22 @@ manifest: projects: - name: golioth path: modules/lib/golioth-firmware-sdk - revision: 60f0e8ab323b6a812fd68759817bc1e27f3258e5 + revision: d703b1f8805c7584a44dabc31bdf09164637d888 url: https://github.com/golioth/golioth-firmware-sdk.git import: file: west-ncs.yml name-allowlist: + - cjson - cmsis_6 - hal_nordic + - libmetal - littlefs - mbedtls - mcuboot - nrf - nrfxlib - oberon-psa-crypto + - open-amp - segger - trusted-firmware-m - zcbor diff --git a/west-thingy91x-controller.yml b/west-thingy91x-controller.yml deleted file mode 100644 index 6006b88..0000000 --- a/west-thingy91x-controller.yml +++ /dev/null @@ -1,24 +0,0 @@ -manifest: - projects: - - name: nrf - revision: v2.9.0 - url: http://github.com/nrfconnect/sdk-nrf - import: - name-allowlist: - - cmsis - - hal_nordic - - littlefs - - mbedtls - - mcuboot - - nrf - - nrfxlib - - oberon-psa-crypto - - segger - - tinycrypt - - trusted-firmware-m - - zcbor - - zephyr - - self: - path: pouch-gateway - west-commands: scripts/west-commands.yml diff --git a/west-zephyr.yml b/west-zephyr.yml index 86b23ad..d1d12bd 100644 --- a/west-zephyr.yml +++ b/west-zephyr.yml @@ -4,7 +4,7 @@ manifest: projects: - name: golioth path: modules/lib/golioth-firmware-sdk - revision: 60f0e8ab323b6a812fd68759817bc1e27f3258e5 + revision: d703b1f8805c7584a44dabc31bdf09164637d888 url: https://github.com/golioth/golioth-firmware-sdk.git import: file: west-zephyr.yml diff --git a/zephyr/module.yml b/zephyr/module.yml index 1699257..122ccb1 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -3,6 +3,7 @@ build: kconfig: Kconfig settings: board_root: . + snippet_root: zephyr samples: - samples runners: diff --git a/zephyr/patches.yml b/zephyr/patches.yml index 8d78456..1cdf51e 100644 --- a/zephyr/patches.yml +++ b/zephyr/patches.yml @@ -1,6 +1,31 @@ patches: + - path: ncs/zephyr/0001-modem-uart_isr-support-mdm-dtr-gpios.patch + sha256sum: 53b5acb22a3471b04bb38d297ef4bd5e3a2ed0464ab74b588f30408599307785 + module: zephyr + author: Marcin Niestroj + email: m.niestroj@emb.dev + date: 2026-02-11 + apply-command: >- + bash -c 'if [ $(west config manifest.file) = "west-ncs.yml" ]; then git am $@; fi' -- + - path: ncs/zephyr/0002-dts-bindings-modem-add-common-autostarts-property.patch + sha256sum: abbdd4193332e4160dd5c0a29eaa1d0e5fde39b2de510fa215694fcdbdc5785a + module: zephyr + author: Marcin Niestroj + email: m.niestroj@emb.dev + date: 2026-02-12 + apply-command: >- + bash -c 'if [ $(west config manifest.file) = "west-ncs.yml" ]; then git am $@; fi' -- + - path: ncs/zephyr/0003-drivers-modem_cellular-add-Ready-signal-handling.patch + sha256sum: a2e3946a3794f3f19c94cd401755458c48c62a306cd39c924658daa5ca769dbc + module: zephyr + author: Marcin Niestroj + email: m.niestroj@emb.dev + date: 2026-02-12 + apply-command: >- + bash -c 'if [ $(west config manifest.file) = "west-ncs.yml" ]; then git am $@; fi' -- + - path: zephyr/zephyr/0001-drivers-net-nsos-support-nrf_bsim.patch - sha256sum: 25ce052740bb44d2d575a7f3187817cf1f22aa41c6328982f0f1b3c4f8ad7593 + sha256sum: 76ee96ad695aba17be8a96d8fe908eec937238fbd9e21be09b8ad9a524b8b90b module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev @@ -8,7 +33,7 @@ patches: apply-command: >- bash -c 'if [ $(west config manifest.file) = "west-zephyr.yml" ]; then git am $@; fi' -- - path: zephyr/zephyr/0002-boards-nrf_bsim-define-NSOS_IRQ-for-offloaded-socket.patch - sha256sum: 13916913dc7f11cd4d5d3ef875da739818e90fac8847f2ce244f3f6705c03149 + sha256sum: 7841eab516807fdff2bfbdf5a263c3a4c6b3573ce2a7d7df7522a21749aef32a module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev @@ -16,7 +41,7 @@ patches: apply-command: >- bash -c 'if [ $(west config manifest.file) = "west-zephyr.yml" ]; then git am $@; fi' -- - path: zephyr/zephyr/0003-nsi-move-nsos_fcntl-to-more-generic-nsi_fcntl.patch - sha256sum: 0830899d226a3b7cd1f7b002b8cd746857a41f2a19ee899bfc5cf15773f296c5 + sha256sum: 88930ff7892bdb51d01a9416306eb972bec92c08e6bd4f96611450664bdfc3ae module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev @@ -24,7 +49,7 @@ patches: apply-command: >- bash -c 'if [ $(west config manifest.file) = "west-zephyr.yml" ]; then git am $@; fi' -- - path: zephyr/zephyr/0004-nsi-fcntl-add-O_CREAT-and-O_TRUNC.patch - sha256sum: dd53fd69065fa432a38a53176778a529ec7cf89b5823c42fd7fa1fcedfb1fd23 + sha256sum: 2839473d364cb08110ed0b825bd5099541540739c186dae7bdaf8d975c78132b module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev @@ -32,7 +57,7 @@ patches: apply-command: >- bash -c 'if [ $(west config manifest.file) = "west-zephyr.yml" ]; then git am $@; fi' -- - path: zephyr/zephyr/0005-subsys-fs-nsim_mount-new-FS-for-mounting-host-filesy.patch - sha256sum: 7380f056216807ca15d220233e38b3b407c0b1fb825e5b4794ae6c926b13e4f0 + sha256sum: 38a053f49ab2c109347bfde5a1c4d0c163ff2e5859adc1c50a52b04976733229 module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev @@ -40,7 +65,7 @@ patches: apply-command: >- bash -c 'if [ $(west config manifest.file) = "west-zephyr.yml" ]; then git am $@; fi' -- - path: zephyr/zephyr/0006-tests-fs-nsim_mount-add-basic-tests-for-implemented-.patch - sha256sum: 5117af152443b7d703e7c8b0fafa76a1d3cf34e5077b1587fbe09583129bbaad + sha256sum: 1a1973a8682684cbe241c873d4f381b9df52bbba47e82a927e71b3cdce58b2e1 module: zephyr author: Marcin Niestroj email: m.niestroj@emb.dev diff --git a/zephyr/patches/ncs/zephyr/0001-modem-uart_isr-support-mdm-dtr-gpios.patch b/zephyr/patches/ncs/zephyr/0001-modem-uart_isr-support-mdm-dtr-gpios.patch new file mode 100644 index 0000000..39c1104 --- /dev/null +++ b/zephyr/patches/ncs/zephyr/0001-modem-uart_isr-support-mdm-dtr-gpios.patch @@ -0,0 +1,44 @@ +From 741febe08c6cac19648a6c345b5c7486240a9c73 Mon Sep 17 00:00:00 2001 +From: Marcin Niestroj +Date: Wed, 11 Feb 2026 22:31:46 +0100 +Subject: [PATCH] modem: uart_isr: support mdm-dtr-gpios + +--- + subsys/modem/backends/modem_backend_uart_isr.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/subsys/modem/backends/modem_backend_uart_isr.c b/subsys/modem/backends/modem_backend_uart_isr.c +index 6c6c27c2db2..07112cb1e31 100644 +--- a/subsys/modem/backends/modem_backend_uart_isr.c ++++ b/subsys/modem/backends/modem_backend_uart_isr.c +@@ -11,6 +11,7 @@ + LOG_MODULE_REGISTER(modem_backend_uart_isr, CONFIG_MODEM_MODULES_LOG_LEVEL); + + #include ++#include + + static void modem_backend_uart_isr_flush(struct modem_backend_uart *backend) + { +@@ -113,6 +114,9 @@ static int modem_backend_uart_isr_open(void *data) + ring_buf_reset(&backend->isr.transmit_rb); + atomic_set(&backend->isr.transmit_buf_len, 0); + modem_backend_uart_isr_flush(backend); ++ if (backend->dtr_gpio) { ++ gpio_pin_set_dt(backend->dtr_gpio, 1); ++ } + uart_irq_rx_enable(backend->uart); + uart_irq_tx_enable(backend->uart); + modem_pipe_notify_opened(&backend->pipe); +@@ -228,6 +232,9 @@ static int modem_backend_uart_isr_close(void *data) + { + struct modem_backend_uart *backend = (struct modem_backend_uart *)data; + ++ if (backend->dtr_gpio) { ++ gpio_pin_set_dt(backend->dtr_gpio, 0); ++ } + uart_irq_rx_disable(backend->uart); + uart_irq_tx_disable(backend->uart); + modem_pipe_notify_closed(&backend->pipe); +-- +2.53.0 + diff --git a/zephyr/patches/ncs/zephyr/0002-dts-bindings-modem-add-common-autostarts-property.patch b/zephyr/patches/ncs/zephyr/0002-dts-bindings-modem-add-common-autostarts-property.patch new file mode 100644 index 0000000..09bfe0e --- /dev/null +++ b/zephyr/patches/ncs/zephyr/0002-dts-bindings-modem-add-common-autostarts-property.patch @@ -0,0 +1,51 @@ +From 00bad68c943c8cea837fd5a862c55dd06289d641 Mon Sep 17 00:00:00 2001 +From: Marcin Niestroj +Date: Thu, 12 Feb 2026 09:44:44 +0100 +Subject: [PATCH] dts: bindings: modem: add common 'autostarts' property + +This property can be used by various modems. Used it successfully with +nRF91-SLM when waiting for "Ready" signal after automatic power-on. + +Signed-off-by: Marcin Niestroj +--- + dts/bindings/modem/quectel,bg95.yaml | 8 -------- + dts/bindings/modem/zephyr,cellular-modem-device.yaml | 7 +++++++ + 2 files changed, 7 insertions(+), 8 deletions(-) + +diff --git a/dts/bindings/modem/quectel,bg95.yaml b/dts/bindings/modem/quectel,bg95.yaml +index 940cd41ea27..8011dd05fbf 100644 +--- a/dts/bindings/modem/quectel,bg95.yaml ++++ b/dts/bindings/modem/quectel,bg95.yaml +@@ -10,11 +10,3 @@ include: zephyr,cellular-modem-device.yaml + properties: + mdm-power-gpios: + type: phandle-array +- +- autostarts: +- type: boolean +- description: | +- Set for modem variants or carrier boards that start the module +- automatically when supply voltage is applied—that is, the modem +- asserts PWRKEY internally and does not require an external PWRKEY +- pulse. +diff --git a/dts/bindings/modem/zephyr,cellular-modem-device.yaml b/dts/bindings/modem/zephyr,cellular-modem-device.yaml +index d2ab0056841..205c0d3e0fb 100644 +--- a/dts/bindings/modem/zephyr,cellular-modem-device.yaml ++++ b/dts/bindings/modem/zephyr,cellular-modem-device.yaml +@@ -44,6 +44,13 @@ properties: + When runtime power management is enabled, this closes the UART. + This requires modem to support waking up the UART using RING signal. + ++ autostarts: ++ type: boolean ++ description: | ++ Set when the modem starts automatically at power-on without requiring ++ an external power or reset pulse. When set, the host waits for a ready ++ indication from the modem before sending AT commands. ++ + cmux-idle-timeout-ms: + type: int + description: Time in milliseconds after which CMUX will enter power save mode. +-- +2.53.0 + diff --git a/zephyr/patches/ncs/zephyr/0003-drivers-modem_cellular-add-Ready-signal-handling.patch b/zephyr/patches/ncs/zephyr/0003-drivers-modem_cellular-add-Ready-signal-handling.patch new file mode 100644 index 0000000..c5ef806 --- /dev/null +++ b/zephyr/patches/ncs/zephyr/0003-drivers-modem_cellular-add-Ready-signal-handling.patch @@ -0,0 +1,29 @@ +From f39324378c5ecfd4c37153ad0a5793dcf38a115b Mon Sep 17 00:00:00 2001 +From: Marcin Niestroj +Date: Thu, 12 Feb 2026 09:46:16 +0100 +Subject: [PATCH] drivers: modem_cellular: add "Ready" signal handling + +This is the same as "APP RDY", but for other modems, such as nRF-SLM. + +Signed-off-by: Marcin Niestroj +--- + drivers/modem/modem_cellular.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/modem/modem_cellular.c b/drivers/modem/modem_cellular.c +index 412ced1dfa8..be075c11070 100644 +--- a/drivers/modem/modem_cellular.c ++++ b/drivers/modem/modem_cellular.c +@@ -622,7 +622,8 @@ MODEM_CHAT_MATCHES_DEFINE(unsol_matches, + MODEM_CHAT_MATCH("+CREG: ", ",", modem_cellular_chat_on_cxreg), + MODEM_CHAT_MATCH("+CEREG: ", ",", modem_cellular_chat_on_cxreg), + MODEM_CHAT_MATCH("+CGREG: ", ",", modem_cellular_chat_on_cxreg), +- MODEM_CHAT_MATCH("APP RDY", "", modem_cellular_chat_on_modem_ready)); ++ MODEM_CHAT_MATCH("APP RDY", "", modem_cellular_chat_on_modem_ready), ++ MODEM_CHAT_MATCH("Ready", "", modem_cellular_chat_on_modem_ready)); + + MODEM_CHAT_MATCHES_DEFINE(abort_matches, MODEM_CHAT_MATCH("ERROR", "", NULL)); + +-- +2.53.0 + diff --git a/zephyr/patches/thingy91x-controller/zephyr/0001-scripts-west_commands-Support-out-of-tree-runners.patch b/zephyr/patches/thingy91x-controller/zephyr/0001-scripts-west_commands-Support-out-of-tree-runners.patch deleted file mode 100644 index 1fc06c9..0000000 --- a/zephyr/patches/thingy91x-controller/zephyr/0001-scripts-west_commands-Support-out-of-tree-runners.patch +++ /dev/null @@ -1,91 +0,0 @@ -From cf3fb498b2789ab57f51349d41658ffd9b3a8bc5 Mon Sep 17 00:00:00 2001 -From: Pieter De Gendt -Date: Thu, 19 Dec 2024 07:31:22 +0100 -Subject: [PATCH] scripts: west_commands: Support out-of-tree runners - -Add runners entry to the module schema and import the file specified. - -Every class that inherits from ZephyrBinaryRunner will be discovered and -added to runners list. - -Signed-off-by: Pieter De Gendt ---- - scripts/west_commands/run_common.py | 20 +++++++++++++++++++- - scripts/zephyr_module.py | 9 +++++++++ - 2 files changed, 28 insertions(+), 1 deletion(-) - -diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py -index 012f27359d6..b807dd03bd3 100644 ---- a/scripts/west_commands/run_common.py -+++ b/scripts/west_commands/run_common.py -@@ -6,6 +6,7 @@ - '''Common code used by commands which execute runners. - ''' - -+import importlib.util - import re - import argparse - import logging -@@ -28,7 +29,9 @@ from runners.core import FileType - from runners.core import BuildConfiguration - import yaml - --from zephyr_ext_common import ZEPHYR_SCRIPTS -+from zephyr_ext_common import ZEPHYR_BASE, ZEPHYR_SCRIPTS -+sys.path.insert(0, str(ZEPHYR_SCRIPTS)) -+import zephyr_module - - # Runners depend on edtlib. Make sure the copy in the tree is - # available to them before trying to import any. -@@ -107,6 +110,13 @@ class SocBoardFilesProcessing: - priority: int = IGNORED_RUN_ONCE_PRIORITY - yaml: object = None - -+def import_from_path(module_name, file_path): -+ spec = importlib.util.spec_from_file_location(module_name, file_path) -+ module = importlib.util.module_from_spec(spec) -+ sys.modules[module_name] = module -+ spec.loader.exec_module(module) -+ return module -+ - def command_verb(command): - return "flash" if command.name == "flash" else "debug" - -@@ -197,6 +207,14 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None): - dump_context(command, user_args, user_runner_args) - return - -+ # Import external module runners -+ for module in zephyr_module.parse_modules(ZEPHYR_BASE, command.manifest): -+ runners_ext = module.meta.get("runners", []) -+ for runner in runners_ext: -+ import_from_path( -+ module.meta.get("name", "runners_ext"), Path(module.project) / runner["file"] -+ ) -+ - build_dir = get_build_dir(user_args) - if not user_args.skip_rebuild: - rebuild(command, build_dir, user_args) -diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py -index c6043154bdc..9b8a52fb629 100755 ---- a/scripts/zephyr_module.py -+++ b/scripts/zephyr_module.py -@@ -161,6 +161,15 @@ mapping: - type: seq - sequence: - - type: str -+ runners: -+ required: false -+ type: seq -+ sequence: -+ - type: map -+ mapping: -+ file: -+ required: true -+ type: str - ''' - - MODULE_YML_PATH = PurePath('zephyr/module.yml') --- -2.48.1 - diff --git a/zephyr/patches/zephyr/zephyr/0001-drivers-net-nsos-support-nrf_bsim.patch b/zephyr/patches/zephyr/zephyr/0001-drivers-net-nsos-support-nrf_bsim.patch index ff354a3..6ed43df 100644 --- a/zephyr/patches/zephyr/zephyr/0001-drivers-net-nsos-support-nrf_bsim.patch +++ b/zephyr/patches/zephyr/zephyr/0001-drivers-net-nsos-support-nrf_bsim.patch @@ -1,4 +1,4 @@ -From 073a10f50ff7275970471af29f27b6ba5c4b17b5 Mon Sep 17 00:00:00 2001 +From 8d013089772fd106241a90255c5b12ed40d1fddd Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 14 Jan 2025 16:53:03 +0100 Subject: [PATCH] drivers: net: nsos: support nrf_bsim @@ -14,7 +14,7 @@ Signed-off-by: Marcin Niestroj 1 file changed, 4 insertions(+) diff --git a/drivers/net/nsos_adapt.c b/drivers/net/nsos_adapt.c -index d1631efc651..9e908982e38 100644 +index 377649cdd1f..5e2976e49f0 100644 --- a/drivers/net/nsos_adapt.c +++ b/drivers/net/nsos_adapt.c @@ -1164,7 +1164,11 @@ static void nsos_adapt_poll_triggered(void) @@ -30,5 +30,5 @@ index d1631efc651..9e908982e38 100644 } else { nsos_adapt_poll_time = nsi_hws_get_time() + NSOS_EPOLL_WAIT_INTERVAL; -- -2.51.0 +2.52.0 diff --git a/zephyr/patches/zephyr/zephyr/0002-boards-nrf_bsim-define-NSOS_IRQ-for-offloaded-socket.patch b/zephyr/patches/zephyr/zephyr/0002-boards-nrf_bsim-define-NSOS_IRQ-for-offloaded-socket.patch index f50459b..00ee86e 100644 --- a/zephyr/patches/zephyr/zephyr/0002-boards-nrf_bsim-define-NSOS_IRQ-for-offloaded-socket.patch +++ b/zephyr/patches/zephyr/zephyr/0002-boards-nrf_bsim-define-NSOS_IRQ-for-offloaded-socket.patch @@ -1,4 +1,4 @@ -From dacb35a6427d1f177bada3e10cea8162af5c0757 Mon Sep 17 00:00:00 2001 +From 3d2a38e73f028b1c1333331e9250f280efbb8e10 Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 14 Jan 2025 17:02:25 +0100 Subject: [PATCH] boards: nrf_bsim: define NSOS_IRQ for offloaded sockets @@ -18,7 +18,7 @@ Signed-off-by: Marcin Niestroj 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/boards/native/nrf_bsim/board_soc.h b/boards/native/nrf_bsim/board_soc.h -index e0b1cb60a59..a99916ec2cf 100644 +index ee77478caab..609038feee1 100644 --- a/boards/native/nrf_bsim/board_soc.h +++ b/boards/native/nrf_bsim/board_soc.h @@ -19,6 +19,7 @@ @@ -52,5 +52,5 @@ index e0b1cb60a59..a99916ec2cf 100644 #define FLASH_PAGE_MAX_CNT 256UL -- -2.51.0 +2.52.0 diff --git a/zephyr/patches/zephyr/zephyr/0003-nsi-move-nsos_fcntl-to-more-generic-nsi_fcntl.patch b/zephyr/patches/zephyr/zephyr/0003-nsi-move-nsos_fcntl-to-more-generic-nsi_fcntl.patch index fe765c4..10bb8b3 100644 --- a/zephyr/patches/zephyr/zephyr/0003-nsi-move-nsos_fcntl-to-more-generic-nsi_fcntl.patch +++ b/zephyr/patches/zephyr/zephyr/0003-nsi-move-nsos_fcntl-to-more-generic-nsi_fcntl.patch @@ -1,4 +1,4 @@ -From 5664e6eff028f7dfb50dcbd0e34775b8a057f5e1 Mon Sep 17 00:00:00 2001 +From e3ad9fabde039ced9dec44d9068ee061bd8e0011 Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 5 Aug 2025 18:18:07 +0200 Subject: [PATCH] nsi: move nsos_fcntl to more generic nsi_fcntl @@ -76,11 +76,11 @@ index ba3e44fd1f4..f439fc76592 100644 target_sources(native_simulator INTERFACE nsos_netdb.c) endif() diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig -index 30f3b4fb30f..10deb67c02d 100644 +index c9672be5f77..1ab24ea93aa 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig -@@ -250,6 +250,7 @@ menuconfig NET_NATIVE_OFFLOADED_SOCKETS - depends on NATIVE_LIBRARY +@@ -249,6 +249,7 @@ menuconfig NET_NATIVE_OFFLOADED_SOCKETS + depends on ARCH_POSIX depends on NET_SOCKETS_OFFLOAD select NATIVE_USE_NSI_ERRNO + select NATIVE_USE_NSI_FCNTL @@ -88,7 +88,7 @@ index 30f3b4fb30f..10deb67c02d 100644 Offloaded sockets for Native Simulator utilize host BSD sockets API (like socket(), connect(), send(), recvfrom(), etc.) in order to provide networking capability. diff --git a/drivers/net/nsos_adapt.c b/drivers/net/nsos_adapt.c -index 9e908982e38..e460a509246 100644 +index 5e2976e49f0..04b36fac51b 100644 --- a/drivers/net/nsos_adapt.c +++ b/drivers/net/nsos_adapt.c @@ -30,7 +30,7 @@ @@ -243,7 +243,7 @@ index 3cab88896f7..00000000000 - -#endif /* __DRIVERS_NET_NSOS_FCNTL_H__ */ diff --git a/drivers/net/nsos_sockets.c b/drivers/net/nsos_sockets.c -index fdf5a7e8bbf..a3b5d4aa8d6 100644 +index 9f50512cda5..ee96b43f31f 100644 --- a/drivers/net/nsos_sockets.c +++ b/drivers/net/nsos_sockets.c @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(nsos_sockets); @@ -255,7 +255,7 @@ index fdf5a7e8bbf..a3b5d4aa8d6 100644 #include "nsos_netdb.h" #include "nsos_socket.h" -@@ -388,14 +388,14 @@ static int nsos_ioctl(void *obj, unsigned int request, va_list args) +@@ -391,14 +391,14 @@ static int nsos_ioctl(void *obj, unsigned int request, va_list args) flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); @@ -272,7 +272,7 @@ index fdf5a7e8bbf..a3b5d4aa8d6 100644 if (ret < 0) { return -nsi_errno_from_mid(-ret); } -@@ -616,7 +616,7 @@ static int nsos_poll_if_blocking(struct nsos_socket *sock, int events, +@@ -619,7 +619,7 @@ static int nsos_poll_if_blocking(struct nsos_socket *sock, int events, non_blocking = true; } else { sock_flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); @@ -281,7 +281,7 @@ index fdf5a7e8bbf..a3b5d4aa8d6 100644 } if (!non_blocking) { -@@ -658,7 +658,7 @@ static int nsos_connect_blocking(struct nsos_socket *sock, +@@ -661,7 +661,7 @@ static int nsos_connect_blocking(struct nsos_socket *sock, int clear_nonblock_ret; int ret; @@ -290,7 +290,7 @@ index fdf5a7e8bbf..a3b5d4aa8d6 100644 if (ret < 0) { return ret; } -@@ -707,7 +707,7 @@ static int nsos_connect(void *obj, const struct sockaddr *addr, socklen_t addrle +@@ -711,7 +711,7 @@ static int nsos_connect(void *obj, const struct sockaddr *addr, socklen_t addrle flags = nsos_adapt_fcntl_getfl(sock->poll.mid.fd); @@ -425,5 +425,5 @@ index 00000000000..d1fb298a532 + return flags; +} -- -2.51.0 +2.52.0 diff --git a/zephyr/patches/zephyr/zephyr/0004-nsi-fcntl-add-O_CREAT-and-O_TRUNC.patch b/zephyr/patches/zephyr/zephyr/0004-nsi-fcntl-add-O_CREAT-and-O_TRUNC.patch index 969d748..16322b7 100644 --- a/zephyr/patches/zephyr/zephyr/0004-nsi-fcntl-add-O_CREAT-and-O_TRUNC.patch +++ b/zephyr/patches/zephyr/zephyr/0004-nsi-fcntl-add-O_CREAT-and-O_TRUNC.patch @@ -1,4 +1,4 @@ -From e427f05d4bb0d82871a6b7abd80805caa3e1f555 Mon Sep 17 00:00:00 2001 +From 81d5d2c8328c48fcb0e0a6b8976a35a837bbef5b Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Thu, 14 Aug 2025 12:30:36 +0200 Subject: [PATCH] nsi: fcntl: add O_CREAT and O_TRUNC @@ -47,5 +47,5 @@ index d1fb298a532..487824e9f4c 100644 FROM_MID(O_EXCL); FROM_MID(O_NONBLOCK); -- -2.51.0 +2.52.0 diff --git a/zephyr/patches/zephyr/zephyr/0005-subsys-fs-nsim_mount-new-FS-for-mounting-host-filesy.patch b/zephyr/patches/zephyr/zephyr/0005-subsys-fs-nsim_mount-new-FS-for-mounting-host-filesy.patch index a62b469..fd1c6ea 100644 --- a/zephyr/patches/zephyr/zephyr/0005-subsys-fs-nsim_mount-new-FS-for-mounting-host-filesy.patch +++ b/zephyr/patches/zephyr/zephyr/0005-subsys-fs-nsim_mount-new-FS-for-mounting-host-filesy.patch @@ -1,4 +1,4 @@ -From f37625a5066c54ba371e055c4c2aa7c19e4de7c2 Mon Sep 17 00:00:00 2001 +From 56ae5d0d190160212a03fddb9819eaf420d6ea94 Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Thu, 14 Aug 2025 12:34:01 +0200 Subject: [PATCH] subsys: fs: nsim_mount: new FS for mounting host filesystem @@ -27,12 +27,12 @@ Signed-off-by: Marcin Niestroj create mode 100644 subsys/fs/nsim_mount_bottom.h diff --git a/include/zephyr/fs/fs.h b/include/zephyr/fs/fs.h -index e2cf7dff73b..99bace60393 100644 +index c43d78e7df5..7a38995566e 100644 --- a/include/zephyr/fs/fs.h +++ b/include/zephyr/fs/fs.h -@@ -61,6 +61,9 @@ enum { - /** Identifier for in-tree Ext2 file system. */ - FS_EXT2, +@@ -64,6 +64,9 @@ enum { + /** Identifier for in-tree Virtiofs file system. */ + FS_VIRTIOFS, + /** Identifier for in-tree Native Simulator mount file system. */ + FS_NSIM_MOUNT, @@ -41,7 +41,7 @@ index e2cf7dff73b..99bace60393 100644 FS_TYPE_EXTERNAL_BASE, }; diff --git a/subsys/fs/CMakeLists.txt b/subsys/fs/CMakeLists.txt -index 48df605ae01..24108d05faa 100644 +index 66206064334..46a42de179f 100644 --- a/subsys/fs/CMakeLists.txt +++ b/subsys/fs/CMakeLists.txt @@ -11,6 +11,11 @@ if(CONFIG_FILE_SYSTEM_LIB_LINK) @@ -57,12 +57,12 @@ index 48df605ae01..24108d05faa 100644 LFS_CONFIG=zephyr_lfs_config.h ) diff --git a/subsys/fs/Kconfig b/subsys/fs/Kconfig -index 4dde4b27100..d895c50ec3c 100644 +index 7693c69e847..0b261685c9e 100644 --- a/subsys/fs/Kconfig +++ b/subsys/fs/Kconfig -@@ -99,6 +99,18 @@ config FUSE_FS_ACCESS - help - Expose file system partitions to the host system through FUSE. +@@ -128,6 +128,18 @@ config FUSE_LIBRARY_V3 + + endchoice +config FILE_SYSTEM_NSIM_MOUNT + bool "Mount Native Simulator host FS to Zephyr" @@ -1012,5 +1012,5 @@ index 00000000000..0ee97b3f371 + +#endif /* ZEPHYR_FS_NSIM_MOUNT_BOTTOM_H */ -- -2.51.0 +2.52.0 diff --git a/zephyr/patches/zephyr/zephyr/0006-tests-fs-nsim_mount-add-basic-tests-for-implemented-.patch b/zephyr/patches/zephyr/zephyr/0006-tests-fs-nsim_mount-add-basic-tests-for-implemented-.patch index 343bd88..786c99f 100644 --- a/zephyr/patches/zephyr/zephyr/0006-tests-fs-nsim_mount-add-basic-tests-for-implemented-.patch +++ b/zephyr/patches/zephyr/zephyr/0006-tests-fs-nsim_mount-add-basic-tests-for-implemented-.patch @@ -1,4 +1,4 @@ -From 20f3456b3e9a36471fe36087f7ac63137c592b6a Mon Sep 17 00:00:00 2001 +From 3346a85779f41103a838d59fedb259928fe26adf Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 5 Aug 2025 15:51:59 +0200 Subject: [PATCH] tests: fs: nsim_mount: add basic tests for implemented @@ -354,5 +354,5 @@ index 00000000000..e8693894deb +tests: + filesystem.nsim_mount.default: {} -- -2.51.0 +2.52.0 diff --git a/zephyr/snippets/thingy91x-uart0-exp-board/snippet.yml b/zephyr/snippets/thingy91x-uart0-exp-board/snippet.yml new file mode 100644 index 0000000..ece31a6 --- /dev/null +++ b/zephyr/snippets/thingy91x-uart0-exp-board/snippet.yml @@ -0,0 +1,5 @@ +name: thingy91x-uart0-exp-board +boards: + /thingy91x/nrf9151/ns/: + append: + EXTRA_DTC_OVERLAY_FILE: thingy91x-uart0-exp-board.overlay diff --git a/zephyr/snippets/thingy91x-uart0-exp-board/thingy91x-uart0-exp-board.overlay b/zephyr/snippets/thingy91x-uart0-exp-board/thingy91x-uart0-exp-board.overlay new file mode 100644 index 0000000..caf4fd6 --- /dev/null +++ b/zephyr/snippets/thingy91x-uart0-exp-board/thingy91x-uart0-exp-board.overlay @@ -0,0 +1,24 @@ +&uart0 { + pinctrl-0 = <&uart_exp_board_default>; + pinctrl-1 = <&uart_exp_board_sleep>; +}; + +&pinctrl { + uart_exp_board_default: uart_exp_board_default { + group1 { + psels = ; + }; + group2 { + psels = ; + bias-pull-up; + }; + }; + + uart_exp_board_sleep: uart_exp_board_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +};