Skip to content

Commit 5b243e2

Browse files
Move debug strings to PMEM
Saves ~600 bytes when in debug mode.
1 parent e530a8a commit 5b243e2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

cores/esp8266/Updater.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
113113
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
114114

115115
#ifdef DEBUG_UPDATER
116-
DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08zX (%zd)\n", roundedSize, roundedSize);
117-
DEBUG_UPDATER.printf("[begin] updateEndAddress: 0x%08zX (%zd)\n", updateEndAddress, updateEndAddress);
118-
DEBUG_UPDATER.printf("[begin] currentSketchSize: 0x%08zX (%zd)\n", currentSketchSize, currentSketchSize);
116+
DEBUG_UPDATER.printf_P(PSTR("[begin] roundedSize: 0x%08zX (%zd)\n"), roundedSize, roundedSize);
117+
DEBUG_UPDATER.printf_P(PSTR("[begin] updateEndAddress: 0x%08zX (%zd)\n"), updateEndAddress, updateEndAddress);
118+
DEBUG_UPDATER.printf_P(PSTR("[begin] currentSketchSize: 0x%08zX (%zd)\n"), currentSketchSize, currentSketchSize);
119119
#endif
120120

121121
//make sure that the size of both sketches is less than the total space (updateEndAddress)
@@ -148,9 +148,9 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
148148
_command = command;
149149

150150
#ifdef DEBUG_UPDATER
151-
DEBUG_UPDATER.printf("[begin] _startAddress: 0x%08X (%d)\n", _startAddress, _startAddress);
152-
DEBUG_UPDATER.printf("[begin] _currentAddress: 0x%08X (%d)\n", _currentAddress, _currentAddress);
153-
DEBUG_UPDATER.printf("[begin] _size: 0x%08zX (%zd)\n", _size, _size);
151+
DEBUG_UPDATER.printf_P(PSTR("[begin] _startAddress: 0x%08X (%d)\n"), _startAddress, _startAddress);
152+
DEBUG_UPDATER.printf_P(PSTR("[begin] _currentAddress: 0x%08X (%d)\n"), _currentAddress, _currentAddress);
153+
DEBUG_UPDATER.printf_P(PSTR("[begin] _size: 0x%08zX (%zd)\n"), _size, _size);
154154
#endif
155155

