Skip to content

Commit ace427f

Browse files
committed
Ensure CRP is set correctly for IAR, GCC and ARM
1 parent d5e3c9a commit ace427f

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ Caution: If CRP3 is selected, no future factory testing can be
3838
performed on the device.
3939
*/
4040

41-
#if !defined(BOOTLOADER_ADDR) // do not include CRP if there is a bootloader.
41+
#if !defined(BOOTLOADER_ADDR) // Do not include CRP if there is a bootloader.
4242
#if defined (__ICCARM__)
43-
const long CRP_Key @0x000002FC = 0xFFFFFFFF;
43+
__root const long CRP_Key@0x000002FC = 0xFFFFFFFF;
44+
#elif defined (__GNUC__)
45+
const long CRP_Key __attribute__((used)) __attribute__((section(".CRPSection"))) = 0xFFFFFFFF;
4446
#else
45-
const long CRP_Key __attribute__((section(".ARM.__at_0x000002FC "))) = 0xFFFFFFFF;
46-
#endif
47+
const long CRP_Key __attribute__((used)) __attribute__((section(".ARM.__at_0x000002FC"))) = 0xFFFFFFFF;
48+
#endif
4749
#endif

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ __Vectors DCD __initial_sp ; Top of Stack
9999
DCD PLL1_IRQHandler ; 48: PLL1 Lock (USB PLL)
100100

101101

102-
IF :LNOT::DEF:NO_CRP
103-
AREA |.ARM.__at_0x02FC|, CODE, READONLY
104-
CRP_Key DCD 0xFFFFFFFF
105-
ENDIF
106-
107-
108102
AREA |.text|, CODE, READONLY
109103

110104

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ ENTRY(Reset_Handler)
4646

4747
SECTIONS
4848
{
49+
.CRPSection 0x000002FC :
50+
{
51+
KEEP(*(.CRPSection))
52+
} > m_data
4953
.text :
5054
{
5155
KEEP(*(.isr_vector))

targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/startup_LPC17xx.S

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -350,26 +350,4 @@ USBActivity_IRQHandler
350350
CANActivity_IRQHandler
351351
B CANActivity_IRQHandler
352352

353-
#ifndef SRAM
354-
SECTION .crp:CODE:ROOT(2)
355-
DATA
356-
/* Code Read Protection
357-
CRP1 0x12345678 - Write to RAM command can not access RAM below 0x10000200.
358-
- Read Memory command: disabled.
359-
- Copy RAM to Flash command: cannot write to Sector 0.
360-
- "Go" command: disabled.
361-
- Erase sector(s) command: can erase any individual sector except
362-
sector 0 only, or can erase all sectors at once.
363-
- Compare command: disabled
364-
CRP2 0x87654321 - Write to RAM command: disabled.
365-
- Copy RAM to Flash: disabled.
366-
- Erase command: only allows erase of all sectors.
367-
CRP3 0x43218765 - Access to chip via the SWD pins is disabled. ISP entry
368-
by pulling PIO0_1 LOW is disabled if a valid user code is
369-
present in flash sector 0.
370-
Caution: If CRP3 is selected, no future factory testing can be
371-
performed on the device.
372-
*/
373-
DCD 0xFFFFFFFF
374-
#endif
375353
END

0 commit comments

Comments
 (0)