-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The engine tries to get the context as follows:
// get radio context
lr11xx_ctx = modem_get_radio_ctx( );Whose setter is called from here
void smtc_modem_set_radio_context( const void* radio_ctx )
{
#if defined( SX1272 ) || defined( SX1276 )
// update modem_radio context with provided one
( ( sx127x_t* ) modem_radio->ral.context )->hal_context = radio_ctx;
#else
// update modem_radio context with provided one
modem_radio->ral.context = radio_ctx;
#endif
// Save modem radio context in case of direct access to radio by the modem
modem_set_radio_ctx( modem_radio->ral.context );
}But, this function is only called from the hal:
usp_zephyr/modules/smtc_modem_hal/smtc_modem_hal.c
Lines 107 to 117 in 5da1e64
| void lorawan_smtc_modem_hal_init(const struct device *transceiver) | |
| { | |
| __ASSERT(transceiver, "transceiver must be provided"); | |
| prv_transceiver_dev = transceiver; | |
| #if defined(CONFIG_USP) | |
| smtc_rac_set_radio_context(prv_transceiver_dev); // Driver HAL implementation | |
| #endif | |
| #if defined( CONFIG_LORA_BASICS_MODEM ) | |
| smtc_modem_set_radio_context(prv_transceiver_dev); | |
| #endif | |
| } |
And CONFIG_LORA_BASICS_MODEM is not defined (????), so the setter is never called, meaning that the end application halts the system. For example, running the periodical_uplink sample, but with the following Kconfig settings:
CONFIG_LORA_BASICS_MODEM_CRYPTOGRAPHY_LR11XX=y
CONFIG_LORA_BASICS_MODEM_CRYPTOGRAPHY_LR11XX_WITH_CREDENTIALS=y
Raises the following logs:
*** Booting Zephyr OS build v4.2.0 ***
[01:03:35.550,366] <inf> usp: LoRaWAN Periodical uplink (60 sec) example is starting
[01:03:35.550,386] <inf> usp: Starting loop...
[01:03:35.797[01:03:35.797,711] <inf> lorawan: RP_HOOK_ID_SUSPEND: 0
[01:03:35.797,740] <inf> lorawan: RP_HOOK_RAC_VERY_HIGH_PRIORITY: 1
[01:03:35.797,769] <inf> lorawan: RP_HOOK_RAC_HIGH_PRIORITY: 2
[01:03:35.797,797] <inf> lorawan: RP_HOOK_RAC_MEDIUM_PRIORITY: 3
[01:03:35.797,826] <inf> lorawan: RP_HOOK_RAC_LOW_PRIORITY: 9
[01:03:35.797,856] <inf> lorawan: RP_HOOK_RAC_VERY_LOW_PRIORITY: 10
[01:03:35.797,885] <inf> lorawan: RP_HOOK_ID_LR1MAC_STACK: 4
[01:03:35.797,912] <inf> lorawan: RP_HOOK_ID_LBT: 5
[01:03:35.797,939] <inf> lorawan: RP_HOOK_ID_CAD: 6
[01:03:35.797,974] <inf> lorawan: RP_HOOK_ID_TEST_MODE: 7
[01:03:35.798,003] <inf> lorawan: RP_HOOK_ID_DIRECT_RP_ACCESS: 8
[01:03:35.798,031] <inf> lorawan: RP_HOOK_ID_MAX: 11
[01:03:35.798,069] <inf> lorawan: Modem Initialization
[01:03:39.048,768] <inf> lorawan: Use lr11xx crypto engine for cryptographic functionalities
[01:03:58.778,404] <err> os: ***** BUS FAULT *****
[01:03:58.778,409] <err> os: Precise data bus error
[01:03:58.778,413] <err> os: BFAR Address: 0x80e7fc30
[01:03:58.778,424] <err> os: r0/a1: 0x80e7fc20 r1/a2: 0x20008114 r2/a3: 0x00005dc0
[01:03:58.778,431] <err> os: r3/a4: 0x000000f7 r12/ip: 0x00005abc r14/lr: 0x0002d977
[01:03:58.778,435] <err> os: xpsr: 0x89000000
[01:03:58.778,439] <err> os: Faulting instruction address (r15/pc): 0x0002d956
[01:03:58.778,459] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[01:03:58.778,479] <err> os: Current thread: 0x20002388 (main)
[01:03:58.908,911] <err> os: Halting system
It breaks in particular here:
usp_zephyr/drivers/usp/lr11xx/lr11xx_hal.c
Lines 53 to 74 in 5da1e64
| static void lr11xx_hal_wait_on_busy(const void *context) | |
| { | |
| const struct device *dev = (const struct device *)context; | |
| const struct lr11xx_hal_context_cfg_t *config = dev->config; | |
| uint32_t end = k_uptime_get_32() + CONFIG_LORA_BASICS_MODEM_DRIVERS_HAL_WAIT_ON_BUSY_TIMEOUT_MSEC; | |
| bool timed_out = false; | |
| while (k_uptime_get_32() <= end) { | |
| timed_out = (gpio_pin_get_dt(&config->busy) == 0)?true:false; | |
| if (timed_out == true) { | |
| break; | |
| } else { | |
| k_usleep(100); | |
| } | |
| } | |
| if (!timed_out) { | |
| LOG_ERR("Timeout of %dms hit when waiting for lr11xx busy!", | |
| CONFIG_LORA_BASICS_MODEM_DRIVERS_HAL_WAIT_ON_BUSY_TIMEOUT_MSEC); | |
| k_oops(); | |
| } | |
| } |
Because &config->busy is a GPIO yet to be defined
Am I missing any configuration?
Edit 1:
In fact, if I change the function definition to:
const void* modem_get_radio_ctx( void )
{
return DEVICE_DT_GET( DT_CHOSEN( zephyr_lorawan_transceiver ) );
}It works like a charm.
However: I am using a LR1121, which per datasheet supports the crypto engine, but does not as per this drivers:
Lines 112 to 129 in 5da1e64
| choice | |
| prompt "Cryptography engine" | |
| default LORA_BASICS_MODEM_CRYPTOGRAPHY_SOFT | |
| help | |
| Specify which crypto engine will be used | |
| config LORA_BASICS_MODEM_CRYPTOGRAPHY_SOFT | |
| bool "Use software based cryptography module" | |
| config LORA_BASICS_MODEM_CRYPTOGRAPHY_LR11XX | |
| bool "Use lr11xx hardware cryptography module" | |
| depends on DT_HAS_SEMTECH_LR1110_ENABLED || DT_HAS_SEMTECH_LR1120_ENABLED | |
| config LORA_BASICS_MODEM_CRYPTOGRAPHY_LR11XX_WITH_CREDENTIALS | |
| bool "Use lr11xx hardware cryptography module with its embedded credentials" | |
| depends on DT_HAS_SEMTECH_LR1110_ENABLED || DT_HAS_SEMTECH_LR1120_ENABLED | |
| endchoice |
I have manually added support for the LR1121, which seems to work (as it should), is there any reason not to be included in the Kconfig fragment?