New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem flashing Riot to Arduino UNO/Mega2560 boards #6535

Closed
yijiazi opened this Issue Feb 1, 2017 · 14 comments

Comments

Projects
None yet
7 participants
@yijiazi

yijiazi commented Feb 1, 2017

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

@mali

This comment has been minimized.

Contributor

mali commented Feb 1, 2017

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

@yijiazi

This comment has been minimized.

yijiazi commented Feb 1, 2017

@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

@kYc0o

This comment has been minimized.

Contributor

kYc0o commented Feb 2, 2017

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.

@cgundogan

This comment has been minimized.

Member

cgundogan commented Feb 2, 2017

@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)

@OlegHahm

This comment has been minimized.

Member

OlegHahm commented Feb 2, 2017

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

Totally true - my fault.

@mali

This comment has been minimized.

Contributor

mali commented Feb 2, 2017

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 ?

@yijiazi

This comment has been minimized.

yijiazi commented Feb 3, 2017

@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.

@yijiazi

This comment has been minimized.

yijiazi commented Feb 3, 2017

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

Now the problem is solved -- thanks very much!

@OlegHahm

This comment has been minimized.

Member

OlegHahm commented Feb 3, 2017

I guess we can close then?

@cgundogan

This comment has been minimized.

Member

cgundogan commented Feb 4, 2017

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?

@shaolinkhoa

This comment has been minimized.

shaolinkhoa commented Mar 17, 2017

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 ?

@aabadie

This comment has been minimized.

Contributor

aabadie commented Mar 17, 2017

Hi,

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

sudo apt-get install avr-libc
@mali

This comment has been minimized.

Contributor

mali commented Mar 17, 2017

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

@shaolinkhoa

This comment has been minimized.

shaolinkhoa commented Mar 17, 2017

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

@aabadie aabadie closed this Mar 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment