boards/arm/stm32l0/b-l072z-lrwan1: fix radio clock and add LoRa configurations

The 32 MHz TCXO that clocks the SX1276 is powered from PA12 and was never
driven, so the radio had no clock at all.  The user button was copied from
the Nucleo L073RZ and left on PC13, which carries DIO3 of the radio on this
board; it is PB2.

Adds lorawan_tx and lorawan_beacon, with the radio defaults of a public
LoRaWAN network in the 915 MHz band, and fills in the board page.

Assisted-by: Claude Code 4.8
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2026-08-05 13:36:55 -03:00 committed by Alan C. Assis
parent 7bda3b7c8b
commit c191bcb76d
6 changed files with 386 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -6,4 +6,233 @@ ST B-L072Z-LRWAN1
.. tags:: chip:stm32, chip:stm32l0, chip:stm32l072
The B-L072Z-LRWAN1 is a development board based on CMWX1ZZABZ-091 (STM32L072CZ and an SX1276 transceiver).
.. figure:: b-l072z-lrwan1.jpg
:align: center
The B-L072Z-LRWAN1 is a LoRa and Sigfox discovery board built around the
Murata CMWX1ZZABZ-091 module, which packs an STM32L072CZ microcontroller and
a Semtech SX1276 sub-GHz transceiver into a single package. The board
carries an SMA connector with a whip antenna, an on-board ST-LINK/V2-1 and
Arduino Uno R3 compatible headers.
Board information
=================
The board features:
- Murata CMWX1ZZABZ-091 module: STM32L072CZ (Cortex-M0+ up to 32 MHz,
192 KiB flash, 20 KiB RAM) plus an SX1276 transceiver
- Programmable RF power, up to +14 dBm on the RFO path and +20 dBm on
PA_BOOST
- SMA and U.FL antenna connectors
- 32 MHz TCXO for the radio, powered from a GPIO
- On-board ST-LINK/V2-1 with mass storage programming and a virtual COM
port
- Arduino Uno R3 headers plus the ST morpho extension headers
- Four LEDs and one user button
- USB 2.0 full speed device connector
- Powered from USB, from an external supply or from a battery
Board documentation:
https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html
Clocking
========
NuttX runs the part from the internal 16 MHz RC oscillator through the PLL,
which gives a 32 MHz system clock. No external crystal is needed for the
microcontroller; the 32 MHz TCXO of the module belongs to the radio.
Serial console
==============
USART2 is wired to the virtual COM port of the on-board ST-LINK and is the
NuttX console in every configuration:
=========== =====
Signal Pin
=========== =====
USART2_TX PA2
USART2_RX PA3
=========== =====
Settings are 115200 8N1. With the board plugged in, the port shows up as
``/dev/ttyACM0`` on Linux.
LEDs
====
The board has four LEDs, all active high:
===== ==== ========================
LED Pin Colour
===== ==== ========================
LED1 PA5 Green, also Arduino D13
LED2 PB5 Green
LED3 PB6 Blue
LED4 PB7 Red
===== ==== ========================
If ``CONFIG_ARCH_LEDS`` is selected, LED1 is driven by the OS to show the
system state:
========================== ==========
State LED1
========================== ==========
Idle stack created ON
In an interrupt Flashing
Signal handler, assertion Flashing
The system has crashed Blinking
========================== ==========
Otherwise the four LEDs are available to the application through
``/dev/userleds`` when ``CONFIG_USERLED`` is selected.
Buttons
=======
======== ==== ===================================
Button Pin Notes
======== ==== ===================================
B1 USER PB2 Pulled up, active low, EXTI capable
B2 RESET NRST Resets the microcontroller
======== ==== ===================================
Radio
=====
The SX1276 sits inside the module and is reached over SPI1. Besides the bus
and the interrupt lines, three GPIOs drive the antenna switch and one powers
the TCXO that clocks the radio:
=============== ==== ============================================
Signal Pin Notes
=============== ==== ============================================
SPI1_NSS PA15 Chip select, driven as a GPIO
SPI1_SCK PB3
SPI1_MISO PA6
SPI1_MOSI PA7
RESET PC0 Active low
DIO0 PB4 Transmit and receive done, EXTI capable
DIO1 PB1
DIO2 PB0
DIO3 PC13
TCXO power PA12 Active high, needs about 5 ms to settle
RX enable PA1 Antenna switch towards RFI_HF
TX RFO enable PC2 Antenna switch towards RFO_HF, up to +14 dBm
TX BOOST enable PC1 Antenna switch towards PA_BOOST
=============== ==== ============================================
The board support code powers the TCXO before registering the driver and
picks the antenna switch position from the operating mode and the requested
power: the RFO path is used up to 14 dBm and PA_BOOST above that. This board
is wired for the high frequency band.
The driver itself, its configuration options and what has to match between
two radios to make them hear each other are documented in :ref:`sx127x`.
Other peripherals
=================
========= ================================================
Interface Pins
========= ================================================
USART1 PA9 (TX), PA10 (RX), on the Arduino header
SPI2 PB12 (NSS), PB13 (SCK), PB14 (MISO), PB15 (MOSI)
I2C1 PB8 (SCL), PB9 (SDA)
ADC PA0, PA4 and the other Arduino analogue pins
========= ================================================
Flashing
========
The board can be programmed through its own ST-LINK or through an external
debug probe on the SWD header.
With the ST-LINK, the simplest route is the mass storage device it exposes;
copying the raw binary to it programs the flash::
$ cp nuttx.bin /media/<user>/DIS_L072Z/
``openocd`` and ``st-flash`` work as well.
With a SEGGER J-Link on the SWD pins, use a command script::
$ cat > flash.jlink << EOF
h
loadbin nuttx.bin, 0x08000000
r
g
q
EOF
$ JLinkExe -device STM32L072CZ -if SWD -speed 4000 -autoconnect 1 \
-nogui 1 -CommanderScript flash.jlink
The virtual COM port of a stand-alone J-Link is not connected to USART2 of
this board, so the console still comes from the ST-LINK USB cable.
Configurations
==============
Each configuration is selected with::
$ ./tools/configure.sh b-l072z-lrwan1:<name>
$ make
nsh
---
The basic NuttShell configuration over USART2, with the ``hello`` example
built in. A good first check that the board boots.
adc
---
NuttShell plus the ``adc`` example, reading the ADC with software triggered
conversions.
nxlines_oled
------------
Runs the ``nxlines`` graphics example on an SSD1306 OLED display connected to
I2C1 (PB8 and PB9), in one bit per pixel mode.
sx127x
------
NuttShell plus the ``sx127x`` example and the SX1276 driver registered at
``/dev/sx127x``. The example defaults to FSK at 930 MHz; everything can be
overridden from the command line::
nsh> sx127x -h
nsh> sx127x -m 0 -f 917200000 -t -p 14 -l 32 # transmit LoRa frames
nsh> sx127x -m 0 -f 917200000 -r # receive them
lorawan_tx
----------
The same interactive setup, but with the radio defaults already matching a
public LoRaWAN network in the 915 MHz band: LoRa modulation, 917.2 MHz,
125 kHz bandwidth, spreading factor 7, CRC enabled and the 0x34 sync word.
Useful to feed a gateway under test::
nsh> sx127x -m 0 -f 917200000 -t -p 14 -l 32 -i 5 -d 60
lorawan_beacon
--------------
The same radio settings without a shell: the example itself is the entry
point and starts transmitting as soon as the board boots, which is what is
needed when the board is driven from a debug probe and no console is wired.
The command line of the example comes from ``CONFIG_INIT_ARGS``, and the
frequency, the payload size and the power from
``CONFIG_EXAMPLES_SX127X_RFFREQ``, ``_TXDATA`` and ``_TXPOWER``.
Talking to another radio
========================
Two of these boards reach each other with the ``lorawan_tx`` configuration,
one receiving and the other transmitting, and the same commands work against
a LoRaWAN gateway. The recipes, and the settings that have to match on both
sides, are in :ref:`sx127x`.

