From 6f6d868cc8f7a5f8fa27b6e884356b2199441369 Mon Sep 17 00:00:00 2001 From: Emily Wilson Date: Tue, 4 Jun 2019 10:44:25 -0700 Subject: fix: WiFi/Bluetooth testing causes testService to hang The method of controlling serial ports caused the testService to hang when data was not available on read. HW-25 --- upload/upload.c | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/upload/upload.c b/upload/upload.c index 90ea281..910b8e5 100644 --- a/upload/upload.c +++ b/upload/upload.c @@ -15,6 +15,10 @@ static const char* DA_PATH = "/home/root/mtfiles/da97.bin"; typedef enum { LDR = 1, N9 = 3, CM4 = 2 } MtkMemorySegment; +ssize_t fd_getByte(int fd, uint8_t* data) { + return read(fd, data, 1); +} + typedef struct { int serialPort; int errorCount; @@ -33,8 +37,8 @@ void configureSerialPort(FlashState* s, int baud) { if (s->serialPort != -1) { close(s->serialPort); } - s->serialPort = open_serial(SERIAL_PORT_PATH, fd_convertBaud(baud)); -} + s->serialPort = fd_openSerial(SERIAL_PORT_PATH, MTK7697_BAUD); +} bool flashDa(FlashState* s) { configureSerialPort(&state, MTK7697_BAUD); @@ -67,34 +71,48 @@ void retryInitSequence(FlashState* s) { configureSerialPort(s, MTK7697_BAUD); } +/** + * Read a response from the MT7697 over UART + * + * This waits for data to be available on the + * UART and checks for a 'C' (the xmodem + * synchronization character). If a 'C" is + * received the connection is initialized + * and the test is successful. The test will + * resest 3 times on an interval of 4 seconds + * (3 seconds if the timeout for xmodem) if + * a 'C' is not received, then the test will + * fail and return an error. + */ + bool mtk_verifyInitSequence(FlashState* s) { uint8_t data; bool initDone = false; s->startTime = util_getUnixDatetime(); - while (!initDone) { - data = fd_getChar(s->serialPort); - fd_flushInput(s->serialPort); - if (data == 'C') { + + while (!initDone){ + ssize_t bytesRead = fd_getByte(s->serialPort, &data); + if (bytesRead > 0){ + LE_INFO("Data read: %d %c", data, data); + if (data == 'C'){ s->cCount++; - LE_INFO("Got a C"); - } else if (data != 0) { - s->errorCount++; - LE_INFO("Got an error"); + LE_INFO("Got a C"); + } } if (s->cCount > 1) { initDone = true; LE_INFO("Init done"); break; } - if (s->errorCount > 3 || (util_getUnixDatetime() - s->startTime > 3)) { - LE_INFO("Retrying..."); + if((util_getUnixDatetime() - s->startTime > 3) && data == 0){ + LE_INFO("Retrying serial"); retryInitSequence(s); + } + if (s->retry > 3){ + LE_INFO("Cannot connect to MTK, abort test"); + break; } - if (s->retry > 3) { - LE_INFO("Aborting"); - break; - } - } + } return initDone; } -- cgit v1.2.3 From 4e6723799d6333afa29cd1a202350bdf10573321 Mon Sep 17 00:00:00 2001 From: Emily Wilson Date: Thu, 6 Jun 2019 16:36:03 -0700 Subject: Bump version to 3.0.2 --- mtkSetup.adef | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtkSetup.adef b/mtkSetup.adef index 5856059..5321698 100644 --- a/mtkSetup.adef +++ b/mtkSetup.adef @@ -1,6 +1,6 @@ sandboxed: false start: manual -version: 3.0.1 +version: 3.0.2 executables: { -- cgit v1.2.3 From f43721045116bf444fd31567a2f61d0e52d07ce1 Mon Sep 17 00:00:00 2001 From: Emily Wilson Date: Thu, 6 Jun 2019 17:05:36 -0700 Subject: fix: WiFi/Bluetooth testing causes testService to hang Editing test case to exit after three failed attempts at serial communication HW-25 --- upload/upload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upload/upload.c b/upload/upload.c index 910b8e5..c6aea41 100644 --- a/upload/upload.c +++ b/upload/upload.c @@ -37,7 +37,7 @@ void configureSerialPort(FlashState* s, int baud) { if (s->serialPort != -1) { close(s->serialPort); } - s->serialPort = fd_openSerial(SERIAL_PORT_PATH, MTK7697_BAUD); + s->serialPort = fd_openSerial(SERIAL_PORT_PATH, baud); } bool flashDa(FlashState* s) { @@ -104,7 +104,7 @@ bool mtk_verifyInitSequence(FlashState* s) { LE_INFO("Init done"); break; } - if((util_getUnixDatetime() - s->startTime > 3) && data == 0){ + if((util_getUnixDatetime() - s->startTime > 3) && data != 'C'){ LE_INFO("Retrying serial"); retryInitSequence(s); } -- cgit v1.2.3