This used to work under IAR 4.x for setting the code-protect value :
__root const Int32U crp_data @ 0x01FC = 0x87654321;
However on 5.4 it gives this error :
Error[Be022]: location address not allowed for initialized variables (writable
variables without the
__no_init attribute) C:\ASM\lpc\evaclink\main.c 25
I don't understand why it thinks a const is writeable....
anone figured out how to do this in IAR 5.x ?
Code protect in IAR 5.x
Started by ●August 1, 2009
Reply by ●August 1, 20092009-08-01
--- In l..., Mike Harrison wrote:
>
> This used to work under IAR 4.x for setting the code-protect value :
>
> __root const Int32U crp_data @ 0x01FC = 0x87654321;
>
> However on 5.4 it gives this error :
>
> Error[Be022]: location address not allowed for initialized variables (writable variables without the
> __no_init attribute) C:\ASM\lpc\evaclink\main.c 25
> I don't understand why it thinks a const is writeable....
> anone figured out how to do this in IAR 5.x ?
>
Hi
IAR4 -> IAR5 has some big differences. I can't comment on the C-compiler behavior since I never tried this form for const variables with it but you could try moving it to assembler .
For example, GCC initilisation code often uses something like this in its interrupt vectors:
_vectors:
ldr pc, [pc, #_reset_handler - . - 8] /* reset vector */
ldr pc, [pc, #_undef_handler - . - 8] /* undefined instruction */
ldr pc, [pc, #_swi_handler - . - 8] /* swi handler */
ldr pc, [pc, #_pabort_handler - . - 8]/* abort prefetch */
ldr pc, [pc, #_dabort_handler - . - 8]/* abort data */
.word 0xB8A06F88 /* LPC boot loader checksum */
ldr pc, [pc, #_irq_handler - . - 8] /* irq */
ldr pc, [pc, #_fiq_handler - . - 8] /* fiq */
Although this code may not be compatible with the IAR assembler the general technique may be easier to solve the problem.
Regards
Mark
http://www.uTasker.com
>
> This used to work under IAR 4.x for setting the code-protect value :
>
> __root const Int32U crp_data @ 0x01FC = 0x87654321;
>
> However on 5.4 it gives this error :
>
> Error[Be022]: location address not allowed for initialized variables (writable variables without the
> __no_init attribute) C:\ASM\lpc\evaclink\main.c 25
> I don't understand why it thinks a const is writeable....
> anone figured out how to do this in IAR 5.x ?
>
Hi
IAR4 -> IAR5 has some big differences. I can't comment on the C-compiler behavior since I never tried this form for const variables with it but you could try moving it to assembler .
For example, GCC initilisation code often uses something like this in its interrupt vectors:
_vectors:
ldr pc, [pc, #_reset_handler - . - 8] /* reset vector */
ldr pc, [pc, #_undef_handler - . - 8] /* undefined instruction */
ldr pc, [pc, #_swi_handler - . - 8] /* swi handler */
ldr pc, [pc, #_pabort_handler - . - 8]/* abort prefetch */
ldr pc, [pc, #_dabort_handler - . - 8]/* abort data */
.word 0xB8A06F88 /* LPC boot loader checksum */
ldr pc, [pc, #_irq_handler - . - 8] /* irq */
ldr pc, [pc, #_fiq_handler - . - 8] /* fiq */
Although this code may not be compatible with the IAR assembler the general technique may be easier to solve the problem.
Regards
Mark
http://www.uTasker.com
Reply by ●August 2, 20092009-08-02
Mike Harrison wrote:
> This used to work under IAR 4.x for setting the code-protect value :
>
> __root const Int32U crp_data @ 0x01FC = 0x87654321;
>
> However on 5.4 it gives this error :
>
> Error[Be022]: location address not allowed for initialized variables (writable variables without the
> __no_init attribute) C:\ASM\lpc\evaclink\main.c 25
> I don't understand why it thinks a const is writeable....
> anone figured out how to do this in IAR 5.x ?
Hi Mike,
There are big differences between IAR 4.x and 5.4. To perform read
protection you need the following.
#pragma location="CodeReadProtection"
__root const DWord_T crp_data = 0x87654321; // Code read protection
You need to add the above in your C code. You then need to go into the
projects ICF file and add the following line.
place at address mem: 0x000001FC { readonly section CodeReadProtection };
This should get you read protection.
regards,
Charles
> This used to work under IAR 4.x for setting the code-protect value :
>
> __root const Int32U crp_data @ 0x01FC = 0x87654321;
>
> However on 5.4 it gives this error :
>
> Error[Be022]: location address not allowed for initialized variables (writable variables without the
> __no_init attribute) C:\ASM\lpc\evaclink\main.c 25
> I don't understand why it thinks a const is writeable....
> anone figured out how to do this in IAR 5.x ?
Hi Mike,
There are big differences between IAR 4.x and 5.4. To perform read
protection you need the following.
#pragma location="CodeReadProtection"
__root const DWord_T crp_data = 0x87654321; // Code read protection
You need to add the above in your C code. You then need to go into the
projects ICF file and add the following line.
place at address mem: 0x000001FC { readonly section CodeReadProtection };
This should get you read protection.
regards,
Charles