Arduino + Ethershield Programming with avr-gcc

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have built the avr-gcc tool chain under Solaris and am able to write and burn simple blinking led programs to my Arduino Duemilanove board with avrdude and a avrispmkII SPI programmer.

I now would like to establish communication between the Duemilanove
board and my host (Solaris 10). I could try RS232 but that would mean
that i have to physically separate the TxD, RxD lines from the ATMEGA to
the USB-chip and instead solder some MAX232 to the board. Since the
Ultra 20 Workstation (Solaris 10) I am using for programmming the board
via SPI does not even have a serial port, I am prefering to communicate
with the board via TCP. I have the Arduino Ethernet Shield board but no
idea how to use that. All samples I have found so far are for Arduino
sketches. Since I am programming on the command line with pico, make,
aavr-gcc and avrdude, I need to do this differently but how? Any example
for that? Help (Example code, Example Makefile) would be greatly
appreciated!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well you have all the example code you need right in the arduino example sketches and library sources. Arduino code is simply C++.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What you have to work with and what you prefer may not be aligned.

If you were able to program using a avrispmkII on your Solaris machine, then I'm assuming your SUN machine has a USB interface.
So why can't you use USB for your serial communication to the AVR?

I'd use a virtual serial port over the USB bus to talk to the AVR.

Seems like the easy answer.
The FTDI chip is already there presenting a serial interface over USB.

If you would burn the Arduino bootloader back into the AVR, you could still use avrdude to program the AVR using the USB serial interface on the Duemilanove board.
The difference is you would not have to use the ISP programmer.

Once the bootloader is in place, it works nearly identically as using the ISP interface if you are using avrdude. The good thing it it doesn't require a dedicated programmer as the AVR programs itself.

With respect to the ethernet arduino code.
I think that will be a can of worms unless you really want to do some porting and write some Arduino code.

glitch wrote:
well you have all the example code you need right in the arduino example sketches and library sources. Arduino code is simply C++.

Arduino does use C++ (although they call it their own language) but arduino code can be C++ code that does not compile outside of the IDE environment.

Arduino does quite a bit hand holding in the IDE. The IDE goes in an does all kinds of things under the hood that can make it difficult to get arduino code built outside of the IDE.

The biggest issue is that the Arduino team are not fans of the command line nor make and so the IDE does not build on top of makefiles but instead does all its own internal build rules and even does code parsing in an attempt to make things easier for the arduino user by doing some things for them.

In fact, the IDE tries to do so much of its own C++ parsing, that sometimes perfectly valid C++ can create errors in the IDE.

It is not straight forward to build arduino code from the command line even if you are using their arduino IDE directory structure with all of their tools (sans IDE).

Their build process is not fully documented.
Some of the things they do are parse your code and generate prototypes, magically determine which "library" modules to include and even which include paths to add.
There are lots of little magic things they do for what they call "libraries", which are not libraries at all but collections of code modules.

So in order to build "arduino" code you end up having to figure how much of this IDE nonsense you have to duplicate.
It can all be done in with makefile rules but not with generic rules as many things for the "libraries" seem to be custom.

In the latest release 0018 , they have even yanked their "broken", but still somewhat helpful makefile for sketches.

The arduino team is simply not interested in supporting building arduino code outside of their IDE.

--- bill

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I'd use a virtual serial port over the USB bus to talk to the AVR.

I had this idea as well and googled a while but found nothing suitable. Who us offerening such a virtual serial port over USB driver for Solaris 10?

Quote:

The arduino team is simply not interested in supporting building arduino code outside of their IDE.

In the meanwhile I have soldered a MAX233 to the Arduino board and connected that to the serial port of a Sun Ray. This means I now have a serial device

/tmp/SUNWut/units/IEEE802.00144fa63a1d/dev/term/a

accessible from Solaris. I know how to program a serial port from the Solaris side but have no idea yet how to program the Arduino side. As mentioned I don't want to use this Arduino sketch clickibunti IDE but program the thing with Makefiles avr-gcc and avrdude (no boot loader).

I would pretty much appreciate a pointer to some example code (Makefile, main.c,...) of a "hello world" program that opens the serial port at 9600 baud and then simply writes some text to the serial port. This would get me going I think. Hints greatly appreciated!

Thanks a lot in advance!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The biggest issue is that the Arduino team are not fans of the command line nor make and so the IDE does not build on top of makefiles but instead does all its own internal build rules and even does code parsing in an attempt to make things easier for the arduino user by doing some things for them.

