Hi,
My problem is:
I have to write with IAP to flash, so I need to save the .text section
after 0x00001000 or 0x00002000 on flash memory.
my linker script for flash executeing is:
ENTRY(_startup) /* our entry point in startup-code */
/* LPC2148 memory map */
MEMORY
{
flash : ORIGIN = 0x00000000, LENGTH = 500K
/* available flash memory LPC2148 */
ram : ORIGIN = 0x40000200, LENGTH = 31964
/* free useable RAM of LPC2148 */
}
/* now define the output sections */
SECTIONS
{
. = 0;
startup :
{
*(.startup)
} >flash
/* all code and readonly values */
.text :
{
*(.text)
/* all .text sections (code) */
*(.rodata)
/* all .rodata sections (constants, strings, etc.) */
*(.rodata*)
/* all .rodata* sections (constants, strings, etc.) */
*(.glue_7)
/* all .glue_7 sections (no idea what these are) */
*(.glue_7t)
/* all .glue_7t sections (no idea what these are) */
} >flash
_text_end = . ;
/* initialized data */
.data :
{
_data_start = . ;
*(.data)
} >ram AT >flash
/* put all the above into RAM (but load the LMA copy into FLASH) */
. = ALIGN(4);
_data_end = . ;
/* uninitialized data */
.bss :
/* bss = block started by symbol */
{
_bss_start = . ;
*(.bss)
} >ram
/* put all the above in RAM (it will be cleared in the startup code */
. = ALIGN(4);
_bss_end = . ;
/* define a global symbol marking the end of the .bss section */
/* stack area */
/*
NOTE:
It will be filled to lower addresses and must begin on align(4)
boundary.
*/
_stack_end = . ;
_stack_start = 0x40007EDC;
/* top of free useable memory */
_end = .;
/* define a global symbol marking the end of application RAM */
}
If I set
flash : ORIGIN = 0x00001000, LENGTH = 500K
the mapfile shows me that .text section beginns at 0x00001000
but the programm doesn`t work after this change.
Have anybody an idea?
thx
Marco
> If I set > flash : ORIGIN = 0x00001000, LENGTH = 500K > the mapfile shows me that .text section beginns at 0x00001000 > but the programm doesn`t work after this change. > Have anybody an idea? I could be quite wrong on this, but it could be that by forcing a change in the ORIGIN the vector table isn't updated with the new location, so its jumping to the old code location. Again, I could be wrong on this. I think the better way to do this is to use a linker flag to move the start location of the text section. On GCC-AVR it would be something like: -Wl,--section-start=.text=0x100 What this command is for you depends on what compiler your using probably.
First check if at least the exceptions-vectors are assigned to a section
named .startup. Something like this in the asm-file for the
exceptions-vectors:
...
section .startup, "ax"
LDR PC, ResetAddress
...
If not this might cause the problem as Jim Kaz already mentioned. If
this is already done (verify this in the map-file) you could try this
approach in the linker-script:
...
MEMORY
{
flash_start_vect : ORIGIN = 0x00000000, LENGTH = 0x1000
flash : ORIGIN = 0x00002000, LENGTH = 500K-0x2000
...
SECTIONS
{
. = ORIGIN(flash_start_vect);
startup :
{
*(.startup .startup.*)
} >flash_start_vect
. = ORIGIN(flash);
.text :
{
...
} >flash
...
(The ORIGIN() lines might be redundant). A --start-section option for
.startup passed to the linker with the frontend's -WL option as proposed
by Jim Kaz should work too but since you are using a self-made
linker-script anyway you could modify it to your needs.
> If I set
> flash : ORIGIN = 0x00001000, LENGTH = 500K
> the mapfile shows me that .text section beginns at 0x00001000
> but the programm doesn`t work after this change.
> Have anybody an idea?
Did you check the location of "startup". If you look into the
disassembly which instruction is at address 0x00000000? It must be the a
"jump" since the reset-vector is expected there.
Why do you use a memory-section between the application-code and not a
section at the "high end"/top of the flash-memory? IRC the LPC2148
offers some "small" flash sectors there too. Then you can simple reduce
the length for the FLASH memory in the linker-script to make sure that
the application code does not overlap with this section and keep
everything else as it is.
Martin Thomas
Thx, i had to process one other projekt until now. Martin Thomas wrote: > > Did you check the location of "startup". If you look into the > disassembly which instruction is at address 0x00000000? It must be the a > "jump" since the reset-vector is expected there. > I looked at the startup.s and at this file there is the start of the flash section defined like: .ifdef FLASH .=. .endif if i write ".=.+0x2000" the flash section will be start at 2000h and now i can write to the adress 0x1000 whitout problems. I had to use this section because the lpc2148 sections at the end of the flash are 32kB. thx & bye Marco
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.