Skip to content

Commit

Permalink
add some debug and semaphore for LCD
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Mar 7, 2023
1 parent 8c7ba72 commit 387a95c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/Adafruit_TestBed_Brains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

Adafruit_TestBed_Brains Brain;

volatile bool LCD_semaphore = false;

// Simple and low code CRC calculation (copied from PicoOTA)
class BrainCRC32 {
public:
Expand Down Expand Up @@ -443,7 +445,11 @@ Adafruit_TestBed_Brains::esp32_programFlashDefl(const esp32_zipfile_t *zfile,

#if 1 // change to 0 to skip pre-flash md5 check for testing
esp32boot->md5Flash(addr, zfile->uncompressed_len, esp_md5);

Serial.printf("Flash MD5: ");
for (size_t i = 0; i < 16; i++) {
Serial.printf("%02X ", esp_md5[i]);
}
Serial.println();
if (0 == memcmp(zfile->md5, esp_md5, 16)) {
LCD_printf(2, "MD5 matched");
return zfile->uncompressed_len;
Expand Down Expand Up @@ -722,6 +728,9 @@ void Adafruit_TestBed_Brains::setColor(uint32_t color) {
}

void Adafruit_TestBed_Brains::lcd_write(uint8_t linenum, char linebuf[17]) {
// wait for semaphore to release
while (LCD_semaphore) yield();
LCD_semaphore = true;
// fill the rest with spaces
memset(linebuf + strlen(linebuf), ' ', 16 - strlen(linebuf));
linebuf[16] = 0;
Expand All @@ -733,6 +742,7 @@ void Adafruit_TestBed_Brains::lcd_write(uint8_t linenum, char linebuf[17]) {
Serial.flush();

_lcd_line = 1 - linenum;
LCD_semaphore = false;
}

#define _LCD_PRINTF(_line, _format) \
Expand Down
8 changes: 3 additions & 5 deletions src/ESP32BootROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,12 @@ bool ESP32BootROMClass::dataFlashDefl(const void *data, uint32_t len) {
header[2] = 0;
header[3] = 0;

DBG_PRINTF("FLASH_DEFL_DATA...");
command(ESP_FLASH_DEFL_DATA, header, sizeof(header), data, len);
DBG_PRINTF(millis()-stamp);
DBG_PRINTF("FLASH_DEFL_DATA...%d", millis()-stamp);

bool b = response(ESP_FLASH_DEFL_DATA, 3000);
DBG_PRINTF(":");
DBG_PRINTF(millis()-stamp);
DBG_PRINTF("\t");
DBG_PRINTF(": %d\t", millis()-stamp);

return (b == 0);
}

Expand Down

0 comments on commit 387a95c

Please sign in to comment.