Menu

AVR Studio integration of FemtoOS

hobby16
2009-11-17
2012-12-09
  • hobby16

    hobby16 - 2009-11-17

    Hi Ruud,
    I had FemtoOS projects compiling fine with your Cygwin toolchain. But my current dev toolchain is AVR Studio + WinAVR so I try to create femto projects in it.
    Apparently, the compiling of the HelloWorld test project is fine (code_TestHelloWorld.o is created) :

        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices"  -mmcu=attiny45 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -f
        short-enums -MD -MP -MT code_TestHelloWorld.o -MF dep/code_TestHelloWorld.o.d  -c  ../src/code_TestHelloWorld.c

    but the linking goes bust :

        avr-gcc -mmcu=attiny45 -Wl,-Map=hello.map code_TestHelloWorld.o   -L"C:\arduino-0015\FemtoOS_0.91\IDE\proc\avr\lib\avr25" -L"C:\arduino-0015\FemtoOS_0.91\IDE\proc\avr\lib"   -o hello.elf
        c:/program files/atmel/winwar/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn45.o:(.init9+0x0): undefined reference to `main'
        code_TestHelloWorld.o: In function `appLoop_Speed':
        C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\default/../src/code_TestHelloWorld.c:77: undefined reference to `taskDelayFromNow'
        code_TestHelloWorld.o: In function `appLoop_Display':
        C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\default/../src/code_TestHelloWorld.c:60: undefined reference to `taskDelayFromNow'
        C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\default/../src/code_TestHelloWorld.c:62: undefined reference to `taskDelayFromNow'
        C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\default/../src/code_TestHelloWorld.c:63: undefined reference to `taskDelayFromNow'
        make: ***  Error 1
        Build failed with 5 errors and 0 warnings…

    Do you have an idea what theses errors are ?
    (compiler used in AVR studio: C:\Program Files\Atmel\WinWAR\bin\avr-gcc.exe, make : C:\Program Files\Atmel\WinWAR\utils\bin\make.exe )
    Thank you in advance.

     
  • De Vlaam

    De Vlaam - 2009-11-17

    The standard options of AVR Studio are not adequate, you have to use these in the  section -and- in the

          -Wall -gdwarf-2  -mint8  -Wl,-defsym=__stack=xOS+xOSstackShift  
          -param inline-call-cost=2  -ffunction-sections  -Wl,-gc-sections
          -Wl,-relax  -Wno-main  -Winline  -Wundef  -fomit-frame-pointer
          -DdefExtReduceProEpilogue=cfgBikini  -Os  -funsigned-char
          -fpack-struct  -fshort-enums
       

    Memory settings and Libraries are not required. Now the problem is that the latest verions of AVR Studio do not allow for symbols as intial stack options (so do no pass the 'Project | Configuration Options | Memory Settings'  - you'll be forced to delete it) and the option is deleted by AVR studio sometimes (i think at closing the project) so you have to be on the watch.

    This is my result when i compile it under AVR Studio for the attiny45:

            Build started 17.11.2009 at 12:48:24
        avr-gcc -I"C:\Test\FemtoOS_HelloWorld\femtoos_devices"  -mmcu=attiny45 -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  -Wl,-defsym=__stack=xOS+xOSstackShift  -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_startup.o -MF dep/femtoos_startup.o.d  -x assembler-with-cpp -Wa,-gdwarf2 -c  ../femtoos_startup.s
        avr-gcc -I"C:\Test\FemtoOS_HelloWorld\femtoos_devices"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  -Wl,-defsym=__stack=xOS+xOSstackShift  -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_core.o -MF dep/femtoos_core.o.d  -c  ../femtoos_core.c
        avr-gcc -I"C:\Test\FemtoOS_HelloWorld\femtoos_devices"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  -Wl,-defsym=__stack=xOS+xOSstackShift  -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_port.o -MF dep/femtoos_port.o.d  -c  ../femtoos_port.c
        avr-gcc -I"C:\Test\FemtoOS_HelloWorld\femtoos_devices"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  -Wl,-defsym=__stack=xOS+xOSstackShift  -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_shared.o -MF dep/femtoos_shared.o.d  -c  ../femtoos_shared.c
        avr-gcc -I"C:\Test\FemtoOS_HelloWorld\femtoos_devices"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  -Wl,-defsym=__stack=xOS+xOSstackShift  -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT code_TestHelloWorld.o -MF dep/code_TestHelloWorld.o.d  -c  ../code_TestHelloWorld.c
        avr-gcc -mmcu=attiny45 -mint8   -param inline-call-cost=2  -ffunction-sections  -Wl,-gc-sections  -Wl,-relax  -Wno-main  -Winline  -Wundef  -fomit-frame-pointer  -DdefExtReduceProEpilogue=cfgBikini -Wl,-defsym=__stack=xOS+xOSstackShift  -Wl,-Map=FemtoOS_HelloWorld.map femtoos_startup.o femtoos_core.o femtoos_port.o femtoos_shared.o code_TestHelloWorld.o     -o FemtoOS_HelloWorld.elf
        avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  FemtoOS_HelloWorld.elf FemtoOS_HelloWorld.hex
        avr-objcopy -j .eeprom -set-section-flags=.eeprom="alloc,load" -change-section-lma .eeprom=0 -no-change-warnings -O ihex FemtoOS_HelloWorld.elf FemtoOS_HelloWorld.eep || exit 0
        avr-objdump -h -S FemtoOS_HelloWorld.elf > FemtoOS_HelloWorld.lss
       
        AVR Memory Usage
        -----------
        Device: attiny45
       
        Program:    1750 bytes (42.7% Full)
        (.text + .data + .bootloader)
       
        Data:         78 bytes (30.5% Full)
        (.data + .bss + .noinit)
       
       
        Build succeeded with 0 Warnings…

    Since you already installed cygwin, you can also force my scripts to use WinAVR by adding the option -system to the command. Now it uses whatever avr-gcc toolchain that is installed (and is on your search path)
    Be sure to first replace the newest script from my website (last minute change)

    Btw, this works for flashing too, so you can use your avrdude from my flash script.

      : http://www.femtoos.org/code.html

     
  • hobby16

    hobby16 - 2009-11-17

    hi Ruud,
    All is fine now ! I finally managed to compile & link a femtoos project with AVR Studio IDE and, best of all, use the IDE's **simulator**.  Yipeee !  BTW, after adjusting for options, I had the same rom size like you.
    Finally, the setting up was not so obvious since I hadn't added all the source code in the /src directorory to the IDE project ;)
    I'll post a tutorial here soon. To me, as a Windows user, AVR Studio would have been much more straightforward than a dev install & toolchain with Cygwin. And much faster to compile.
    Now time for diner…

     
  • hobby16

    hobby16 - 2009-11-17

    FemtoOS with AVR Studio

    The following configuration assumes

    http://faztech.free.fr/images/femtoos1.png

    a) you have all the files installed by the Cygwin scripts, with the files tree above (minus the AVR studio project file hello.aps which will be created later on)

    b) a functional AVR Studio with a AVR gcc compiler (use WinAVR)

    c) you know how to create and compile a C project with AVR

    http://faztech.free.fr/images/femtoos2.png

    Create a new project named "hello" in C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld

    http://faztech.free.fr/images/femtoos3.png

    Add ALL the sources in C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\src to the project
    Add also the config file C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include\config_application.h where you can redefine various default parameters of FemtoOS for your firmware

    Now set the project's Configuration options as described below (change your device if it's not Attiny45)

    http://faztech.free.fr/images/femtoos4.png

    devices\ is C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices

    include\ is C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include\

    Don't change Libraries and Memory Settings

    http://faztech.free.fr/images/femtoos5.png

    For Custom compilation options/All files, set these options

        -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections
        -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini  
        -Wl,-defsym=__stack=xOS+xOSstackShift -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums

    http://faztech.free.fr/images/femtoos6.png

    For Custom compilation options/Linker options, set these options

        -mint8 -param inline-call-cost=2 -ffunction-sections
        -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer
        -DdefExtReduceProEpilogue=cfgBikini -Wl,-defsym=__stack=xOS+xOSstackShift

    Compile (F7) and if sucessful, you should have this

        Build started 17.11.2009 at 20:50:38
        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include"  -mmcu=attiny45 -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini   -Wl,-defsym=__stack=xOS+xOSstackShift          -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_start up.o -MF dep/femtoos_startup.o.d  -x assembler-with-cpp -Wa,-gdwarf2 -c  ../src/femtoos_startup.s
        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini   -Wl,-defsym=__stack=xOS+xOSstackShift          -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_core.o -MF dep/femtoos_core.o.d  -c  ../src/femtoos_core.c
        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini   -Wl,-defsym=__stack=xOS+xOSstackShift          -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_port.o -MF dep/femtoos_port.o.d  -c  ../src/femtoos_port.c
        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini   -Wl,-defsym=__stack=xOS+xOSstackShift          -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT code_TestHelloWorld.o -MF dep/code_TestHelloWorld.o.d  -c  ../src/code_TestHelloWorld.c
        avr-gcc -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\devices" -I"C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\include"  -mmcu=attiny45 -Wall -gdwarf-2 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini   -Wl,-defsym=__stack=xOS+xOSstackShift          -DF_CPU=8000000UL -Os -funsigned-char -fpack-struct -fshort-enums -MD -MP -MT femtoos_shared.o -MF dep/femtoos_shared.o.d  -c  ../src/femtoos_shared.c
       
        avr-gcc -mmcu=attiny45 -mint8 -param inline-call-cost=2 -ffunction-sections -Wl,-gc-sections -Wl,-relax -Wno-main -Winline -Wundef -fomit-frame-pointer -DdefExtReduceProEpilogue=cfgBikini -Wl,-defsym=__stack=xOS+xOSstackShift -Wl,-Map=hello.map femtoos_startup.o femtoos_core.o femtoos_port.o code_TestHelloWorld.o femtoos_shared.o     -o hello.elf
        avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  hello.elf hello.hex
        avr-objcopy -j .eeprom -set-section-flags=.eeprom="alloc,load" -change-section-lma .eeprom=0 -no-change-warnings -O ihex hello.elf hello.eep || exit 0
        avr-objdump -h -S hello.elf > hello.lss
       
        AVR Memory Usage
        -----------
        Device: attiny45
       
        Program:    1894 bytes (46.2% Full)
        (.text + .data + .bootloader)
       
        Data:         94 bytes (36.7% Full)
        (.data + .bss + .noinit)
       
        Build succeeded with 0 Warnings…

    Now you can simulate the project or flash the freshly compiled firmware
    C:\arduino-0015\FemtoOS_0.91\IDE\workspace\FemtoOS_HelloWorld\default\hello.hex

    Cheers. FemtoOS is great.

     
  • De Vlaam

    De Vlaam - 2009-11-17

    In one word: SUPER!  This is indeed how it goes, nice screenshots. 

    Since you have much more experience with AVR Studio, maybe you know how to circumvent the problem that, if you clck Memory Settings, you are forced to delete the Initial Stack setting (or press cancel)?

     
  • hobby16

    hobby16 - 2009-11-18

    > Since you have much more experience
    > with AVR Studio, maybe you know how to
    > circumvent the problem that, if you
    > clck Memory Settings, you are forced
    > to delete the Initial Stack setting
    > (or press cancel)?

    Rudd,

    The "Memory Settings" window interracts with the "Custom compilation options" window (and vice versa).
    So if ever you are blocked by the error message "the address is too long" in the former (because AVR Studio can't take symbol for stack init in this windows), change in the latter, like this :

    1. uncheck the box "Specify Initial
        Stack Address"
    2. go to Custom
        compilation options/Linker options
        and paste again the option " -Wl,-defsym=__stack=xOS+xOSstackShift " (which has been deleted because you unchecked the box in 1).

    Now if you go back to the "Memory Settings" window, you'll see the box checked again with stack defined by a symbol instead of the default 0x100. Don't touch it anymore and use the "Custom compilation options" window instead for any compilation tweaking, this stack setting is stored and retrieved correctly in the AVR Studio project file, for me anyway (AVR Studio 4.16.638  ).

    BTW, if you want to post my AVR Studio integration tutorial on your site (images can't be display on this forum) it would be great. I even think it would be greatly convenient to provide a package for it, with just the femtoOS  sources and demo projects in a zip file. No bash script would then be necessary and it would spare Windows users of the hassles of a Cygwin install and a new toolchain install.

    All the bests.

     
  • De Vlaam

    De Vlaam - 2009-11-18

    > Don't touch it anymore and use the
    > "Custom compilation options" window
    > instead for any compilation tweaking,
    > this stack setting is stored and
    > retrieved correctly in the AVR Studio
    > project file, for me anyway (AVR
    > Studio 4.16.638 ).

    Unfortunately this has been changed in 4.17. If you pass the window again you are forced to delete the entry or cancel. At certain moments (i don't know which) AVR Studio detects the incorrect setting and deletes the option by itself too.

    I already made a post on  but nobody responded. This issue makes use of the option really hard.

    > BTW, if you want to post my AVR Studio
    > integration tutorial on your site
    > (images can't be display on this
    > forum) it would be great. I even think
    > it would be greatly convenient to
    > provide a package for it, with just
    > the femtoOS sources and demo projects
    > in a zip file. No bash script would
    > then be necessary and it would spare
    > Windows users of the hassles of a
    > Cygwin install and a new toolchain
    > install.

    Your tutorial is fine, so this is a good idea. However, on the long run i think it is too long for first time users. (Of course its much better than installing cygwin….) I would prefer to provide a click&ready solution. Since maintaining the distribution is an other issue i like a project generator (like the one for eclipse) more than a package.

    Now i have looked at the project structure of AVR Studio and the content of project files, and unfortunately it contains full filenames that i can never guess. I could write an installer, but that sounds as a lot of work. At the moment i have not decided yet what to do … and of course there are also a lot of people asking for an implementation in the Arduino IDE.

      : http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=86178

     
  • hobby16

    hobby16 - 2009-11-18

    > Your tutorial is fine, so this is a
    > good idea. However, on the long run i
    > think it is too long for first time
    > users. (Of course its much better than
    > installing cygwin….) I would prefer
    > to provide a click&ready solution.
    > Since maintaining the distribution is
    > an other issue i like a project
    > generator (like the one for eclipse)
    > more than a package.

    I have removed all absolute paths in the AVR Studio project file and it compiles well. Now I can put \IDE\workspace anywhere of the dir tree and projects always compile (of course, once you save back the project file within the AVR IDE, paths become absolute again). Have a try of  on your Studio V4.17. If you want to make more trials, send me some sample Studio project files, I'll tell you if they still work in my dev environment.

    Maybe that's finally your turnkey solution for AVRstudio ;)

    Cheers.

      : http://faztech.free.fr/images/hello.aps

     
  • De Vlaam

    De Vlaam - 2009-11-18

    > Maybe that's finally your turnkey
    > solution for AVRstudio ;)

    I experimented a little with amputated xml configuration files, and indeed, this seems possible. I just exclude what i do not like, and AVR Studio fills in the gaps at opening of the project. Nice! Only nasty point is the occasional deletion of the Initial Stack Address.

    Furthermore, i get the following warning (yellow dot in message pane of Message Window) at opening of the project, which is of course very clear:

        Error Code: -2147467259:

    But it will be possible to make a project install script that will support all demo's out of the box. I will make that, and post it as soon as find the time. Thanks for your support.

     
  • De Vlaam

    De Vlaam - 2009-12-02

    The latest version (0.912) contains an installer for AVR Studio.

     

Log in to post a comment.