FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2009 Threads] reallocate main programPosted by jonathan on April 1, 2009 Hi all,
We use Freertos on an ARM7 (SAM7S from ATMEL) and we have somting that work pretty well. First we have developped an bootloader. try some in house code on the sam7s and all works fine. But if I try to use the sample from freertos, the program hangs when it's not located to 0 in flash. IF I test the program and place it to address 0, everythings work. If I put an offset in the linker file, The program start but as soon as the task is started, the program hang and the Watchdog reset the CPU.
I have use the sample sam7x sample file for GCC.
Does anyone here have try to offset an Freertos project ? We have us ucos/II in the past without any problem . I have some problem finding what cause this kind of things.
regards
jonathan
RE: reallocate main programPosted by Adam Turowski on April 2, 2009 The beginning of ARM memory is occupied by reset/exceptions vectors. They have to be always there because CPU is forced to executes the code from there when reset/exception occurs. Please check first if these vectors placed at 0x00000 address after you have made your offset.
Best regards, Adam
RE: reallocate main programPosted by jonathan on April 2, 2009 HI,
This is what i conclude. The SWI handler is the problem I think. I need to be able to put this in RAM. When we use ucos/II, we don't have this problem because they don't use this SWI interrupt.
Now we try to figure out how to get the SWI handler remaped to RAM.
If someone have done this and would liek to share their startup asm file, ld + makefile, I'll appreciate.
Jonathan
RE: reallocate main programPosted by Adam Turowski on April 2, 2009 I am using this kind of assembly file:
/*==============================================*/ /* exceptions and interrupt vectors table setup */ /*==============================================*/ .section .startup,"ax" .arm .align 0
b start /* jump from here just after reset */ b vUndefinedInstructionException b vPortYieldProcessor /* used for manual calling SWI instruction to call the scheduler and task yielding */ b vPrefetchAbortException b vDataAbortException b vReservedException ldr pc,[pc, # -0xF20] /* jump to the interrupt exception handler address given in AIC register*/ b vFiqException
This is setting up exception/reset vector table in section called ".startup". In linker script I simply put this section where it belongs:
MEMORY { FLASH : ORIGIN = 0x0, LENGTH = 256K RAM : ORIGIN = 0x200000, LENGTH = 64K /* length of RAM */ }
__ram_end__ = RAM_ORIGIN + RAM_SIZE;
SECTIONS { /* setup TEXT section */ . = 0; __text_beg__ = .; startup : { *(.startup) } > FLASH
Of course you can hardcode this section origin address in assembly, but I prefer to have that control in linker file.
Hope that helps.
Regards, Adam
RE: reallocate main programPosted by jonathan on April 2, 2009 HI Adam,
This is very interesting.
With this setup, you can have your vector in flash, but the vector a realocated in the linker script ? I see that in you ld script, you have you startup section to addr 0, but if I change the FLASH ORIGIN to 0x1780 for exemple, the startup section will be place at 0x1780 ?
am I wrong ?
Jonathan
RE: reallocate main programPosted by Adam Turowski on April 2, 2009 Yes, if you change FLASH origin, the section .startup address will change accordingly. Please enable and check your *.map file generated during linking stage for all needed information.
RE: reallocate main programPosted by incrediball on April 7, 2009 The problem with a bootloader is that it defines the default vector table and you would need to get the bootloader interrupt handling to relay all the interrupts through to the main program. This is messy, may not support all of the interrupt types (e.g. SWI in your case) and adds latency to the interrupt handling. To use get around this problem modify your main program so:
1. Define your ROM or FLASH sector at 0x00100000 plus the size of the bootloader sector. For example if you reserve 4K for the bootloader (this corresponds to the first lockable page on the AT91SAM7S64) then define it at 0x00101000.
Note that the flash memory on the AT91SAM7S is really located at 0x00100000 so doing this is not a trick. This memory is only mirrored to 0x00000000 by default.
2. Locate your vector table at 0x00200000, for example:
/* Exception vectors located at 0x00200000. These are re-mapped to 0x00000000 by the re-map command */ /* Note that undf, pabt, dabt just execute a null loop. */
.section.vectors _vectors: b./* 0x00 reset - not used since the processor has already reset when it re-maps the memory */ b./* 0x04 undef */ ldrpc, _swi_ram/* 0x08 swi */ b./* 0x0C pabt */ b./* 0x10 dabt */ nop/* 0x14 rsvd */ ldrpc, [pc,#-0xF20]/* 0x18 irq - load PC with the interrupt vector in AT91C_BASE_AIC->AIC_IVR */ ldrpc, [pc,#-0xF20]/* 0x1c fiq - load PC with the interrupt vector in AT91C_BASE_AIC->AIC_FVR */ _swi_ram:.word vPortYieldProcessor
You will need to modify your linker script to tell the linker to put the vectors section first in the RAM.
3. Perform a remap command as soon as the main program starts up. This mirrors the vector table defined at 0x00200000 to 0x00000000 thus replacing the vector table defined by the bootloader.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|