Mein Server!

Wowza. The 091223 LUFA release has had around 1100 downloads, nearly causing my server to go into conniptions. That’s easily more than double the number of releases of previous releases, and I’m pleased as punch with the increased uptake. I’m dying however to get a new release out with the major fixes to the AVRISP-MKII project code and other demos, but I want to complete TPI protocol support in the AVRISP-MKII project first. Thankfully it looks like I’ll have that working very soon, so we can all look forward to the next official release. I’m planning to have it enter a two week beta testing cycle (with the increased user-base, it is now more important to ensure each release is as free of defects as possible) beginning late this week.

I thought I’d fill up this entry with a short guide to loading my XPLAIN Bridge firmware into the XPLAIN board, after some coaxing. Without further ado, here it is!

Loading the XPLAIN Bridge code into the XPLAIN board

Step 1: Get the Source

Before you begin, you will need a fresh copy of the latest XPLAINBridge code. This is part of my LUFA project, however you will need the most recent in-development code instead of the latest LUFA release. Start by downloading a zipped package of all the latest LUFA code, straight from my online source repositories.

Extract out the entire package somewhere on your hard drive – a path without spaces is best (such as C:\AVR\LUFA_SRC\).

Step 2: Get the AVR-GCC Compiler and Tools

Most people should already have the required tools installed for AVR development, but I’ll put it here for completeness. On Windows, look no further than the WinAVR package – just download, install and you’re done. On Linux, grab the “avrgcc” package from your repositories. This will install the required compiler which can compile your source code into machine code that can be loaded into the AVR microcontrollers on the XPLAIN.

The other tool you’ll need is the Atmel FLIP software, which will act as our programming frontend for the USB AVR later on. Download and install it – if you are on an x64 based system, you’ll need these signed drivers instead.

Step 3: Build the Source

LUFA is a big project. No seriously, it’s HUGE and I’ve spent a lot of time on it. While it can make the USB AVR on the XPLAIN board to wondrous things with a minimum amount of pain, we’re only interested in one small project I’ve made with it. For that reason, you’ll need to navigate to the {LUFA Root Directory}/Projects/XPLAINBridge/ folder before you compile, lest you sit around for 10 minutes watching around 100,000 lines of source code be compiled.

Once in the XPLAINBridge project, you need to open up your terminal (that’s Command Prompt in Windows-land) and type make all. This will compile the XPLAINBridge code into the machine code needed for the AVR processor to execute.

When run, you’ll see a lot of similarly named files with different extensions be created. Most of these are related to the compiling itself, and we are only interested in the XPLAINBridge.hex file that is created – that’s the file which contains the compiled machine code for our programmer software to use.

Step 4: GET TO THE BOOTLOAAWDERRR!! (this is funny if you read it in an Arnold Schwarzenegger voice)

Unless you’re unlucky enough to have a first revision XPLAIN board (which 99.99% of you will not) your XPLAIN’s USB AVR comes preloaded with a special AVR program in it called a bootloader. This special program lives in the upper sections of the chip’s non-volatile FLASH memory, and allows you to reprogram the remainder of the memory with a regular AVR application through a non-standard interface (in this case directly from the USB port) without external hardware.

To get to the bootloader, you need to jumper the TCK pin to GND on the USB AVR JTAG header, that is, pins one and two shown here:

Jumper the circled pins to enter the bootloader.

When jumpered, plugging in the XPLAIN to a PC via the USB port will cause it to start it’s DFU class bootloader. You should get a driver popup under Windows – point it to {FLIP Install Directory}/usb for x86 systems, or to the drivers in the signed driver package you downloaded earlier for x64 systems. If this does not happen, you may need to apply power to the board and momentarily jumper pins 6 and 10 as well to force a reset of the USB AVR.

Step 4: Program the USB AVR

After you have started FLIP, you should see a screen similar to the one below (click to enlarge).

The FLIP Interface.

