# FreeRTOS on AT91SAM7A3

**URL:** <https://forums.freertos.org/t/freertos-on-at91sam7a3/2405>\
**Category:** Kernel\
**Created:** [February 24, 2009, 4:32pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405 "2009-02-24T16:32:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 24, 2009, 4:32pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/1 "2009-02-24T16:32:31Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Tuesday, February 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc):

HI 🙂

I’ve created a FreeRTOS project for the AT91SAM7A3 based on the AT91SAM7S64.  
It now compiles and downloads but when I start single stepping through the code the first 4 statements of the Cstartup.s file:

&nbsp;&nbsp; ldr&nbsp;&nbsp;&nbsp;&nbsp; r13,=TOP\_OF\_MEMORY  
&nbsp;&nbsp; ldr&nbsp;&nbsp;&nbsp;&nbsp; r0,=AT91F\_LowLevelInit  
&nbsp;&nbsp; mov&nbsp;&nbsp;&nbsp;&nbsp; lr, pc  
&nbsp;&nbsp; bx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r0

are visualised and executed by the IAR debugger as:

&nbsp; BIC&nbsp;&nbsp;&nbsp; R0, R0, #0x300  
&nbsp; MOV&nbsp;&nbsp;&nbsp; R1, #0x4  
&nbsp; STR&nbsp;&nbsp;&nbsp; R1, [R0, #+0]  
&nbsp; BX&nbsp;&nbsp;&nbsp; LR

could anyone state a reason for this?

thanks

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 25, 2009, 12:47pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/2 "2009-02-25T12:47:55Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Wednesday, February 25, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/f953):

Are you running from RAM or flash?

Check the script that the debugger runs (.mac?) when it starts up. It might be performing a remap operation so the vector table is moved.

Also check the linker script is correct for that device.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 25, 2009, 3:00pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/3 "2009-02-25T15:00:32Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Wednesday, February 25, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/6e6f):

The problem seems to be in fact related with the vector table.  
The vector table is not being placed at 0x00100000, instead it ends up at 0x00101490.

In the .icf file there is a definition:  
define symbol \_\_ICFEDIT\_intvec\_start\_\_ = 0x00000000;

but somehow this definition does not seemed to produce any result.

would there be anyother way like a good old ORG to place the vector table at 0x00100000?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 25, 2009, 4:02pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/4 "2009-02-25T16:02:49Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Wednesday, February 25, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/0730):

I’ve noticed that the original project uses Thumb mode instead of ARM.  
When this option is changed the code generated for the vector table is then placed at the right address.

Why Thumb mode?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [February 25, 2009, 4:21pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/5 "2009-02-25T16:21:42Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, February 25, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/0730/b63d):

The SAM7 will run both ARM and THUMB code - but is optimised to run THUMB as it has 16bit internal interfaces.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2009, 7:27am UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/6 "2009-02-26T07:27:58Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Thursday, February 26, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/6253):

I’ve noticed that the original project uses Thumb mode instead of ARM.  
When this option is changed the code generated for the vector table is then placed at the right address.

Why Thumb mode?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2009, 7:46am UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/7 "2009-02-26T07:46:01Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Thursday, February 26, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/f2e4):

Just for my knowledge what would be the reason for the vector table to be placed in no man’s land when the processor mode selected was ARM?  
The Cstartup.s must use ARM mode since an ARM statement is at the begin.

Now, I’m experiencing a different behaviour. I can compile/download but when it is time to pu breakpoints IAR refuses to do so, just emits a sound!!!  
By using J-Link Control Panel I verify that I already have a breakpoint at iar\_semihosting and a Watchpoint at 0x8000000, but I don’t seem to be capable to delete them.

Help! 🙂

thanks

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2009, 9:19am UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/8 "2009-02-26T09:19:44Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Thursday, February 26, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/f2e4/1827):

Make sure your project is not trying to do semihosting via the SWI interrupt as this won’t work with FreeRTOS.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2009, 5:24pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/9 "2009-02-26T17:24:54Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Thursday, February 26, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00e2):

Hi 🙂

At the moment I’m able to run until the call vPortStartFirstTask in the function xPortStartScheduler in the file port.c.

Once I made the call it falls apart.  
I’m not able to put any breakpoint in portSAVE\_CONTEXT in ISR\_Support.h to see exactly what happens.

Once I break the debugger it is somewhere between address 8h to 24h.

any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 26, 2009, 5:50pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/10 "2009-02-26T17:50:49Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Thursday, February 26, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00e2/e010):

Are you in Supervisor mode when main() is called? You need to be.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2009, 2:41pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/11 "2009-02-27T14:41:01Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Friday, February 27, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00e2/e010/a76c):

When the program gets into main:

CPSR MODE is 10011 (Supervisor)  
and the processor is in Thumb mode.

althought all five SPSR indicate the MODE as 10000 (User)!!!

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2009, 4:00pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/12 "2009-02-27T16:00:44Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Friday, February 27, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00eb):

I’m able to follow till this point in tasks.c (line 676)

/\* Force a reschedule if xTaskResumeAll has not already done so, we may have put ourselves to sleep. \*/

if( !xAlreadyYielded )  
{  
&nbsp; taskYIELD();  
}

this call to taskYIELD() is disasemblied as:

SWI 0

as defined in portmacro.h

The result of single-step this call taskYIELD() is that the PC is at address 14h on ARM mode.

What I should see is the swi handler being called as defined in Cstartup.s

\_\_swi\_handler:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ldr&nbsp; pc,[pc,#+24]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;; Software interrupt (SWI/SVC)

which in turn should use

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DC32&nbsp; vPortYieldProcessor

and end-up in vPortYieldProcessor in portasm.s79.

shouldn’t this file portasm.s79 be in ARM mode? I don’t see the RARM directive.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2009, 4:21pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/13 "2009-02-27T16:21:58Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Friday, February 27, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00eb/28bd):

Yes it should be in ARM mode but I think it will be anyway. When you look at the disassembly is there an instruction every 4 bytes or every 2 bytes?

It looks like the SWI handler is working. Is is correctly jumping to vPortYieldProcessor().

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 27, 2009, 4:53pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/14 "2009-02-27T16:53:20Z")

</div>

**[eavg](https://sourceforge.net/u/eavg/)** wrote on [Friday, February 27, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/00eb/28bd/ab96):

at address 14h is 4 bytes but at address 20h becomes 2 bytes.  
(but the instructions are somehow strange! (ARM/Thumb issue!!!???))

This is the code:  
14h BC08469C STCLT p6, C4, [R8], {156}  
18h 46C04760 STRMIB R4, [R0], +R0, ROR #14  
1Ch 00100968 ANDEQS R0, R0, R8, ROR #18  
20h B5FF PUSH {R0,R1,R2.R3,R4,R5,R6,R7,LR}  
22h B081 SUB SP, SP, #4

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 2, 2009, 3:05pm UTC](https://forums.freertos.org/t/freertos-on-at91sam7a3/2405/15 "2009-03-02T15:05:10Z")

</div>

**[johst](https://sourceforge.net/u/johst/)** wrote on [Monday, March 02, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/651ed7f2/#7acc/815c):

After all, I still have the problem with the vector table.  
I thought that the vector table was being placed at the right address but it isn’t!!!

The vector table is not being placed at 0x00100000, instead it ends up at 0x00101040.

In the .icf file there is a definition:  
&nbsp; define symbol \_\_ICFEDIT\_intvec\_start\_\_ = 0x00000000;  
but somehow this definition does not seem to produce any result.

In this way when the instruction SWI is executed the processor starts running the wrong code.  
(Nevertheless, IAR is able to start the program properly!!!!)

How do I place the vector table at 0x00100000, please?

/Johan on behalf of eavg
