Author Topic: webbotlib 2.08 issues  (Read 4567 times)

0 Members and 1 Guest are viewing this topic.

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
webbotlib 2.08 issues
« on: March 16, 2012, 08:52:48 PM »
I'm running into some issues trying to get code compiled using webbotlib 2.08 to run on...well, anything.  Here's the rundown so far:

* I've verified that the test firmware works just fine on both devices I've tried (Axon 2, Axon Mote)
* I've created a default project (no additional devices) using Designer, exported telling it to write to uart1 (axon 2) or usb (axon mote) (which should both write to usb, for some reason the name is different by default) then imported it into AVR Studio 5 (using the expedient of adding all the files to an empty project, then forcing the project to build using the makefile).
* I then wrote the project to the MC using a programmer.

In the case of the Axon 2, the marquee works and I can get servos to move but nothing ever gets written to the UART (even if I add random debug statements).  I've verified that the bitrate is 115200 on both ends.  In the case of the Mote, nothing works at all--the device doesn't seem to boot (neither LED turns on).

If I take the exact same mote project and export it using webbotlib 1.35, then build it in AVR Studio 5 using the exact same process, it works just fine.  I haven't tried to do this for the Axon 2 yet, but for that MC I did test both C and C++ and got the same (bad) results in both languages.

Writing precompiled images seems to work just fine (tried it with the test firmwares), so I'm quickly running out of ideas.  Are there any known compatibility issues between webbotlib 2 and AVR Studio 5?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: webbotlib 2.08 issues
« Reply #1 on: March 17, 2012, 05:57:16 AM »
I know you don't want to hear this but . . . does the same code work fine in AVR Studio 4?

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #2 on: March 17, 2012, 07:08:29 AM »
I haven't tried.  I guess I'll install it and see what happens.

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #3 on: March 17, 2012, 02:34:17 PM »
Ok, it works fine under AVR Studio 4.  So I guess AVR Studio 5 + webbotlib 2 = bad.

I'll experiment later to see if I can't use AVR Studio 5 (which is a lot nicer) with the AVR Studio 4 toolchain.

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #4 on: March 17, 2012, 05:33:43 PM »
Actually, it seems I spoke a little too soon.  It works for the Axon 2, but I can't compile the Mote project.  The line that creates the USB UART fails with 'initializer element is not constant':

lib/lib_hardware.c:32:1: error: initializer element is not constant
lib/lib_hardware.c:32:1: error: (near initialization for '__C_USB._uart_.tx')
lib/lib_hardware.c:32:1: error: initializer element is not constant
lib/lib_hardware.c:32:1: error: (near initialization for '__C_USB._uart_.txPut')
lib/lib_hardware.c:32:1: error: initializer element is not constant
lib/lib_hardware.c:32:1: error: (near initialization for '__C_USB._uart_.rx')
lib/lib_hardware.c:32:1: error: initializer element is not constant
lib/lib_hardware.c:32:1: error: (near initialization for '__C_USB._uart_.rxGet')

I made this sample project using the same process as I used for the Axon 2 (just created an empty project in Designer and exported it).

In case it helps, I'm attaching the project.  It should be buildable as-is, other than changing the location of webbotlib in the makefile.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: webbotlib 2.08 issues
« Reply #5 on: March 18, 2012, 05:02:32 AM »

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #6 on: March 18, 2012, 07:47:32 AM »
Erm...this last error I get with AVR Studio 4.  Are you saying it's something known to happen with v5?  In that case then maybe there's something in the PATH that's messing with the toolchain.  I'll see if uninstalling AVRS5 solves this. =/

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: webbotlib 2.08 issues
« Reply #7 on: March 18, 2012, 08:01:35 AM »
I don't use or recommend AVR5 because it's still buggy and has library compatibility issues. It's also a hog for system resources . . .

As it becomes more stable and AVR4 gets phased out, Webbot will likely consider ensuring compatibility.

Let him know if you figure it out and he'll work with you on it.

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #8 on: March 18, 2012, 08:59:49 AM »
Ok, I can't get past this error (without modifying webbotlib) even after uninstalling AVR Studio 5 and using only AVR Studio 4 (version 4.19, with toolchain installed).

The problem seems to be in _uart_common.h, line 123:

#define MAKE_UART_COMMON(rxBuf,txBuf,class, rxPin, txPin, reader, writer) { \
   rxBuf, txBuf, null, null, FALSE, FALSE, FALSE, class, -1, rxPin, txPin, reader, writer, null, \
   FALSE,null,null,\
   (txBuf==null) ? &__uartSendUnbuffered : &__uartSendBuffered, \
   (txBuf==null) ? &__uartSendNextUnbuffered : &__uartSendNextBuffered, \
   (rxBuf==null) ? &__uartReceiveUnbuffered : &__uartReceiveBuffered, \
   (rxBuf==null) ? &__uartGetByteUnbuffered : &__uartGetByteBuffered \
   }

My C is a little rusty, but apparently what's happening is that you can't use those expressions in an initializer because they're evaluated at runtime and initializers need to be resolved at compile time.

Removing those four ternary expressions and replacing them with either the buffered or unuffered variable makes the code work, so I'm thinking this just won't work.  I can think of a couple solutions to this:

1. Stop using an initializer and instead assign those values by hand, or
2. Don't refactor the initializers for the buffered and unbuffered UARTs into MAKE_UART_COMMON, instead just write either side separately.

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #9 on: March 18, 2012, 09:06:02 AM »
One more thing.  This is why this doesn't break for the Axon 2:

HW_UART __C_uart1 = MAKE_UART_BUFFERED(null,null,UCSR1A,UCSR1B,UBRR1L,UBRR1H,UDR1,null,BV(U2X1),D2,D3,&uart1GetByte,&uart1SendByte);

Because the buffer is a compile time constant (null), the compiler is able to determine the value of those expressions at compile time.  However, this is how the Mote declares the same thing:

HW_UART __C_USB = MAKE_UART_BUFFERED(&rx_USB_Buffer,&tx_USB_Buffer,UCSR0A,UCSR0B,UBRR0L,UBRR0H,UDR0,null,BV(U2X0),E0,E1,&USBGetByte,&USBSendByte);

Because the first two arguments aren't compile time constants, the macro fails.

So, unless I'm understanding something incorrectly here, the MAKE_UART_BUFFERED macro is never going to work for the buffered case, only for the unbuffered case.


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: webbotlib 2.08 issues
« Reply #10 on: March 18, 2012, 09:11:05 AM »
I forwarded this to webbot.

As a side note, I also don't use the toolchain  :P

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: webbotlib 2.08 issues
« Reply #11 on: March 19, 2012, 12:06:54 PM »
It compiles fine for me. I'm using WinAVR rather than any compile toolchain that comes with AVRStudio (i.e. I probably dont need any version of AVRStudio installed - but haven't tried that!). Equally I just use 'make' rather than building in AVRStudio.

Edit:- And of course there is now AVRStudio6 Beta as well  ::)
« Last Edit: March 19, 2012, 12:51:23 PM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline ivernTopic starter

  • Jr. Member
  • **
  • Posts: 25
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #12 on: March 19, 2012, 08:34:10 PM »
I've performed some experiments:

* It works with WinAVR (which uses avr-gcc 4.3.3)
* It does not work with the version of avr-gcc bundled with Ubuntu 11.10 (4.5.3)
* It does not work with AVR Studio 4 or 5

I can give you a patch for my solution if you want--it'll make the code work in all of these environments.

In addition, there's an issue with the generated makefile for the Mote: it lists the webbotlib library as libWebbot-ATmega128RFA1.a, when in the zipfile it's libWebbot-ATMega128RFA1.a (the M in Mega is capitalized).  This breaks the build in case-sensitive filesystems.

Offline totalis

  • Full Member
  • ***
  • Posts: 89
  • Helpful? 0
Re: webbotlib 2.08 issues
« Reply #13 on: March 19, 2012, 08:40:07 PM »
Just a bit of info, i have successfully used AVR Studio 5 with webbotlib (1.31) I have not tried with v2 yet.

It required me importing a known working project into avrstudio 5 and compiling to make sure.

i then started a new project and went through the config and basically copied every setting.

after that i have had no issues at all, its been really good to me.

wish they had an arduino uploader though

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: webbotlib 2.08 issues
« Reply #14 on: March 20, 2012, 01:49:13 PM »
Feel free to PM me with any fix and I'll have a look. Not sure I'll get around to a patch shortly as I'm nearing completion on WebbotLib Studio (but available time is also a problem with that!).
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk