Skip to content

Commit e16c677

Browse files
authored
Merge pull request #53 from tmobile/tmo-Upgraded-mfg-tests
Upgraded manufacturing tests
2 parents 3290d93 + 666d1b2 commit e16c677

File tree

3 files changed

+131
-7
lines changed

3 files changed

+131
-7
lines changed

samples/tmo_shell/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ config SEGGER_RTT_BUFFER_SIZE_DOWN
2929
int
3030
default 8192 if TMO_SHELL_BUILD_EK
3131

32+
config TMO_TEST_MFG_CHECK_GOLDEN
33+
bool "Check modem type is golden"
34+
default y
35+
3236
source "Kconfig.zephyr"

samples/tmo_shell/src/misc_test.c

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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>
@@ -13,18 +14,20 @@
1314

1415
int 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
}

samples/tmo_shell/src/tmo_shell.c

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extern uint32_t getData;
9999
extern int buzzer_test();
100100
extern int led_test();
101101
extern int misc_test();
102+
extern int fw_test();
102103

103104
const struct shell *shell = NULL;
104105

@@ -1979,23 +1980,66 @@ int udp_profile_dtls(const struct shell *shell, size_t argc, char **argv)
19791980
return tmo_profile_dtls(shell, argv[1], (int) strtol(argv[2], NULL, 10));
19801981
}
19811982

1983+
int golden_check()
1984+
{
1985+
char cmd_buf[64];
1986+
struct net_if *iface = net_if_get_by_index(MODEM_ID);
1987+
int sd = zsock_socket_ext(AF_INET, SOCK_STREAM, IPPROTO_TCP, iface);
1988+
strcpy(cmd_buf, "golden");
1989+
strupper(cmd_buf);
1990+
int res = fcntl(sd, GET_ATCMD_RESP, cmd_buf);
1991+
zsock_close(sd);
1992+
if (res < 0) {
1993+
printf("Modem firmware type detect failed (%d)\n", res);
1994+
return 1;
1995+
} else {
1996+
printf("Modem firmware type %s\n", cmd_buf);
1997+
return strcmp(cmd_buf, "GOLDEN");
1998+
}
1999+
}
2000+
2001+
bool light_on;
2002+
2003+
2004+
static void led_blnk_tmr_f(struct k_timer *timer_id)
2005+
{
2006+
if (light_on) {
2007+
led_off(device_get_binding("pwmleds"), 0);
2008+
} else {
2009+
led_on(device_get_binding("pwmleds"), 0);
2010+
}
2011+
light_on = !light_on;
2012+
}
2013+
2014+
K_TIMER_DEFINE(led_blink_timer, led_blnk_tmr_f, NULL);
2015+
19822016
int cmd_mfg_test(const struct shell *shell, size_t argc, char **argv)
19832017
{
2018+
k_timer_stop(&led_blink_timer);
19842019
int rc = 0;
19852020
shell_print(shell, "Run mfg tests...");
19862021
rc |= buzzer_test();
19872022
k_sleep(K_SECONDS(1));
19882023
rc |= led_test();
19892024
k_sleep(K_SECONDS(2));
1990-
misc_test();
2025+
rc |=misc_test();
2026+
#if CONFIG_TMO_TEST_MFG_CHECK_GOLDEN
2027+
rc |= golden_check();
2028+
#endif /* CONFIG_TMO_TEST_MFG_CHECK_GOLDEN */
19912029

19922030
const struct device * pwm_dev = device_get_binding("pwmleds");
1993-
if (rc == 0) {
2031+
2032+
if (rc == 0 && !fw_test()) {
19942033
led_on(pwm_dev, 2); // Green LED
19952034
shell_fprintf(shell_backend_uart_get_ptr(), SHELL_INFO, "TESTS PASSED\n");
2035+
} else if (rc == 0) {
2036+
led_on(pwm_dev, 3); // Blue LED
2037+
shell_fprintf(shell_backend_uart_get_ptr(), SHELL_WARNING, "FIRMWARE OUT OF DATE\n");
2038+
k_timer_start(&led_blink_timer, K_MSEC(500), K_SECONDS(1));
19962039
} else {
19972040
led_on(pwm_dev, 1); // Red LED
19982041
shell_fprintf(shell_backend_uart_get_ptr(), SHELL_ERROR, "TESTS FAILED\n");
2042+
k_timer_start(&led_blink_timer, K_MSEC(500), K_MSEC(500));
19992043
}
20002044
return 0;
20012045
}

0 commit comments

Comments
 (0)