First click the Select Target button (#1). From the dropdown, choose the AT90USB1287 entry (this is the USB AVR mounted on the XPLAIN board) and click OK to dismiss the window. Next, open the device via the Select Communication Medium button (#2) and choosing USB – click OK when the dialog opens up to establish a connection with your XPLAIN’s USB AVR.

Now you need to load the XPLAINBridge firmware into FLIP. To do this, click the Load HEX File button (#3) and select the XPLAINBridge.hex file you compiled earlier in step 3. Program it into the USB AVR by hitting the Run button (#4). Remove the jumper you placed earlier to access the DFU bootloader, then start the new firmware via the Start Application button (5). Don’t worry if you forget to remove the jumper before this step – just remove it and power cycle the board to exit the bootloader.

Step 5: Load the Bridge Drivers

By now, you should see a new driver window pop up, asking for the LUFA XPLAIN Bridge drivers. You’ve now successfully programmed in the bridge firmware! In the mode you are currently seeing, the firmware is acting as a USB-to-Serial bridge for the XMEGA AVR on the XPLAIN board. Before it will work correctly however, we need to supply the right drivers. In actual fact, Windows already contains the appropriate drivers, but you’ll need to supply the XPLAIN Bridge.inf file in the {LUFA Root Directory}/Projects/XPLAINBridge/ folder for it to use them. This will probably pop up an unsigned driver warning on your system — this is Microsoft’s fault (and not mine!) for not signing their own driver.

When loaded, you’ll be able to communicate with your XMEGA chip by the new virtual COM port the driver will create on your system.

Step 6: Load the PDI Programmer Drivers

The XPLAINBridge firmware contains a second mode – it can act as a clone of an Atmel AVRISP-MKII so that you can reprogram the XMEGA from within AVRStudio. To access this mode, you’ll need to jumper the TDI and GND pins of the USB AVR JTAG connector (pins 9 and 10) together and power-cycle the board, much like you did to enter the DFU bootloader:

Jumper the circled pins to switch to the programmer mode.

This should cause Windows to ask for a second set of drivers, for the new AVRISP-MKII Clone Programmer device. Point it to your {Atmel Program Files Folder}/AVR Tools/usb/ folder (for x86 systems) or {Atmel Program Files Folder}/AVR Tools/usb64/ folder (for x64 systems) and let it install Atmel’s drivers. You’ve now got yourself a programmer! To exit programming mode and return to the USB-to-Serial bridge mode, just remove the jumper you placed on the JTAG port and power cycle the board.

Step 7: Program the XMEGA AVR

When in programmer mode, you can reprogram the XPLAIN’s onboard ATXMEGA128A1 microcontroller via the PDI protocol, using any supported host software you like, such as AVRDude (note: PDI programming is broken in the latest release and requires manual patching) or Atmel’s own AVRStudio. For AVRStudio, you can follow the procedure in the AVR Tools help file, included with the application – just connect to the AVRISP MKII programmer, select the ATXMEGA128A1 target and use it like you would a regular AVRISP-MKII device.


Comments: 133

Leave a reply »


Hi Dean,
sorry if this has been asked before, but i’m still struggling with the differences of XPLAIN vs. XPLAINED and the various Atmel XMega boards. So here goes: is this Software usable in an XMega256A3BU board as a replacement for the FLIP/bootloader combo to program this board? In other words: is this software supported to be used on that board, which would then be recognized as a AVRISPmkII programmer by AVRstudio (V4/5/6)?


No. This firmware was designed to replace the original firmware in the secondary AVR processor of the original green XPLAIN board, which served as an interface between the non-USB XMEGA AVR and the host PC. Newer “Xplained” series boards either have native USB on the primary AVR, or come with a 32-bit UC3B device as the secondary board controller, which this firmware is incompatible with. For the A3BU, you need an alternative bootloader, not this firmware, if you want a different way of programming it without using an external programmer/debugger all the time.

– Dean

Per-Tore Aasestrand


I am not able to get the card into the bootloader.
On the back side of the card it says:


Atmel Corp 2009

A08-0551, Rev 2

Could it be it is a version without the bootloader?




I can’t say for certain, but I guess it’s possible (since I don’t know the release history of the board firmware). Did you try shorting the required pin to ground, them pulsing the /RESET line momentarily with the board plugged in?

– Dean

Per-Tore Aasestrand

Yes, I’ve tried that.
No success.

Would it be possible to load the SW with bootloader with AVR Studio and AVR ISP Mk II ?


You might be out of luck — you have to use a JTAG interface to reprogram the AT90USB1287 on the board, since only the JTAG lines are exposed and not the ISP lines I’m afraid. If you don’t have a STK600, Dragon, JTAG-ICE MKII or JTAG-ICE3 lying around try posting on, as there might be a member close enough to you flash it on for you with their own tools. Alternatively I can do it for you, but I don’t think the time and postage costs to/from Norway would be worth it.

– Dean

Per-Tore Aasestrand

Hi Dean,

I think I should have an old JTAG laying around somewhere…

If I find it, I’ll give it a try.

If not, I’m also in Norway, so I could just send it to you.


Per-Tore Aasestrand

Hi again,

Found the old JTAG, but is not able to get it to work.


What model JTAG is it? If it’s a JTAG-ICE MKI (gray box) it won’t be able to program the AT90USB1287, you need a JTAG-ICE MKII or later, or a Dragon.

One other option is that you can connect your AVRISP-MKII to the board and program the XMEGA that way, rather than trying to program the board controller. That will work just fine, although you would then need to attach the external programmer every time you want to change the XMEGA firmware, unless you load a serial bootloader into the XMEGA device and use AVRDUDE for programming instead.

Where in Norway are you? I’m happy to reprogram it for you if you really want the board controller running as an embedded programmer.

– Dean

Per-Tore Aasestrand

Hi Dean,

It is not an original Atmel JTAG, but it should be compatible with AVR Studio.

I am in Bergen.

What would you say is the pros & cons for doing this FW change/upgrade?




The pro would be that you can easily reprogram the XMEGA directly from Atmel Studio, using just a switch on one of the board’s pin headers to switch between programming and USB to Serial passthrough modes. There isn’t really a downside – but if you have an external AVRISP-MKII that will work just as well without modifying the board controller firmware. For me it was partly about convenience and partly to lower the entry point cost to use the board (to remove the additional cost of an external programmer, making the boards ideal for students in the classroom) but whether it’s worth it to you is your call. There isn’t really a con, the new firmware just adds programming support to what the original board controller firmware could do.

– Dean

Per-Tore Aasestrand

Hi Dean,

Thanks for your response.

Since I do have an original AVRISP MkII, I guess I could just as well use that one. However, how do I connect it??

I can only find JTAG connectors. My board is the green one.


See “PDI” on this page:

You need to connect GND and VCC on the AVRISP-MKII pins listed above to the GND and V3P3 pins of the “JTAG/PDI XMEGA” header to the right of the large SRAM chip. Connect DATA on the AVRISP-MKII to DATA on the same header, and connect the AVRISP-MKII’s PDI CLOCK line to RESET on the same header.

– Dean

Per-Tore Aasestrand

OK, thanks, will give it a try.


Per-Tore Aasestrand

Hi again,

Thanks a lot for your help and patience!

All the best,



Hi Dean,

Thanks for the wonderful work!

I’ve been trying to get the XPLAIN work with avrdude for quite some time and I think the XPLAINbridge_AVRDUDE.hex file may be broken. I’m using the latest WinAVR-20100110 with avrdude 5.10 and kept receiving:

avrdude: stk500v2_recv_mk2: error in USB receive

I found an old post from 2010 on avrfreaks ( with a different XPLAINBridge.hex you built and it works great now.

I’m not sure if I did something incorrectly with the current version of XPLAINBridge_AVRDUDE.hex file but just wanted to let you know.

Thanks again for your efforts! Now I can finally play around with xmegaduino 😀


Hi Danny,

Darn, that sounds like I accidentally overwrote both versions with the Jungo driver (Atmel Studio) compatibility version. I’ve updated both builds with new ones from the latest SVN revision, can you please test these on your board?

– Dean



Will this tutorial also work for XMEGA-A1 Xplained board with atxmega128A1 ?



No, it covers the original green XPLAIN board only. The newer XPLAINED series boards have a board controller that uses a UC3 rather than an AVR8, and the LUFA Xplain Bridge firmware has not been ported to it.

– Dean


I read the text file in your explained bridge directory, it’s only supported avr is at90usb1287. can i use other usb avr like atmega8u2,


Hi Justin,

The XPLAINBridge project is for the original Atmel XPLAIN board, which only had a AT90USB1287 co-processor (so support for other processors wouldn’t make sense). However, the code is based on my LUFA stack, which supports the whole 8-bit AVR8 series USB devices, so you can port over the functions you need (or base your project on one of the many demos included with the stack).

– Dean


my original green XPLAIN board has worked very well with AVRStudio 6.2, now I have installing AVRStudio 7 and unfortunately it does not work ;-(.
AVRStudio 7 recognizes tool AVRISPmkII but when I click on the button “Apply” then comes an error message “Unable to connect to tool AVRISP mkII (000200212345)”

Does anyone know a solution?


Are you using a libUSB Win32 driver (filter or otherwise) with the XPLAIN board? Newer versions of the Atmel Studio backend will try to bind to libUSB devices that have a recognized VID and PID, but won’t actually be able to talk to them properly. Make sure you’re using the Jungo driver (and if so, reinstall the driver from the Atmel Studio 7 folder).

– Dean


No, I not use libUSB, I use the Jungo driver with your Firmware “XPLAINBridge_AS.hex”, with Studio 6.2 has worked very well. In Control center I see it as “Jungo-> AVRISPmkII”


so, I download an installing the USB drivers from Atmel (Atmel USB Installer) but nothing has changed.
Error is the same “Unable to connect to tool AVRISP mkII”
Details: Could not establish communication with the tool.


Okiedokie, looks like I need to dig out my old XPLAIN board then. Did you recompile the firmware yourself or did you use my prebuilt one from my site? I may have forgotten to recompile in some fixes I did for compatibility a while back.

– Dean


No ;-( , i use your prebuilt from your site, I see is Built on November 23, 2013 !


Hrm, that should be OK, but I’ve rebuilt it anyway for you. Try – if that doesn’t work I’ll have to troubleshoot on my end.

– Dean


Thank you Dean, unfortunately does not work ;-(


Uh oh, you’re right, I can replicate it here now. I’ll see what I can dig up – I think I remember someone posting a patch for a similar issue a couple of months ago.

– Dean


The last Firmware (from today) does not work too with AStudio 4.9 (I have parallel yet).
The prebuilt Firmware from November 23, 2013 from your site work fine with Studio 4.9 and 6.2 (parallel)


Might be the reported firmware version bump.

There’s definitely a communications issue with AS7 – I’ve made a bug tracker entry for it while I investigate. Unfortunately it looks like my USB hackery to be compatible with the endpoint layout of the Jungo driver is finally starting to really break.

– Dean


I thank you.


Leave a Reply

(will not be published)


Vital Stats

  • 35 Years Old
  • Australian
  • Lover of embedded systems
  • Firmware engineer
  • Self-Proclaimed Geek

Latest Blog Posts