OpenDCC - details on the software, Update

How to Update the Software

    OpenDCC can be loaded with different software. In the following the different methods how the software is loaded to the box are described. No fear, it is easier than it looks on a first glance.
    Of course one can use (in any situation) the direct load procedure used during construction of OpenDCC (e.g. Ponyprog)
    However, it is much more easier and convenient to use a bootloader. The housing does not have to be opened for this. The following steps must be performed:
    1. Before switching on OpenDCC press the STOP button and keep pressed. Instead of the normal mode of operation now a boot loader is started (recognizably by the continuousbright CTRL LED), which waits now for a new software from the PC. This software will be loaded to the internal non volatile memory of OpenDCC.
    2. For OpenDCC (Atmega32): Copy update_opendcc.bat, update_opendcc_eeprom.bat, opendcc.hex, opendcc.eep, Atmega32.xml and avrosp.exe (see below) to a directory of your choice. Then open the command entry and execute update_opendcc COM1 (resp. with the correct port number). Important: COM1 must be typed in capitals! Now the update takes place.
    3. For OpenDCC_XP (Atmega644P): Copy update_opendcc.bat, update_opendcc_eeprom.bat, opendcc_xp.hex, opendcc_xp.eep, Atmega644p.xml and avrosp.exe (see below) to a directory of your choice. Then open the command entry and execute update_opendcc COM1 (resp. with the correct port number). Important: COM1 must be typed in capitals! Now the update takes place.
    4. If the EEPROM is to be written: start update_opendcc_eeprom COM1
    5. Restart OpenDCC - done!
    6. If OpenDCC is attached by USB, just use the port number of the virtual com port.
      (Note: the USB driver of OpenDCC installs a serial port, this will be assigned a port number from the operation system (e.g. COM8). This number may change if a different USB port is used.
      You can retrieve the actual port through device manager.
    How it works:
    The boot loader is a separate program, which is loaded completely to the end of the internal memory. By appropriate programming of the configuration bits (so-called fuses) the AVR is instructed to start program execution after RESET with the boot loader. The boot loader checks the stop button and if the key is not pressed it will execute the normal RESET vector at 0x0000; You will more information in the Application Notes AVR109 and AVR911 from Atmel. There are also the source files on

    In order to create a the bootloader for OpenDCC, the loaded source files must be adapted. You have to open preprocessor.xls and follow the guidelines. After configuration the boot loader can be built with "make".
      Do not open the makefile with an editor which replaces TABs by BLANKs.
      The linker calculates in units of bytes, therefore the doubled number compared to the fuses must be used.

    The following fuses are required to execute the boot loader:
  • BOOTRST = 0 (0=programmed): this redirect the RESET from 0x0000 to the boot loader;
  • BOOTSZ1 = 0 und BOOTSZ0 = 1: this indicates the size of the boot loader. This setting indicates a size of 1k words, i.e. the range from 0x0000 to 0x3BFF (93,5%) is used for the application, the range 0x3C00 to 0x3FFF is used by boot loader.
    (both bits = 0 would mean 2k words, i.e. the range 0x0000 to 0x37FF is for the application, the range 0x3800 to 0x3FFF is for the loader.)
  • BASEADDR = 0x7800: This instruction in the makefile of the boot loaders ensures that the boot loader is located to the correct area. (Note: the linker calculates with bytes, therefore: 0x7800 = 2*0x3C00) (for Atmega644P: 0xF800)
    Interacting with the boot loader:
    A program must be started on the PC side, which interacts with the bootloader. There are several possibilities:
  • avrosp:
    I use this tool. It is includes in the AppNote AVR911. The command looks as follows:
    avrosp -dATmega32 -e -pf -vf -ifopendcc.hex -cCOM3
    The baud rate of the port must be adjusted correctly:
    mode com3 baud=19200 parity=n data=8
  • avrdude:
    This tool comes with WinAVR, the command looks as follows:
    avrdude -c avr910 -p m32 -P com3 -U flash:w:opendcc.hex -b 19200
  • Menu item 'Tools' in AVR Studio.


    Hex file of the boot loader: bootloader.hex For first time installation this file must be loaded with the ISP Programmer. Source code already adapted for this:

    Tool from Atmel for update of Flash and EEPROM: AVROSP.EXE

    Batch for easier update: update_opendcc.bat (if *.bat is not delivered by ISP: zip-file)
    Note: Simply copy opendcc.hex, opendcc.eep, avrosp.exe and this batch into a directory and start the batch. The batch also sets up the com port.
    In order to start a batch, one must open the command line. Unfortunately, the default after opening the command line is the 'home' directory. It easier to open the command line with right mouse button from the explorer. See here, how this can be acheived.