Skip to content

Commit

Permalink
Release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cmalletsmtc committed Jun 13, 2023
1 parent 55808fe commit 6c3fe0a
Show file tree
Hide file tree
Showing 28 changed files with 17,385 additions and 182 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.0] - 2023-06-05

### Changed

- [driver] Updated LR11xx driver to v2.3.0

## [2.1.0] - 2022-04-08

### Added
Expand Down
6,890 changes: 6,890 additions & 0 deletions application/inc/lr1110_transceiver_0308.h

Large diffs are not rendered by default.

6,890 changes: 6,890 additions & 0 deletions application/inc/lr1120_transceiver_0102.h

Large diffs are not rendered by default.

1,921 changes: 1,921 additions & 0 deletions application/inc/lr1121_transceiver_0102.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion application/inc/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {

#ifndef DEMO_VERSION
#warning "No demo version provided"
#define DEMO_VERSION "v2.1.0"
#define DEMO_VERSION "v2.2.0"
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion application/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* --- DEPENDENCIES ------------------------------------------------------------
*/

#include "lr1121_transceiver_0101.h"
#include "lr1110_transceiver_0308.h"

#include "configuration.h"
#include "system.h"
Expand Down
32 changes: 30 additions & 2 deletions lr11xx_driver/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v2.3.0] 2023-05-10

### Added

* [radio] `lr11xx_radio_set_lora_sync_timeout_with_mantissa_exponent()` function
* [radio] `LR11XX_RADIO_PKT_TYPE_BPSK` packet type, with `lr11xx_radio_set_bpsk_pkt_params` and `lr11xx_radio_set_bpsk_mod_params` functions
* [GNSS] `lr11xx_gnss_apply_mixer_cfg_workaround()` function
* [GNSS] Add function `lr11xx_gnss_read_gnss_rssi_test` to read RSSI on GNSS path
* [GNSS] Add function `lr11xx_gnss_read_freq_search_space`
* [GNSS] Add function `lr11xx_gnss_set_freq_search_space`
* [GNSS] Add function `lr11xx_gnss_get_nb_visible_satellites`
* [GNSS] Add function `lr11xx_gnss_get_visible_satellites`
* [GNSS] add structure `lr11xx_gnss_visible_satellite_t` to support `lr11xx_gnss_get_visible_satellites` function
* [lr-fhss] Add function `lr11xx_lr_fhss_get_bit_delay_in_us` to compute the delay between the last LR-FHSS bit sent and the TX done interrupt
* [radio] Add function `lr11xx_radio_set_lr_fhss_sync_word` to configure the LR-FHSS syncword
* [radio] Add function `lr11xx_radio_set_lr_fhss_mod_params` to configure the LR-FHSS modulation parameters
* [radio] Add helper function `lr11xx_radio_convert_nb_symb_to_mant_exp` to convert a number of symbols into mantissa/exponent representation
* [crypto] Add functions `lr11xx_crypto_check_encrypted_firmware_image` and `lr11xx_crypto_get_check_encrypted_firmware_image_result`; and helper function `lr11xx_crypto_check_encrypted_firmware_image_full` to check suitability of encrypted firmware image prior to actual flashing
* [ranging] Add `lr11xx_ranging_*` functions as part of new ranging component `lr11xx_ranging`

### Changed

* [GNSS] Call to `lr11xx_gnss_apply_mixer_cfg_workaround()` in `lr11xx_gnss_scan_autonomous()` and `lr11xx_gnss_scan_assisted()` (can be removed by defining `LR11XX_DISABLE_MIXER_CFG_WORKAROUND`)
* [system] Field `type` of `lr11xx_system_version_t` is now an enumerated type named `lr11xx_system_version_type_t`
* [system] Add IRQ raised on LoRa symbol received over-the-air
* [radio] `lr11xx_radio_set_lora_sync_timeout` takes argument `nb_symbol` as `uint16_t`
* [regmem] `lr11xx_regmem_write_regmem32` and `lr11xx_regmem_read_regmem32` test the number of words to write/read before actually requesting the chip, and raise an error status if it is higher than 64

## [v2.1.1] 2022-04-06

