16
16
#include <zephyr/devicetree.h>
17
17
18
18
#include "nwp.h"
19
+ #include "nwp_fw_version.h"
19
20
#include "sl_wifi_callback_framework.h"
20
21
21
22
#include "sl_si91x_ble.h"
@@ -249,6 +250,54 @@ static void siwx91x_configure_network_stack(sl_si91x_boot_configuration_t *boot_
249
250
}
250
251
}
251
252
253
+ static int siwx91x_check_nwp_version (void )
254
+ {
255
+ sl_wifi_firmware_version_t expected_version ;
256
+ sl_wifi_firmware_version_t version ;
257
+ int ret ;
258
+
259
+ ret = sl_wifi_get_firmware_version (& version );
260
+ if (ret != SL_STATUS_OK ) {
261
+ return - EINVAL ;
262
+ }
263
+
264
+ sscanf (SIWX91X_NWP_FW_EXPECTED_VERSION , "%hhX.%hhd.%hhd.%hhd.%hhd.%hhd.%hd" ,
265
+ & expected_version .rom_id ,
266
+ & expected_version .major ,
267
+ & expected_version .minor ,
268
+ & expected_version .security_version ,
269
+ & expected_version .patch_num ,
270
+ & expected_version .customer_id ,
271
+ & expected_version .build_num );
272
+
273
+ /* Ignore rom_id:
274
+ * B is parsed as an hex value and we get 11 in expected_version.rom_id
275
+ * We received rom_id=17 in version.rom_id, we suspect a double hex->decimal conversion
276
+ */
277
+ if (expected_version .major != version .major ) {
278
+ return - EINVAL ;
279
+ }
280
+ if (expected_version .minor != version .minor ) {
281
+ return - EINVAL ;
282
+ }
283
+ if (expected_version .security_version != version .security_version ) {
284
+ return - EINVAL ;
285
+ }
286
+ if (expected_version .patch_num != version .patch_num ) {
287
+ return - EINVAL ;
288
+ }
289
+ if (expected_version .customer_id != version .customer_id ) {
290
+ LOG_DBG ("customer_id diverge: expected %d, actual %d" , expected_version .customer_id ,
291
+ version .customer_id );
292
+ }
293
+ if (expected_version .build_num != version .build_num ) {
294
+ LOG_DBG ("build_num diverge: expected %d, actual %d" , expected_version .build_num ,
295
+ version .build_num );
296
+ }
297
+
298
+ return 0 ;
299
+ }
300
+
252
301
int siwx91x_get_nwp_config (sl_wifi_device_configuration_t * get_config , uint8_t wifi_oper_mode ,
253
302
bool hidden_ssid , uint8_t max_num_sta )
254
303
{
@@ -334,7 +383,7 @@ int siwx91x_nwp_mode_switch(uint8_t oper_mode, bool hidden_ssid, uint8_t max_num
334
383
static int siwg917_nwp_init (void )
335
384
{
336
385
sl_wifi_device_configuration_t network_config ;
337
- sl_status_t status ;
386
+ int status ;
338
387
__maybe_unused sl_wifi_performance_profile_t performance_profile = {
339
388
.profile = SI91X_POWER_PROFILE };
340
389
__maybe_unused sl_bt_performance_profile_t bt_performance_profile = {
@@ -349,6 +398,13 @@ static int siwg917_nwp_init(void)
349
398
return - EINVAL ;
350
399
}
351
400
401
+ /* Check if the NWP firmware version is correct */
402
+ status = siwx91x_check_nwp_version ();
403
+ if (status < 0 ) {
404
+ LOG_ERR ("Unexpected NWP firmware version (expected: %s)" ,
405
+ SIWX91X_NWP_FW_EXPECTED_VERSION );
406
+ }
407
+
352
408
if (IS_ENABLED (CONFIG_SOC_SIWX91X_PM_BACKEND_PMGR )) {
353
409
if (IS_ENABLED (CONFIG_BT_SILABS_SIWX91X )) {
354
410
status = sl_si91x_bt_set_performance_profile (& bt_performance_profile );
0 commit comments