Skip to content

Commit c856b35

Browse files
authored
Merge pull request #101 from tmobile/CFSPDK-984-dfu-gecko-module
TMO_SHELL: DFU: Clean up and file name changes
2 parents 69b8db2 + c68ee9d commit c856b35

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

samples/tmo_shell/src/dfu_murata_1sc.c

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ typedef enum modem_app_state_e {
7878
MODEM_FW_UPGRADE_DONE
7979
} modem_app_state_t;
8080

81-
// application control block
81+
/* application control block */
8282
typedef struct modem_app_cb_s {
83-
// wlan application state
83+
/* wlan application state */
8484
modem_app_state_t state;
8585
} modem_app_cb_t;
8686

87-
// application control block
87+
/* application control block */
8888
modem_app_cb_t modem_app_cb;
8989

90-
// FW send variable, buffer
90+
/* FW send variable, buffer */
9191
static uint32_t chunk_cnt = 0u, chunk_check = 0u, offset = 0u, fw_image_size = 0u, remainder = 0u;
9292
static uint8_t recv_buff_hdr[UA_HEADER_SIZE] = { 0 };
9393
static uint8_t recv_buff_1k [1024] = { 0 };
@@ -259,15 +259,13 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
259259
switch (cmd) {
260260
case AT_GET_FILE_MODE:
261261
res = fcntl_ptr(sd, GET_FILE_MODE, recv_buff_hdr);
262-
263262
if (res < 0) {
264263
printf("GET_FILE_MODE failed\n");
265264
}
266265
break;
267266

268267
case AT_GET_CHKSUM_ABILITY:
269268
res = fcntl_ptr(sd, GET_CHKSUM_ABILITY, recv_buff_hdr);
270-
271269
if (res < 0) {
272270
printf("GET_CHKSUM_ABILITY failed\n");
273271
}
@@ -284,7 +282,6 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
284282
init_xfer_params.imagecrc);
285283

286284
res = fcntl_ptr(sd, INIT_FW_XFER, &init_xfer_params);
287-
288285
if (res < 0) {
289286
printf("\tINIT_FW_XFER failed with update.ua, error %d\n", res);
290287
}
@@ -295,7 +292,6 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
295292

