Author Topic: Enabling CRP (working with IAR)  (Read 14725 times)

noelia

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Enabling CRP (working with IAR)
« on: February 03, 2012, 06:24:31 AM »
I am working with LPC1764 and IAR compiler. I am trying to enable CRP in my code but I can't. Flash Magic always say to me "CRP is disabled" (I tried with two different boards and always test it through a power cycle).

I tried two options:
1) Writing this code in main, but it doesn't work because is for KEIL

Code: [Select]
const unsigned long crp __attribute__ ((at(0x2FC))) = 0x87654321;
2) Adding this to startup_LPC17xx.s after Default interrupt handlers and before END. I attached the file.

Code: [Select]
SECTION .crp:CODE:ROOT(2)
DATA
DCD 0x87654321

Flash Magic works perfectly, I can read memory, erase, program, etc. But I can't protect my board.
I read the UM10360 and AN10851.
What am I doing wrong?

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2190
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Enabling CRP (working with IAR)
« Reply #1 on: February 06, 2012, 01:56:01 AM »
When you read the memory of your programmed device what value is at location 2FCH?

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

noelia

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Enabling CRP (working with IAR)
« Reply #2 on: February 06, 2012, 05:27:46 AM »
When I go to ISP->Display Memory-> 000002F0
I see this:
00 88 36 30 DF F8 08 1B 08 80 DF F8 34 09 00 78

I was testing with different values in my startup (0x87654321, 0x12345678 and 0xFFFFFFFF) and I always read the same.

This is the line in my hex file:
:1002F000 00883630DFF8081B0880DFF834090078 02

Am I looking the value (0x87654321) in the correct line?
My code is already protected? or not?

Thanks

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2190
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Enabling CRP (working with IAR)
« Reply #3 on: February 06, 2012, 05:37:27 AM »
The hex file and memory contents match up - you are programming the value 0x78000934, which does not turn CRP on. I presume that value is part of your application. I think you will need to consult your IAR documentation to find the correct compiler extensions to use.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

noelia

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Enabling CRP (working with IAR)
« Reply #4 on: February 06, 2012, 09:54:03 AM »
I could program CRP OK!
I can see "CRP is at level 1" in Flash Magic. When I want to read memory says Operation Failed (reading data - security violation in device).

My startup was OK but the error was in my IAR project. It is important to configure a correct icf file in Linker Options (Options->Linker->Config->Linker Configuration File). This file has the definition for crp section.
I take LPC1768_Flash.icf from an LPC1768 example from IAR. Now I have to write one for LPC1764.
Thanks for your help.


laurianus

  • Jr. Member
  • **
  • Posts: 1
    • View Profile
    • Email
Re: Enabling CRP (working with IAR)
« Reply #5 on: October 22, 2012, 03:25:29 AM »
Can some one give me a good icf file so I can enable CRP for a LPC1768 using IAR?

noelia

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Enabling CRP (working with IAR)
« Reply #6 on: October 22, 2012, 07:00:07 AM »
This is my icf file, it works with LPC1764.
Good luck!