Skip to content

Commit 6ea6949

Browse files
soc: silabs: siwx91x: removed sscanf for nwp firmware version check
This patch removes the use of sscanf to maintain compatibility with tests that use the minimal cpp library. The expected version is now defined using multiple individual values rather than a single formatted string. Signed-off-by: Martin Hoff <[email protected]>
1 parent dbdd5e9 commit 6ea6949

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

modules/hal_silabs/wiseconnect/nwp_fw_version.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
*/
66

77
/* This value needs to be updated when the Wiseconnect SDK (hal_silabs/wiseconnect) is updated
8-
* Actually mapped to Wiseconnect SDK 3.5.0
8+
* Actually mapped to Wiseconnect SDK 3.5.2
99
*/
10-
#define SIWX91X_NWP_FW_EXPECTED_VERSION "B.2.14.5.2.0.7"
10+
#define SIWX91X_NWP_FW_EXPECTED_ROM_ID 11
11+
#define SIWX91X_NWP_FW_EXPECTED_MAJOR 2
12+
#define SIWX91X_NWP_FW_EXPECTED_MINOR 14
13+
#define SIWX91X_NWP_FW_EXPECTED_SECURITY_VERSION 5
14+
#define SIWX91X_NWP_FW_EXPECTED_PATCH_NUM 2
15+
#define SIWX91X_NWP_FW_EXPECTED_CUSTOMER_ID 0
16+
#define SIWX91X_NWP_FW_EXPECTED_BUILD_NUM 7

soc/silabs/silabs_siwx91x/siwg917/siwx91x_nwp.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,23 @@ static void siwx91x_configure_network_stack(sl_si91x_boot_configuration_t *boot_
261261

262262
static int siwx91x_check_nwp_version(void)
263263
{
264-
sl_wifi_firmware_version_t expected_version;
265264
sl_wifi_firmware_version_t version;
265+
sl_wifi_firmware_version_t expected_version = {
266+
.rom_id = SIWX91X_NWP_FW_EXPECTED_ROM_ID,
267+
.major = SIWX91X_NWP_FW_EXPECTED_MAJOR,
268+
.minor = SIWX91X_NWP_FW_EXPECTED_MINOR,
269+
.security_version = SIWX91X_NWP_FW_EXPECTED_SECURITY_VERSION,
270+
.patch_num = SIWX91X_NWP_FW_EXPECTED_PATCH_NUM,
271+
.customer_id = SIWX91X_NWP_FW_EXPECTED_CUSTOMER_ID,
272+
.build_num = SIWX91X_NWP_FW_EXPECTED_BUILD_NUM,
273+
};
266274
int ret;
267275

268276
ret = sl_wifi_get_firmware_version(&version);
269277
if (ret != SL_STATUS_OK) {
270278
return -EINVAL;
271279
}
272280

273-
sscanf(SIWX91X_NWP_FW_EXPECTED_VERSION, "%hhX.%hhd.%hhd.%hhd.%hhd.%hhd.%hd",
274-
&expected_version.rom_id,
275-
&expected_version.major,
276-
&expected_version.minor,
277-
&expected_version.security_version,
278-
&expected_version.patch_num,
279-
&expected_version.customer_id,
280-
&expected_version.build_num);
281-
282281
/* Ignore rom_id:
283282
* B is parsed as an hex value and we get 11 in expected_version.rom_id
284283
* We received rom_id=17 in version.rom_id, we suspect a double hex->decimal conversion
@@ -414,8 +413,15 @@ static int siwx91x_nwp_init(const struct device *dev)
414413
/* Check if the NWP firmware version is correct */
415414
ret = siwx91x_check_nwp_version();
416415
if (ret < 0) {
417-
LOG_ERR("Unexpected NWP firmware version (expected: %s)",
418-
SIWX91X_NWP_FW_EXPECTED_VERSION);
416+
LOG_ERR("Unexpected NWP firmware version (expected: %X.%d.%d.%d.%d.%d.%d)",
417+
SIWX91X_NWP_FW_EXPECTED_ROM_ID,
418+
SIWX91X_NWP_FW_EXPECTED_MAJOR,
419+
SIWX91X_NWP_FW_EXPECTED_MINOR,
420+
SIWX91X_NWP_FW_EXPECTED_SECURITY_VERSION,
421+
SIWX91X_NWP_FW_EXPECTED_PATCH_NUM,
422+
SIWX91X_NWP_FW_EXPECTED_CUSTOMER_ID,
423+
SIWX91X_NWP_FW_EXPECTED_BUILD_NUM);
424+
return -EINVAL;
419425
}
420426

421427
if (IS_ENABLED(CONFIG_SOC_SIWX91X_PM_BACKEND_PMGR)) {

0 commit comments

Comments
 (0)