### Fixed
Expand All @@ -19,8 +47,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* [radio] `LR11XX_RADIO_LORA_BW_200`, `LR11XX_RADIO_LORA_BW_400` and `LR11XX_RADIO_LORA_BW_800` entries to `lr11xx_radio_lora_bw_t`
* [radio] `LR11XX_RADIO_GFSK_PKT_VAR_LEN_SX128X_COMP` entry in `lr11xx_radio_gfsk_pkt_len_modes_t` to support compatibility with SX128x
* [radio] `LR11XX_RADIO_GFSK_DC_FREE_WHITENING_SX128X_COMP` entry in `lr11xx_radio_gfsk_dc_free_t` to support compatibility with SX128x
* [GNSS] `lr1110_gnss_get_consumption` function
* [Wi-Fi] `lr1110_wifi_get_consumption` function
* [GNSS] `lr11xx_gnss_get_consumption` function
* [Wi-Fi] `lr11xx_wifi_get_consumption` function
* [Wi-Fi] `lr11xx_wifi_are_scan_mode_result_format_compatible` function

### Changed
Expand Down
48 changes: 46 additions & 2 deletions lr11xx_driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The driver is split in several components:
- Wi-Fi Passive Scanning
- GNSS Scan Scanning
- Crypto engine
- Ranging

### Bootloader

Expand Down Expand Up @@ -42,6 +43,10 @@ This component is used to configure and initiate the acquisition of GNSS signals

This component is used to set and derive keys in the internal keychain and perform cryptographic operations with the integrated hardware accelerator.

### Ranging

This component is used to configure and operate the device's LoRa Ranging feature.

## Structure

Each component is based on different files:
Expand Down Expand Up @@ -81,7 +86,7 @@ The workaround is to reset the bit 30 in the register `0x00F30054` when the chip

This workaround does not solve the case where `LR11XX_RADIO_MODE_SLEEP` is configured with `lr11xx_radio_auto_tx_rx` and the chip is set to Rx mode. This is dues to the fact that the workaround cannot be applied before the subsequent transmission, automatically launched by the chip after waking up from sleep mode with retention.

#### Implementation 1
#### Implementation 1: systematic call by the driver

The first implementation - enabled by default in the driver - adds an implicit call updating the parameter to each function that could set the chip in transmission - directly or not -:

