summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Beckwith <darren@brnkl.io>2019-06-07 08:50:21 -0700
committerGitHub <noreply@github.com>2019-06-07 08:50:21 -0700
commit6c58a9343460e090909b5524248a9d07e0eb7761 (patch)
tree10d8c212bd299d1d62a5c432d6e8f4d96f4d4378
parent3d745aad3dcb5da8d05f79ada149e044a41a19ae (diff)
parentf43721045116bf444fd31567a2f61d0e52d07ce1 (diff)
Merge pull request #1 from brnkl/mtkTesting
fix: WiFi/Bluetooth testing causes testService to hang
-rw-r--r--mtkSetup.adef2
-rw-r--r--upload/upload.c52
2 files changed, 36 insertions, 18 deletions
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:
{
diff --git a/upload/upload.c b/upload/upload.c
index 90ea281..c6aea41 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, 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 != 'C'){
+ 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;
}