CRP (in Assembler)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CRP (in Assembler)

1,188 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Sat Jul 06 11:46:49 MST 2013
I'm writing my first program for the LPC Cortex M0. . .

I included the lines

       .org 0x02FC
CRP_WORD:         .word     0x12345678

in my program, but I get the message:

/Applications/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld: Linker CRP Enabled, but no CRP_WORD provided within application

I also get this warning:

/Applications/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol ResetISR; defaulting to 0000000000000000

Any ideas?
0 Kudos
Reply
13 Replies

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Feb 10 14:58:10 MST 2014
Jenkins:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

Basically, it is an automated build system.
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rocketdawg on Mon Feb 10 14:08:11 MST 2014

Quote: IanB

And who is Jenkins?



Who is Jenkins?  You have to ask?  The great an powerful Jenkins?

there is a tool in C (which you would not know of course) that is called __LINE__.  Assertions can reference this object.  this object just return the full path of the current line of C code where the assertion happened.   This reference is to a line of code in elf32-arm.c and Jenkins is the user that built the binary for that bin utility.

now you could go to ARMtools_2012q4_Mac_build/gcc-arm-none-eabi-4_6-2012q4-20121016/src/binutils/bfd/elf32-arm.c  line  12511
to inspect what the assertion was ...
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Feb 10 11:38:41 MST 2014
That error message is reporting an internal error in the linker.

These very rare errors are normally caused by problems in your application code or linker script.

Sorry that I can't be more specific, but you will have to experiment with your source code to try to find out what is causing the problem (try backing out recent changes to see what causes it).

BTW: Why are you using LPCXpresso 5.2.4 when v6.1.4 is available? (it won't make any difference to this issue as the linker is identical, but there are lots of other enhancements in v6: http://www.lpcware.com/lpcxpresso/home)
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Feb 10 10:59:42 MST 2014
I get this error, which I think is from the linker:

collect2: ld terminated with signal 11 [Segmentation fault: 11]
/Applications/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld: BFD (GNU Tools for ARM Embedded Processors) 2.21.1.20121016 assertion fail /Users/build/Jenkins/workspace/ARMtools_2012q4_Mac_build/gcc-arm-none-eabi-4_6-2012q4-20121016/src/binutils/bfd/elf32-arm.c:12511
make: *** [libsfc2.axf] Error 1

What does it mean? (or where can I look up in the literature what it means?) How do I tell which line in the code (or in the linker script) caused it? And who is Jenkins?
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Sat Feb 08 16:40:39 MST 2014
Spot on! Thanks.

0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Sat Feb 08 14:36:49 MST 2014
I guess you need to make the symbol visible outside of your source file. By default it will be local, so you need to use
.global
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Sat Feb 08 02:32:22 MST 2014
Thanks for that.

Am I correct in thinking that if my code says:

    .org 0x02fc
    .word 0x0

or

    .org 0x02fc
    .word 0x12345678

then CRP gets set to the appropriate level, because it is just the value stored a location 0x02FC in the flash memory, even if I turn off "Enable Code Read Protect" in Properties->MCU Linker->Target?
Thus the nannying error message will go away, and I can still have code read protection.

Similarly, if the code includes:

    .org 0x0000

.word0x10002000                /*  0 Top of Stack                 */
/* CM0 system interrupts */
.wordResetISR                    /*  1 Reset Handler                */

then, presumably, execution will start at the label "ResetISR". (Yes I do have a label called ResetISR, but I still get the error message, so what do I do to make the error message go away, as there appears to be no real error, just an irritating message.




0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Feb 07 10:05:21 MST 2014
For background on CRP, see:

http://support.code-red-tech.com/CodeRedWiki/CodeReadProtect
http://support.code-red-tech.com/CodeRedWiki/CRP_LinkError
http://www.lpcware.com/content/faq/lpcxpresso/code-read-protect-crp

So for CRP in assembler, with the managed linker script mechanism enabled (or a linker script that you have copied yourself based on a managed linker script), you will need something like:

 .section ".crp","a",%progbits
  .global CRP_WORD
CRP_WORD:
  .word  -1


The ResetISR warning is presumably because your own code does not declare the function ResetISR - which the managed linker script mechanism assumes is the entry point…

ENTRY(ResetISR)


If this isn't the name of your reset handler, then change this to match your codebase.

Remember the managed linker script mechanism makes assumes about the naming and structure of your code - which match how the wizards create C / C++ projects. If you 'do your own thing' with regards to code, then you may well need to take control of the linker scripts too.

For LPCXpresso 6 see : http://www.lpcware.com/content/faq/lpcxpresso/own-linker-scripts
Fpr LPCXpresso 5 see : http://support.code-red-tech.com/CodeRedWiki/OwnLinkScripts
[though the principles are basically the same in both versions.]

Regards,
LPCXpresso Support
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Wed Feb 05 10:08:55 MST 2014
I have returned to this after 8 months.

I still get the errors:
/Applications/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld: Linker CRP Enabled, but no CRP_WORD provided within application
and
/Applications/lpcxpresso_5.2.4_2122/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol ResetISR; defaulting to 0000000000000000

WHY?

Both CRP_WORD and ResetISR are defined in the code.
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Tue Jul 09 13:17:57 MST 2013
Thanks.

As I write the entire program in one file, and as I use the .org directive to specify where I want the assembler to put the code, then I suppose that don't need a linker, so I made a linker script with nothing in, and it seems to work.

I presume that if the right value ends up at 0x02fc then the CRP still works, regardless of how the right value got in location 0x02fc, and the vectors will work provided that they are in the right place.

I now have a project containing just a .s file, a .o file and an almost blank linker file.
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Jul 08 23:36:52 MST 2013
If you use Enable CRP option in the Linker, the managed linker script mechanism will place your section in the correct location . If you uncheck this option, you will need to locate the section manually.

If you want the linker (or any other modules) to be able to see your assembler symbol, you need to use the .global assembler directive. By default symbols are all module-private. Read the GNU Assembler manual for more details.

The Entry symbol defines then entry point of the program in the executable. For embedded applications it is not strictly necessary, but if you use the managed linker scripts, then should be defined.

Most people who write assembler also provide their own linker scripts...
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Jul 08 13:20:36 MST 2013
Thanks.

It seems it is something to do with sections. It's a pity that none of the documentation I can find adequately explains what they do, presumably something to do with declaring where the code goes, and where the RAM is, something that is normally done perfectly adequately with the .org directive.

If I define a section called CRP do I have to tell it what address it goes at?


I changed Reset to ResetISR, and still get the same error. What does it mean by an "entry symbol"?
0 Kudos
Reply

1,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Jul 07 01:53:51 MST 2013
From memory, the linker script expects the CRP word to be in a specific section name (.crp). This is done automatically when you are doing things in C. But if you are doing everything in assembler, then you'll need to set this up yourself.

It also expects the Reset handler to have a specific name - ResetISR.

For reference, here is the FAQ on the CRP error..

http://support.code-red-tech.com/CodeRedWiki/CRP_LinkError

Might be worth you generating a standard LPCXpresso C project using the wizard, and generating an assembler listing so that you can see what is going on...

http://support.code-red-tech.com/CodeRedWiki/DisassObsjExes

There have also been a few previous posts where users have been wanting to write purely in assembler. Might be worth you doing a search for "assembler" to find them.

Regards,
CodeRedSupport
0 Kudos
Reply