156156
if (!_verify) {
@@ -178,7 +178,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
178178

179179
if(hasError() || (!isFinished() && !evenIfRemaining)){
180180
#ifdef DEBUG_UPDATER
181-
DEBUG_UPDATER.printf("premature end: res:%u, pos:%zu/%zu\n", getError(), progress(), _size);
181+
DEBUG_UPDATER.printf_P(PSTR("premature end: res:%u, pos:%zu/%zu\n"), getError(), progress(), _size);
182182
#endif
183183

184184
_reset();
@@ -196,7 +196,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
196196
if (_verify) {
197197
ESP.flashRead(_startAddress + _size - sizeof(uint32_t), &sigLen, sizeof(uint32_t));
198198
#ifdef DEBUG_UPDATER
199-
DEBUG_UPDATER.printf("[Updater] sigLen: %d\n", sigLen);
199+
DEBUG_UPDATER.printf_P(PSTR("[Updater] sigLen: %d\n"), sigLen);
200200
#endif
201201
if (sigLen != _verify->length()) {
202202
_setError(UPDATE_ERROR_SIGN);
@@ -207,7 +207,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
207207
int binSize = _size - sigLen - sizeof(uint32_t) /* The siglen word */;
208208
_hash->begin();
209209
#ifdef DEBUG_UPDATER
210-
DEBUG_UPDATER.printf("[Updater] Adjusted binsize: %d\n", binSize);
210+
DEBUG_UPDATER.printf_P(PSTR("[Updater] Adjusted binsize: %d\n"), binSize);
211211
#endif
212212
// Calculate the MD5 and hash using proper size
213213
uint8_t buff[128];
@@ -219,7 +219,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
219219
_hash->end();
220220
#ifdef DEBUG_UPDATER
221221
unsigned char *ret = (unsigned char *)_hash->hash();
222-
DEBUG_UPDATER.printf("[Updater] Computed Hash:");
222+
DEBUG_UPDATER.printf_P(PSTR("[Updater] Computed Hash:"));
223223
for (int i=0; i<_hash->len(); i++) DEBUG_UPDATER.printf(" %02x", ret[i]);
224224
DEBUG_UPDATER.printf("\n");
225225
#endif
@@ -231,7 +231,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
231231
}
232232
ESP.flashRead(_startAddress + binSize, (uint32_t *)sig, sigLen);
233233
#ifdef DEBUG_UPDATER
234-
DEBUG_UPDATER.printf("[Updater] Received Signature:");
234+
DEBUG_UPDATER.printf_P(PSTR("[Updater] Received Signature:"));
235235
for (size_t i=0; i<sigLen; i++) {
236236
DEBUG_UPDATER.printf(" %02x", sig[i]);
237237
}
@@ -243,7 +243,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
243243
return false;
244244
}
245245
#ifdef DEBUG_UPDATER
246-
DEBUG_UPDATER.printf("[Updater] Signature matches\n");
246+
DEBUG_UPDATER.printf_P(PSTR("[Updater] Signature matches\n"));
247247
#endif
248248
} else if (_target_md5.length()) {
249249
_md5.calculate();
@@ -253,7 +253,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
253253
return false;
254254
}
255255
#ifdef DEBUG_UPDATER
256-
else DEBUG_UPDATER.printf("MD5 Success: %s\n", _target_md5.c_str());
256+
else DEBUG_UPDATER.printf_P(PSTR("MD5 Success: %s\n"), _target_md5.c_str());
257257
#endif
258258
}
259259

@@ -271,10 +271,10 @@ bool UpdaterClass::end(bool evenIfRemaining){
271271
eboot_command_write(&ebcmd);
272272

273273
#ifdef DEBUG_UPDATER
274-
DEBUG_UPDATER.printf("Staged: address:0x%08X, size:0x%08zX\n", _startAddress, _size);
274+
DEBUG_UPDATER.printf_P(PSTR("Staged: address:0x%08X, size:0x%08zX\n"), _startAddress, _size);
275275
}
276276
else if (_command == U_SPIFFS) {
277-
DEBUG_UPDATER.printf("SPIFFS: address:0x%08X, size:0x%08zX\n", _startAddress, _size);
277+
DEBUG_UPDATER.printf_P(PSTR("SPIFFS: address:0x%08X, size:0x%08zX\n"), _startAddress, _size);
278278
#endif
279279
}
280280

@@ -301,12 +301,12 @@ bool UpdaterClass::_writeBuffer(){
301301
if (_currentAddress == _startAddress + FLASH_MODE_PAGE) {
302302
flashMode = ESP.getFlashChipMode();
303303
#ifdef DEBUG_UPDATER
304-
DEBUG_UPDATER.printf("Header: 0x%1X %1X %1X %1X\n", _buffer[0], _buffer[1], _buffer[2], _buffer[3]);
304+
DEBUG_UPDATER.printf_P(PSTR("Header: 0x%1X %1X %1X %1X\n"), _buffer[0], _buffer[1], _buffer[2], _buffer[3]);
305305
#endif
306306
bufferFlashMode = ESP.magicFlashChipMode(_buffer[FLASH_MODE_OFFSET]);
307307
if (bufferFlashMode != flashMode) {
308308
#ifdef DEBUG_UPDATER
309-
DEBUG_UPDATER.printf("Set flash mode from 0x%1X to 0x%1X\n", bufferFlashMode, flashMode);
309+
DEBUG_UPDATER.printf_P(PSTR("Set flash mode from 0x%1X to 0x%1X\n"), bufferFlashMode, flashMode);
310310
#endif
311311

312312
_buffer[FLASH_MODE_OFFSET] = flashMode;

0 commit comments

Comments
 (0)