Archive for the ‘Brian’ Category.

Arduino Wireless Bootloading Using Series 2 XBees and XBeeBoot

I built a line-following robot a few months back using an Arduino Uno. I soon found out that connecting the Arduino to the PC with a USB cable every time I wanted to upload a new sketch got old very quickly, especially during debugging and testing. I had some XBee Series 2 RF modules from Digi and thought, “Wouldn’t it be great to do wireless bootloading with the Arduino so I could ditch the USB cable?”. Fortunately, many people around the internet have contributed to making this possible. The following pseudo-walkthrough is based on my notes of how I got it working on Windows, using David Sainty’s XBeeBoot boot loader.

But before we start, a special thank you to David Sainty for answering my questions when I first struggled to get things working.

NOTE: This post isn’t intended to provide every detailed step needed to get things working – you’ll need familiarity with Windows, Linux, C/C++ programming, BASH shell scripting, Arudinos, the Arudino IDE, etc. 

Background

There are a few guides of varying quality floating around the web explaining how to do this. I had a few false starts but I ultimately got David Sainty’s XBeeBoot working on Windows with a stock Arduino Uno. The following is a rundown of the sources I reviewed before I ultimately got it working:

Hardware you’ll need

  • Arduino UNO R3 with 5V ATMega328P running at 16MHz
    •  I first used the pre-built bootloader from the git repo, with a hardcoded 9600 baud rate, then built and tested the atmega328 bootloader at hardcoded rates of 9600, 19200, 38400, 57600, and 115200 baud.
  • At least two XBee Series 2 modules
    • I have S2C XBees but it should work with the S2B and older Series 2 versions. The great thing about the S2C is that it has all the Router/Coordinator/API/AT flavors of the firmware bundled together in flash so you don’t need to change the firmware when you want to change operating modes. It may work with Series 3 as well, I don’t own any Series 3 XBees so I haven’t tried it yet.
  • Something to connect the XBee to your computer
  • Something to connect the XBee to your Arduino.
    • I used a Sparkfun XBee Shield because it was easy but there are many ways to do it. You can wire the XBee up on a breadboard but you’ll need a breakout board or some other means of converting the 2mm pins on the XBee to the .1″ pins on a breadboard.
  • An AVR programmer to write the XBeeBoot bootloader to the Arduino.
    • I had a spare Arduino Uno sitting around which can be used as a programmer. Sparkfun has a tutorial on Installing an Arduino Bootloader using this method that is very easy to follow.

Step 1: Build avrdude for Windows

(If you give a mouse a cookie…)

The avrdude (version 6.3 as of this writing) that comes bundled with the Arduino IDE does not support the protocol needed to upload sketches via XBee. You’ll need to get the source code for avrdude and build it, then patch it to support the XBee protocol. Doing so on Windows turned out to be a bit more involved than I anticipated, but it’s still doable. The easiest way to build avrdude for Windows is to use the build scripts that the Arduino team provides: https://github.com/arduino/avrdude-build-script

Step 1a – Install Windows Subsystem for Linux

As you read the instructions for how the Arduino team builds avrdude for Windows, you soon learn that the standard way is to build it on Linux and cross-compile for Windows. There have been attempts to create native Cygwin and Mingw builds but these have all been abandoned. In a Windows environment, the easiest way to build on Windows without the hassle of dual-booting to Linux is to install the Windows Subsystem for Linux.  There are many online guides available to walk you through this. I followed instructions, chose the Ubuntu option, and viola!, I have an Ubuntu terminal on Windows without needing to dual boot:

Ubuntu on Windows

Ubuntu On Windows

Step 1b – Install the packages needed for building avrdude

Next I had to install the packages used for building avrdude. The Arduino avrdude build script state that you’ll need the gcc-mingw-w64-i686 package but in reality you need several more:

  • devtools-essential (includes make and gcc)
  • build-essential
  • bison
  • zip
  • automake
  • flex
  • pkg-config
  • g++-mingw-w64-i686
  • gcc-mingw-w64-i686
  • libtool
Steb 1c – Clone the Arduino avrdude build script repo and follow the instructions for cross-compiling on windows.

I ran into one hiccup I will note here, but your mileage will probably vary depending on what versions of tools you have:

  • The configure script for libelf has a check for the size of 64- and 32-bit integers that kept failing. On 64-bit Windows, ints and longs are typically 32-bits while a 64-bit integer is a long long. The test was failing trying to compare a string value of “4” (bytes) to the numeric value of 4. If I had more bash shell kung-fu I could have probably fixed this more elegantly but I simply commented out the check and manually defined int as int32, long as int32, and long long as int64.

