wiki:How_to_flash_the_FSC

Version 2 (modified by dneise, 10 years ago) ( diff )

--

Here I try to collect some information about flashing new firmware onto the FSC board. While the FSC has been built to be Arduino-compatible, we never really managed to install the well known Arduino bootloader onto the FSC. So the firmware can't be installed via USB, but needs to be programmed via the ISP port using an external ISP programmer like the one shown in the picture below. This is an original "AVR ISP mkII", but others should work as well.

The AVR ISP mkII on Ubuntu

Check if the USB connection works. Leave the programmer unplugged from the board to be programmed, but connect it to your PC via USB. You should see it, when typing lsusb in a terminal, e.g. like this:

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 007: ID 03eb:2104 Atmel Corp. AVR ISP mkII               <--- this is it.
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

In order to speak to the programmer, the program called avrdude is needed. It can be simply installed by

sudo apt-get install avrdude

We can check, if avrdude can talk to the programmer, even before the programmer is connected to the board, by typing:

avrdude -p m328 -c avrispmkII -P usb -v

Here the -p parameter, specifies the type of the microcontroller (MCU) we want to program, since we actually don't want to program any MCU right now, but just check, if we can talk to the programmer, this parameter doesn't matter. However this parameter is not optional. The -c parameter specifies the type of programmer, we want to use and -P specifies the port, we connnected the programmer to. (Luckily specifying 'usb' is enough and we don't have to specify the bus and device number).

The ouput might look like this:

dneise@NeiseLenovo:~$ avrdude -p m32 -c avrispmkII -P usb -v

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/dneise/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : avrispmkII
avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"
avrdude: usb_open(): cannot read product name "error sending control message: Operation not permitted"
avrdude: usbdev_open(): Found [unnamed product], serno: [unknown]
avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted
avrdude: usbdev_open(): did not find any USB device "usb"

The problem here is, that your user does not have access rights for this USB device. We solve this quickly by putting sudo in front of the command. Also we add the -v option in order to get more information

dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -v

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/dneise/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : avrispmkII
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200059292
         AVR Part                      : ATmega32
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 1
         Firmware Version Master : 1.13
         Vtarget         : 0.0 V
         SCK period      : 0.50 us

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Target not detected
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

As we see, in the end avrdude complains about a missing target. The reason is simply, that we did not yet connect the board. Now let's connect the board. Make sure the connector is plugged the right way around. Pin 1 of the ISP connector on the FSC board is the one farthest away from the MCU. Also make sure the board is powered, since it will not be powered through the programmer. In case all connections are fine and the board is powered your output might look like this:

dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9502

avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)

avrdude done.  Thank you.

You can even use the programmer in a kind of interactive session, and e.g. ask for the supply voltage level of the board. In order to change into interactive mode, add the -t option (for "terminal" mode). After you're conected to the board, you can ask for some paramters of the target, using the "parms" command. In order to quit, simply type "quit". It might look like this:

dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -t

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9502
avrdude> parms
>>> parms 
Vtarget         : 4.9 V
SCK period      : 0.50 us
avrdude> quit
>>> quit 

avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)

avrdude done.  Thank you.

If you accomplished this, you can be sure, that your programmer is nicely connected to the FSC board.

Note: See TracWiki for help on using the wiki.