Tincan tools. Trainer-XM

Hello everyone.

Most of the posts on the Trainer and the AtMega on it are outdated.
So i'll try to update everyone here as i just used it. Although. Just
for a blink program yet.
:slight_smile:

very useful post

http://blog.makezine.com/archive/2010/09/playing-with-the-arduino-compatible.html

I asked their support a couple of questions.

Their reply The ATmega328 on the

Trainer / Trainer-xM boards comes programmed from Tin Can Tools with
the Arduino bootloader already programmed into the ATmega328
processor. You have two options:

Option 1) You can use the Arduino bootloader and send your Arduino
programs to the ATmega328 via the serial port from the BeagleBoard.
You program the ATmega328 just like you would a standard Arduino
board. You can keep uploading multiple programs to the ATmega328 via
the serial port until you are happy with the code. The Arduino
bootloader remains programmed on the ATmega328 and it allows you to
send multiple programs to it.

Option 2) If you do not want to use Arduino code and would prefer to
use standard AVR C or AVR assembly code then you would need to
purchase an AVR programmer (hardware device) to program the ATmega328
via the in sytem programming header at J2 (6 pin header located on the
Trainer-xM board). You would flash your AVR C program directly into
the ATmega328 using the AVR programmer. This process would erase the
Arduino bootloader and run your code directly on the ATmega328
processor. You could always reprogram the Arduino bootloader at a
later time if you ever wanted to go back to "Arduino compatible mode".

So to summarize: The Trainer / Trainer-xM board comes with the
Arduino bootloader already programmed into the ATmega328. If you want
to use Arduino code, you do not have to purchase a AVR programmer.

The main problem I faced. The mainline u-boot did not enable UART2.
Even in the Trainer-Xm #define.

This http://elinux.org/BeagleBoardPinMux#UART2_enabling_within_U-boot
helped.

I don't exactly know why all these defines are used.
I tried using only
MUX_VAL(CP(UART2_RX),
and MUX_VAL(CP(UART2_TX),

And something wasn't working. So i used them all.

Arduino IDE.
Installation was weird. I recommend using the Software center.

Arduino IDE cannot be connected to the Atmega directly. We need the
hex file that it generates.
The hex file is not normally visible.
It is only stored in a folder in tmp when upload is click. Even if
upload failed.

The bootloader i told the Arduino IDE was the duemilanov.

Press Shift while clicking on the Upload button. upload will fail.
(NOTE : if you have bb-xm connected on uart. the data will be visible.
its a weird mix of characters. :p)

Holding shift enables verbose output on the console while compiling.
It shows where the hex file is.

Copy the hex file to the beagle.
Copy http://elinux.org/Avrgal onto the beagle.

then run these
enable permissions using chmod +x Avrgal
./Avrgal Test.hex

when you press the atmega reset button. the arduino bootloader runs
initially.
At that time the bootloader can accept another program via serial.

Note: When you press reset. And run ./Avrgal Test.hex.
It might say sync failed.
There is short time window where it works perfectly.

I had to try several times. reset run. run reset. here n there.
then it worked.

Uart port used : /dev/ttyS1
Autodetect for Fade.hex : Intel Hex
Acquire SYNC with AVR : Passed
Uploading and writing to flash : Passed

in my case. The led started blinking as i used the blink example.

One weird issue : there seems to be some offset in the schematics/
code.
If i write in the code to output high on pin 13. pin 17 actually goes
high.
I haven't traced the problem yet. it might be with the schematic that
i have. or it might be something else.

If someone could guide me to a wiki page to update. I'll update it
properly.
I just posted some quick notes from my mind here so someone searching
in the future could find this easier.
Its a great way to get more gpio's at 3.3v or 5v from the XM.

5v gpios. :slight_smile:

Regards
ZubairLK

ZubairLK,

a couple of notes:

the arduino bootloader can be used with any avr code, it is not
specific to "arduino" code.

there is a gpio pin from the omap3 that controls the power for the
avr. this is used to power the avr on/off when using avrgal to program
the avr. i assume from your description that this gpio is incorrectly
muxed in your u-boot as well, hence the need for you to use the reset
button. under normal conditions this is not needed.

the rev A and rev B schematics for the trainer are available at:
http://www.elinux.org/BeagleBoard_Trainer

there has been no change in the pinout for the avr and all pins have
been verified.

Dave

GPIO 162. I've used it actually using sysfs. It works.
I'll check again.
Thanks for the info.

And the change in pinouts. I'm surprised as well. I'll update here
when i find out.

Regards
ZubairLK