I digged a little bit into this topic. There is a option in ~/.arduino/preferences.txt to make the output verbose while compiling. So I could update the broken Makefile for the sketch examples. The only magic in the arduino build process is building a library from the source files (serial driver and pin abstraction) and generating a real main file by adding the startup code (calling setup()) and the main loop (calling loop()) to the sketch from the main.cxx template in the core directory (at least it was in 0017 so, in 0018 there was some minor changes).

Here is a arduino overlay package that contains the repaired makefile for some sketch examples.
http://download.savannah.nongnu....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are probably like me, no stinking GUI for real programming and if that is the case, you should definitely stay away from all the Arduino IDE nonsense.
The entire "Arduino way of life" is geared towards non-programmers.

For virtual comm support, I think solaris has FTDI USB chip support built in.
You should check in to this, it would save you a ton of work as you could use the USB interface that is already on your Arduino board for your serial communication with the AVR.

You could always switch over to linux... :-)

Whether you use a bootloader or not will not affect your build environment very much.

I use an AVR dragon for ISP and a bootloader for self programming and from the viewpoint of updating the flash inside the AVR they will both be the same.

"make program" or whatever rule you write.
avrdude will be doing the update. All that changes between ISP vs bootloader is the command line arguments to avrdude inside the makefile.

In fact I use the same makefile on Linux and Windows, with and without a bootloader so my build environment
is essentially the same in all cases. And my serial connection is handled over the USB via a virtual comm port
for both OSes.

The code for talking to the UART on the AVR side is really simple if you poll it. Just 2-3 lines of C.

For sample code on how to talk to the AVR serial port, see the AVR libc manual:
http://www.nongnu.org/avr-libc/user-manual/index.html
The specific example is here:
It shows how to hook the uart up to stdio.

http://www.nongnu.org/avr-libc/user-manual/group__stdiodemo.html
Scroll down for the uart code.

It is worth spending some time going through the AVR libc user manual. I'd start with the FAQs.

For more examples, and even interrupt driven examples, have a look at AVR freaks project pages:
https://www.avrfreaks.net/index.php?module=FreaksAcademy&func=viewProjects

Search for "uart".

There is a treasure trove of wealth in the projects section.

--- bill

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bperrybap wrote:
You are probably like me, no stinking GUI for real programming and if that is the case, you should definitely stay away from all the Arduino IDE nonsense.
The entire "Arduino way of life" is geared towards non-programmers.

Yes, that would be me. I have nothing against efficient IDEs (if I have developed them and know exactly what happens behind the scenes)! :-)

bperrybap wrote:

For virtual comm support, I think solaris has FTDI USB chip support built in.

Where have you seen that? My googling revealed nothing so far. I have no idea how to setup such a virtual port.

In the meanwhile I have soldeed a MAX233 to the Arduino board and am trying to establish serial connection. I have written a little ATMEL program that initializes the serial port and sends out starts. I can see the signal on the scope, also on the +12V/-12V line behind the MAX233 but I don't receive anything on the Solaris side yet (still investigating)!

bperrybap wrote:

The code for talking to the UART on the AVR side is really simple if you poll it. Just 2-3 lines of C.

For sample code on how to talk to the AVR serial port, see the AVR libc manual:
http://www.nongnu.org/avr-libc/user-manual/index.html
The specific example is here:
It shows how to hook the uart up to stdio.

http://www.nongnu.org/avr-libc/user-manual/group__stdiodemo.html
Scroll down for the uart code.

It is worth spending some time going through the AVR libc user manual. I'd start with the FAQs.

For more examples, and even interrupt driven examples, have a look at AVR freaks project pages:
https://www.avrfreaks.net/index.php?module=FreaksAcademy&func=viewProjects

Search for "uart".

There is a treasure trove of wealth in the projects section.

Thanks for the links!!!

- Andreas

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ahoesch wrote:

Where have you seen that? My googling revealed nothing so far. I have no idea how to setup such a virtual port.
- Andreas

I've seen hints of FTDI USB chip support but it seems to be on the Intel Open Solaris versions.

The easiest thing is probably to simply plug it in and see if the OS recognizes it.
(Check out the messages file)
If so, you will get a /dev entry created that works just like a serial port.

From a software perspective, it will look and work just like a "normal" serial port.

--- bill