View file

@ -0,0 +1,72 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="b-l072z-lrwan1"
CONFIG_ARCH_BOARD_B_L072Z_LRWAN1=y
CONFIG_ARCH_CHIP="stm32l0"
CONFIG_ARCH_CHIP_STM32=y
CONFIG_ARCH_CHIP_STM32L072CZ=y
CONFIG_ARCH_CHIP_STM32L072XX=y
CONFIG_ARCH_CHIP_STM32L0=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=2796
CONFIG_BUILTIN=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_WIRELESS=y
CONFIG_DEBUG_WIRELESS_ERROR=y
CONFIG_DEBUG_WIRELESS_INFO=y
CONFIG_DEBUG_WIRELESS_WARN=y
CONFIG_DISABLE_ENVIRON=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_DRIVERS_LPWAN=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_SX127X=y
CONFIG_EXAMPLES_SX127X_RFFREQ=917200000
CONFIG_EXAMPLES_SX127X_TXDATA=32
CONFIG_EXAMPLES_SX127X_TXPOWER=17
CONFIG_INIT_ARGS="\"-m\", \"0\", \"-t\", \"-d\", \"0\""
CONFIG_INIT_ENTRYPOINT="sx127x_main"
CONFIG_INIT_STACKSIZE=1536
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_LPWAN_SX127X=y
CONFIG_LPWAN_SX127X_LORA_BW_DEFAULT=7
CONFIG_LPWAN_SX127X_LORA_SYNCWORD=0x34
CONFIG_LPWAN_SX127X_RFFREQ_DEFAULT=917200000
CONFIG_LPWAN_SX127X_RXSUPPORT=y
CONFIG_LPWAN_SX127X_TXSUPPORT=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_MAXARGUMENTS=12
CONFIG_NSH_READLINE=y
CONFIG_NUNGET_CHARS=0
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_PTHREAD_MUTEX_UNSAFE=y
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_RAM_SIZE=20480
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=19
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2013
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_SERIAL_CONSOLE=y

