File tree 1 file changed +23
-4
lines changed
encrypted/hello_encrypted
1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,29 @@ int main() {
15
15
stdio_init_all ();
16
16
17
17
#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
+ }
22
41
#endif
23
42
extern char secret_data [];
24
43
You can’t perform that action at this time.
0 commit comments