Catching the xboot "enter bootloader" command

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Xboot bootloader requires the ESC character (0x1B) before receiving the 'S' character from the 'avr109 virtual programmer' within avrdude to initiate programming.  If one wants to initiate programming via UART from main application code, then the main application code needs to 'catch' the 0x1B character - which is the first character sent out by avrdude.  Once this character is captured by the main application, the main application executes code which causes a software reset.  The device then restarts in the boot-loader (this is a fuse setting).

 

The issue I am having is that once the xboot boot-loader starts, it is waiting for the ESC character first in order to enter programming mode, but this character has already been received (and read) in the main application code.  So the bootloader's first received character is the 'S' character (sent from avrdude) which is not sufficient to initiate programming mode, and therefore avrdude hangs, waiting for a response from the bootloader.

 

A few questions : 

 

a)  Does a software reset clear the received byte in the USART?

 

b)  Does reading a received byte in the USART, clear it automatically?

 

c) Any suggestion on howto solve this issue?

 

Thank you

This topic has a solution.
Last Edited: Thu. May 31, 2018 - 06:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

A reset, software initiated or otherwise, sets the bits in most registers to zero.  That includes the USART DATA register.

 

It seems you need another PC program, maybe a terminal emulator, to send the magic code to the application that causes it to invoke the bootloader.

 

 

From the AU manual:

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you.. I wrote this little bash script in ubuntu to solve the issue :

 

#!/bin/bash

 

echo -ne "\x1b" > /dev/ttyUSB0

sleep 0.4

avrdude -p atxmega32e5 -P /dev/ttyUSB0 -c avr109 -b 57600 -e -U flash:w:232.hex

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah.  I should have thought of that.