This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Subject: GNU ARM cross compiler failing to call code in ram from flash


I cannot find a way to call a function in another memory device (calling
a function in ram from flash).

I am using the following ARM_ELF tools on an ATMEL at91m55800a arm
processor:
GCC - 3.1.1 built with Libraries [newlib-1.10.0] for both Big/Little
endian and ARM/Thumb

The setup:

--  flash at address 0x01000000, size of 512 kBytes
--  ram containing data and two functions (flash-write and flash-erase)
at 0x02000000, size of 256 kBytes
--  Code compiled in 16-bit mode (except exception handling routines in
32-bit mode) using arm-thumb-elf tools

Compile options:
-g -Os -MMD -mcpu=arm7tdmi -fsigned-char -ffixed-lr -nostdinc
-save-temps -mlong-calls -mthumb-interwork

(I also tried the following options but had no success:
-g -Os -MMD -mcpu=arm7tdmi -fsigned-char -ffixed-lr -nostdinc
-save-temps -mlong-calls -mcaller-super-interworking
-g -Os -MMD -mcpu=arm7tdmi -fsigned-char -ffixed-lr -nostdinc
-save-temps -mlong-calls -mcallee-super-interworking
)

The code compiles and run until I call the functions in ram.  The
compiler produced the following code (calling via r3):

	1823			    result = flash_erase_sector((UINT16
*)i);	// Erase the entire sector.  
-	0x10070c2	<DoFLASHTest()+66>:		mov	r0, r6
(add r0, r6, #0)
-	0x10070c4	<DoFLASHTest()+68>:		ldr	r3, [pc,
#160]	(0x1007168 <_Z11DoFLASHTestv+232>)
-	0x10070c6	<DoFLASHTest()+70>:		bl
0x100cca8 <_call_via_r3>

Execution stops after this due to a bad exception.  The program counter
is in ram, but about 100 bytes after the start of the function and none
of the code in the functions seems to have been executed.

Any advice would be appreciated,
Kor Snyman
Kor at wavenet dot com dot au


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]