If the build is successful you’ll end up with a .zip file containing a Windows executable for avrdude and the avrdude.conf file. You should extract the zip package to a location preferably without spaces in the pathname (your command-line life is just easier when there aren’t spaces in the path) and add the location to your Windows PATH environment variable (in Powershell its $Env:Path):


PS C:\Users\Brian> which avrdude 
C:\Users\Brian\avrdude\bin\avrdude.exe

It’s probably a good idea to verify that your custom-built version of avrdude actually works. I uploaded a sketch with it just to make sure.

NOTE 1: You can choose to overwrite the Arduino IDE-supplied version of avrdude if you wish, but I kept the two versions separate.

NOTE 2: You may want to modify the build scripts to give your version of avrdude a custom version. I forgot to do this.

NOTE 3: The build script actually downloads the avrdude source and patches it with Arduino-specific patches so you have to build it before you can patch it with the XBee protocol as the avrdude source isn’t checked into the Arduino repo.

NOTE 4: In Powershell I have a function in my startup script to emulate the which command.

Step 1d – Patch avrdude

Now you need to actually add the XBee protocol to avrdude. David Sainty created a patch for avrdude back in 2015 but it never got included into the avrdude core. Unfortunately, avrdude has changed a bit so the patch doesn’t work out of the box and requires some tweaking.  I patchd the avrdude source and re-built it using the following steps:

  • Patched pgm_type.c, makefile.am, avrdude.conf.in, and xbee.h according to the patch file – these work without changes.
  • For xbee.c, there there is no longer any pgm.h or serial.h in the latest versions of avrdude. They were replaced by libavrdude.h so you’ll need to modify xbee.c to remove the references to those two include files and add the reference to libavrdude.h.
  • Comment out the line in package-avrdude.bash that removes all already-built directories, should be around line 88. Don’t want to wipe out all the build work we’ve already done and our newly patched code. 
  • Comment out the line in avrdude-6.3.build.bash that patches avrdude with the Arduino-specific patches. It was already patched in the first build.
  • Comment out the unnecessary git clone in avrdude-6.3.build.bash as we already have cloned avrdude in the first go round.
  • Build as previously.

If all goes well you will have a version of avrdude that supports the Xbee protocol. I extracted the contents of my .zip file like before and made sure the XBee patched version worked with a regular sketch before I tried to do anything wirelessly with the XBee bootloader.

Step 2 – Burn the XBee bootloader

There are many guides on the internet for how to burn a bootloader. I happened to have a spare Arduino that I used as an ISP.  In theory you can put the boards-1.6.txt files and the pre-built bootloader in the right location to burn the bootloader from the Arduino IDE but I did it on the command line following the Sparkfun tutorial. The trick is getting the fuse bits right.

Erase the chip and set the fuse bits and lock bits:


PS C:\Users\Brian> avrdude -v -v -CC:\Users\Brian\avrdude\etc\avrdude.conf -P COM3 -b 19200 -c arduino -p atmega328p -e -Ulock:w:0x3F:m -Ulfuse:w:0xFF:m -Uhfuse:w:0xDC:m -Uefuse:w:0xFD:m

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

System wide configuration file is "C:\Users\Brian\avrdude\etc\avrdude.conf"

Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as DC
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: erasing chip
avrdude.exe: reading input file "0x3F"
avrdude.exe: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude.exe: 1 bytes of lock written
avrdude.exe: verifying lock memory against 0x3F:
avrdude.exe: load data lock data from input file 0x3F:
avrdude.exe: input file 0x3F contains 1 bytes
avrdude.exe: reading on-chip lock data:

Reading | ################################################## | 100% 0.02s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lock verified
avrdude.exe: reading input file "0xFF"
avrdude.exe: writing lfuse (1 bytes):

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

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

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

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

Writing | ################################################## | 100% 0.01s

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

Reading | ################################################## | 100% 0.02s

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

Writing | ################################################## | 100% 0.02s

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

Reading | ################################################## | 100% 0.02s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of efuse verified

avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as DC
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: safemode: Fuses OK (E:FD, H:DC, L:FF)

avrdude.exe done. Thank you.

NOTE1: when using an arduino as an ISP the Arduino as ISP sketch is hardcoded to 19200 baud. 

