[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Autogenerated files

Autogenerated files are virtual read-only files that do not exist externally but that are provided by AVRDUDE instead. They have the form prefix:parameters and can be used to write the contents of memory. The prefix tells AVRDUDE which sort of file to generate while the part after the colon is usually an underscore-separated list of parameters that determines the contents of the autogenerated file.

Currently, the only autogenerated files are urboot bootloaders from the https://github.com/stefanrueger/urboot project. They take the form urboot:features. Bootloader features are specified using an underscore-separated list in arbitrary order, eg, urboot:autobaud_2s. For a complete list of possible features see below. The following example writes a suitable autobaud bootloader to the flash of an ATmega328P target:

 
$ avrdude -c dryrun -p m328p -U urboot:autobaud
Reading 260 bytes for flash from input file urboot:autobaud
Writing 260 bytes to flash
Writing | ################################################## | 100% 0.00 s
Reading | ################################################## | 100% 0.00 s
260 bytes of flash verified
Setting fuses for bootloader urboot:autobaud

Avrdude done.  Thank you.

Autogenerated bootloaders can be used in the terminal as well:

 
$ avrdude -c dryrun -p m328p -t
avrdude> write flash urboot:autobaud
Caching | ################################################## | 100% 0.00 s

avrdude> quit
Synching cache to device ...
Writing | ################################################## | 100% 0.00 s

Avrdude done.  Thank you.

Note that using urboot:... in -U options has the desired side effect of also setting all necessary fuse configurations for the bootloader to work correctly. This does not happen when using the terminal write command, where the necessary fuse configurations need to be requested manually.

The terminal mode is great for exploring possible bootloaders interactively:

 
$ avrdude -c dryrun -p m328p -t
avrdude> write flash urboot:autobaud_list
   Selection Size Use Vers Features  Type               Canonical file name
         _pr *256 256 u8.0 w---jPra- vector/spmready    urboot_m328p_1s_autobaud_u...
   _ee_ce_pr *378 384 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_u...
   _ee_u4_pr  372 384 u8.0 weU-jPra- vector/spmready    urboot_m328p_1s_autobaud_u...
   _ce_u4_pr  362 384 u8.0 w-U-jPrac vector/spmready    urboot_m328p_1s_autobaud_u...
      _u4_pr  316 384 u8.0 w-U-jPra- vector/spmready    urboot_m328p_1s_autobaud_u...
_ee_ce_u4_hw *400 512 u8.0 weU-hprac hardware-supported urboot_m328p_1s_autobaud_u...
_ee_ce_u4_pr  414 512 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_u...
   _ee_u4_hw  354 512 u8.0 weU-hpra- hardware-supported urboot_m328p_1s_autobaud_u...

The list feature does not generate the bootloader code but instead interactively lists possible selections. In above example, the last column is cut off for space reasons. Using successively ee (provide a bootloader with EEPROM r/w capability), ce (add chip erase emulation code to the generated bootloader) and u4 (generate code skipping all redundant flash page writes and page erases to wear out the flash memory less and speed up the bootloading process) will then iteratively reduce the available selection:

 
avrdude> write flash urboot:autobaud_list_ee
Selection Size Use Vers Features  Type               Canonical file name
   _ce_pr *378 384 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_uart...
   _u4_pr  372 384 u8.0 weU-jPra- vector/spmready    urboot_m328p_1s_autobaud_uart...
_ce_u4_hw *400 512 u8.0 weU-hprac hardware-supported urboot_m328p_1s_autobaud_uart...
_ce_u4_pr  414 512 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_uart...
   _u4_hw  354 512 u8.0 weU-hpra- hardware-supported urboot_m328p_1s_autobaud_uart...

avrdude> write flash urboot:autobaud_list_ee_ce
Select Size Use Vers Features  Type               Canonical file name
   _pr *378 384 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_uart0_r...
_u4_hw *400 512 u8.0 weU-hprac hardware-supported urboot_m328p_1s_autobaud_uart0_r...
_u4_pr  414 512 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_uart0_r...

avrdude> write flash urboot:autobaud_list_ee_ce_u4
Sel Size Use Vers Features  Type               Canonical file name
_hw *400 512 u8.0 weU-hprac hardware-supported urboot_m328p_1s_autobaud_uart0_rxd0...
_pr  414 512 u8.0 weU-jPrac vector/spmready    urboot_m328p_1s_autobaud_uart0_rxd0...

In all lists the starred bootloaders are those that are the most feature-rich given the available used flash space, which — out of necessity — must be a multiple of flash pages or minimal boot section. These can be selected with the best feature. The show feature displays the properties of the bootloader that would be written without actually writing it; removing show will then write the bootloader to flash and, using -U, also set the necessary fuses:

 
$ avrdude -qq -c dryrun -p m328p -U urboot:autobaud_show_best_ee
378 384 u8.0 weU-jPrac vector/spmready urboot_m328p_1s_autobaud_uart0_rxd0_txd1_no...

$ avrdude -qq -c dryrun -p m328p -U urboot:autobaud_best_ee && echo OK
OK

Like the urboot project AVRDUDE currently only provides bootloaders for classic parts. The following table lists possible features.

2sWDT timeout: 250ms, 500ms, 1s (default), 2s, 4s or 8s (*0)
autobaudBootloader adapts to host baud rate within MCU capability (*1)
uart<n>Hardware UART number, eg, uart0 (default), uart1, ...
alt<n>Alternative UART I/O lines (*2)
9.6kbaudOr other reasonable baud rates; also accepting baud unit
16MHzOr other CPU frequencies; also accepting kHz and Hz units
[xa-q]Optional F_CPU prefix designator, eg, i9.2MHz (*3)
  - x: external oscillator (default)
  - i: internal oscillator
  - [a-h]: internal oscillator that is 10% (a) to 1.25% (h) slow
  - [j-q]: internal oscillator that is 1.25% (j) to 10% (q) fast
swioSoftware I/O, must specify rx and tx pins
rx[a-h][0-7]MCU receive pin for swio, eg, rxb0
tx[a-h][0-7]MCU transfer pin for swio, eg, txb1
lednopIf no LED is specified generate template bootloader
no-led/noledDrop blinking code unless a LED is specified
led[+-][a-h][0-7]Generate code for activity LED with polarity +/-, eg, led+b5
dualDual boot; must specify CS pin for external SPI flash (*4)
cs[a-h][0-7]Chip select pin for dual boot, eg, csd5
hwGenerate bootloader with hardware boot section (*5)
v<n>Optional vector for vector bootloader, eg, v25 or vspmready
eeGenerate bootloader with EEPROM r/w support
ceGenerate bootloader that can emulate a chip erase
prGenerate vector bootloader with reset vector protection (*6)
u1Generate bootloader that skips redundant flash page writes (*7,8)
u2... and skips redundant flash page erases during emulated CE (*7,8)
u3... and skips not needed flash page erases during page write (*7,8)
u4... and skips empty flash page writes after page erase (*8)
serialno=abc123Put serial number, eg, abc123, in top of unused bootloader flash
fill=urboot\x20Fill otherwise unused bootloader flash repeatedly with argument
save=myfile.hexSave bootloader to file with chosen name (*9)
saveSave bootloader to file with canonical file name (*9)
tags=myfile.tagSave symbols to tag file with chosen name (*9)
tagsSave symbols to tag file with canonical file name (*9)
configsShow needed fuse configuration but do not write to memories
showShow bootloader features but do not write to flash
listList possible bootloader configurations but do not write to flash
bestSelect smallest feature-rich bootloader (first in list) and, if the baud rate error is too high for UART, switch to swio
helpShow this help message and return

Notes. Features can also be specified like in elements of a canonical file name. For details on urboot bootloaders and their features see https://github.com/stefanrueger/urboot.

*0Some parts do not provide 4 s or 8 s watchdog timeout
*1autobaud only works with UART I/O where the RX port pin is bit-addressable
*2From classic parts, only ATtiny441/841 have alternate UART signals
*3There is a subtle difference between external oscillators (x), which are reasonably accurate, and internal oscillators (a...h, i, j...q), which tend to be inaccurate for classic parts. The former can afford higher baud rate errors up to 2.2% while for the latter AVRDUDE warns at the lower threshold of 0.7% baud rate error. Cassic UARTs have integer baud rate divisors, which can lead to high baud rate quantisation errors. Used with the feature best AVRDUDE can automagically replace UART I/O code with swio I/O code when the former exhibits too high baud rate errors. For that, AVRDUDE better knows the type of oscillator (x or i) that drives a board. For lowest baud rate errors on an individual board that runs on internal oscillators it is best to measure F_CPU and use the measured value with the i prefix. Alternatively, one can use the nominal internal F_CPU (say 8 MHz) and use prefix letters that make the bootloader work: depending on the letter AVRDUDE subtracts from or adds to the nominal F_CPU multiples of 1.25%.
*4Dual boot is not supported for parts that lack standard SPI communication
*5Not all parts provide hardware bootloader support; hw renders pr meaningless
*6Reset vector protection is only available if flash size is a power of 2 (not ATmega406)
*7u1...u3 is only advisory, ie, can result in any of u1...u4
*8u1...u4 is not available for parts with the 4-page-erase quirk
*9The file is still written to disk in connection with configs, show or list. Bootloader files are per default written as Intel Hex format with comments. A filename of - writes the file to stdout. If a bootloader is a vector bootloader then the bootloader file contains a segment for initialising the reset vector to point to the bootloader. Tag files can be used in connection with the terminal disasm command.

Baud rate quantification errors are displayed with -v. A 0.79% baud rate error is considered OK for external oscillators but too high for internal oscillators. Hence, AVRDUDE selects software I/O when neither uart nor swio are explicitly requested:

 
$ avrdude -qv -c dryrun -p m328p -U urboot:x8mhz_56kbaud |& grep -i baud.rate
Baud rate error -0.79% for external oscillator OK

$ avrdude -qv -c dryrun -p m328p -U urboot:i8mhz_56kbaud |& grep -i baud.rate
Switching to SWIO as baud rate error -0.79% too high for internal oscillator
Baud rate error -0.10% for internal oscillator OK

There is a warning when the user requests hardware UART I/O:

 
$ avrdude  -qvc dryrun -p m328p -U urboot:i8mhz_56kbaud_uart0 |& grep -i baud.rate
Warning: high baud rate error -0.79% for int oscillator: consider switching to swio

Requesting best makes AVRDUDE switch to swio when UART quatisation errors are considered too high:

 
$ avrdude -qvc dryrun -p m328p -U urboot:i8mhz_56kbaud_uart0_best |& grep -i baud.rat
Switching to SWIO as baud rate error -0.79% too high for internal oscillator
Baud rate error -0.10% for internal oscillator OK

Alternatively, the user can request swio on those rx/tx lines that the UART uses:

 
$ avrdude -qvc dryrun -p m328p -U urboot:i8mhz_56kbaud_uart0_swio |& grep -i baud.rat
Baud rate error -0.10% for internal oscillator OK

Tag files can be used in connection with disasm:

 
$ avrdude -qqc dryrun -p m328p -U urboot:m328p_autobaud_ee_tags=/tmp/x \
    -T "disasm -gt=/tmp/x flash 0 -1"

[...]
        .equ    io.mcusr,   0x34
        .equ    io.spmcsr,  0x37
        .equ    mem.wdtcsr, 0x60
[...]
        .text
main:
__vector_reset:
L0000:  rjmp    .-386                ; L7e80 (urboot)

urmarker:                            ; Urboot marker bytes
L0002:  .byte   0x75, 0x72           ; ur

L0004:  .fill   16190, 2, 0xffff

; Rjmp from L0000
urboot:                              ; Entry point for bootloader
L7e80:  clr     r1
L7e82:  in      r2, io.mcusr
L7e84:  out     io.mcusr, r1
L7e86:  ldi     r24, 0x00            ; 0
L7e88:  rcall   set_watchdog         ; L7f5c
L7e8a:  sbrs    r2, 1                ; Bit 1 = 0x02
application:
L7e8c:  rjmp    .+470                ; L0064 (__vector_spm_ready)
serial_boot:                         ; Serial port bootloading
L7e8e:  ldi     r24, 0x0e            ; 14
L7e90:  rcall   set_watchdog         ; L7f5c

[...]

Label27:
L7fea:  clr     r1
L7fec:  ret

unused:                              ; 12 bytes for _serialno= and/or _fill=
L7fee:  .fill   6, 2, 0xffff

npages_vecnum:                       ; Usage of 3 pages; vector/spmready bootloader
L7ffa:  .byte   0x03, 0x19           ; __

L7ffc:  rjmp    pgm_write_page       ; L7f78

features_version:                    ; Encodes u8.0 weU-jPra-
L7ffe:  .byte   0xe6, 0x40           ; _ 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on June 23, 2025 using texi2html 1.82.