View file

@ -0,0 +1,64 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="b-l072z-lrwan1"
CONFIG_ARCH_BOARD_B_L072Z_LRWAN1=y
CONFIG_ARCH_CHIP="stm32l0"
CONFIG_ARCH_CHIP_STM32=y
CONFIG_ARCH_CHIP_STM32L072CZ=y
CONFIG_ARCH_CHIP_STM32L072XX=y
CONFIG_ARCH_CHIP_STM32L0=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=2796
CONFIG_BUILTIN=y
CONFIG_DISABLE_ENVIRON=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_DISABLE_POSIX_TIMERS=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_DRIVERS_LPWAN=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_SX127X=y
CONFIG_EXAMPLES_SX127X_RFFREQ=917200000
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=1536
CONFIG_INTELHEX_BINARY=y
CONFIG_LINE_MAX=64
CONFIG_LPWAN_SX127X=y
CONFIG_LPWAN_SX127X_LORA_BW_DEFAULT=7
CONFIG_LPWAN_SX127X_LORA_SYNCWORD=0x34
CONFIG_LPWAN_SX127X_RFFREQ_DEFAULT=917200000
CONFIG_LPWAN_SX127X_RXSUPPORT=y
CONFIG_LPWAN_SX127X_TXSUPPORT=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=64
CONFIG_NSH_MAXARGUMENTS=12
CONFIG_NSH_READLINE=y
CONFIG_NUNGET_CHARS=0
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_PTHREAD_MUTEX_UNSAFE=y
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_RAM_SIZE=20480
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=19
CONFIG_START_MONTH=5
CONFIG_START_YEAR=2013
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART2_SERIAL_CONSOLE=y

View file

@ -65,21 +65,20 @@
/* Button definitions *******************************************************/
/* The Nucleo L073RZ supports two buttons; only one button is controllable
* by software:
/* The board has two buttons, only one of which is controllable by software:
*
* B1 USER: user button connected to the I/O PC13 of the STM32L073RZT6.
* B2 RESET: push button connected to NRST is used to RESET the
* STM32L073RZT6.
* B1 USER: user button connected to PB2, pulled up, active low.
* B2 RESET: push button connected to NRST.
*
* NOTE that EXTI interrupts are configured.
* NOTE that EXTI interrupts are configured. PC13 is not a button here: on
* this board it carries DIO3 of the radio.
*/
#define MIN_IRQBUTTON BUTTON_USER
#define MAX_IRQBUTTON BUTTON_USER
#define NUM_IRQBUTTONS 1
#define GPIO_BTN_USER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN13)
#define GPIO_BTN_USER (GPIO_INPUT|GPIO_PULLUP|GPIO_EXTI|GPIO_PORTB|GPIO_PIN2)
/* SX1276
* RESET - PC0 (active low)
@ -103,6 +102,13 @@
#define GPIO_SX127X_CRF2 (GPIO_SPEED_HIGH | GPIO_PORTC | GPIO_PIN2)
#define GPIO_SX127X_CRF3 (GPIO_SPEED_HIGH | GPIO_PORTC | GPIO_PIN1)
/* The 32 MHz TCXO of the module is powered from PA12. The radio has no
* clock at all until this is driven high.
*/
#define GPIO_SX127X_TCXO (GPIO_OUTPUT | GPIO_SPEED_HIGH | \
GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN12)
/* Oled configuration */
#define OLED_I2C_PORT 1

View file

@ -32,6 +32,7 @@
#include <assert.h>
#include <nuttx/debug.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/signal.h>
#include <nuttx/wireless/lpwan/sx127x.h>
@ -249,6 +250,12 @@ int stm32_lpwaninitialize(void)
wlinfo("Register the sx127x module\n");
/* Power the TCXO that clocks the radio, and give it time to settle */
stm32_configgpio(GPIO_SX127X_TCXO);
stm32_gpiowrite(GPIO_SX127X_TCXO, true);
up_mdelay(10);
/* Setup DIO0 */
stm32_configgpio(GPIO_SX127X_DIO0);