MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / autoFlash

Function autoFlash

ESP32_AP-Flasher/src/usbflasher.cpp:51–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49#endif
50
51bool autoFlash(flasher* f) {
52 f->getFirmwareMD5();
53
54 if (f->findTagByMD5()) {
55 // this tag currently contains original firmware, found its fingerprint
56 cmdSerial.printf("Found original firmware tag, recognized its fingerprint (%s)\r\n", f->md5char);
57 f->readInfoBlock();
58 f->getFirmwareMac();
59 f->prepareInfoBlock();
60 f->writeInfoBlock();
61 cmdSerial.printf("Attempting to perform a flash...\r\n");
62 if (f->writeFlashFromPack("/Tag_FW_Pack.bin", f->tagtype)) {
63 cmdSerial.printf("Successfully flashed the tag!\r\n");
64 return true;
65 } else {
66 cmdSerial.printf("Couldn't flash the tag, for some reason...\r\n");
67 }
68 } else if (f->getInfoBlockMD5()) {
69 // did find an infoblock MD5 that looks valid
70 if (f->findTagByMD5()) {
71 // did find the md5 in the database
72 cmdSerial.printf("Found an already-flashed tag, recognized its fingerprint (%s)\r\n", f->md5char);
73 f->getInfoBlockMac();
74 f->getInfoBlockType();
75 f->readInfoBlock();
76 cmdSerial.printf("Attempting to perform a flash...\r\n");
77 if (f->writeFlashFromPack("/Tag_FW_Pack.bin", f->tagtype)) {
78 cmdSerial.printf("Successfully flashed the tag!\r\n");
79 return true;
80 } else {
81 cmdSerial.printf("Couldn't flash the tag, for some reason...\r\n");
82 }
83 } else {
84 // couldn't find the md5 from the infoblock
85 cmdSerial.printf("Found an already-flashed tag, but we couldn't find its fingerprint (%s) in the database\r\n", f->md5char);
86 return false;
87 }
88 } else {
89 // We couldn't recognize the tag from it's fingerprint...
90 cmdSerial.printf("Found a tag but didn't recognize its fingerprint\r\n", f->md5char);
91 f->backupFlash();
92 cmdSerial.printf("Saved this MD5 binary to filesystem\r\n");
93 }
94 return false;
95}
96
97void sendFlasherAnswer(uint8_t answer_cmd, uint8_t* ans_buff, uint32_t len, uint8_t transportType) {
98 uint8_t* answer_buffer = (uint8_t*)calloc(3 + 2 + 2 + len + 2 + 13, 1);

Callers 1

processFlasherCommandFunction · 0.70

Calls 12

printfMethod · 0.80
getFirmwareMD5Method · 0.45
findTagByMD5Method · 0.45
readInfoBlockMethod · 0.45
getFirmwareMacMethod · 0.45
prepareInfoBlockMethod · 0.45
writeInfoBlockMethod · 0.45
writeFlashFromPackMethod · 0.45
getInfoBlockMD5Method · 0.45
getInfoBlockMacMethod · 0.45
getInfoBlockTypeMethod · 0.45
backupFlashMethod · 0.45

Tested by

no test coverage detected