Skip to content

Commit

Permalink
Make microbit bootloader optional for kl27z HIC
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrossard committed Jan 13, 2021
1 parent fb4d5da commit 1d7ad5d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions records/board/kl27z_microbit_bl.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
common:
macros:
- MICROBIT_LOCK_BOOTLOADER
common:
sources:
board:
Expand Down
1 change: 1 addition & 0 deletions records/board/microbitv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ common:
- USB_PROD_STR="BBC micro:bit CMSIS-DAP"
- IO_CONFIG_OVERRIDE
- DELAY_FAST_CYCLES=2U
- MICROBIT_LOCK_BOOTLOADER
includes:
- source/board/microbitv2
sources:
Expand Down
19 changes: 19 additions & 0 deletions source/hic_hal/freescale/kl27z/armcc/startup_MKL27Z4.s
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ __Vectors_Size EQU __Vectors_End - __Vectors
; <o5> Backdoor Comparison Key 5. <0x0-0xFF:2>
; <o6> Backdoor Comparison Key 6. <0x0-0xFF:2>
; <o7> Backdoor Comparison Key 7. <0x0-0xFF:2>
#if defined(MICROBIT_LOCK_BOOTLOADER)
BackDoorK0 EQU 0x4D ; 'M'
BackDoorK1 EQU 0x49 ; 'I'
BackDoorK2 EQU 0x43 ; 'C'
Expand All @@ -175,6 +176,16 @@ BackDoorK4 EQU 0x4F ; 'O'
BackDoorK5 EQU 0x42 ; 'B'
BackDoorK6 EQU 0x49 ; 'I'
BackDoorK7 EQU 0x54 ; 'T'
#else
BackDoorK0 EQU 0xFF
BackDoorK1 EQU 0xFF
BackDoorK2 EQU 0xFF
BackDoorK3 EQU 0xFF
BackDoorK4 EQU 0xFF
BackDoorK5 EQU 0xFF
BackDoorK6 EQU 0xFF
BackDoorK7 EQU 0xFF
#endif
; </h>
; <h> Program flash protection bytes (FPROT)
; <i> Each program flash region can be protected from program and erase operation by setting the associated PROT bit.
Expand All @@ -190,7 +201,11 @@ BackDoorK7 EQU 0x54 ; 'T'
; <o.5> FPROT3.5
; <o.6> FPROT3.6
; <o.7> FPROT3.7
#if defined(MICROBIT_LOCK_BOOTLOADER)
nFPROT3 EQU 0x0F ; Enable protection of the first 32 kB of flash
#else
nFPROT3 EQU 0x00
#endif
FPROT3 EQU nFPROT3:EOR:0xFF
; </h>
; <h> FPROT2
Expand Down Expand Up @@ -281,7 +296,11 @@ FOPT EQU 0x39
; * <2=> Backdoor key access enabled
; <3=> Backdoor key access disabled
; <i> Backdoor Key Security Enable
#if defined(MICROBIT_LOCK_BOOTLOADER)
FSEC EQU 0xBE
#else
FSEC EQU 0xFE
#endif
; </h>
; </h>

Expand Down
11 changes: 11 additions & 0 deletions source/hic_hal/freescale/kl27z/gcc/startup_MKL27Z4.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,23 @@ __Vectors:

.size __Vectors, . - __Vectors

#if defined(DAPLINK_BL)
/* TODO: Bootloader Configuration Area (BCA) used by Kinetis ROM Bootloader
#endif
/* Flash Configuration */
.section .FlashConfig, "a"
#if defined(MICROBIT_LOCK_BOOTLOADER)
.long 0x5243494D
.long 0x5449424F
.long 0xFFFFFFF0
.long 0xFFFF39FE
#else
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFF3FFE
#endif

.text
.thumb
Expand Down

0 comments on commit 1d7ad5d

Please sign in to comment.