Closed danielSchaeble closed 1 year ago
Rather looks like a pure LORA driver point.
An optimal solution would be an option in the device tree to select the preferred RFO pin.
The SX127X driver has such an option, but not the SX126X driver, as both the SX1261 and SX1262 chips only have a single RF output, respectively LP and HP. The HP and LP output seems specific to the ST implementation, and the way to switch is not documented in the STM32WL reference manual, nor in the SX126X manual.
That said it is possible to find the way to switch between the two implementation by looking at STM32Cube. It appears that it uses a modified version of the loramac-node library, and uses the bit that selects between the SX1261 and the SX1262. So you might be able to get the LP output working by changing SX1262 into SX1261 in these lines: https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/lora/sx126x_common.h#L25-L27
Rather looks like a pure LORA driver point.
If that works it should be possible to add a property in the st,stm32wl-subghz-radio
binding and use it to select the correct chip version.
The HP and LP output seems specific to the ST implementation, and the way to switch is not documented in the STM32WL reference manual,
IIUC, it's actually documented in §5.8.4:
Set_PaConfig() command: byte 3 bits 7:1 Reserved, must be kept at reset value. bit 0 PaSel: PA selection. 0: HP PA selected 1: LP PA selected (default)
IIUC, it's actually documented in §5.8.4:
Indeed I search too quickly through the reference manual. Apologies.
IIUC, it's actually documented in §5.8.4:
Indeed I search too quickly through the reference manual. Apologies.
Took me some time to find it :-D
Thanks, so I am adding this up from you. According to the STM32WLE5CC RM (https://www.st.com/resource/en/reference_manual/rm0461-stm32wlex-advanced-armbased-32bit-mcus-with-subghz-radio-solution-stmicroelectronics.pdf) in §4.8.4 the Set_PaConfig(PaDutyCycle, HpMax, PaSel, 0x01) sets to LP or HP RFO.
In modules/lib/loramac-node/src/radio/sx126x/sx126x.c
the function void SX126xSetTxParams( int8_t power, RadioRampTimes_t rampTime)
calls the set_PaConfig() function according to the device. This is for SX1261 a LP setting and for SX1262 a HP setting.
That said it is possible to find the way to switch between the two implementation by looking at STM32Cube. It appears that it uses a modified version of the loramac-node library, and uses the bit that selects between the SX1261 and the SX1262. So you might be able to get the LP output working by changing SX1262 into SX1261 in these lines: https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/lora/sx126x_common.h#L25-L27
According to these lines for STM32WL the SX1262 is selected and so HP output is selected.
So I just changed line 27 from #define SX126X_DEVICE_ID SX1262
to #define SX126X_DEVICE_ID SX1261
and it seems to work. My test with the rssi (of course the RFO pins in this case NOT connected) improved from -110 to -70.
An idea for a solution in the zephyrproject discord:
https://discord.com/channels/720317445772017664/883448180950327366/1072593303729623100
Note that until this issue is fixed boards which exclusively use the RFO_LP
pin can't send LoRa transmissions, and the power amplifier may even be damaged if used in this configuration for longer durations.
I've spent two days debugging until I traced it to the RFO_
pins configuration and this issue, as my Olimex STM32WL Devkit wasn't sending detectable transmissions.
Is your enhancement proposal related to a problem? Please describe.
The STM32WL chip series has on chip LoRa and provides two input and two output pins for this. The low power output pin (RFO_LP) and the high power output pin (RFO_HP) are currently not choosable. By default the RFO_HP pin is used.
The limitation was found because of the following problem: A custom board with STM32WLE5CC, which is optimized to only use the RFO_LP pin was configured with two different firmwares. The first firmware is a bare metal version configured with STM32CubeMX and the second one is the lorawan class a sample from zephyr. The bare metal firmware reached and rssi of around -70 and the zephyr sample only of -110. After connecting the RFO_LP and the RFO_HP pin the zephyr sample reached an rssi of around -60.
Describe the solution you'd like An optimal solution would be an option in the devicetree to select the preferred RFO pin.
Additional context From the Datasheet of STM32WLE5CC