Skip to content

Commit 12f6db1

Browse files
committed
CRP is now placed at 0x000002FC and relocated if a bootloader exists
GCC Linker now includes CRP region
1 parent ace427f commit 12f6db1

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ CRP3 0x43218765 - Access to chip via the SWD pins is disabled. ISP entry
3737
Caution: If CRP3 is selected, no future factory testing can be
3838
performed on the device.
3939
*/
40-
41-
#if !defined(BOOTLOADER_ADDR) // Do not include CRP if there is a bootloader.
42-
#if defined (__ICCARM__)
43-
__root const long CRP_Key@0x000002FC = 0xFFFFFFFF;
44-
#elif defined (__GNUC__)
45-
const long CRP_Key __attribute__((used)) __attribute__((section(".CRPSection"))) = 0xFFFFFFFF;
46-
#else
47-
const long CRP_Key __attribute__((used)) __attribute__((section(".ARM.__at_0x000002FC"))) = 0xFFFFFFFF;
48-
#endif
40+
#if !defined(APPLICATION_ADDR) // Relocate CRP if there is a bootloader.
41+
#define APPLICATION_ADDR 0
42+
#endif
43+
44+
#if defined (__ICCARM__)
45+
__root const long CRP_Key@APPLICATION_ADDR + 0x000002FC = 0xFFFFFFFF;
46+
#elif defined (__ARMCC_VERSION)
47+
const long CRP_Key __attribute__((used)) __attribute__((at(APPLICATION_ADDR+0x000002FC))) = 0xFFFFFFFF;
48+
#elif defined (__GNUC__)
49+
const long CRP_Key __attribute__((used)) __attribute__((section(".CRPSection"))) = 0xFFFFFFFF;
4950
#endif

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

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

4747
SECTIONS
4848
{
49-
.CRPSection 0x000002FC :
50-
{
51-
KEEP(*(.CRPSection))
52-
} > m_data
5349
.text :
5450
{
5551
KEEP(*(.isr_vector))
52+
/* Code Read Protect data */
53+
. = 0x000002FC ;
54+
KEEP(*(.CRPSection))
55+
/* End of Code Read Protect */
5656
*(.text*)
5757

5858
KEEP(*(.init))
@@ -75,6 +75,8 @@ SECTIONS
7575
*(.rodata*)
7676

7777
KEEP(*(.eh_frame*))
78+
79+
7880
} > FLASH
7981

8082
.ARM.extab :

0 commit comments

Comments
 (0)