-
Notifications
You must be signed in to change notification settings - Fork 1
TinyG Boot Loader
Huge thanks to Kevin Osborn who got this working
Topics:
- How Do I Know if I Have the Bootloader?
- Updating TinyG Firmware using the Boot Loader
- Flashing the Boot Loader onto the Xmega Chip
- Project Setup and Compiling the Boot Loader for TinyG
TinyG's shipped from March 10, 2013 have a boot loader that supports flashing the TinyG firmware using AVRdude (aka the AVR109 protocol). You can tell if you have the boot loader if the Spindle Direction LED flashes 10 times when you hit reset.
If the LED doesn't flash you don't have the bootloader. See Flashing the Boot Loader onto the Xmega Chip if you want do do this yourself. You can also return your board to us and we'll do it. Contact us if you want us to put the bootloader onto your board.
To update the TinyG firmware run avrdude from a directory that has the tinyg.hex file you want to load.
Step1. Navigate to the directory that has the tinyg.hex file you want.
Step2. Find your serial port. You will need to enter the USB port you are actually using. To find your serial port in Mac/Linux you can run ls /dev and look for the tty.usbserial-XXXXXXX port
Step3. Enter the boot loader and flash the chip using Avrdude. Use the Avrdude distributed with the Arduino - it's pretty up to date. You can enter the bootloader any of the following ways:
- Hit reset on the board
- Send a
^x(control X) to the board (software reset) - Send an
ESCto the board - Send the command
$boot=1 - Send the JSON command `{"boot":1}
Next you need to enter the avrdude command before the LED stops blinking. It currently blinks 10 times, or about 3 seconds.
Here's an example command line from Windows:
avrdude -p x192a3 -c avr109 -b 115200 -P COM19 -U flash:w:tinyg.hex
Here's an example command line from Mac:
avrdude -p x192a3 -c avr109 -b 115200 -P /dev/tty.usbserial-AE01DWZS -U flash:w:tinyg.hex
You should see the following dialog if the loader works correctly
The following instructions are how to flash the boot loader using Atmel Studio6. AVRStudio4 is similar, as would be command-line operation. These instructions use the xboot.hex file already in the project. You can get the xboot.hex file here. xboot.hex NOTE: You need to right click and save as on the xboot.hex link to download the hex file correctly. If you want to compile go to the next section: Project Setup and Compiling the Boot Loader for TinyG
Step 1. Get the right programmer. The xmega requires PDI programming. Use the Atmel AVRISP mkii or some other programmer that supports PDI programming. Plug the programmer into TinyG and apply power to TinyG.
Step 2. Bring up Studio6 and the device programming panel. Look under Tools / Device Programming
- In the programming panel verify Tool is AVRISP mkii, the device is ATxmega192A3 and the interface is PDI. Hit
Apply, thenRead. You should see the Device signature and voltage field populate. Voltage should be 3.2v or thereabouts.
Step 3. Set the fuses. Go to Fuses and set the following
- set BOOTRST to BOOTLDR
Other values should be left alone. These are:
- JTAGUSERID = 0xFF
- WDWP = 8clk
- WDP = 8clk
- DVSDON = (unchecked)
- BODPD = disabled
- RSTDISBL = (unchecked) Don't check this - you will brick the board
- SUT = 0ms
- WDLOCK = (unchecked)
- JTAGEN = (CHECKED) Don't uncheck this, you will brick the board
- BODACT = disabled
- EESAVE = (unchecked)
- BODLVL = 1v6
Hit Program to program the fuses
Step 4. Go to Memories. Select xboot.hex in the Flash section. Do not use xboot-boot.hex as it's org'ed in the wrong place (0 instead of 0x30000). Check the Erase Flash Before programming box or it won't verify. Hit Program.
[put screen capture of device programming here]
Step 5. Do this step if you aslo want to program TinyG onto the chip. Select tinyg.hex in the Flash section. Uncheck the Erase Flash Before programming box. Hit Program.
If this all worked you will see the Spindle Direction light flash for about 3 seconds then TinyG will deliver its startup messages.
Use these instructions if you want to change the xboot.hex file. If all you want to do is flash it onto TinyG see the previous section.
The boot loader is Alex Forencich's xboot which can be found in the xboot directory in the main TinyG git tree. This xboot has the settings and modifications for use on TinyG. (You can safely ignore the xmega_boot directory.)
Bring up a cmd window and navigate to the working directory. Run the command:
make conf/x192a3.conf.mk
Step 1. The command line you need is:
make conf\x192a3.conf.mk
But beware - it only works in windows. Use cmd and navigate to the (lower) xboot directory something like:
Z:\Username\Projects\...\TinyG\xboot\xboot\make conf\x192a3.conf.mk
It enters an infinite loop in Linux and generates this error in OSX
macintosh-3:xboot your-user-dir$ make conf\x192a3.conf.mk .dep/fifo.o.d:1: *** multiple target patterns. Stop. macintosh-3:xboot your-user-dir$
We have not diagnosed or fixed this yet, but are working on getting it to compile under Atmel Studio6 (below).
You should now be ready to flash xboot.hex onto the xmega192. Refer to the Flashing... section, above.
Xboot has been set up as an AVRStudio4 project (Windows only). use the xboot.aps project file.
You can either use the native makefile or have AS4 auto generate a makefile. The auto-generated option allows you to use the AVR simulator to debug - otherwise there is no functional difference.
To use the native makefile check Use External Makefile in Project / Configuration Options.
Running the external make from AS4 does not create the config.h file. Manually run make conf/x192a3.conf.mk from a windows command line. You will have to do this initially and each time you change x192a3.conf.mk.
You want to use the xboot.hex in the xboot working directory.
To use the auto-generated makefile do the following:
- Generate config.h by running
make conf/x192a3.conf.mkfrom a windows command line (as above). You will have to do this initially and each time you change x192a3.conf.mk. - Setup the xboot project configuration in
Project \ Configuration Options
in the General section: uncheck `Use External Makefile` frequency = 32000000 (32 Mhz) optimization = -Os
add the following to Custom Options, [All files]: -DUSE_CONFIG_H -ffunction-sections -fdata-sections
add the following to Custom Options, [Linker Options]: -Wl,--section-start=.text=0x030000 -Wl,-Map=xboot.map,--cref -Wl,--gc-sections
You will want to use the xboot.hex file found in the default directory
Note: this isn't working yet. Xboot seems to only compile under the AVRGCC (WinAVR 20100110) 4.3.3. Studio 6 runs the AVR_8_bit_GNU_Toolchain_3.4.0_663 (4.6.2). For some reason the newer version doesn't work - it fails during EEPROM write. Check back later for updates
But if you want to try this do the following:
The project files are the xboot.atsln and xboot.cproj files in the github TinyG/support dir. Move these to your project directory then click on xboot.atsln to start the project up.
This project uses the Studio6 auto-generated makefile in the Debug directory instead of the native xboot Makefile in the working directory. This is so the debugger can support symbolic debugging. The following need to be done for this to work.
- You must generate config.h by running
make conf/x192a3.conf.mk. If the conf file changes you must run this again to refresh config.h - Setup the xboot project properties:
in Build Events / post-build event: avr-objcopy -O ihex --change-addresses -0x30000 xboot.hex xboot-boot.hex avr-nm -n xboot.elf > xboot.sym
in Symbols: F_CPU=32000000L USE_CONFIG_H
in Optimization: -Os
in Miscellaneous -I. -gdwarf-2 -std=gnu99 -ffunction-sections -fdata-sections -fno-jump-tables -Wa,-adhlns=flash.lst -Wstrict-prototypes -- alternately -- -I. -gdwarf-2 -std=gnu99 -ffunction-sections -fdata-sections -fno-jump-tables -Wa,-adhlns=flash.lst -Wstrict-prototypes
in Linker/Memory Settings: .text=0x18000 (yes, it's 0x30000 divided by 2)
Still to do:
- Find a way to pre-process the config.h file
