55 */
66
77#include <stdio.h>
8+ #include <stdlib.h>
89#include <string.h>
910#include <zephyr/kernel.h>
1011#include <zephyr/drivers/pwm.h>
1314
1415int misc_test ()
1516{
16- int ret = 0 ;
17+ int ret = 0 , rc = 0 ;
1718
1819#if DT_NODE_EXISTS (DT_NODELABEL (as6212 ))
1920 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "sensor get TEMP_0" )) != 0 )
2021 {
22+ rc |= ret ;
2123 printf ("sensor get TEMP_0 - as6212 temp sensor - shell command failed %d \n" , ret );
2224 } else {
2325 printf ("sensor get TEMP_0 - as6212 temp sensor - shell command was successful\n" );
2426 }
2527#else
2628 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "sensor get TEMP_0" )) != 0 )
2729 {
30+ rc |= ret ;
2831 printf ("sensor get TEMP_0 - tmp108 temp sensor - shell command failed %d \n" , ret );
2932 } else {
3033 printf ("sensor get TEMP_0 - tmp108 temp sensor - shell command was successful\n" );
@@ -33,19 +36,22 @@ int misc_test()
3336#if DT_NODE_EXISTS (DT_NODELABEL (bq24250 ))
3437 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c read_byte I2C_1 0x6a 0x3" )) != 0 )
3538 {
39+ rc |= ret ;
3640 printf ("i2c read_byte I2C_1 0x6a 0x3 - BQ24250 voltage regulator- shell command failed %d \n" , ret );
3741 } else {
3842 printf ("i2c read_byte I2C_1 0x6a 0x3 - BQ24250 voltage regulator- shell command was successful\n" );
3943 }
4044#else
4145 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c read I2C_1 25 10" )) != 0 )
4246 {
47+ rc |= ret ;
4348 printf ("i2c read I2C_1 25 10 - ACT81460 PMIC - shell command failed %d \n" , ret );
4449 } else {
4550 printf ("i2c read I2C_1 25 10 - ACT81460 PMIC - shell command was successful\n" );
4651 }
4752 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c write_byte I2C_1 25 47 98" )) != 0 )
4853 {
54+ rc |= ret ;
4955 printf ("i2c write_byte I2C_1 25 47 98 - ACT81460 PMIC turn on GNSS - shell command failed %d \n" , ret );
5056 } else {
5157 printf ("i2c write_byte I2C_1 25 47 98 - ACT81460 PMIC turn on GNSS - shell command was successful\n" );
@@ -54,6 +60,7 @@ int misc_test()
5460#if DT_NODE_EXISTS (DT_NODELABEL (sonycxd5605 ))
5561 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c read I2C_1 24 10" )) != 0 )
5662 {
63+ rc |= ret ;
5764 printf ("i2c read I2C_1 24 10 - Sony cxd5605 GNSS - shell command failed %d \n" , ret );
5865 } else {
5966 printf ("i2c read I2C_1 24 10 - Sony cxd5605 GNSS - shell command was successful\n" );
@@ -62,6 +69,7 @@ int misc_test()
6269#if DT_NODE_EXISTS (DT_NODELABEL (tsl2540 ))
6370 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "sensor get TSL2540" )) != 0 )
6471 {
72+ rc |= ret ;
6573 printf ("sensor get TSL2540 - tsl25403 ambient light sensor - shell command failed %d \n" , ret );
6674 } else {
6775 printf ("sensor get TSL2540 - tsl25403 ambient light sensor - shell command was successful\n" );
@@ -70,6 +78,7 @@ int misc_test()
7078#if DT_NODE_EXISTS (DT_NODELABEL (murata_1sc ))
7179 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "tmo modem 1 imei" )) != 0 )
7280 {
81+ rc |= ret ;
7382 printf ("tmo modem 1 imei - murata 1sc- shell command failed %d \n" , ret );
7483 } else {
7584 printf ("tmo modem 1 imei - murata 1sc - shell command was successful\n" );
@@ -78,12 +87,14 @@ int misc_test()
7887#if DT_NODE_EXISTS (DT_NODELABEL (rs9116w ))
7988 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "tmo wifi status 2" )) != 0 )
8089 {
90+ rc |= ret ;
8191 printf ("tmo wifi status 2 - rs9116w- shell command failed %d \n" , ret );
8292 } else {
8393 printf ("tmo wifi status 2 - rs9116w - shell command was successful\n" );
8494 }
8595 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "tmo wifi scan 2" )) != 0 )
8696 {
97+ rc |= ret ;
8798 printf ("tmo wifi scan 2 - rs9116w- shell command failed %d \n" , ret );
8899 } else {
89100 printf ("tmo wifi scan 2 - rs9116w - shell command was successful\n" );
@@ -92,6 +103,7 @@ int misc_test()
92103#if DT_NODE_EXISTS (DT_NODELABEL (lis2dw12 ))
93104 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "sensor get LIS2DW12" )) != 0 )
94105 {
106+ rc |= ret ;
95107 printf ("sensor get LIS2DW12 - accelerometer - shell command failed %d \n" , ret );
96108 } else {
97109 printf ("sensor get LIS2DW12 - accelerometer - shell command was successful\n" );
@@ -100,36 +112,100 @@ int misc_test()
100112#if DT_NODE_EXISTS (DT_NODELABEL (lps22hh ))
101113 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "sensor get LPS22HH" )) != 0 )
102114 {
115+ rc |= ret ;
103116 printf ("sensor get LPS22HH - pressure sensor - shell command failed %d \n" , ret );
104117 } else {
105118 printf ("sensor get LPS22HH - pressure sensor - shell command was successful\n" );
106119 }
107120#endif
108121 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "fs write /tmo/access_id.txt 30 31 32 33 0a 0d" )) != 0 )
109122 {
123+ rc |= ret ;
110124 printf ("fs write /tmo/access_id.txt 30 31 32 33 0a 0d - SPI nor flash - shell command failed %d \n" , ret );
111125 } else {
112126 printf ("fs write /tmo/access_id.txt 30 31 32 33 0a 0d - SPI nor flash - shell command was successful\n" );
113127 }
114128 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "fs read /tmo/access_id.txt" )) != 0 )
115129 {
130+ rc |= ret ;
116131 printf ("fs read /tmo/access_id.txt - SPI nor flash - shell command failed %d \n" , ret );
117132 } else {
118133 printf ("fs read /tmo/access_id.txt - SPI nor flash - shell command was successful\n" );
119134 }
120135 if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "fs rm /tmo/access_id.txt" )) != 0 )
121136 {
137+ rc |= ret ;
122138 printf ("fs fs rm /tmo/access_id.txt - SPI nor flash - shell command failed %d \n" , ret );
123139 } else {
124140 printf ("fs rm /tmo/access_id.txt - SPI nor flash - shell command was successful\n" );
125141 }
126142 if (strcmp (CONFIG_BOARD , "tmo_dev_edge" ) == 0 ) {
127- if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c scan I2C_0 " )) != 0 )
143+ if ((ret = shell_execute_cmd (shell_backend_uart_get_ptr (), "i2c scan I2C_1 " )) != 0 )
128144 {
129- printf ("i2c scan I2C_0 - shell command failed %d \n" , ret );
145+ rc |= ret ;
146+ printf ("i2c scan I2C_1 - shell command failed %d \n" , ret );
130147 } else {
131- printf ("i2c scan I2C_0 - shell command was successful\n" );
148+ printf ("i2c scan I2C_1 - shell command was successful\n" );
132149 }
133150 }
134- return (ret );
151+ return rc ;
152+ }
153+
154+ #include "dfu_rs9116w.h"
155+ #include "dfu_murata_1sc.h"
156+ #include <zephyr/drivers/sensor.h>
157+ #include <zephyr/drivers/sensor/cxd5605.h>
158+ #include <rsi_driver.h>
159+ extern const struct device * cxd5605 ;
160+
161+ int fw_test ()
162+ {
163+ char buf [MAX (DFU_RS9116W_FW_VER_SIZE , DFU_MODEM_FW_VER_SIZE )];
164+ int major , minor , rev , rc ;
165+ char * v_ptr ;
166+
167+ dfu_modem_get_version (buf );
168+ v_ptr = strchr (buf , '_' ) + 1 ;
169+
170+ major = strtol (v_ptr , NULL , 10 );
171+ v_ptr = strchr (v_ptr , '_' ) + 1 ;
172+ minor = strtol (v_ptr , NULL , 10 );
173+ v_ptr = strchr (v_ptr , '_' ) + 1 ;
174+ v_ptr = strchr (v_ptr , '_' ) + 1 ;
175+ v_ptr = strchr (v_ptr , '_' ) + 1 ;
176+ rev = strtol (v_ptr , NULL , 10 );
177+
178+ if (major < 3 || minor < 2 || rev < 20161 ) {
179+ printk ("Murata firmware < RK_03_02_00_00_20161\n" );
180+ return 1 ;
181+ }
182+ if (rsi_driver_cb -> common_cb -> state < RSI_COMMON_CARDREADY ) {
183+ printk ("RS9116 not in ready state!\n" );
184+ return 2 ;
185+ }
186+ dfu_wifi_get_version (buf );
187+ v_ptr = strchr (buf , '.' ) + 1 ;
188+
189+ major = strtol (v_ptr , NULL , 10 );
190+ v_ptr = strchr (v_ptr , '.' ) + 1 ;
191+ minor = strtol (v_ptr , NULL , 10 );
192+ v_ptr = strchr (v_ptr , '.' ) + 1 ;
193+ rev = strtol (v_ptr , NULL , 10 );
194+
195+ if (major < 2 || minor < 6 ) {
196+ printk ("RS9116 firmware < 2.6\n" );
197+ return 2 ;
198+ }
199+
200+ struct sensor_value sens_values = {0 ,0 };
201+
202+ sens_values .val1 = 0 ;
203+ sens_values .val2 = 0 ;
204+ rc = sensor_attr_get (cxd5605 ,GNSS_CHANNEL_POSITION ,GNSS_ATTRIBUTE_VER , & sens_values );
205+ if (rc || !sens_values .val2 || sens_values .val2 < 0x20047 ) {
206+ printk ("GNSS firmware read failure\n" );
207+ return 3 ;
208+ }
209+
210+ return 0 ;
135211}
0 commit comments