@@ -84,7 +84,11 @@ const t_monitor_if usbcdc_if =
84
84
/* The pointer to the interface object use by the monitor */
85
85
t_monitor_if * ptr_monitor_if ;
86
86
87
+ #ifdef SECURE_BY_DEFAULT
88
+ bool b_security_enabled = true;
89
+ #else
87
90
bool b_security_enabled = false;
91
+ #endif
88
92
89
93
/* b_terminal_mode mode (ascii) or hex mode */
90
94
volatile bool b_terminal_mode = false;
@@ -225,6 +229,7 @@ void sam_ba_putdata_term(uint8_t* data, uint32_t length)
225
229
return ;
226
230
}
227
231
232
+ #ifndef SECURE_BY_DEFAULT
228
233
volatile uint32_t sp ;
229
234
void call_applet (uint32_t address )
230
235
{
@@ -247,6 +252,7 @@ void call_applet(uint32_t address)
247
252
/* Jump to application Reset Handler in the application */
248
253
asm("bx %0" ::"r" (app_start_address ));
249
254
}
255
+ #endif
250
256
251
257
uint32_t current_number ;
252
258
uint32_t erased_from = 0 ;
@@ -413,6 +419,7 @@ static void sam_ba_monitor_loop(void)
413
419
414
420
sam_ba_putdata_term ((uint8_t * ) & current_number , 4 );
415
421
}
422
+ #ifndef SECURE_BY_DEFAULT
416
423
else if (!b_security_enabled && command == 'G' ) // Execute code. Will not allow when security is enabled.
417
424
{
418
425
call_applet (current_number );
@@ -423,6 +430,7 @@ static void sam_ba_monitor_loop(void)
423
430
ptr_monitor_if -> put_c (0x6 );
424
431
}
425
432
}
433
+ #endif
426
434
else if (command == 'T' ) // Turn on terminal mode
427
435
{
428
436
b_terminal_mode = 1 ;
@@ -711,7 +719,12 @@ void sam_ba_monitor_run(void)
711
719
PAGES = NVMCTRL -> PARAM .bit .NVMP ;
712
720
MAX_FLASH = PAGE_SIZE * PAGES ;
713
721
722
+ #ifdef SECURE_BY_DEFAULT
723
+ b_security_enabled = true;
724
+ #else
714
725
b_security_enabled = NVMCTRL -> STATUS .bit .SB != 0 ;
726
+ #endif
727
+
715
728
ptr_data = NULL ;
716
729
command = 'z' ;
717
730
while (1 )
0 commit comments