Riot: Problem flashing Riot to Arduino UNO/Mega2560 boards

Created on 1 Feb 2017  路  14Comments  路  Source: RIOT-OS/RIOT

Hi,

I'm trying to flash Riot to Arduino boards -- however, I need very good luck to flash the Riot OS to the UNO board, because most of the time, I got error messages like (it might stop at any point):

(I'm using the Ubuntu VM downloaded from vagrant https://github.com/RIOT-OS/RIOT/tree/master/dist/tools/vagrant running on a Mac OS host.)

avrdude -p atmega328p -c arduino -P /dev/ttyACM0 -b 115200 -F -D -U flash:w:bin/arduino-uno/Task01.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "bin/arduino-uno/Task01.hex"
avrdude: input file bin/arduino-uno/Task01.hex auto detected as Intel Hex
avrdude: writing flash (5676 bytes):

Writing | ############################### | 62% 0.69s
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x00
Writing | ################################ | 64% 1.84savrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_cmd(): programmer is out of sync

If I was in luck (after 20~ retries), I will be able to see:

avrdude -p atmega328p -c arduino -P /dev/ttyACM0 -b 115200 -F -D -U flash:w:bin/arduino-uno/Task01.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "bin/arduino-uno/Task01.hex"
avrdude: input file bin/arduino-uno/Task01.hex auto detected as Intel Hex
avrdude: writing flash (5676 bytes):

Writing | ################################################## | 100% 1.11s

avrdude: 5676 bytes of flash written
avrdude: verifying flash memory against bin/arduino-uno/Task01.hex:
avrdude: load data flash data from input file bin/arduino-uno/Task01.hex:
avrdude: input file bin/arduino-uno/Task01.hex auto detected as Intel Hex
avrdude: input file bin/arduino-uno/Task01.hex contains 5676 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.92s

avrdude: verifying ...
avrdude: 5676 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done. Thank you.

I tried different kinds of Arduino UNO R3 boards, including the original Arduino version, but still hard to get the Riot OS uploaded.
It seems to be problem related to avrdude -- but without knowing detail of it, I have no idea what's wrong.

When I try with Arduino Mega2560, I will also get error message like:

/home/vagrant/Tutorials/task-01/bin/arduino-mega2560/Task01.elf
avrdude -p m2560 -c stk500v2 -P /dev/ttyACM0 -b 115200 -F -D -U flash:w:bin/arduino-mega2560/Task01.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "bin/arduino-mega2560/Task01.hex"
avrdude: input file bin/arduino-mega2560/Task01.hex auto detected as Intel Hex
avrdude: writing flash (6230 bytes):

Writing | ###################### | 44% 0.48savrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
^C/home/vagrant/RIOT/Makefile.include:330: recipe for target 'flash' failed
make: *** [flash] Interrupt

Any idea what's wrong?

thanks in advance

AVR question

All 14 comments

Hum .. don't seem related with arduino API ?
@yijiazi Which avrdude version ?

@mali : the avrdude is

avrdude -v

avrdude: Version 6.2
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

I think it's the default one provided by the vagrant VM

I think the problem lies on the fact that you're using the vagrant VM. It comes with predefined default access to several boards which provide UART connectivity, and usually it works good so far. At the same time, if the resources of the host are not so high, of course it has a consequence on the communication with external hardware.

Which kind of native OS are you using? Be aware that RIOT can be built in any Linux or OS X based system.

@yijiazi could you try BOARD=arduino-uno make flash instead of the direct call to avrdude? One thing I spotted is that you use a baud rate of 115200, while RIOT is using 9600 (see RIOT/board/arduino-common/Makefile.include)

Hum .. don't seem related with arduino API ?

Totally true - my fault.

I use avrdude: Version 6.1, compiled on Sep 11 2014 at 20:00:34 and never had this kind of problem.
As suggested by @Kycoo, can you try flashing directly from your MacOS host ?

@cgundogan : What I used was BOARD=arduino-uno make flash, I simply copied the part about the flashing. The default baud rate used by the BOARD=arduino-uno make flash was 11520.
I also tried with other rates from 9600, it doesn't work either.

But I'll try Riot without using the VM as @mali and @kYc0o suggested, and come back to you later.

thanks a lot.

OK, I tried it without using VM -- apparently, it works fine now.

Now the problem is solved -- thanks very much!

I guess we can close then?

Before we close this issue I would actually like to confine the problem. AFAIK, flashing arduino boards (at least used to) work with a linux host. @yijiazi is using a OSX machine and we had several problems before with OSX. Can anyone with an OSX host ( @kYc0o ?) try to reproduce this error by flashing an arduino-uno from within vagrant?

hi,
I have the problem while flashing Arduino Mega2560 board too.

khoa@khoa:~/RIOT/examples/arduino_hello-world$ make BOARD=arduino-mega2560 flash
Building application "arduino_hello-world" for "arduino-mega2560" with MCU "atmega2560".

In file included from /home/khoa/RIOT/drivers/include/periph/uart.h:48:0,
                 from /home/khoa/RIOT/sys/arduino/include/serialport.hpp:24,
                 from /home/khoa/RIOT/sys/arduino/include/arduino.hpp:29,
                 from /home/khoa/RIOT/examples/arduino_hello-world/_sketches.cpp:1:
/usr/lib/gcc/avr/4.9.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
 # include_next <stdint.h>
                          ^
compilation terminated.
/home/khoa/RIOT/Makefile.base:70: recipe for target '/home/khoa/RIOT/examples/arduino_hello-world/bin/arduino-mega2560/arduino_hello-world/_sketches.o' failed
make[1]: *** [/home/khoa/RIOT/examples/arduino_hello-world/bin/arduino-mega2560/arduino_hello-world/_sketches.o] Error 1
/home/khoa/RIOT/examples/arduino_hello-world/../../Makefile.include:275: recipe for target 'all' failed
make: *** [all] Error 2

I can't find # include_next <stdint.h> in RIOT/drivers/include/periph/uart.h
Would you mind helping me ?

Hi,

Did you try on a Debian-like system ? If yes, can you try this:

sudo apt-get install avr-libc

arduino Mega2560 or Uno ?
if it's a Mega2560 you should use make BOARD=arduino-mega2560 ?
Have you installed avr-libc ?

Sorry for my misstake, I copied when I tried with Uno. I fixed it
After installed avr-libc, it works. Thanks all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaspar030 picture kaspar030  路  6Comments

l3nko picture l3nko  路  7Comments

nikosft picture nikosft  路  6Comments

jcarrano picture jcarrano  路  7Comments

jdavid picture jdavid  路  5Comments