# Forum: ARM programming with GCC/GNU tools freertos and swi_handler

 Author: Jonathan D. (dumarjo) Posted on: 2009-04-01 23:23

Rate this post
 0 ▲ useful ▼ not useful
Hi all,

I try to make the freertos sam7x256 project sample working. I got it
working right when I use the makefile, boot.S and atmel-rom.ld that came
with freertos.

Now I want to use the cstartup.S, new ld files and new makefile from the
gamma_sample.

I Have not been able to start the demo anymore. I want to use those new
file because I would like to be able to have my vector in ram and use
the garbage collector too.

So now, I'm a little bit lost. I attached the files That I have modified
to get the freertos demo working.

is there somebody that can take a look at this ? or get something
similar that he want to share ?

Jonathan

 Author: Martin T. (mthomas) (Moderator) Posted on: 2009-04-04 18:22

Rate this post
 0 ▲ useful ▼ not useful
Jonathan Dumaresq wrote:
> Hi all,
>
> I try to make the freertos sam7x256 project sample working. I got it
> working right when I use the makefile, boot.S and atmel-rom.ld that came
> with freertos.
>
> Now I want to use the cstartup.S, new ld files and new makefile from the
> gamma_sample.
>
> I Have not been able to start the demo anymore. I want to use those new
> file because I would like to be able to have my vector in ram and use
> the garbage collector too.

I have not done much with FreeRTOS but AFAIK it uses the SWI-Interrupt
for context-switching. The gamma-example includes it's own swi-handler
which does not know anything context-switching or FreeRTOS. I have used
the SWI for operations that must be done a privileged mode since the
application runs in user-mode. This is not really needed for smaller
ARM-controller. If the application runs in supervisor-mode as in the
FreeRTOS example you do not need SWI for i.e. enabling/disabling IRQ on
core-level.

With "garbage collection" I expect you mean the unused code removal
feature. For this you just need:
- make sure the vectors are not removed (KEEP in linker-script)
- either ENTRY must be given in linker-script or the init-functions must
be located in a section that is used with KEEP
- make sure the "wildcard" is in the linker-script for the section (i.e.
not just *(.text) but *(.text .text.*), same for data, rodata, bss
- add -ffunction-sections to the compiler-options
- add -gc-sections to the linker options (when called from the frontend
with -Wl,--gc-sections

For "vectors in RAM":
- place the vector-implementation in the working code into an extra
section
(usually by using the .section diretive in the source-code)
- make sure this section is linked to the .data-segment as first entry
for .data in the linker-script with this the linker will reserve space
for the vectors and the startup-code will copy them into RAM
- remap (see AT91 datasheet)

See examples from the Atmel software-package might show this better than
my over-complicated gamma-example.

> So now, I'm a little bit lost. I attached the files That I have modified
> to get the freertos demo working.
The main problem should be the swi-handling. FreeRTOS needs it but you
code uses it for something else.

> is there somebody that can take a look at this ? or get something
> similar that he want to share ?
I just had a quick look into your code. Sorry, no time to modify it as
needed but it might be easier to modify the original FreeRTOS example

Hope this helps at least a little bit.
Martin

 Author: Jonathan D. (dumarjo) Posted on: 2009-04-06 14:44

Rate this post
 0 ▲ useful ▼ not useful
Hi,

This is more than with need for the explanation. We got it running. We
are just not much familiar in the startup files... Now we are :P

We have correctly redirected the SWI handling in RAM with the remap
feature.

So now we have something functionnal.

I'll like to tell you that your explanation are always precise, exact
and educative !

Jonathan

• $formula (LaTeX syntax)$