NOTE2: The XBeeboot loader fits in 1KB so I used Engbedded’s fuse calculator to figure out the right fuse bits for a 1024 byte (512 words) bootloader size .

Next, upload the XBeeBoot bootloader and set the lock bits:


PS C:\Users\Brian> avrdude -v -v -CC:\Users\Brian\avrdude\etc\avrdude.conf -P COM3 -b 19200 -c arduino -p atmega328p -Uflash:w:C:\Users\Brian\Projects\xbeeboot\xbeeboot\bootloaders\xbeeboot\xbeeboot_atmega328.hex:i -Ulock:w:0x0F:m
avrdude.exe: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Users\Brian\avrdude\etc\avrdude.conf"

Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as DC
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "C:\Users\Brian\Projects\xbeeboot\xbeeboot\bootloaders\xbeeboot\xbeeboot_atmega328.hex"
avrdude.exe: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.03s

avrdude.exe: 32768 bytes of flash written
avrdude.exe: verifying flash memory against C:\Users\Brian\Projects\xbeeboot\xbeeboot\bootloaders\xbeeboot\xbeeboot_atmega328.hex:
avrdude.exe: load data flash data from input file C:\Users\Brian\Projects\xbeeboot\xbeeboot\bootloaders\xbeeboot\xbeeboot_atmega328.hex:
avrdude.exe: input file C:\Users\Brian\Projects\xbeeboot\xbeeboot\bootloaders\xbeeboot\xbeeboot_atmega328.hex contains 32768 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 0.03s

