Arduino yun

From Finninday
Revision as of 19:18, 6 November 2014 by Rday (Talk | contribs)

Jump to: navigation, search

Upgrading an Arduino Yun

background

Essentially the task I'm documenting is outlined here: http://linino.org/doku.php?id=wiki:upgradetolininoio

But I'm adding a bit of background that I was missing since this is my first exposure to the Yun. See? I didn't even spell it with the proper accent over the U.

I'm pleased that the Yun has such good documentation:

I didn't end up using this sketch, but it included some nice hints about using the stock Serial Terminal in the Arduino IDE

This was the most succinct and useful documentation I found on setting up the tftpd server that is needed for the upgrade

http://www.df.lth.se/~triad/krad/tftpserver.html

environment

  • I'm using a Fedora 20 system connected via usb to provide power and access to serial terminal
  • The Yun is connected via wired ethernet to a network with a dhcp server providing IP config
  • I have an apache server providing binaries for download to the Yun
  • I have a tftp server providing binaries for download to the Yun
  • I have installed the version of the Arduino IDE (1.5.8 BETA) that is new enough to support the Yun

prep the Yun

  • connect ethernet and usb to boot the Yun
  • watch the dhcp logs to see the mac address of the yun and enter into dhcpd.conf
  • reboot Yun
  • let dhcp configure
  • log in via ssh. I have yun in my /etc/hosts with the IP address provided by dhcp. I'll be doing several of these boards and each time the image changes, the host id changes, so let's not fiddle with those. The default password is doghunter.
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@yun
  • download the latest serial terminal to the Yun
root@j17:~# cd /tmp
root@j17:/tmp# wget http://download.linino.org/pkg-bin/serialTerminal.hex
Connecting to download.linino.org (88.198.63.58:80)
serialTerminal.hex   100% |*******************************| 17420   0:00:00 ETA
  • install the latest serial terminal on the Yun
root@j17:/tmp# run-avrdude /tmp/serialTerminal.hex

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9587
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFB"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFB:
avrdude: load data efuse data from input file 0xFB:
avrdude: input file 0xFB contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "/tmp/serialTerminal.hex"
avrdude: writing flash (6188 bytes):

Writing | ################################################## | 100% 3.61s

avrdude: 6188 bytes of flash written
avrdude: verifying flash memory against /tmp/serialTerminal.hex:
avrdude: load data flash data from input file /tmp/serialTerminal.hex:
avrdude: input file /tmp/serialTerminal.hex contains 6188 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.37s

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

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

upgrade uboot

  • launch the Arduino IDE
Arduino-ide-yun.png
  • set Tools > Board > Arduino Yun
  • set Tools > Port > /dev/ttyACM0
  • start Tools > Serial Monitor
  • configure Serial Monitor to use New line, 512000 baud
  • enter ~2 in the Serial Monitor and get ready to press send
  • press the "YUN RST" button (near the corner with the LEDs)
Yun-reset.jpg
  • press send
  • within 4 seconds, enter a letter and press send again
  • this should pause the boot here:
athrs26_reg_init_lan
ATHRS26: resetting s26
ATHRS26: s26 reset done
eth1 up
eth0, eth1
Hit any key to stop autoboot:  4  3  2  1  0
  • the fact that the prompt says "Hit any key to stop autoboot" is an indication that we have the old version
  • configure network manually with values that dhcp would have given
ar7240> setenv serverip 10.0.0.5;
ar7240> setenv ipaddr 10.0.0.119;
ar7240> ping 10.0.0.5
dup 1 speed 100
Using eth0 device
host 10.0.0.5 is alive
  • transfer the new uboot image
ar7240> tftp 0x8006000 uboot.bin
Using eth0 device
TFTP from server 10.0.0.5; our IP address is 10.0.0.119
Filename 'uboot.bin'.
Load address: 0x8006000
Loading: T T T T T T T T T T
Retry count exceeded; starting again
eth1 link down
FAIL
Using eth0 device
TFTP from server 10.0.0.5; our IP address is 10.0.0.119
Filename 'uboot.bin'.
Load address: 0x8006000
Loading: T T T T ####################################
done
Bytes transferred = 181852 (2c65c hex)
ar7240>
  • perform the upgrade
ar7240> erase 0x9f000000 +0x40000
Erase Flash from 0x9f000000 to 0x9f03ffff in Bank # 1
First 0x0 last 0x3 sector size 0x10000
   0    1    2    3
Erased 4 sectors
ar7240>

