Difference between revisions of "DFU"

From PaparazziUAV
Jump to navigation Jump to search
(add usb access troubleshooting info)
 
(17 intermediate revisions by 2 users not shown)
Line 5: Line 5:


__TOC__
__TOC__
'''sw/tools/dfu/stm32_mem.py will be used to upload code, this wiki article was written in thought dfu-util would be used,however, maybe it's useful...'''
DFU (Device Firmware Upgrade) is the standard method to upload paparazzi code to a stm32fx MCU via usb.<br/>
The native dfu bootloader is already embedded in the ROM of the MCU. The MCU will not go automatically in dfu mode, so either [[Luftboot]] is needed or it is done on hardware side (e.g. stm32f4-discovery).
==Entering dfu mode==
===With extra bootloader===
[[Luftboot]] will enter dfu mode automatically if the board is connected to a pc.<br/>
[[KroozSD#Bootloader|KroozSD]] has also a own dfu bootloader.


===With native dfu bootloader===
DFU (Device Firmware Upgrade) is the standard method to upload new code to a STM32 MCU via USB.<br/>
This can be used on the stm32f4-discovery board e.g.
 
Provide the board with power and connect the usb cable for dfu upload.<br/>
There are two different DFU bootloader which require different software:
Connect BOOT0 pin with 3V pin(BOOT1 with GND ?), press reset button , disconnect BOOT0 and 3V.
* custom [[Luftboot]]/[[KroozSD#Bootloader|KroozSD]] bootloader which uses stm32_mem.py script
* native (embedded in ROM) dfu bootloader which requires dfu-util
 
==Custom bootloader (e.g.[[Luftboot]],[[KroozSD#Bootloader|KroozSD]])==
 
This bootloader must be upload first, so paparazzi center can use stm32_mem.py to upload code to the MCU.<br/>
This bootloader is available for LisaM/Lia ([[Luftboot]]) and Krooz/kroozSD ([[KroozSD#Bootloader|KroozSD]]) boards.
 
===Airframe configuration===
 
To use custom DFU bootloader via USB as default:<br/>
Set '''FLASH_MODE=DFU'''
   
   
  dfu-util -l
===stm32_mem.py===
 
stm32_mem.py will be used to upload the code.<br/>
To get a list of possible options, run:
  sw/tools/dfu/stm32_mem.py --help
 
==Native DFU bootloader (embedded in ROM)==
 
STM32F4 MCUs have a bootloader already embedded in the ROM. <br/>
The MCU will not go automatically in DFU mode. <br/>
To trigger DFU mode, connect pin BOOT0 with 3V (if it dowsn't work also connect BOOT1 with GND), Reset MCU, disconnect BOOT0 (and BOOT1).<br>
 
 
For further information, look at the [http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf STM's Application note AN2606]
 
===Airframe configuration===


This will list all devices in dfu-mode.
To use ROM based DFU via USB as default:<br/>
Set '''FLASH_MODE=DFU-UTIL'''


==Airframe configuration==
===Needed software===
Set '''Flash_Mode=DFU'''
Maybe it is set by default.


==Software Tools==
dfu-util packet is needed for this bootloader.<br/>
dfu-util is needed and must be installed
Present in the current Ubuntu and Debian repo: <br/>
  sudo apt-get install dfu-util
  sudo apt-get install dfu-util
More information about dfu-util can be found at their Homepage [http://dfu-util.gnumonks.org/ http://dfu-util.gnumonks.org]
==Troubleshooting==
You e.g. get the message <tt>can't find STM32 (autopilot) device</tt>.
* Check if your device is recognized by the kernel:
** e.g. for STM32 boards: <source lang="bash">lsusb -v -d 1d50:600f</source> should print something like
  <source lang="bash">
Bus 003 Device 005: ID 1d50:600f OpenMoko, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType        1
  bcdUSB              2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass        0
  bDeviceProtocol        0
  bMaxPacketSize0        64
  idVendor          0x1d50 OpenMoko, Inc.
  idProduct          0x600f
  bcdDevice            1.00
  iManufacturer          1 1 BIT SQUARED
  iProduct                2 Lisa/M V2.1 (Upgrade) V1.1
  iSerial                3 LM21031 36311743414D303731FFD305
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                9
    bDescriptorType        2
    wTotalLength          27
    bNumInterfaces          1
    bConfigurationValue    1
    iConfiguration          0
    bmAttributes        0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      0
      bNumEndpoints          0
      bInterfaceClass      254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      2
      iInterface              4 @Internal Flash  /0x08000000/4*002Ka,124*002Kg
      Device Firmware Upgrade Interface Descriptor:
        bLength                            9
        bDescriptorType                    33
        bmAttributes                        9
          Will Detach
          Manifestation Intolerant
          Upload Unsupported
          Download Supported
        wDetachTimeout                    255 milliseconds
        wTransferSize                    2048 bytes
        bcdDFUVersion                  1.1a
Device Status:    0x0000
  (Bus Powered)
  </source>
* If you can see your device but still don't have access:
** Check your [[Udev]] rules are up-to-date.
** Check if the device is assigned to the <tt>plugdev group</tt> (via [[Udev]] rules) and you are a member of that group.


More information about dfu-util can be found at their Homepage [http://dfu-util.gnumonks.org/ http://dfu-util.gnumonks.org]
[[Category:Firmware Flashing]] [[Category:Developer_Documentation]]

Latest revision as of 13:52, 1 May 2016

DFU (Device Firmware Upgrade) is the standard method to upload new code to a STM32 MCU via USB.

There are two different DFU bootloader which require different software:

  • custom Luftboot/KroozSD bootloader which uses stm32_mem.py script
  • native (embedded in ROM) dfu bootloader which requires dfu-util

Custom bootloader (e.g.Luftboot,KroozSD)

This bootloader must be upload first, so paparazzi center can use stm32_mem.py to upload code to the MCU.
This bootloader is available for LisaM/Lia (Luftboot) and Krooz/kroozSD (KroozSD) boards.

Airframe configuration

To use custom DFU bootloader via USB as default:
Set FLASH_MODE=DFU

stm32_mem.py

stm32_mem.py will be used to upload the code.
To get a list of possible options, run:

sw/tools/dfu/stm32_mem.py --help

Native DFU bootloader (embedded in ROM)

STM32F4 MCUs have a bootloader already embedded in the ROM.
The MCU will not go automatically in DFU mode.
To trigger DFU mode, connect pin BOOT0 with 3V (if it dowsn't work also connect BOOT1 with GND), Reset MCU, disconnect BOOT0 (and BOOT1).


For further information, look at the STM's Application note AN2606

Airframe configuration

To use ROM based DFU via USB as default:
Set FLASH_MODE=DFU-UTIL

Needed software

dfu-util packet is needed for this bootloader.
Present in the current Ubuntu and Debian repo:

sudo apt-get install dfu-util

More information about dfu-util can be found at their Homepage http://dfu-util.gnumonks.org

Troubleshooting

You e.g. get the message can't find STM32 (autopilot) device.

  • Check if your device is recognized by the kernel:
    • e.g. for STM32 boards:
      lsusb -v -d 1d50:600f
      
      should print something like
Bus 003 Device 005: ID 1d50:600f OpenMoko, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1d50 OpenMoko, Inc.
  idProduct          0x600f 
  bcdDevice            1.00
  iManufacturer           1 1 BIT SQUARED
  iProduct                2 Lisa/M V2.1 (Upgrade) V1.1
  iSerial                 3 LM21031 36311743414D303731FFD305
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           27
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      2 
      iInterface              4 @Internal Flash   /0x08000000/4*002Ka,124*002Kg
      Device Firmware Upgrade Interface Descriptor:
        bLength                             9
        bDescriptorType                    33
        bmAttributes                        9
          Will Detach
          Manifestation Intolerant
          Upload Unsupported
          Download Supported
        wDetachTimeout                    255 milliseconds
        wTransferSize                    2048 bytes
        bcdDFUVersion                   1.1a
Device Status:     0x0000
  (Bus Powered)
  • If you can see your device but still don't have access:
    • Check your Udev rules are up-to-date.
    • Check if the device is assigned to the plugdev group (via Udev rules) and you are a member of that group.