avrdude.exe: verifying ...
avrdude.exe: 32768 bytes of flash verified
avrdude.exe: reading input file "0x0F"
avrdude.exe: writing lock (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude.exe: 1 bytes of lock written
avrdude.exe: verifying lock memory against 0x0F:
avrdude.exe: load data lock data from input file 0x0F:
avrdude.exe: input file 0x0F contains 1 bytes
avrdude.exe: reading on-chip lock data:

Reading | ################################################## | 100% 0.02s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of lock verified

avrdude.exe: safemode: lfuse reads as FF
avrdude.exe: safemode: hfuse reads as DC
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: safemode: Fuses OK (E:FD, H:DC, L:FF)

avrdude.exe done. Thank you.

NOTE3: The atmega328 bootloader inthe XBeeBoot repo is hard coded to 9600 baud; however, because a standard Arduino Uno has an external crystal and UART, it should be able to support higher baud rates. I recompiled the bootloader with a hardcoded 19200 buad rate and it worked great. I haven’t tried higher baud rates yet.

Step 3 – Configure your XBees and hardware

I used XCTU, which only runs on Windows, to configure the XBee coordinate and router radios. Sparkfun’s original wireless bootloading tutorial provides a guide for configuring your XBees ; however, it’s a bit outdated and is intended for Series 1 XBees. You’ll need your Series 2 XBees configured for API mode.

Here is the config for the base, acting as coordinator:

Networking

Set the PAN ID and enable as a coordinator

Addressing

Destination High and Low of the router

Serial Interfacing

API mode enabled with escaping

I/O Settings

D3 set to input

I/O Sampling

Monitor D3 for changes

NOTE: I didn’t have encryption or sleep modes or other advanced features enabled but this should work seamlessly with those features.

Here is the config for the remote, as router:

Networking

Same PAN ID

Addressing

High and low address of the Coordinator

Serial Interfacing

Router_serial

Also API mode with escaping

 I/O

Pin3 is output (from the xbee to the Arudino)

You should also wire your hardware up as described in the XBeeBoot github page or in the Sparkfun tutorial. In my case, the Sparkfun XBee shield took care of connecting the XBee DOUT (pin 2) to the Atmega RXD (Atmega328P pin 2/ Arduino Uno 0), and connecting the XBee DIN (pin 3) to the Atmega TXD (Atmega328P pin 3, Arduino Uno 1). All I had to do was connect the XBee DIO3 pin (pin 17) to the Atmega RESET pin (Atmega328P pin 1/ Arduino Uno RESET). The XBee shield made this pretty easy with the through-hole breakouts as shown in the following picture (I skipped the capacitor):

XBeeShield

XBeeShield with DIO3 to RESET

NOTE: If you are using an XBee shield, you’ll want to set the DLINE/UART switch to UART because the bootloader doesn’t have any way of knowing that you’re sending and receiving on Arduino Uno digital pins 2 and 3 if you have the switch set to DLINE. As the Sparkfun hookup guide cautions, remember to set the switch back to DLINE if you’re going to upload a sketch via USB cable with rather than wirelessly via the XBee.

Step 4 – Enjoy Wirelessly Bootloading!

Create a sketch using the Adduino IDE; however, instead of uploading the sketch to an Arduino from the IDE, select Export Compiled Binary from the menu. This will create the .hex file in the directory where your sketch is saved:


PS C:\Users\Brian\Projects\Arduino\Blinktest> dir
Directory: C:\Users\Brian\Projects\Arduino\Blinktest
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/15/2019 8:45 PM 1838 Blinktest.ino
-a---- 9/15/2019 8:45 PM 2889 Blinktest.ino.standard.hex
-a---- 9/15/2019 8:45 PM 4244 Blinktest.ino.with_bootloader.standard.hex

You can then use your version of avrdude with the XBee protocol to upload:

PS C:\Users\Brian\Projects\Arduino\Blinktest> avrdude -CC:\Users\Brian\avrdude\etc\avrdude.conf -b 19200 -c xbee -p atmega328p -u -Uflash:w:BlinkTest.ino.standard.hex:i -P0013A20040DDE8FD@COM5

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.08s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "BlinkTest.ino.standard.hex"
avrdude.exe: writing flash (1022 bytes):

Writing | ################################################## | 100% 3.76s

avrdude.exe: 1022 bytes of flash written
avrdude.exe: verifying flash memory against BlinkTest.ino.standard.hex:
avrdude.exe: load data flash data from input file BlinkTest.ino.standard.hex:
avrdude.exe: input file BlinkTest.ino.standard.hex contains 1022 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 3.18s

avrdude.exe: verifying ...
avrdude.exe: 1022 bytes of flash verified

avrdude.exe done. Thank you.

NOTE1: In this example I was using a version of the bootloader compiled for 19200 baud. You’ll want to change the baud rate to 9600 (and your XBees should be configured for that as well) if you’re using the bootloader directly from the XBeeBoot repo.

A Note on Higher Baud Rates

You can build the XBeeBoot bootloader to use higher baud rates; however, your mileage may vary given your configuration. I compiled a version of the bootloader at 9600, 19200, 38400, 57600, and 115200 baud and tested all of them successfully on the Arudino Uno. I didn’t build or test the bootlaoder for any other devices such as the Arudino Pro because I don’t have any other devices. Remember that you also need to configure your XBees with the appropriate baud rate.

For example, the following shows the successful wireless upload of a 20kb sketch at 115200 baud:


avrdude -CC:\Users\Brian\avrdude\etc\avrdude.conf -b 115200 -c xbee -p atmega328p -u -Uflash:w:20kbtest.ino.standard.hex:i -P0013A20040DDE8FD@COM5 
avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "20kbtest.ino.standard.hex"
avrdude.exe: writing flash (20006 bytes):

Writing | ################################################## | 100% 39.36s

avrdude.exe: 20006 bytes of flash written
avrdude.exe: verifying flash memory against 20kbtest.ino.standard.hex:
avrdude.exe: load data flash data from input file 20kbtest.ino.standard.hex:
avrdude.exe: input file 20kbtest.ino.standard.hex contains 20006 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 34.32s

avrdude.exe: verifying ...
avrdude.exe: 20006 bytes of flash verified

avrdude.exe done. Thank you.

The following table shows the actual performance times I noted to write and read 20006 bytes at the different baud rates

Bytes Baud Make Error Write (seconds) Read (seconds)
20006 9600 0.10% 133.46 133.85
20006 19200 0.10% 74.45 62.94
20006 38400 0.10% 47.3 49.89
20006 57600 0.70% 38.7 34.36
20006 115200 2.10% 39.36 34.32

The Make Error is the error reported from a baud rate calculation done at build time. If baud rate check produces more than 2% error you’ll get a warning while building the bootloader but it will still succeed:


brian@MrBurns$ make atmega328
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L -DBAUD_RATE=115200 -c -o xbeeboot.o xbeeboot.c
xbeeboot.c:305:6: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
#warning BAUD_RATE error greater than 2%
^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega328p -DF_CPU=16000000L -DBAUD_RATE=115200 -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -nostdlib -o xbeeboot_atmega328.elf xbeeboot.o -lc
avr-size xbeeboot_atmega328.elf
text data bss dec hex filename
978 0 0 978 3d2 xbeeboot_atmega328.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex xbeeboot_atmega328.elf xbeeboot_atmega328.hex
avr-objdump -h -S xbeeboot_atmega328.elf > xbeeboot_atmega328.lst
rm xbeeboot_atmega328.elf xbeeboot.o

I hope you enjoy wireless bootloading with XBees. Thanks again to David Sainty for the XBeeBoot bootloader and everyone else that has contributed to the ability to wirelessly bootload with XBees.

New computer and merit badge

With 5 kids in school and each one needing to do a class project or report as well as play games, competition for the computer has become fierce. Time to get a second one. If I really had the kids’ interests in mind I would get a laptop that they could use around the house; unfortunately, that would mean I’m stuck with an older, but still very good, desktop computer when what I really want is a smoking hot powerhouse of a new computer to play with. What do to? Build a new powerhouse for me and give the kids the old one of course!

Unpacking the new parts

Unpacking the new parts

Sam is somewhat interested in the new computer (mainly to see whether I will put any new video games on it) so I figured we might kill two birds with one stone and start working on the Computers Merit Badge as we build the new PC. We’ll update our progress here so we can document his efforts for the merit badge. Most of the parts came today although I was a dolt and forgot to order the CPU cooler so we’ll have to wait until Friday before we can really get into the build.

I’ve been going over parts lists and prices and specs for weeks now in preparation. Nancy teases me and says I’m like a kid in a candy store. I suppose that’s true. The planning and anticipation are half the fun. In fact, the planning and anticipation are 90% of the fun because, let’s face it, the actual build is only somewhat fun and installing and configuring all the software isn’t fun at all.

Beijing 2013

A couple of weeks ago I went to China with some colleagues from work. We have some developers in our China offices joining the team and we went there to meet and train them. I’ve been to Beijing a few times over the past 20 years and it’s always interesting to me how some things change and some things stay the same. Some noticeable differences between now and the first time I visited nearly 20 years ago:

  • Nearly everyone wore either the Mao suits or the padded pajama-style clothing 20 years ago. Now, nearly everyone doesn’t. I saw a few old-timers still wearing them but most people wear western clothing.
  • The roads were clogged with bicycles 20 years ago. Now they’re clogged with cars.
  • The sales-English of the vendors at all the tourist spots has improved significantly. 20 years ago a “look, look” and “handmade” were about all they could muster in Engligh. Now the purveyors of dong-xis and t-shirts and souvenir Mao watches and fake jade have significantly expanded their vocabulary to the point that I could have reasonably intelligible conversations with them. The annoyingness of their omnipresence hasn’t changed though
  • The air quality is significantly worse now than it was 20 years ago. So significant that NASA posted satellite pictures of the pollution the week I was there.

I’ve been in the bad Beijing air before so I thought I knew what I was getting into but it was surprising how bad it was the week I was there. Shockingly bad. Chokingly, coughingly, the-whole-city-smelled-like-a-campfire bad. The first night we were there we went to the Beijing Olympic Park to check things out. It was bitterly cold and there were very few people there except for a few hardy peddlers selling kites and fake Olympic medals and the like.

The "water cube"

The “water cube”

I still thought the buildings looked pretty cool through the choking fog/smog. It would have been cooler if the water-cube had been changing colors but that night it was just a static blue.

The "birds nest"

The “birds nest”

We picked one of the working days to do some sightseeing at the Great Wall and Forbidden City. After hitting those tourist spots for what is probably the 3rd or 4th time I can now understand why my Mom refuses to go there anymore after living 12 years in Beijing. Although impressive, they do tend to get boring after multiple trips. But I was a good sport and enjoyed watching my colleagues prowl around the Great Wall and Forbidden City for the first time. I mean, how can you go to China for the first time and not visit the Great Wall?

great_wall2

Wow – blue sky. A sight not often seen near Beijing in the winter.

We were lucky in that the night before our sightseeing trip a storm blew in and blew out all the polluted air. It made for a perfect day of blue skies and sunshine – a rare sight around Beijing in the winter time. At the Great Wall I couldn’t help but draw a parallel in my mind between the Chinese’s historic attempts to control their borders and the raging debates in the US over the same subject. I wondered if the US puts up a big huge wall on its southern border, will it turn out to be a big tourist attraction in the year 4013?

Yup - it's a great big wall

Yup – it’s a great big wall

My colleagues were pretty adventurous in terms of trying new foods so before driving back to the city our hosts took us to a rural restaurant where I tried donkey meat for the first time. It was actually quite tasty.

The forbidden city

The forbidden city

The air was still pretty good by the time we got to the Forbidden City but it was getting worse by the minute. The Forbidden City is as impressive as usual. They still have the same “students” doing an art exhibit and selling art to tourists as they did 20 years ago, the same folks hawking souvenir books, and the same audio self-tour (which I recommend) although Roger Moore is no longer the narrator – he’s been replaced with a nondescript female voice that. Not listening to Roger Moore was kind of a bummer. I always thought it was cool to have the voice of James Bond guide you around the forbidden city.

At the forbidden city

At the forbidden city

At the end of the day we hiked the hill behind the forbidden city and looked out as the smog and pollution of the day started to get heavier and heavier. The next day it was chokingly bad again.

Starting to get smoggy again

Starting to get smoggy again over the forbidden city

Overall it was a good trip. The Beijing developers are smart, the training went well, and they were excellent hosts. Of course what international trip would be complete without the obligatory catching of a cold bestowed upon me by a plane full of coughing people? The more things change, the more they stay the same.

Christmas Lights

This year the weather was nice so I decided to get up on the roof and do the lights. Usually I manage to wait around long enough until I can use the weather as an excuse because I’m deathly afraid of heights – even of getting up past the 3rd run on a ladder. Unfortunately the weather wouldn’t cooperate and the kids were whining at me to do it so I strapped on the old climbing harness and rope and clambered to the top.

I really, really hate being on top of the roof. I hate even worse having to lean over a bit and reach out to put the lights on the edge. I hate having to scootch slowly across the roof on my butt because I’m too scared to walk. I don’t understand how my neighbors run around on their roofs like mountain goats while I get petrified just looking down.

I told Nancy and the kids to not bug me while I was up on the roof because I had to concentrate but they managed to snap this picture:

Man, I hate doing the lights...

Man, I hate doing the lights…

Every time I get on the roof I commit myself to never doing it again. Next year, I don’t care how much it costs, I’m hiring someone to put the lights up.

2011 Pioneer Trek

I was asked by the stake to be a “big brother” for Trek this year. “What’s a big brother?”, you ask. Well, it’s basically just a helper. All the youth on trek are divided up into handcart groups with a “ma” and “pa” (husband and wife couple) and adult “big brother” for each cart. The ma and pa are in charge of the handcart and the big brother basically just helps out, which suited me just fine. I had never been on a pioneer trek before. They weren’t en vogue when I was in Young Men. You have to be 14 by the beginning of June in order to go on Trek so that meant just Emily and I were going. I found a trek-worth hat at the local ranch store and Nancy made me up some pioneer shirts to wear. Nancy kind of over-estimated my size when she made the shirt so I end up with a big billowing shirt in the Wyoming wind for 4 days but they looked fairly “pioneery” so it all worked out. Nancy also made a pioneer dress for Emily that looked great.

The trek took place somewhere out on the plains of Wyoming and Utah at a church property where they ranch cattle, sheep, and youth groups. We got there, loaded up our handcarts and set off on the hike to the first campground.

Preparing the handcarts

Preparing the handcarts

At the beginning the kids were excited to pull the handcart and we moved along at a brisk pace – everyone all bunched up together along a grassy plain. After a few hours, we left the beautiful grassy plain and hit a dusty trail. Then the excitement of the handcart wore off and the chore of watching out for cow pies and leg-breaking gopher holes became the order of the day.

Along the trail - day 1

Along the trail – day 1

Water break along the trail - day 1

Water break along the trail – day 1

Water was supplied for the whole group by a big water trailer called “the buffalo” that was towed by a truck ahead of the group to the next break or campsite. Each handcart also carried water on the cart. The buffalo water was warm and highly chlorinated though so it tasted and smelled pretty bad. Our Pa had filled up the the cooler with a huge block of ice that kept the water cold and diluted the chlorine for the first few days so I was eternally grateful for it. By day 3 the ice was gone though so we were stuck with warm chlorine buffalo water.

Along the trail - day 1

Along the trail – day 1

Pioneer girls along the trail - day 1

Pioneer girls along the trail – day 1

Spread out along the trail - day 1

Spread out along the trail – day 1

For the most part we followed along a dusty dirt road that crossed over streams via culverts but on the first day we came to a little ditch that had water that we got to cross. It was fun to watch everyone try and figure out the best way to get the carts across the ditch.

Crossing the stream - day 1

Crossing the stream – day 1

There were two strategies – go fast through the ditch with momentum so you could get up the other side easier or go slow through the ditch to minimize splashing. We took the fast approach with our cart and it worked out well. Some guys carried the girls across the stream on their backs, some people took of their shoes and socks and waded across and some people just trudged through it and got their boots wet.

Crossing the stream - day 1

Crossing the stream – day 1

I suppose for the true pioneers the fun of crossing streams with handcarts soon wore off; especially once the weather got cold. Still, for us it was a fun little experience and everyone had a good time splashing around in the water.

For some must push and some must pull - day 1

For some must push and some must pull – day 1

Most of the handcart groups slept under their cart the first night. They tilted the cart up in the air and then hung a tarp from the cart to make a big type of tent – it looked like a nomad tent. The big brothers didn’t sleep with the youth or the mas and pas – we had our own tents. In some cases, the kids didn’t even bother with hanging tarps on the handcarts but just slept right out in the open on a tarp laid on the ground.

Emily preparing to sleep under the stars - day 1

Emily preparing to sleep under the stars – day 1

We weren’t allowed to have open fires for cooking but we did have “cooking platforms” which were foiled covered boards that we could put coals on and cook with a dutch oven. I’m never so hungry as I am when out camping. I’m not sure why but for some reason food always tastes great when you’re on a campout.

Cooking dinner - day 1

Cooking dinner – day 1

The next evening turned out to be freezing cold with strong winds and rain that turned to sleet. They broke out some big propane heaters, set up tents for everyone (they had brought the tents along just in case it was too cold to sleep under the stars), and basically everyone just focused on keeping warm and trying to get a little sleep as the winds blew during the night.

Warming by the fire - day 2

Warming by the fire – day 2

A cold night - day 2

A cold night – day 2

Day three turned out to be hot and dusty. Each morning various handcart groups had to do chores like cleaning out the porta-potties, making sure the camp was clean, helping load and unload the food trucks, etc. The porta-potties were all on a big trailer that was pulled ahead to the next break site and campsite each day, along with a big refrigerated truck that had the food for the trip, and the aforementioned buffalo. Before we could set out on the trail each morning we had to make sure that the potty truck and the other support vehicles had passed on ahead of us.

Waiting for the potty trucks - day 3

Waiting for the potty trucks – day 3

Rocking the cool pioneer shirt - day 3

Rocking the cool pioneer shirt – day 3

Day three was the day for the women’s pull. I guess the theory is that some pioneer women had to pull their handcarts all by themselves, or with their kids, because their husbands had died or were otherwise unavailable. The women’s pull was supposed to give the women a taste of what it would be like to have to cross the plains by themselves. All the men lined up along the hill and watched as the women huffed and puffed and pushed and pulled the handcarts up the hill. It was hard enough pulling them up hills with all the men and boys helping out so it certainly was a difficult task for the women to pull them up by themselves.

Women's pull - day 3

Waiting for the women to come up the hill – day 3

Women's pull - day 3

Women’s pull – day 3

As we watched the women pull the carts up the hill, the first instinct was to want to jump in and help them but we weren’t allowed to. We had to just watch in silence as they struggled up the hill. It certainly gave me an appreciation for how hard the pioneer women worked to cross the plains.

Taking a break - day 3

Taking a break after the women’s pull – day 3

My handcart family - day 3

My handcart family – day 3

Spaced out on the trail - day 3

Spaced out on the trail – day 3

Day four was a short trip in the morning from the campsite to the end of the trail where we unloaded the carts and loaded everyone into busses for the trip home. It was a fun trek and I’m glad I went. I got to know some of the youth in the stake and although camping and handcart pulling isn’t my favorite thing I was able to gain an appreciation for the work and sacrifice of the early pioneers. Both Anne and Caroline will be old enough to go in 2015 when the next trek is scheduled so perhaps I’ll get another opportunity to go again. I’ll be fine as long as there isn’t a “men’s pull” up that same steep hill.

January Birthdays

Caroline and Dad's Birthday

Caroline and Dad’s Birthday

Unfortunately for Caroline, it wasn’t her turn for a friend party this year so she had to share her birthday party with me. I guess that’s just the price you pay when your birthday is a day after your dads. On the plus side, you get to have two different kinds of cake!

My Startup Adventure

While life at Dataimage was good, I started to feel a bit stagnant and, although I hadn’t finished my Masters degree yet, decided to jump at the opportunity when a couple of former colleagues told me about a startup they were working at. I’ve worked for big companies and small companies and startups in the past. In fact, this was my third time at a startup. Although in some respects software development is the same no matter where you work, the different types of companies all have their own interesting mix of challenges and rewards.

As a startup, we moved offices three times in one year due to growth, expiring leases and the like. While we were still waiting around for some office furniture I snapped this photo of the temporary desk I rigged up from a table missing a leg and a stack of unused chairs.

Reachable1

Truly a desk fit for a startup

That’s life at a startup – prop up a table and keep on coding.

I also had the opportunity to represent the company at a trade show. On second thought, opportunity isn’t the best word because I really detest trade shows. I detest them when I’m a guest, walking my way through endless booths looking searching for an interesting product or vendor, and I detest them as an exhibitor, telling the same story over and over again and trying to be positive and upbeat while my feet are killing me and the guy in the booth next door with the loud microphone is blaring endlessly throughout the day. Never again will I underestimate how tough it is to be a “booth babe”.

Reachable2

The view from the booth

If I never have to go to another trade show in my life it won’t be soon enough. Aside from my stint as the designated tech geek in the booth, I’m currently enjoying the challenges of working at a fast-paced startup.

September 2011 Update: After a year at the startup I finally completed my Masters Degree and decided to accept a management opportunity with Adobe Systems.

New Office Cabinets

A couple of months ago we decided to finish our basement. Brian thought that it would also be a great time to get cabinets put in his office. Today was the day that they got put in. Even though there are a few more touch ups to be done on them, I think they turned out really nice.

The Cadet Chapel

This weekend I was in Colorado Springs on a business trip. We had some free time on Sunday and decided to go up to the Air Force Academy (about 5 minutes away from the hotel). I was worried that they might not let us in but there was a big sign on the freeway that said “Air Force Academy Visitor’s Center” and that it was open. When we drove up to the gates the sign said it was FPCON Alpha (Force Protection Condition Alpha). I’m not sure what FPCON Alpha meant but I guess it meant they were supposed to check my driver’s license and look in the trunk of the car because that is what they did. After a brief moment of me figuring out how to open the trunk on the rental car we were on our way to the Academy. We passed a big B-52 bomber and saw several other planes displayed on the campus. I thought they were pretty cool but the guy I was with informed me that the Hill Air Force Base Museum had cooler planes.

cadetchapel1.png
Cadet Chapel

The Air Force Academy has a visitors center where you watch a 10 minute movie on what it’s like to be a cadet (too tough for me) and then you can check out the cockpit of a jet, buy Air Force Falcon’s gear, check out the various kinds of uniforms, and read all about the founding of the Academy and its glorious history. You can then take a little walk through the woods to the Cadet Chapel.

cadetchapel2.png
Protestant Chapel Organ

The Cadet Chapel is a very impressive building and probably the signature building of the Academy (every other building looks like a 1970s college dorm). The chapel has two main chapels – one upstairs for the Protestants (the biggest one) and one downstairs for the Catholics. There is also a Jewish room and several rooms for those that fall in the “other” category.

cadetchapel3.png
Front of the Protestant Chapel

I thought the coolest thing about the Protestant chapel was the organ at the back. Supposedly they can hold services in both the Catholic and Protestant chapels simultaneously without disturbing each other but I wondered if they Catholics could hear the Protestants organ coming from upstairs. The second coolest thing was the height of the chapel and the stained glass and lights. We tried to go into the Jewish section but it was locked.

cadetchapel4.png
Catholic Chapel

The Air Force Academy is a beautiful place. I’m not sure I would want my kids to go there but I have only respect for the cadets do go and eventually become officers. When I called Nancy that evening she mentioned that the kids were worried about the fact that I didn’t go to church that day. I was pleased to inform her that I did indeed go to church – it just wasn’t an LDS church.

Executive Secretary

Today I was sustained as the Executive Secretary. Although I don’t think this calling will be terribly difficult, it will definitely be time consuming. I started off my first week with a bang – I didn’t get home until 3:45 from 9:00 a.m. church. Of course, it could be worse. The Bishop was at Stake Priesthood Meeting this morning at 7:00 a.m., had Bishopric meeting at 8:00 a.m., was with me at the church until 3:30 and was leaving for a stake meeting when I went home.

I definitely think I’ll need to prioritize the things I spend my time on. That means less computer games and less TV. Thus, I actually think it will be good for me.