296293
case AT_SEND_FW_HEADER:
297294
res = fcntl_ptr(sd, SEND_FW_HEADER, recv_buff_hdr);
298-
299295
if (res < 0) {
300296
printf("\tSEND_FW_HEADER failed\n");
301297
} else if (recv_buff_hdr[0] == 0) {
@@ -323,7 +319,6 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
323319
send_params.len = numofbytes;
324320

325321
res = fcntl_ptr(sd, SEND_FW_DATA, &send_params);
326-
327322
if (res < 0) {
328323
printf("\tSEND_FW_DATADONE failed, error %d\n", res);
329324
} else {
@@ -332,9 +327,7 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
332327
break;
333328

334329
case AT_INIT_FW_UPGRADE:
335-
// AT%UPGCMD="UPGVRM","b:/update.ua"
336330
res = fcntl_ptr(sd, INIT_FW_UPGRADE, "b:/update.ua");
337-
338331
if (res < 0) {
339332
printf("\tAT_INIT_FW_UPGRADE failed with update.ua\n");
340333
}
@@ -371,7 +364,6 @@ int dfu_send_ioctl(int cmd, int numofbytes) {
371364

372365
case AT_RESET_MODEM:
373366
res = fcntl_ptr(sd, RESET_MODEM, NULL);
374-
375367
if (res < 0) {
376368
printf("\tAT_RESET_MODEM failed\n");
377369
}
@@ -475,7 +467,6 @@ static int32_t dfu_modem_write_image(const struct dfu_file_t *dfu_file)
475467
}
476468

477469
printf("\tSending image header\n");
478-
// printf("\tHeader -> %s\n", recv_buff_hdr);
479470
int res = dfu_send_ioctl(AT_SEND_FW_HEADER, UA_HEADER_SIZE);
480471
if (res < 0) {
481472
return -1;
@@ -493,19 +484,13 @@ static int32_t dfu_modem_write_image(const struct dfu_file_t *dfu_file)
493484

494485
/* Loop until all the chunks are read and written */
495486
while (offset <= fw_image_size) {
496-
if (chunk_cnt == chunk_check) {
497-
/* printf("Murata 1SC FW update started\n"); */
498-
// break;
499-
}
500-
501487
if (chunk_cnt < (chunk_check-1)) {
502488
readsize = DFU_CHUNK_SIZE;
503489
}
504490
else {
505491
readsize = remainder;
506492
}
507493

508-
// printf("readsize: %d chunk_cnt: %d total %d\n", readsize, chunk_cnt, chunk_check);
509494
if (readsize > 0) {
510495
if (file_read_flash(dfu_file, readsize) != 0) {
511496
printf("file system flash read failed\n");
@@ -532,7 +517,6 @@ static int32_t dfu_modem_write_image(const struct dfu_file_t *dfu_file)
532517
}
533518
modem_app_cb.state = MODEM_FW_UPGRADE_DONE;
534519
} else {
535-
//printf("\tModem FW update continues with in-between chunks\n");
536520
printk(".");
537521
dfu_send_ioctl(AT_SEND_FW_DATA, readsize);
538522
if (status != 0) {
@@ -626,6 +610,24 @@ int dfu_modem_is_golden()
626610
return -1;
627611
}
628612

613+
int select_modem_file(char *filename) {
614+
char* token;
615+
char* rest = filename;
616+
int idx = 0;
617+
char from[10];
618+
619+
while ((token = strtok_r(rest, ".", &rest))) {
620+
if (idx == 1) {
621+
strcpy(from, token);
622+
} else if (idx == 2) {
623+
if (!strcmp(from, "20161") && !strcmp(token, "20351"))
624+
return 1;
625+
}
626+
idx++;
627+
}
628+
return 0;
629+
}
630+
629631
int dfu_modem_firmware_upgrade (const struct dfu_file_t *dfu_file)
630632
{
631633
int ret = 0;
@@ -637,14 +639,7 @@ int dfu_modem_firmware_upgrade (const struct dfu_file_t *dfu_file)
637639
printf("Murata 1SC FW update has aborted - reading the Murata 1SC FW version has failed !\n");
638640
}
639641

640-
if (strstr (dfu_file->lfile, "sample") != NULL)
641-
selected_murata_file = 1;
642-
else if (strstr(dfu_file->lfile, "golden") != NULL)
643-
selected_murata_file = 2;
644-
else {
645-
printf("Murata FW is invalid\n");
646-
return -1;
647-
}
642+
selected_murata_file = select_modem_file((char *)dfu_file->rfile);
648643

649644
int is_golden = dfu_modem_is_golden();
650645

samples/tmo_shell/src/tmo_dfu_download.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ int tmo_dfu_download(const struct shell *shell, enum dfu_tgts dfu_tgt, char *bas
210210
sprintf((char *)dfu_files_rs9116w[0].rfile, "%s.rps",base);
211211
dfu_files = dfu_files_rs9116w;
212212

213-
strncpy(base_url_s,user_base_url_s,sizeof(base_url_s)-1);
213+
sprintf(base_url_s,"%",user_base_url_s);
214214

215215
default:
216216
break;

samples/tmo_shell/src/tmo_dfu_download.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "dfu_murata_1sc.h"
1111
#include "dfu_rs9116w.h"
12-
//#include "dfu_gecko_lib.h"
12+
#include "dfu_gecko_lib.h"
1313
#include "tmo_shell.h"
1414
#include <zephyr/shell/shell.h>
1515

samples/tmo_shell/src/tmo_shell.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,8 @@ int cmd_dfu_update(const struct shell *shell, size_t argc, char **argv)
20032003
int status;
20042004
sprintf(dfu_modem_file.desc, "Murata 1SC Firmware Update");
20052005
sprintf(dfu_modem_file.lfile, "/tmo/%s.ua", dfu_modem_filename);
2006+
sprintf(dfu_modem_file.rfile, "%s.ua", dfu_modem_filename);
2007+
20062008
status = dfu_modem_firmware_upgrade(&dfu_modem_file);
20072009
if (status != 0) {
20082010
shell_error(shell, "The FW update of Murata 1SC failed");

0 commit comments

Comments
 (0)