1414#include "eboot_command.h"
1515#include <uzlib.h>
1616
17- extern unsigned char _gzip_dict ;
1817
1918#define SWRST do { (*((volatile uint32_t*) 0x60000700)) |= 0x80000000; } while(0);
2019
2120extern void ets_wdt_enable (void );
2221extern void ets_wdt_disable (void );
2322
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-
2723int print_version (const uint32_t flash_addr )
2824{
2925 uint32_t ver ;
3026 if (SPIRead (flash_addr + APP_START_OFFSET + sizeof (image_header_t ) + sizeof (section_header_t ), & ver , sizeof (ver ))) {
3127 return 1 ;
3228 }
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 );
3930 return 0 ;
4031}
4132
@@ -222,6 +213,16 @@ int main()
222213 bool clear_cmd = false;
223214 struct eboot_command cmd ;
224215
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+
225226 print_version (0 );
226227
227228 if (eboot_command_read (& cmd ) == 0 ) {
@@ -236,32 +237,26 @@ int main()
236237 }
237238
238239 if (cmd .action == ACTION_COPY_RAW ) {
239- uint32_t cp = S ('c' , 'p' , ':' , 0 );
240- ets_printf ((const char * )& cp );
240+ ets_printf ("cp:" );
241241
242242 ets_wdt_disable ();
243243 res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], false);
244244 ets_wdt_enable ();
245245
246- cp = S ('0' + res , '\n' , 0 , 0 );
247- ets_printf ((const char * )& cp );
246+ ets_printf ("%d\n" , res );
248247#if 0
249248 //devyte: this verify step below (cmp:) only works when the end of copy operation above does not overwrite the
250249 //beginning of the image in the empty area, see #7458. Disabling for now.
251250 //TODO: replace the below verify with hash type, crc, or similar.
252251 // 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:" );
257253 if (res == 0 ) {
258254 ets_wdt_disable ();
259255 res = copy_raw (cmd .args [0 ], cmd .args [1 ], cmd .args [2 ], true);
260256 ets_wdt_enable ();
261257 }
262258
263- cp = S ('0' + res , '\n' , 0 , 0 );
264- ets_printf ((const char * )& cp );
259+ ets_printf ("%d\n" , res );
265260#endif
266261 if (res == 0 ) {
267262 cmd .action = ACTION_LOAD_APP ;
@@ -274,13 +269,10 @@ int main()
274269 }
275270
276271 if (cmd .action == ACTION_LOAD_APP ) {
277- ets_putc ( 'l' ); ets_putc ( 'd' ); ets_putc ( '\n' );
272+ ets_printf ( "ld\n" );
278273 res = load_app_from_flash_raw (cmd .args [0 ]);
279274 // 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 );
284276 }
285277
286278 if (res ) {
0 commit comments