diff --git a/CODEOWNERS b/CODEOWNERS index 8bd3c9872cf..e1ac4c1e32b 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -112,6 +112,7 @@ /boards/arm/qemu_cortex_r*/ @stephanosio /boards/arm/qemu_cortex_m*/ @ioannisg /boards/arm/quick_feather/ @kowalewskijan @kgugala +/boards/arm/rak4631_nrf52840/ @gpaquet85 /boards/arm/rak5010_nrf52840/ @gpaquet85 /boards/arm/ronoth_lodev/ @NorthernDean /boards/arm/xmc45_relax_kit/ @parthitce diff --git a/boards/arm/rak4631_nrf52840/Kconfig.board b/boards/arm/rak4631_nrf52840/Kconfig.board new file mode 100644 index 00000000000..f5db0172189 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/Kconfig.board @@ -0,0 +1,8 @@ +# RAKWIRELESS RAK4631 selection + +# Copyright (c) 2021 Guillaume Paquet +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_RAK4631_NRF52840 + bool "RAK4631 DK NRF52840" + depends on SOC_NRF52840_QIAA diff --git a/boards/arm/rak4631_nrf52840/Kconfig.defconfig b/boards/arm/rak4631_nrf52840/Kconfig.defconfig new file mode 100644 index 00000000000..46d127f3001 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/Kconfig.defconfig @@ -0,0 +1,24 @@ +# RAKWIRELESS RAK4631 Board configuration + +# Copyright (c) 2021 Guillaume Paquet +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_RAK4631_NRF52840 + +config BOARD + default "rak4631_nrf52840" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config BT_CTLR + default BT + +endif # BOARD_RAK4631_NRF52840 diff --git a/boards/arm/rak4631_nrf52840/board.cmake b/boards/arm/rak4631_nrf52840/board.cmake new file mode 100644 index 00000000000..e15baec6761 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/board.cmake @@ -0,0 +1,9 @@ +# Copyright (c) 2021 Guillaume Paquet +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=nrf52" "--speed=4000") +board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) diff --git a/boards/arm/rak4631_nrf52840/doc/img/rak4631-front-parts.jpg b/boards/arm/rak4631_nrf52840/doc/img/rak4631-front-parts.jpg new file mode 100644 index 00000000000..4ee9193bad5 Binary files /dev/null and b/boards/arm/rak4631_nrf52840/doc/img/rak4631-front-parts.jpg differ diff --git a/boards/arm/rak4631_nrf52840/doc/index.rst b/boards/arm/rak4631_nrf52840/doc/index.rst new file mode 100644 index 00000000000..475f4aea163 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/doc/index.rst @@ -0,0 +1,156 @@ +.. _rak4631_nrf52840: + +RAK4631 +####### + +Overview +******** + +RAK4631 is a WisBlock Core module for RAK WisBlock. +It extends the WisBlock series with a powerful +Nordic nRF52840 MCU that supports Bluetooth 5.0 +(Bluetooth Low Energy) and the newest LoRa transceiver +from Semtech, the SX1262. The Semtech SX1262 has compared +to the older SX127x series a lower power consumption at +the same TX power. This makes the RAK4631 an ultra-low +power communication solution. RAK4631 can be comfortably +programmed with ZephyrRTOS. + +.. image:: img/rak4631-front-parts.jpg + :width: 500px + :align: center + :alt: RAK4631-NRF52840 + +Hardware +******** + +To use a RAK4631, you need at least a WisBlock Base +to plug the module in. WisBlock Base is the power +supply for the RAK4631 module and has the +programming/debug interface. + +- nRF52840 ARM Cortex-M4F Processor +- 64 MHz CPU clock +- 1 Micro-AB USB OTG host/device +- Semtech SX1262 low power high range LoRa transceiver +- iPEX connectors for the LORA antenna and BLE antenna. +- Multiple interfaces, I2C, UART, GPIO, ADC +- 2 user LEDs on RAK5005 mother Board +- Powered by either Micro USB, 3.7V rechargeable battery or a 5V Solar Panel Port + +Supported Features +================== + +The rak4631_nrf52840 board configuration supports the following hardware features: + ++-----------+------------+----------------------+ +| Interface | Controller | Driver/Component | ++===========+============+======================+ +| ADC | on-chip | adc | ++-----------+------------+----------------------+ +| CLOCK | on-chip | clock_control | ++-----------+------------+----------------------+ +| FLASH | on-chip | flash | ++-----------+------------+----------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+----------------------+ +| I2C(M) | on-chip | i2c | ++-----------+------------+----------------------+ +| MPU | on-chip | arch/arm | ++-----------+------------+----------------------+ +| NVIC | on-chip | arch/arm | ++-----------+------------+----------------------+ +| PWM | on-chip | pwm | ++-----------+------------+----------------------+ +| RADIO | on-chip | Bluetooth, | +| | | ieee802154 | ++-----------+------------+----------------------+ +| RADIO | on-board | LoRa (SX1262) | ++-----------+------------+----------------------+ +| RTC | on-chip | system clock | ++-----------+------------+----------------------+ +| SPI(M/S) | on-chip | spi | ++-----------+------------+----------------------+ +| UART | on-chip | serial | ++-----------+------------+----------------------+ +| USB | on-chip | usb | ++-----------+------------+----------------------+ +| WDT | on-chip | watchdog | ++-----------+------------+----------------------+ + +The default board configuration can be found in the defconfig file: + + ``boards/arm/rak4631_nrf52840/rak4631_nrf52840_defconfig`` + +Connections and IOs +=================== + +LED +--- + +* LED1 (green) = P1.3 +* LED2 (blue) = P1.4 + +Programming and Debugging +************************* + +The RAK4631 board shall be connected to a Segger Embedded Debugger Unit +`J-Link OB `_. This provides a debug +interface to the NRF52840 chip. You can use JLink to communicate with +the NRF52840. + +Flashing +======== + +#. Download JLink from the Segger `JLink Downloads Page`_. Go to the section + "J-Link Software and Documentation Pack" and install the "J-Link Software + and Documentation pack for Linux". The application JLinkExe needs to be + accessible from your path. + +#. Run your favorite terminal program to listen for output. Under Linux the + terminal should be :code:`/dev/ttyACM0`. For example: + + .. code-block:: console + + $ minicom -D /dev/ttyACM0 -o + + The -o option tells minicom not to send the modem initialization string. + Connection should be configured as follows: + + - Speed: 115200 + - Data: 8 bits + - Parity: None + - Stop bits: 1 + +#. Connect the RAK4631 board to your host computer using the USB debug port. +Then build and flash the :ref:`hello_world` application. + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: rak4631_nrf52840 + :goals: build flash + + You should see "Hello World! rak4631_nrf52840" in your terminal. + +Debugging +========= + +You can debug an application in the usual way. Here is an example for the +:ref:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: rak4631_nrf52840 + :maybe-skip-config: + :goals: debug + +References +********** + +.. target-notes:: + +.. _RAK4631 Product Description: + https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/#overview + +.. _JLink Downloads Page: + https://www.segger.com/downloads/jlink diff --git a/boards/arm/rak4631_nrf52840/rak4631_nrf52840.dts b/boards/arm/rak4631_nrf52840/rak4631_nrf52840.dts new file mode 100644 index 00000000000..983b2998dcf --- /dev/null +++ b/boards/arm/rak4631_nrf52840/rak4631_nrf52840.dts @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2021 Guillaume Paquet + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + +/ { + model = "RAKWireless RAK4631 WisBlock LPWAN Module with a Nordic NRF52840 SoC"; + compatible = "nordic,rak4631_nrf52840"; + + chosen { + zephyr,console = &uart1; + zephyr,shell-uart = &uart1; + zephyr,uart-mcumgr = &uart1; + zephyr,bt-mon-uart = &uart1; + zephyr,bt-c2h-uart = &uart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + }; + + leds { + compatible = "gpio-leds"; + blue_led: led_2 { + gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; + label = "Blue LED"; + }; + green_led: led_1 { + gpios = <&gpio1 3 GPIO_ACTIVE_LOW>; + label = "Green LED"; + }; + }; + + /* Declaration of aliases */ + aliases { + led0 = &blue_led; + lora0 = &lora; + }; +}; + +&adc { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uart"; + status = "okay"; + current-speed = <115200>; + tx-pin = <20>; + rx-pin = <19>; +}; + +&uart1 { + compatible = "nordic,nrf-uarte"; + current-speed = <115200>; + status = "okay"; + tx-pin = <16>; + rx-pin = <15>; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + status = "okay"; + sda-gpios = <&gpio0 13 0>; + scl-gpios = <&gpio0 14 0>; +}; + +&i2c1 { + compatible = "nordic,nrf-twi"; + /* Cannot be used together with spi1. */ + /* status = "okay"; */ + sda-gpios = <&gpio0 24 0>; + scl-gpios = <&gpio0 25 0>; +}; + +&spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + sck-pin = <43>; + mosi-pin = <44>; + miso-pin = <45>; + cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; + + lora: sx1262@0 { + compatible = "semtech,sx1262"; + reg = <0>; + label = "sx1262"; + reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>; + busy-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>; + tx-enable-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + rx-enable-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + dio1-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; + dio2-tx-enable; + dio3-tcxo-voltage = ; + tcxo-power-startup-delay-ms = <5>; + spi-max-frequency = <1000000>; + }; +}; + +&qspi { + status = "okay"; + sck-pin = <3>; + io-pins = <30>, <29>, <28>, <2>; + csn-pins = <26>; +}; + +&flash0 { + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x000000000 0x0000C000>; + }; + slot0_partition: partition@c000 { + label = "image-0"; + reg = <0x0000C000 0x00067000>; + }; + slot1_partition: partition@73000 { + label = "image-1"; + reg = <0x00073000 0x00067000>; + }; + scratch_partition: partition@da000 { + label = "image-scratch"; + reg = <0x000da000 0x0001e000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; + +&usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; +}; diff --git a/boards/arm/rak4631_nrf52840/rak4631_nrf52840.yaml b/boards/arm/rak4631_nrf52840/rak4631_nrf52840.yaml new file mode 100644 index 00000000000..a8635c8fe48 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/rak4631_nrf52840.yaml @@ -0,0 +1,20 @@ +identifier: rak4631_nrf52840 +name: RAK4631-NRF52840 +type: mcu +arch: arm +flash: 1024 +ram: 256 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - ble + - counter + - gpio + - i2c + - pwm + - usb_cdc + - usb_device + - watchdog diff --git a/boards/arm/rak4631_nrf52840/rak4631_nrf52840_defconfig b/boards/arm/rak4631_nrf52840/rak4631_nrf52840_defconfig new file mode 100644 index 00000000000..a1d21db3092 --- /dev/null +++ b/boards/arm/rak4631_nrf52840/rak4631_nrf52840_defconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_RAK4631_NRF52840=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable RTT +CONFIG_USE_SEGGER_RTT=y + +# enable GPIO +CONFIG_GPIO=y + +# enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# additional board options +CONFIG_GPIO_AS_PINRESET=y diff --git a/samples/drivers/lora/receive/sample.yaml b/samples/drivers/lora/receive/sample.yaml index d74b10c5cb4..80503e45ec1 100644 --- a/samples/drivers/lora/receive/sample.yaml +++ b/samples/drivers/lora/receive/sample.yaml @@ -6,3 +6,4 @@ sample: tests: sample.driver.lora.receive: platform_allow: 96b_wistrio + platform_allow: rak4631_nrf52840 diff --git a/samples/drivers/lora/send/sample.yaml b/samples/drivers/lora/send/sample.yaml index ff4bbac8117..aca6f1924f8 100644 --- a/samples/drivers/lora/send/sample.yaml +++ b/samples/drivers/lora/send/sample.yaml @@ -6,3 +6,4 @@ sample: tests: sample.driver.lora.send: platform_allow: 96b_wistrio + platform_allow: rak4631_nrf52840 diff --git a/tests/drivers/adc/adc_api/src/test_adc.c b/tests/drivers/adc/adc_api/src/test_adc.c index e71ef453200..9bd3c0f4022 100644 --- a/tests/drivers/adc/adc_api/src/test_adc.c +++ b/tests/drivers/adc/adc_api/src/test_adc.c @@ -35,6 +35,7 @@ #elif defined(CONFIG_BOARD_NRF21540DK_NRF52840) || \ defined(CONFIG_BOARD_NRF52DK_NRF52832) || \ defined(CONFIG_BOARD_NRF52840DK_NRF52840) || \ + defined(CONFIG_BOARD_RAK4631_NRF52840) || \ defined(CONFIG_BOARD_RAK5010_NRF52840) || \ defined(CONFIG_BOARD_NRF52840DONGLE_NRF52840) || \ defined(CONFIG_BOARD_NRF52840_BLIP) || \