ar7240> cp.b $fileaddr 0x9f000000 $filesize
Copy to Flash... write addr: 9f000000
done

ar7240> reset
  • it now reboots and should have the newer version of uboot
  • verify by switching serial monitor with ~1 and typing "lin" within 4 seconds to get uboot prompt:
<line noise>
eth1: b4:21:8a:00:00:01
eth0, eth1
autoboot in 4 seconds (stop with 'lin')...
linino>
  • view bootargs
linino> printenv
bootargs=console=ttyATH0,115200 board=linino-yun mem=64M rootfstype=squashfs,jffs2 noinitrd mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware)
bootcmd=bootm 0x9fea0000
bootdelay=4
baudrate=115200
ethaddr=0xb4:0x21:0x8a:0x00:0x00:0x10
ipaddr=192.168.1.2
serverip=192.168.1.1
stdin=serial
stdout=serial
stderr=serial
ethact=eth0

Environment size: 399/65532 bytes
  • set boot args
linino> setenv bootargs 'console=spicons board=linino-yun mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware) mem=64M rootfstype=squashfs,jffs2 noinitrd'
  • I wasn't able to set baudrate here, so skipping that step and setting it later in linux
  • save environment variables
linino> saveenv
Saving Environment to Flash...
Protect off 9F040000 ... 9F04FFFF
Un-Protecting sectors 4..4 in bank 1
Un-Protected 1 sectors
Erasing Flash...Erase Flash from 0x9f040000 to 0x9f04ffff in Bank # 1
First 0x4 last 0x4 sector size 0x100   4
Erased 1 sectors
Writing to Flash... write addr: 9f040000
done
Protecting sectors 4..4 in bank 1
Protected 1 sectors
linino>
  • reboot
linino> reset
  • allow boot to proceed to completion. it takes about 70 seconds

upgrade linio image

  • ssh to linux
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@yun
  • display version before upgrade

  • download linio image
root@j17:~# cd /tmp
root@j17:/tmp# wget http://10.0.0.5/yun.bin
Connecting to 10.0.0.5 (10.0.0.5:80)
yun.bin              100% |*******************************| 15759k  0:00:00 ETA
  • apply the new image
root@j17:/tmp# sysupgrade -n -v yun.bin
Sending TERM to remaining processes ... uSDaemon uhttpd dbus-daemon dnsmasq avahi-daemon alljoyn-daemon thd ntpd sleep syslogd klogd hotplug2 ubusd netifd
Sending KILL to remaining processes ... uhttpd
Switching to ramdisk...
Performing system upgrade...
Unlocking firmware ...

Writing from <stdin> to firmware ...  [w]
[w]
[w]
Upgrade completed
Rebooting system...

  • ssh to box and set baud rate
root@linino:~# fw_setenv baudrate 250000
root@linino:~#
  • run-avrdude
root@linino:~# run-avrdude /etc/linino/bathos-mcuio.hex

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9587
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD8"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFB"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFB:
avrdude: load data efuse data from input file 0xFB:
avrdude: input file 0xFB contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "/etc/linino/bathos-mcuio.hex"
avrdude: writing flash (32748 bytes):

Writing | ################################################## | 100% 17.25s

avrdude: 32748 bytes of flash written
avrdude: verifying flash memory against /etc/linino/bathos-mcuio.hex:
avrdude: load data flash data from input file /etc/linino/bathos-mcuio.hex:
avrdude: input file /etc/linino/bathos-mcuio.hex contains 32748 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 15.94s

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

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
  • display build info after upgrade
root@linino:~# cat /etc/linino_version
DISTRIB_ID="Linino"
DISTRIB_RELEASE="lininoIO"
DISTRIB_REVISION="5720072"
DISTRIB_CODENAME="attitude_adjustment"
DISTRIB_TARGET="ar71xx/generic"
BUILD_DATE="2014-10-14"
  • display bootargs
root@linino:~# fw_printenv
bootcmd=bootm 0x9fea0000
bootdelay=4
ethaddr=0xb4:0x21:0x8a:0x00:0x00:0x10
ipaddr=192.168.1.2
serverip=192.168.1.1
stdin=serial
stdout=serial
stderr=serial
ethact=eth0
bootargs=console=spicons board=linino-yun mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14656k(rootfs),1280k(kernel),64k(nvram),64k(art),15936k@0x50000(firmware) mem=64M rootfstype=squashfs,jffs2 noinitrd
baudrate=250000