FreeRTOS for AVR32 example does not build :-(

s_potter wrote on Tuesday, December 02, 2008:

http://www.freertos.org/portAVR32.html does not build, due to missing definitions that are nowhere in the FreeRTOS download package.

(from https://sourceforge.net/project/showfiles.php?group_id=111543&package_id=120544)

"Rebuild All":-

Building configuration: rtosdemo - Debug
Updating build tree…

48  file(s) deleted.
Updating build tree…
BlockQ.c 
ParTest.c 
PollQ.c 
comtest.c 
death.c 
dynamic.c 
exception.s82
Error[As012]: Undefined symbol: AVR32_INTC_IPR0_INTLEV_OFFSET C:\FreeRTOS\FreeRTOS\Source\portable\IAR\AVR32_UC3\exception.s82 300
Error while running Assembler
flash.c 
flop.c 
gpio.c 
heap_3.c 
intc.c 
Error[Pe020]: identifier "AVR32_INTC_IPR0_INTLEV_SIZE" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\DRIVERS\INTC\intc.c 52
Error[Pe136]: struct "avr32_intc_t" has no field "icr3" C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\DRIVERS\INTC\intc.c 111
Error[Pe020]: identifier "AVR32_INTC_IPR0_INTLEV_MASK" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\DRIVERS\INTC\intc.c 199
Error[Pe020]: identifier "AVR32_INTC_IPR0_INTLEV_OFFSET" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\DRIVERS\INTC\intc.c 199
Error while running C/C++ Compiler
integer.c 
led.c 
Error[Pe020]: identifier "AVR32_PWM_PWM_0_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\BOARDS\EVK1100\led.c 77
Error[Pe020]: identifier "AVR32_PWM_PWM_1_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\BOARDS\EVK1100\led.c 77
Error[Pe020]: identifier "AVR32_PWM_PWM_2_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\BOARDS\EVK1100\led.c 77
Error[Pe020]: identifier "AVR32_PWM_PWM_3_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\BOARDS\EVK1100\led.c 77
Error while running C/C++ Compiler
list.c 
main.c 
pm.c 
port.c 
Error[Pe020]: identifier "AVR32_USART1_RXD_0_PIN" is undefined C:\FreeRTOS\FreeRTOS\Source\portable\IAR\AVR32_UC3\port.c 134
Error[Pe020]: identifier "AVR32_USART1_RXD_0_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Source\portable\IAR\AVR32_UC3\port.c 134
Error[Pe020]: identifier "AVR32_USART1_TXD_0_PIN" is undefined C:\FreeRTOS\FreeRTOS\Source\portable\IAR\AVR32_UC3\port.c 135
Error[Pe020]: identifier "AVR32_USART1_TXD_0_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Source\portable\IAR\AVR32_UC3\port.c 135
Error while running C/C++ Compiler
queue.c 
read.c 
semtest.c 
serial.c 
Error[Pe020]: identifier "AVR32_USART0_RXD_0_PIN" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\serial\serial.c 173
Error[Pe020]: identifier "AVR32_USART0_RXD_0_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\serial\serial.c 173
Error[Pe020]: identifier "AVR32_USART0_TXD_0_PIN" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\serial\serial.c 174
Error[Pe020]: identifier "AVR32_USART0_TXD_0_FUNCTION" is undefined C:\FreeRTOS\FreeRTOS\Demo\AVR32_UC3\serial\serial.c 174
Error while running C/C++ Compiler
tasks.c 
tc.c 
trampoline.s82
usart.c 
write.c 

Total number of errors: 17
Total number of warnings: 0

s_potter wrote on Tuesday, December 02, 2008:

I tried V5.1.1 & 5.1.0

The first symbol that the build complains about,
AVR32_INTC_IPR0_INTLEV_OFFSET
is not defined anywhere in the package.

s_potter wrote on Tuesday, December 02, 2008:

(Using V3.10 IAR embedded Workbench:-
IAR Assembler for Atmel AVR32
3.10A/W32 (3.10.1.3)
C:\Program Files\IAR Systems\Embedded Workbench 5.3 Kickstart\avr32\bin\aavr32.exe
17/10/2008 13:44:30, 4345856 bytes

IAR C/C++ Compiler for Atmel AVR32
3.10A/W32 (3.10.1.3)
C:\Program Files\IAR Systems\Embedded Workbench 5.3 Kickstart\avr32\bin\iccavr32.exe
17/10/2008 13:48:36, 9138176 bytes
…)

Where are the missing definitions to get this going?

bmenkveld wrote on Tuesday, December 02, 2008:

I use GCC, so I don’t know whether things might work differently with the IAR compiler.

I found that the best way to get a working project (ie. one that builds and runs) is to start with one of the example projects supplied with AVR32 Studio.  This is done by selecting File->New->Example (in AVR32 Studio), and then picking an example project for your processor (there are 4 sections in the list of examples).  This creates a complete project that builds and runs, and that you can then modify to your heart’s content.


Bert Menkveld

rtel wrote on Tuesday, December 02, 2008:

I have just taken one of the undefined symbols at random (AVR32_INTC_IPR0_INTLEV_SIZE) and searched for it in my IAR installation directory, and found it to be defined in IAR Systems\Embedded Workbench 4.0\avr32\inc\avr32\intc.h

However, my installation is not up to date so maybe IAR have changed the names of the definitions?

Also, there was a lot of confusion over header files when this port was first done, some mess up with the compiler or other, and Atmel provided me with a patch for the compiler.  Maybe the file comes from that?

Take a look at the Atmel UC3 Software Framework which can be downloaded from:
http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=4192

This runs on top of FreeRTOS.org and is a bit different.

Regards.

s_potter wrote on Tuesday, December 02, 2008:

I started with ThreadX then went for FreeRTOS.
I want a file system and, later, TCP/IP stack (at least TFTP,FTP,HTTP).

I AM using a more recent IAR workbench (V3.10A) than came with the IAR Kickstart CDROM.

Missing definitions appear to be related to Interrupt priorities, PWM and UART.

s_potter wrote on Tuesday, December 02, 2008:

Yup.

Older workbench doesn’t complain about the same symbols.

Fewer issues repoted.

Now, Use old workbench or newer workbench?

Building configuration: rtosdemo - Debug
Updating build tree…

46  file(s) deleted.
Updating build tree…
BlockQ.c
ParTest.c
PollQ.c
comtest.c
death.c
dynamic.c
exception.s82
flash.c
flop.c
gpio.c
heap_3.c
intc.c
integer.c
led.c
list.c
main.c
pm.c
Error[Pe020]: identifier "AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 162
Error[Pe020]: identifier "AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 163
Error[Pe020]: identifier "AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G2" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 223
Error[Pe020]: identifier "AVR32_PM_OSCCTRL1_MODE_CRYSTAL_G3" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 224
Error[Pe020]: identifier "AVR32_PM_OSCCTRL32_MODE_EXT_CLOCK" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 278
Error[Pe020]: identifier "AVR32_PM_OSCCTRL32_MODE_CRYSTAL" is undefined C:\FreeRTOS\V5.1.1\FreeRTOS\Demo\AVR32_UC3\DRIVERS\PM\pm.c 284
port.c
queue.c
read.c
semtest.c
serial.c
tasks.c
tc.c
trampoline.s82
usart.c
write.c

Total number of errors: 6
Total number of warnings: 0

klvaneyll wrote on Tuesday, December 02, 2008:

Make sure you have v1.3 of Atmel’s framework, you can download from Atmel’s website. The framework contains the headers files in “FrameworkDir/Utils/AVR32_HEADER_FILES”. Unzip to the compiler’s include directory (C:\Program Files\IAR Systems\Embedded Workbench 5.3\avr32\inc\avr32 on my machine). This overwrites the existing files so I recommend backing up the old headers first.

s_potter wrote on Thursday, December 04, 2008:

I spent yesterday fixing symbol names in the demo kit to match workbench 5.3.

It builds! and executes in debug.
But no LEDS; no serial output. :frowning:

I got an email from IAR, to update some AVR32 include files in v5.3 of the KickStart workbench.

I did that.

Then recopied the FreeRTOS 5.1.1 demos tree (i.e. to version, as downloaded, without my fixes from yesterday). and rebuilt.

Same Interrupt, pwm, and UART symbol issues showed up.

This is going to be a headache for develoment integrity.

Does anyone have a complete FreeRTOS, demo package, for AVR32, running with KickStart WorkBench 5.3?

s_potter wrote on Thursday, December 04, 2008:

I shouldn’t have to debug a supposedly working demo.

FreeRTOS 5.1.1 on AVR32 Kickstart v5.3

After fixing demo symbols for Interrupts, PWM, and UARTS, and gettig it to build:-

“The stack pointer for stack ‘System’ (currently Memory:0x5278) is outside the stack range (Memory:0xF800 to Memory:0x10000)”

This is going to be painfull.

OK, which version of Kickstart Workbench is FreeRTOS demo (v5.1.1) (for AVR32) supposed to work with?

I don’t have time to debug this demo for workbench 5.3.

klvaneyll wrote on Thursday, December 04, 2008:

The stack pointer warning can be safely ignored as task stack is allocated on the heap rather than the stack defined in the build options.

rtel wrote on Thursday, December 04, 2008:

I just tried compiling the latest FreeRTOS download with V2.21B of the IAR tools and it built fine, but as I said before I think I have some patches that were supplied by Atmel.  It looks like the latest compiler version I have is 3.10a, I will try installing that now.

You can ignore the warning about the stack, that is just because the compiler expects the stack to be within the region defined in the linker script, whereas in fact its within the heap.

Regards.

rtel wrote on Thursday, December 04, 2008:

Having installed the new compiler version I can see that the libraries have changed, probably to be made simpler.  All was going well doing the updates, as:

AVR32_INTC_IPR0_INTLEV_OFFSET -> AVR32_INTC_INTLEV_OFFSET
AVR32_INTC_NUM_INT_LEVELS -> AVR32_INTC_INTLEV_SIZE
AVR32_INTC_IPR0_INTLEV_MASK -> AVR32_INTC_INTLEV_MASK
AVR32_INTC_IPR0_INTLEV_OFFSET -> AVR32_INTC_INTLEV_OFFSET

until I got to this code:

static tLED_DESCRIPTOR LED_DESCRIPTOR[LED_COUNT] =
{
#define INSERT_LED_DESCRIPTOR(LED_NO, unused)                
  {                                                          
    {LED##LED_NO##_GPIO / 32, 1 << (LED##LED_NO##_GPIO % 32)},
    {LED##LED_NO##_PWM,       LED##LED_NO##_PWM_FUNCTION    }
  },
  MREPEAT(LED_COUNT, INSERT_LED_DESCRIPTOR, ~)
#undef INSERT_LED_DESCRIPTOR
};

Yuk - what on earth is that!  I’m sure somebody is very pleased with how clever they have been there but I’m not even going to attempt to fix the compile error its now generating.  Its just too horible.

I think I am going to have to get in touch with Atmel and merge the latest FreeRTOS.org version with their software framework.  They must have fixed this stuff in there, on the assumption they are using the latest compiler.

The other problem is the different revisions of the chips need different fixes applied, so this also needs sorting.

Sorry not to be of more use, this appears to be a bit of a smudge on the project that needs cleaning off.

Again I think the best course of action would be to use the official Atmel stuff.

Regards.

rtel wrote on Thursday, December 04, 2008:

I have added this to the Known Issues list: http://www.freertos.org/a00104.html#knownissues

Regards.

s_potter wrote on Thursday, December 04, 2008:

There’s a PWM_PWM symbol name part ‘tidy up’.

I cleaned up the INTLEVEL, PWM, UART (and LED) references and got FreeRTOs AVR32 Demo (V5.1.1) to build under kickstart 5.3, but it ain’t running yet.
(3 days, so far)

I might get some help from Atmel.

I’ll keep you posted.

(Which version of KickStart Workbench does the FreeRTOS AVR32 demo work with?)

s_potter wrote on Thursday, December 04, 2008:

Here are my changes that will, at lest, get the demo ‘built’ (though it ain’t running yet:-

in int.c :-

around line 111 :-

__int_handler _get_interrupt_handler(unsigned int int_lev)
{
  // ICR3 is mapped first, ICR0 last.
  // Code in exception.S puts int_lev in R12 which is used by AVR32-GCC to pass
  // a single argument to a function.
// Workbench compatibility issue:-
/* Workbench v?.?
  unsigned int int_grp = (&AVR32_INTC.icr3)[INT3 - int_lev];
  unsigned int int_req = AVR32_INTC.irr[int_grp];
*/
// Workbench v5.3
  unsigned int int_grp = (&AVR32_INTC.icr[INT3])[INT3 - int_lev];
  unsigned int int_req = AVR32_INTC.irr[int_grp];
//

Around line 197 :-
  // NOTE: The _intx functions are intermediate assembly functions between the
  // core interrupt system and the user interrupt handler.
// Workbench compatibility issue:-
/* Workbench v?.?
    AVR32_INTC.ipr[int_grp] = ipr_val[int_lev & (AVR32_INTC_IPR0_INTLEV_MASK >> AVR32_INTC_IPR0_INTLEV_OFFSET)];
*/
// Workbench v5.3
    AVR32_INTC.ipr[int_grp] = ipr_val[int_lev & (AVR32_INTC_IPR_INTLEV_MASK >> AVR32_INTC_IPR_INTLEV_OFFSET)];
//
}

In intc.h :-

around line # 55 :-

//! Number of interrupt priority levels.
// Workbench compatibility issue:-
/* Workbench v?.?
#define AVR32_INTC_NUM_INT_LEVELS                   (1 << AVR32_INTC_IPR0_INTLEV_SIZE)
*/
// Workbench v5.3
#define AVR32_INTC_NUM_INT_LEVELS                   (1 << AVR32_INTC_IPR_INTLEV_SIZE)
//

In FreeRTOSConfig.h :-

around lines 104 to 123 :-

/* Debug trace configuration.
   configDBG is a boolean indicating whether to activate the debug trace. */
#define configDBG                     1

// EVK1100 :-
#if BOARD == EVK1100
// Workbench compatibility issue:-
/* Workbench v?.?
#define configDBG_USART               (&AVR32_USART1)
#define configDBG_USART_RX_PIN        AVR32_USART1_RXD_0_PIN
#define configDBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_FUNCTION
#define configDBG_USART_TX_PIN        AVR32_USART1_TXD_0_PIN
#define configDBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_FUNCTION
#define configDBG_USART_BAUDRATE      57600
#define serialPORT_USART              (&AVR32_USART0)
#define serialPORT_USART_RX_PIN       AVR32_USART0_RXD_0_PIN
#define serialPORT_USART_RX_FUNCTION  AVR32_USART0_RXD_0_FUNCTION
#define serialPORT_USART_TX_PIN       AVR32_USART0_TXD_0_PIN
#define serialPORT_USART_TX_FUNCTION  AVR32_USART0_TXD_0_FUNCTION
#define serialPORT_USART_IRQ          AVR32_USART0_IRQ
#define serialPORT_USART_BAUDRATE     57600
*/
// Workbench v5.3
#define configDBG_USART               (&AVR32_USART1)
#define configDBG_USART_RX_PIN        AVR32_USART1_RXD_0_0_PIN
#define configDBG_USART_RX_FUNCTION   AVR32_USART1_RXD_0_0_FUNCTION
#define configDBG_USART_TX_PIN        AVR32_USART1_TXD_0_0_PIN
#define configDBG_USART_TX_FUNCTION   AVR32_USART1_TXD_0_0_FUNCTION
#define configDBG_USART_BAUDRATE      57600
#define serialPORT_USART              (&AVR32_USART0)
#define serialPORT_USART_RX_PIN       AVR32_USART0_RXD_0_0_PIN
#define serialPORT_USART_RX_FUNCTION  AVR32_USART0_RXD_0_0_FUNCTION
#define serialPORT_USART_TX_PIN       AVR32_USART0_TXD_0_0_PIN
#define serialPORT_USART_TX_FUNCTION  AVR32_USART0_TXD_0_0_FUNCTION
#define serialPORT_USART_IRQ          AVR32_USART0_IRQ
#define serialPORT_USART_BAUDRATE     57600
//

// EVK1101 :-
#elif BOARD == EVK1101
#define configDBG_USART               (&AVR32_USART1)

and in exception.s82 :-

around line # 300 :-

ipr_val:
// Workbench compatibility issue:-
/* Workbench v?.?
  DC32  (INT0 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int0 - _evba),
        (INT1 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int1 - _evba),
        (INT2 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int2 - _evba),
        (INT3 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int3 - _evba)
*/
// Workbench v5.3
  DC32  (INT0 << AVR32_INTC_IPR_INTLEV_OFFSET) | (_int0 - _evba),
        (INT1 << AVR32_INTC_IPR_INTLEV_OFFSET) | (_int1 - _evba),
        (INT2 << AVR32_INTC_IPR_INTLEV_OFFSET) | (_int2 - _evba),
        (INT3 << AVR32_INTC_IPR_INTLEV_OFFSET) | (_int3 - _evba)
//

  END

s_potter wrote on Thursday, December 04, 2008:

Response from Atmel:-

"You need to know which version of IAR was used to compile the V 5.1.1 package.

Our software framework 1.3.0 provides the header files for IAR Workbench 4.0 (IAR V2.2.2 at least).

You can download it at the following URL : http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4192

We are about to release our software framework 1.4.0 which provides the header files for IAR Workbench 5.3 (IAR V3.1.0a at least).

You can download a beta version at the following URL : http://www.atmel.no/beta_ware/

You can try to compile the V 5.1.1 package with those two environments.

If it does not work, I suggest you use our code examples which are provided in our software framework packages in folder : SERVICES\FREERTOS\Demo

and see if they suit to your needs. In every case, you need to update your header files by unzipping \UTILS\AVR32_HEADER_FILES\AVR32_Header_Files.zip package in C:\Program Files\IAR Systems\Embedded Workbench 4.0\avr32\inc. This will update the avr32 folder including the header files. I advise you backup your original header files first. "

rtel wrote on Thursday, December 04, 2008:

Wow - how did you manage to get an answer from Atmel so quickly?  Do you have the email address of an engineer or go through their support ticketing system?

It looks like is going to be some effort to get up to the latest IAR versions.

Regards.

s_potter wrote on Thursday, December 04, 2008:

I need to get the demos (currently v5.1.1) working asap,
on an EVK1100 platform, under workbench 5.3.

When I do (if someone doesn’t beat this newbie FreeRTOS & newbie Atmel, old fart programmer to it) I’ll be happy to give it back to this community.

Is someone else working to get the FreeRTOS, for AVR32, working with Workbanch 5.3?

rtel wrote on Thursday, December 04, 2008:

The best place to ask would be on the AVR freaks forum http://www.avrfreaks.net , although the WEB site only seems to work for me one day in 3.  Most AVR32 chatter comes directly from Atmel.

Regards.