# The old supervisor mode chestnut...

**URL:** <https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821>\
**Category:** Kernel\
**Created:** [January 29, 2007, 5:16pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821 "2007-01-29T17:16:03Z")\
**Posts on this page:** 12\
**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:** [January 29, 2007, 5:16pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/1 "2007-01-29T17:16:03Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0):

Hello peeps,

I have myself an at91sam7x256-ek IAR kickstart dev kit, including the IAR branded j-link.  
I’ve downloaded pretty much everything related to GNU ARM development i can find, so i have all the tools, and i can just about get them to work (though it did take me a week to discover that you had to d/l the .bin via sam-ba before you could use the GDB stuff!). My set up is eclipse with the cdt and embedded debugger, using the GNUARM toolchain, and while i have the 30-day licence, the segger jlink gdb server, as it works better then the yahoo groups version.

Anywho, i’ve been trying to get the lwIP\_Demo\_Rowley\_ARM7 to work, but it’s failing on the portRESTORE\_CONTEXT() macro.  
Now i’ve searched, and it seems to be a common problem, but i have seen any ‘this is how to fix it’ posts apart from make sure it’s in supervisor mode. Well, as far as i can tell it is. I’m using the demo pretty much right out of the box, i’ve just move a couple of directories around, and edited the makefile accordingly.

So what is it i’m doing wrong?

TIA

Paul (nobody) Sheppard

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 29, 2007, 5:26pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/2 "2007-01-29T17:26:35Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/f1a0):

In portRESTORE\_CONTEXT(), when you execute the line

LDMFD&nbsp;&nbsp;&nbsp; LR, {R0-R14}^

the \*\*\*user/system mode\*\*\* registers should get loaded with values such that R1 contains 0x01010101, R2 contains 0x02020202, up to R14 which should contain 0xaaaaaaaa.

If executing this line causes any of the Supervisor mode registers to change then you are not in the right mode.&nbsp; Especially, if the Supervisor mode LR contains 0xaaaaaaaa after the execution of the above line then its a dead give away.

I presume you are using the start up code form the demo?

Inspecting the mode bits of the CPSR should show that the last last 5 bits are set to 10011 binary.

If you are in the right mode then can you say which line within portRESTORE\_CONTEXT causes the problem?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 29, 2007, 5:40pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/3 "2007-01-29T17:40:37Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/bfc7):

Wow, quick reply cheers.

at the point restore\_context is executed the cpsr is 0b11110111, and R1-14 are alsorts of values, so not at all correct.  
My mind doesn’t work too well in asm, but the last access to that register in boot.s look to be setting SVR mode…

Paul Sheppard

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 29, 2007, 6:03pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/4 "2007-01-29T18:03:52Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba):

sorry, my mistake, it’s 0xF3. So the last 5 bit are right… just stepping through now.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 29, 2007, 6:07pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/5 "2007-01-29T18:07:20Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92):

Bombs out on:  
&nbsp;&nbsp;&nbsp; /\* Restore all system mode registers for the task. \*/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
&nbsp;&nbsp;&nbsp; "LDMFD&nbsp;&nbsp;&nbsp; LR, {R0-R14}^&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n\t"&nbsp;&nbsp;&nbsp; \

where cpsr is 0xd3, and error returned: Cannot access memory at address 0x1111110d

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 29, 2007, 8:00pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/6 "2007-01-29T20:00:37Z")

</div>

**nobody** wrote on [Monday, January 29, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178):

Weird - LR must be 0x1111110d I think.&nbsp; Looks like this is the value that should be in R11.&nbsp; Thoughts anybody?

You mentioned that you changed the makefile.&nbsp; Was this just the paths?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 30, 2007, 10:23am UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/7 "2007-01-30T10:23:35Z")

</div>

**nobody** wrote on [Tuesday, January 30, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c):

yep, just the paths. I moved the code to my project directory and moved the includes and sources referenced there too.

I’ll go ahead try the demo where it unpacks to and not alter anything…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 30, 2007, 11:17am UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/8 "2007-01-30T11:17:53Z")

</div>

**nobody** wrote on [Tuesday, January 30, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c/3a17):

Ok, the fresh demo does the same compiled under GCC, but compiling under Rowley Crossworks and using the same tools (eclipse, arm-elf-gdb, jlinkgdb, etc) for debugging works just fine. Devils in the detail, somewhere.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 30, 2007, 1:30pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/9 "2007-01-30T13:30:29Z")

</div>

**nobody** wrote on [Tuesday, January 30, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c/3a17/9f84):

Which version of [FreeRTOS.org](http://FreeRTOS.org) and GNUARM are you using?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 30, 2007, 2:18pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/10 "2007-01-30T14:18:12Z")

</div>

**nobody** wrote on [Tuesday, January 30, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c/3a17/9f84/a1ff):

All the lastest:  
FreeRTOS v4.1.3  
GNUARM v4.1.1 (cygwin binary)

i guess something’s wrong with the boot.s/atmel-rom.ld

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 30, 2007, 2:41pm UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/11 "2007-01-30T14:41:47Z")

</div>

**nobody** wrote on [Tuesday, January 30, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c/3a17/9f84/a1ff/4fe8):

Just tried FreeRTOS v4.1.0, and GNUARM v4.1.0

Still no go ☹

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [February 1, 2007, 10:37am UTC](https://forums.freertos.org/t/the-old-supervisor-mode-chestnut/2821/12 "2007-02-01T10:37:12Z")

</div>

**nobody** wrote on [Thursday, February 01, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/7f0f5743/#64b0/54ba/ff92/8178/d02c/3a17/9f84/a1ff/4fe8/40b3):

update: i used Winarm and info from here:  
[http://en.mikrocontroller.net/topic/67145](http://en.mikrocontroller.net/topic/67145)  
to compile and run the project which got past the portRESTORE() bit, but then locked up somewhere in the yeild section (both co-op and pre-emp).  
even tried using the startup script, liner script and makefile of a similar project [http://en.mikrocontroller.net/topic/87535](http://en.mikrocontroller.net/topic/87535) to no avail - locked up as above.

I simply don’t have the experience or knowledge of the ARM arch. or the AT91SAM7 to be able to fiddle with the assembly start-up scripts (where surely the problem lies). To that end I’m giving up and using rowley - it worked first time!
