Skip to content

Commit 1436bdc

Browse files
committed
ARMmbed#99 Enable flash protection on DAPLink bootloader region
- Set backdoor key to 'MICROBIT'. - Enable FPROT for first 32 kB of flash. - Fix FPROTx numbering according to KL27 RM, where FPROT3 is at address 0x408. - Enable backdoor key in FSEC. - Added asterisks next to selected options in comments for FOPT and FSEC.
1 parent 5d90bf4 commit 1436bdc

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

source/hic_hal/freescale/kl27z/armcc/startup_MKL27Z4.s

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -167,49 +167,35 @@ __Vectors_Size EQU __Vectors_End - __Vectors
167167
; <o5> Backdoor Comparison Key 5. <0x0-0xFF:2>
168168
; <o6> Backdoor Comparison Key 6. <0x0-0xFF:2>
169169
; <o7> Backdoor Comparison Key 7. <0x0-0xFF:2>
170-
BackDoorK0 EQU 0xFF
171-
BackDoorK1 EQU 0xFF
172-
BackDoorK2 EQU 0xFF
173-
BackDoorK3 EQU 0xFF
174-
BackDoorK4 EQU 0xFF
175-
BackDoorK5 EQU 0xFF
176-
BackDoorK6 EQU 0xFF
177-
BackDoorK7 EQU 0xFF
170+
BackDoorK0 EQU 0x4D ; 'M'
171+
BackDoorK1 EQU 0x49 ; 'I'
172+
BackDoorK2 EQU 0x43 ; 'C'
173+
BackDoorK3 EQU 0x52 ; 'R'
174+
BackDoorK4 EQU 0x4F ; 'O'
175+
BackDoorK5 EQU 0x42 ; 'B'
176+
BackDoorK6 EQU 0x49 ; 'I'
177+
BackDoorK7 EQU 0x54 ; 'T'
178178
; </h>
179179
; <h> Program flash protection bytes (FPROT)
180180
; <i> Each program flash region can be protected from program and erase operation by setting the associated PROT bit.
181181
; <i> Each bit protects a 1/32 region of the program flash memory.
182-
; <h> FPROT0
183-
; <i> Program Flash Region Protect Register 0
182+
; <h> FPROT3
183+
; <i> Program Flash Region Protect Register 3
184184
; <i> 1/32 - 8/32 region
185-
; <o.0> FPROT0.0
186-
; <o.1> FPROT0.1
187-
; <o.2> FPROT0.2
188-
; <o.3> FPROT0.3
189-
; <o.4> FPROT0.4
190-
; <o.5> FPROT0.5
191-
; <o.6> FPROT0.6
192-
; <o.7> FPROT0.7
193-
nFPROT0 EQU 0x00
194-
FPROT0 EQU nFPROT0:EOR:0xFF
195-
; </h>
196-
; <h> FPROT1
197-
; <i> Program Flash Region Protect Register 1
198-
; <i> 9/32 - 16/32 region
199-
; <o.0> FPROT1.0
200-
; <o.1> FPROT1.1
201-
; <o.2> FPROT1.2
202-
; <o.3> FPROT1.3
203-
; <o.4> FPROT1.4
204-
; <o.5> FPROT1.5
205-
; <o.6> FPROT1.6
206-
; <o.7> FPROT1.7
207-
nFPROT1 EQU 0x00
208-
FPROT1 EQU nFPROT1:EOR:0xFF
185+
; <o.0> FPROT3.0
186+
; <o.1> FPROT3.1
187+
; <o.2> FPROT3.2
188+
; <o.3> FPROT3.3
189+
; <o.4> FPROT3.4
190+
; <o.5> FPROT3.5
191+
; <o.6> FPROT3.6
192+
; <o.7> FPROT3.7
193+
nFPROT3 EQU 0x0F ; Enable protection of the first 32 kB of flash
194+
FPROT3 EQU nFPROT3:EOR:0xFF
209195
; </h>
210196
; <h> FPROT2
211197
; <i> Program Flash Region Protect Register 2
212-
; <i> 17/32 - 24/32 region
198+
; <i> 9/32 - 16/32 region
213199
; <o.0> FPROT2.0
214200
; <o.1> FPROT2.1
215201
; <o.2> FPROT2.2
@@ -221,43 +207,57 @@ FPROT1 EQU nFPROT1:EOR:0xFF
221207
nFPROT2 EQU 0x00
222208
FPROT2 EQU nFPROT2:EOR:0xFF
223209
; </h>
224-
; <h> FPROT3
225-
; <i> Program Flash Region Protect Register 3
210+
; <h> FPROT1
211+
; <i> Program Flash Region Protect Register 1
212+
; <i> 17/32 - 24/32 region
213+
; <o.0> FPROT1.0
214+
; <o.1> FPROT1.1
215+
; <o.2> FPROT1.2
216+
; <o.3> FPROT1.3
217+
; <o.4> FPROT1.4
218+
; <o.5> FPROT1.5
219+
; <o.6> FPROT1.6
220+
; <o.7> FPROT1.7
221+
nFPROT1 EQU 0x00
222+
FPROT1 EQU nFPROT1:EOR:0xFF
223+
; </h>
224+
; <h> FPROT0
225+
; <i> Program Flash Region Protect Register 0
226226
; <i> 25/32 - 32/32 region
227-
; <o.0> FPROT3.0
228-
; <o.1> FPROT3.1
229-
; <o.2> FPROT3.2
230-
; <o.3> FPROT3.3
231-
; <o.4> FPROT3.4
232-
; <o.5> FPROT3.5
233-
; <o.6> FPROT3.6
234-
; <o.7> FPROT3.7
235-
nFPROT3 EQU 0x00
236-
FPROT3 EQU nFPROT3:EOR:0xFF
227+
; <o.0> FPROT0.0
228+
; <o.1> FPROT0.1
229+
; <o.2> FPROT0.2
230+
; <o.3> FPROT0.3
231+
; <o.4> FPROT0.4
232+
; <o.5> FPROT0.5
233+
; <o.6> FPROT0.6
234+
; <o.7> FPROT0.7
235+
nFPROT0 EQU 0x00
236+
FPROT0 EQU nFPROT0:EOR:0xFF
237237
; </h>
238238
; </h>
239239
; <h> Flash nonvolatile option byte (FOPT)
240240
; <i> Allows the user to customize the operation of the MCU at boot time.
241241
; <o.0> LPBOOT0
242242
; <0=> Core and system clock divider (OUTDIV1) is 0x7 (divide by 8) when LPBOOT1=0 or 0x1 (divide by 2) when LPBOOT1=1.
243-
; <1=> Core and system clock divider (OUTDIV1) is 0x3 (divide by 4) when LPBOOT1=0 or 0x0 (divide by 1) when LPBOOT1=1.
243+
; * <1=> Core and system clock divider (OUTDIV1) is 0x3 (divide by 4) when LPBOOT1=0 or 0x0 (divide by 1) when LPBOOT1=1.
244244
; <o.1> BOOTPIN_OPT
245-
; <0=> Force Boot from ROM if BOOTCFG0 asserted, where BOOTCFG0 is the boot config function which is muxed with NMI pin
245+
; * <0=> Force Boot from ROM if BOOTCFG0 asserted, where BOOTCFG0 is the boot config function which is muxed with NMI pin
246246
; <1=> Boot source configured by FOPT (BOOTSRC_SEL) bits
247247
; <o.2> NMI_DIS
248-
; <0=> NMI interrupts are always blocked
248+
; * <0=> NMI interrupts are always blocked
249249
; <1=> NMI_b pin/interrupts reset default to enabled
250250
; <o.3> RESET_PIN_CFG
251251
; <0=> RESET pin is disabled following a POR and cannot be enabled as reset function
252-
; <1=> RESET_b pin is dedicated
252+
; * <1=> RESET_b pin is dedicated
253253
; <o.4> LPBOOT1
254254
; <0=> Core and system clock divider (OUTDIV1) is 0x7 (divide by 8) when LPBOOT0=0 or 0x3 (divide by 4) when LPBOOT0=1.
255-
; <1=> Core and system clock divider (OUTDIV1) is 0x1 (divide by 2) when LPBOOT0=0 or 0x0 (divide by 1) when LPBOOT0=1.
255+
; * <1=> Core and system clock divider (OUTDIV1) is 0x1 (divide by 2) when LPBOOT0=0 or 0x0 (divide by 1) when LPBOOT0=1.
256256
; <o.5> FAST_INIT
257257
; <0=> Slower initialization
258-
; <1=> Fast Initialization
258+
; * <1=> Fast Initialization
259259
; <o.6..7> BOOTSRC_SEL
260-
; <0=> Boot from Flash
260+
; * <0=> Boot from Flash
261261
; <2=> Boot from ROM
262262
; <3=> Boot from ROM
263263
; <i> Boot source selection
@@ -267,21 +267,21 @@ FOPT EQU 0x39
267267
; <i> WARNING: If SEC field is configured as "MCU security status is secure" and MEEN field is configured as "Mass erase is disabled",
268268
; <i> MCU's security status cannot be set back to unsecure state since Mass erase via the debugger is blocked !!!
269269
; <o.0..1> SEC
270-
; <2=> MCU security status is unsecure
270+
; * <2=> MCU security status is unsecure
271271
; <3=> MCU security status is secure
272272
; <i> Flash Security
273273
; <o.2..3> FSLACC
274274
; <2=> Freescale factory access denied
275-
; <3=> Freescale factory access granted
275+
; * <3=> Freescale factory access granted
276276
; <i> Freescale Failure Analysis Access Code
277277
; <o.4..5> MEEN
278278
; <2=> Mass erase is disabled
279-
; <3=> Mass erase is enabled
279+
; * <3=> Mass erase is enabled
280280
; <o.6..7> KEYEN
281-
; <2=> Backdoor key access enabled
281+
; * <2=> Backdoor key access enabled
282282
; <3=> Backdoor key access disabled
283283
; <i> Backdoor Key Security Enable
284-
FSEC EQU 0xFE
284+
FSEC EQU 0xBE
285285
; </h>
286286
; </h>
287287

@@ -293,7 +293,7 @@ FSEC EQU 0xFE
293293

294294
DCB BackDoorK0, BackDoorK1, BackDoorK2, BackDoorK3
295295
DCB BackDoorK4, BackDoorK5, BackDoorK6, BackDoorK7
296-
DCB FPROT0 , FPROT1 , FPROT2 , FPROT3
296+
DCB FPROT3 , FPROT2 , FPROT1 , FPROT0
297297
DCB FSEC , FOPT , 0xFF , 0xFF
298298

299299
AREA |.text|, CODE, READONLY

0 commit comments

Comments
 (0)