@@ -21,20 +21,20 @@ extern unsigned char _gzip_dict;
21
21
extern void ets_wdt_enable (void );
22
22
extern void ets_wdt_disable (void );
23
23
24
+ // Converts bit of a string into a uint32
25
+ #define S (a ,b ,c ,d ) ( (((uint32_t)a) & 0xff) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | (((uint32_t)d)<<24) )
26
+
24
27
int print_version (const uint32_t flash_addr )
25
28
{
26
29
uint32_t ver ;
27
30
if (SPIRead (flash_addr + APP_START_OFFSET + sizeof (image_header_t ) + sizeof (section_header_t ), & ver , sizeof (ver ))) {
28
31
return 1 ;
29
32
}
30
- char fmt [7 ];
31
- fmt [0 ] = 'v' ;
32
- fmt [1 ] = '%' ;
33
- fmt [2 ] = '0' ;
34
- fmt [3 ] = '8' ;
35
- fmt [4 ] = 'x' ;
36
- fmt [5 ] = '\n' ;
37
- fmt [6 ] = 0 ;
33
+ // We don't have BSS and can't print from flash, so build up string
34
+ // 4 chars at a time. Smaller code than byte-wise assignment.
35
+ uint32_t fmt [2 ];
36
+ fmt [0 ] = S ('v' , '%' , '0' , '8' );
37
+ fmt [1 ] = S ('x' , '\n' , 0 , 0 );
38
38
ets_printf ((const char * ) fmt , ver );
39
39
return 0 ;
40
40
}
@@ -234,26 +234,32 @@ int main()
234
234
}
235
235
236
236
if (cmd .action == ACTION_COPY_RAW ) {
237
- ets_putc ('c' ); ets_putc ('p' ); ets_putc (':' );
237
+ uint32_t cp = S ('c' , 'p' , ':' , 0 );
238
+ ets_printf ((const char * )cp );
238
239
239
240
ets_wdt_disable ();
240
241
res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], false);
241
242
ets_wdt_enable ();
242
243
243
- ets_putc ('0' + res ); ets_putc ('\n' );
244
+ cp = S ('0' + res , '\n' , 0 , 0 );
245
+ ets_printf ((const char * )cp );
244
246
#if 0
245
247
//devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
246
248
//beginning of the image in the empty area, see #7458. Disabling for now.
247
249
//TODO: replace the below verify with hash type, crc, or similar.
248
250
// Verify the copy
249
- ets_putc ('c' ); ets_putc ('m' ); ets_putc ('p' ); ets_putc (':' );
251
+ uint32_t v [2 ];
252
+ v [0 ] = S ('c' , 'm' , 'p' , ':' );
253
+ v [1 ] = 0 ;
254
+ ets_printf (const char * )v );
250
255
if (res == 0 ) {
251
256
ets_wdt_disable ();
252
257
res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], true);
253
258
ets_wdt_enable ();
254
259
}
255
260
256
- ets_putc ('0' + res ); ets_putc ('\n' );
261
+ cp = S ('0' + res , '\n' , 0 , 0 );
262
+ ets_printf ((const char * )cp );
257
263
#endif
258
264
if (res == 0 ) {
259
265
cmd .action = ACTION_LOAD_APP ;
@@ -268,8 +274,11 @@ int main()
268
274
if (cmd .action == ACTION_LOAD_APP ) {
269
275
ets_putc ('l' ); ets_putc ('d' ); ets_putc ('\n' );
270
276
res = load_app_from_flash_raw (cmd .args [0 ]);
271
- //we will get to this only on load fail
272
- ets_putc ('e' ); ets_putc (':' ); ets_putc ('0' + res ); ets_putc ('\n' );
277
+ // We will get to this only on load fail
278
+ uint32_t e [2 ];
279
+ e [0 ] = S ('e' , ':' , '0' + res , '\n' );
280
+ e [1 ] = 0 ;
281
+ ets_printf ((const char * )e );
273
282
}
274
283
275
284
if (res ) {
0 commit comments