14
14
#include "eboot_command.h"
15
15
#include <uzlib.h>
16
16
17
- extern unsigned char _gzip_dict ;
18
17
19
18
#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);
20
19
21
20
extern void ets_wdt_enable (void );
22
21
extern void ets_wdt_disable (void );
23
22
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
-
27
23
int print_version (const uint32_t flash_addr )
28
24
{
29
25
uint32_t ver ;
30
26
if (SPIRead (flash_addr + APP_START_OFFSET + sizeof (image_header_t ) + sizeof (section_header_t ), & ver , sizeof (ver ))) {
31
27
return 1 ;
32
28
}
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
- ets_printf ((const char * ) fmt , ver );
29
+ ets_printf ("v%08x\n" , ver );
39
30
return 0 ;
40
31
}
41
32
@@ -222,6 +213,16 @@ int main()
222
213
bool clear_cmd = false;
223
214
struct eboot_command cmd ;
224
215
216
+ // BSS init commented out for now to save space. If any static variables set
217
+ // to 0 are used, need to uncomment it or else the BSS will not be cleared and
218
+ // the static vars will power on with random values.
219
+ #if 0
220
+ // Clear BSS ourselves, we don't have handy C runtime
221
+ extern char _bss_start ;
222
+ extern char _bss_end ;
223
+ ets_bzero (& _bss_start , & _bss_end - & _bss_start );
224
+ #endif
225
+
225
226
print_version (0 );
226
227
227
228
if (eboot_command_read (& cmd ) == 0 ) {
@@ -236,32 +237,26 @@ int main()
236
237
}
237
238
238
239
if (cmd .action == ACTION_COPY_RAW ) {
239
- uint32_t cp = S ('c' , 'p' , ':' , 0 );
240
- ets_printf ((const char * )& cp );
240
+ ets_printf ("cp:" );
241
241
242
242
ets_wdt_disable ();
243
243
res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], false);
244
244
ets_wdt_enable ();
245
245
246
- cp = S ('0' + res , '\n' , 0 , 0 );
247
- ets_printf ((const char * )& cp );
246
+ ets_printf ("%d\n" , res );
248
247
#if 0
249
248
//devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
250
249
//beginning of the image in the empty area, see #7458. Disabling for now.
251
250
//TODO: replace the below verify with hash type, crc, or similar.
252
251
// Verify the copy
253
- uint32_t v [2 ];
254
- v [0 ] = S ('c' , 'm' , 'p' , ':' );
255
- v [1 ] = 0 ;
256
- ets_printf (const char * )v );
252
+ ets_printf ("cmp:" );
257
253
if (res == 0 ) {
258
254
ets_wdt_disable ();
259
255
res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], true);
260
256
ets_wdt_enable ();
261
257
}
262
258
263
- cp = S ('0' + res , '\n' , 0 , 0 );
264
- ets_printf ((const char * )& cp );
259
+ ets_printf ("%d\n" , res );
265
260
#endif
266
261
if (res == 0 ) {
267
262
cmd .action = ACTION_LOAD_APP ;
@@ -274,13 +269,10 @@ int main()
274
269
}
275
270
276
271
if (cmd .action == ACTION_LOAD_APP ) {
277
- ets_putc ( 'l' ); ets_putc ( 'd' ); ets_putc ( '\n' );
272
+ ets_printf ( "ld\n" );
278
273
res = load_app_from_flash_raw (cmd .args [0 ]);
279
274
// We will get to this only on load fail
280
- uint32_t e [2 ];
281
- e [0 ] = S ('e' , ':' , '0' + res , '\n' );
282
- e [1 ] = 0 ;
283
- ets_printf ((const char * )e );
275
+ ets_printf ("e:%d\n" , res );
284
276
}
285
277
286
278
if (res ) {
0 commit comments