File tree Expand file tree Collapse file tree
encrypted/hello_encrypted Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,10 +15,29 @@ int main() {
1515 stdio_init_all ();
1616
1717#if PICO_CRT0_IMAGE_TYPE_TBYB
18- // If TBYB image, then buy it
19- uint8_t * buffer = malloc (4096 );
20- rom_explicit_buy (buffer , 4096 );
21- free (buffer );
18+ boot_info_t boot_info = {};
19+ int ret = rom_get_boot_info (& boot_info );
20+ if (ret ) {
21+ // BOOT_TBYB_AND_UPDATE_FLAG_BUY_PENDING will always be set, but check anyway
22+ if (boot_info .tbyb_and_update_info & BOOT_TBYB_AND_UPDATE_FLAG_BUY_PENDING ) {
23+ // Need to check flash_update_base is set to see if this is a TBYB update
24+ uint32_t flash_update_base = boot_info .reboot_params [0 ];
25+ if (flash_update_base ) {
26+ printf ("Perform self-check... " );
27+ if (1 == 1 ) {
28+ printf ("passed\n" );
29+ } else {
30+ printf ("failed - looping forever\n" );
31+ while (true) sleep_ms (1000 );
32+ }
33+ }
34+ uint32_t buf_size = flash_update_base ? 4096 : 0 ;
35+ uint8_t * buffer = flash_update_base ? malloc (buf_size ) : NULL ;
36+ int ret = rom_explicit_buy (buffer , buf_size );
37+ assert (ret == 0 );
38+ if (buffer ) free (buffer );
39+ }
40+ }
2241#endif
2342 extern char secret_data [];
2443
You can’t perform that action at this time.
0 commit comments