Expand All @@ -94,8 +99,47 @@ This implementation can be disabled by defining the macro `LR11XX_DISABLE_HIGH_A

The main advantage of this implementation is that it is transparent to the user who only needs to update the driver without changing its application. The main drawback is that the implicit call is done systematically even when not required.

#### Implementation 2
#### Implementation 2: user-handled call

The second method requires the user to explicitly call the function `lr11xx_radio_apply_high_acp_workaround` when the chip wakes up from sleep mode with retention (note: to ease the implementation, it can be called when the chip wakes up from any sleep mode).

This method requires the macro `LR11XX_DISABLE_HIGH_ACP_WORKAROUND` to be defined so the implementation 1 of the workaround (enabled by default) is disabled.

### Mixer configuration

#### Description

The following firmware versions are affected:

- LR1120 firmware 0x0101

When the chip ends a reception in the 2.4 GHz band, a parameter is not reconfigured properly. This misconfiguration will prevent a subsequent GNSS scan from working properly.

It is important to note that if the chip enters one of the following state between the reception in the 2.4GHz band and the GNSS scan, the parameter is properly reconfigured and the limitation does not appear:

- sleep mode (with or without retention)
- Wi-Fi scan
- Reception in the sub-GHz band

### Workaround

The workaround is to set the bit 4 in the register `0x00F30024` when the chip ends a reception in the 2.4GHz band before launching a GNSS scan.

This workaround is not needed when using any LR1110 firmware version. Nevertheless, it does not prevent a LR1110 from working properly if the workaround is not deactivated.

#### Implementation 1: systematic call by the driver

The first implementation - enabled by default in the driver - adds an implicit call updating the parameter to each function that could set the chip in GNSS scan mode:

- `lr11xx_gnss_scan_autonomous`
- `lr11xx_gnss_scan_assisted`

This implementation can be disabled by defining the macro `LR11XX_DISABLE_MIXER_CFG_WORKAROUND`. This disabling will be useful when, in the future, a new firmware integrating a fix is released and does not require the workaround anymore.

The main advantage of this implementation is that it is transparent to the user who only needs to update the driver without changing its application. The main drawback is that the implicit call is done systematically even when not required.

#### Implementation 2: user-handled call

The second method requires the user to explicitly call the function `lr11xx_gnss_apply_mixer_cfg_workaround` when the chip ends a reception in the 2.4GHz if a GNSS scan is planned after, without going through one of the states specified in the description of this limitation.

This method requires the macro `LR11XX_DISABLE_MIXER_CFG_WORKAROUND` to be defined so the implementation 1 of the workaround (enabled by default) is disabled.
124 changes: 111 additions & 13 deletions lr11xx_driver/src/lr11xx_crypto_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
* --- PRIVATE CONSTANTS -------------------------------------------------------
*/

#define LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32 ( 64 )
#define LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT8 ( LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32 * 4 )

#define LR11XX_CRYPTO_SELECT_CMD_LENGTH ( 2 + 1 )
#define LR11XX_CRYPTO_SET_KEY_CMD_LENGTH ( 2 + 17 )
#define LR11XX_CRYPTO_DERIVE_KEY_CMD_LENGTH ( 2 + 18 )
Expand All @@ -62,6 +65,8 @@
#define LR11XX_CRYPTO_RESTORE_FROM_FLASH_CMD_LENGTH ( 2 )
#define LR11XX_CRYPTO_SET_PARAMETER_CMD_LENGTH ( 2 + 1 + 4 )
#define LR11XX_CRYPTO_GET_PARAMETER_CMD_LENGTH ( 2 + 1 )
#define LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_CMD_LENGTH ( 2 + 4 )
#define LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_CMD_LENGTH ( 2 )

/*
* -----------------------------------------------------------------------------
Expand All @@ -73,19 +78,21 @@
*/
enum
{
LR11XX_CRYPTO_SELECT_OC = 0x0500,
LR11XX_CRYPTO_SET_KEY_OC = 0x0502,
LR11XX_CRYPTO_DERIVE_KEY_OC = 0x0503,
LR11XX_CRYPTO_PROCESS_JOIN_ACCEPT_OC = 0x0504,
LR11XX_CRYPTO_COMPUTE_AES_CMAC_OC = 0x0505,
LR11XX_CRYPTO_VERIFY_AES_CMAC_OC = 0x0506,
LR11XX_CRYPTO_ENCRYPT_AES_01_OC = 0x0507,
LR11XX_CRYPTO_ENCRYPT_AES_OC = 0x0508,
LR11XX_CRYPTO_DECRYPT_AES_OC = 0x0509,
LR11XX_CRYPTO_STORE_TO_FLASH_OC = 0x050A,
LR11XX_CRYPTO_RESTORE_FROM_FLASH_OC = 0x050B,
LR11XX_CRYPTO_SET_PARAMETER_OC = 0x050D,
LR11XX_CRYPTO_GET_PARAMETER_OC = 0x050E,
LR11XX_CRYPTO_SELECT_OC = 0x0500,
LR11XX_CRYPTO_SET_KEY_OC = 0x0502,
LR11XX_CRYPTO_DERIVE_KEY_OC = 0x0503,
LR11XX_CRYPTO_PROCESS_JOIN_ACCEPT_OC = 0x0504,
LR11XX_CRYPTO_COMPUTE_AES_CMAC_OC = 0x0505,
LR11XX_CRYPTO_VERIFY_AES_CMAC_OC = 0x0506,
LR11XX_CRYPTO_ENCRYPT_AES_01_OC = 0x0507,
LR11XX_CRYPTO_ENCRYPT_AES_OC = 0x0508,
LR11XX_CRYPTO_DECRYPT_AES_OC = 0x0509,
LR11XX_CRYPTO_STORE_TO_FLASH_OC = 0x050A,
LR11XX_CRYPTO_RESTORE_FROM_FLASH_OC = 0x050B,
LR11XX_CRYPTO_SET_PARAMETER_OC = 0x050D,
LR11XX_CRYPTO_GET_PARAMETER_OC = 0x050E,
LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_OC = 0x050F,
LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_OC = 0x0510,
};

/*
Expand Down Expand Up @@ -113,6 +120,15 @@ enum
static void lr11xx_crypto_fill_cbuffer_opcode_key_data( uint8_t* cbuffer, uint16_t opcode, uint8_t key_id,
const uint8_t* data, uint16_t length );

/*!
* @brief Returns the minimum of the operand given as parameter and the maximum allowed block size
*
* @param [in] operand Size to compare
*
* @returns Minimum between operand and @ref LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32
*/
static uint8_t lr11xx_crypto_get_min_from_operand_and_max_block_size( uint32_t operand );

/*
* -----------------------------------------------------------------------------
* --- PUBLIC FUNCTIONS DEFINITION ---------------------------------------------
Expand Down Expand Up @@ -469,6 +485,76 @@ lr11xx_status_t lr11xx_crypto_get_parameter( const void* context, lr11xx_crypto_
return ( lr11xx_status_t ) hal_status;
}

lr11xx_status_t lr11xx_crypto_check_encrypted_firmware_image( const void* context, const uint32_t offset_in_byte,
const uint32_t* data, const uint8_t length_in_word )
{
const uint8_t cbuffer[LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_CMD_LENGTH] = {
( uint8_t ) ( LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_OC >> 8 ),
( uint8_t ) ( LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_OC >> 0 ),
( uint8_t ) ( offset_in_byte >> 24 ),
( uint8_t ) ( offset_in_byte >> 16 ),
( uint8_t ) ( offset_in_byte >> 8 ),
( uint8_t ) ( offset_in_byte >> 0 ),
};

uint8_t cdata[256] = { 0 };
for( uint8_t index = 0; index < length_in_word; index++ )
{
uint8_t* cdata_local = &cdata[index * sizeof( uint32_t )];

cdata_local[0] = ( uint8_t ) ( data[index] >> 24 );
cdata_local[1] = ( uint8_t ) ( data[index] >> 16 );
cdata_local[2] = ( uint8_t ) ( data[index] >> 8 );
cdata_local[3] = ( uint8_t ) ( data[index] >> 0 );
}

return ( lr11xx_status_t ) lr11xx_hal_write( context, cbuffer, LR11XX_CRYPTO_CHECK_ENCRYPTED_FW_IMAGE_CMD_LENGTH,
cdata, length_in_word * sizeof( uint32_t ) );
}

lr11xx_status_t lr11xx_crypto_check_encrypted_firmware_image_full( const void* context, const uint32_t offset_in_byte,
const uint32_t* buffer,
const uint32_t length_in_word )
{
uint32_t remaining_length = length_in_word;
uint32_t local_offset = offset_in_byte;
uint32_t loop = 0;

while( remaining_length != 0 )
{
const lr11xx_status_t status = lr11xx_crypto_check_encrypted_firmware_image(
context, local_offset, buffer + loop * LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32,
lr11xx_crypto_get_min_from_operand_and_max_block_size( remaining_length ) );

if( status != LR11XX_STATUS_OK )
{
return status;
}

local_offset += LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT8;
remaining_length = ( remaining_length < LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32 )
? 0
: ( remaining_length - LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32 );

loop++;
}

return LR11XX_STATUS_OK;
}

lr11xx_status_t lr11xx_crypto_get_check_encrypted_firmware_image_result( const void* context,
bool* is_encrypted_fw_image_ok )
{
const uint8_t cbuffer[LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_CMD_LENGTH] = {
( uint8_t ) ( LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_OC >> 8 ),
( uint8_t ) ( LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_OC >> 0 ),
};

return ( lr11xx_status_t ) lr11xx_hal_read( context, cbuffer,
LR11XX_CRYPTO_GET_CHECK_ENCRYPTED_FW_IMAGE_RESULT_CMD_LENGTH,
( uint8_t* ) is_encrypted_fw_image_ok, 1 );
}

/*
* -----------------------------------------------------------------------------
* --- PRIVATE FUNCTIONS DEFINITION --------------------------------------------
Expand All @@ -488,4 +574,16 @@ static void lr11xx_crypto_fill_cbuffer_opcode_key_data( uint8_t* cbuffer, uint16
}
}

uint8_t lr11xx_crypto_get_min_from_operand_and_max_block_size( uint32_t operand )
{
if( operand > LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32 )
{
return LR11XX_CRYPTO_FW_IMAGE_DATA_MAX_LENGTH_UINT32;
}
else
{
return ( uint8_t ) operand; // Downcast done on purpose given that the value is smaller than 64
}
}

/* --- EOF ------------------------------------------------------------------ */
Loading

0 comments on commit 6c3fe0a

Please sign in to comment.