2

I'm trying to add DFU support to the u-boot I'm using in my project because I figured out that DFU support is not enabled in it.

I'm using freescale u-boot (cloning from git://git.freescale.com/imx/uboot-imx.git) and I checked out the tag "rel_imx_4.1.15_1.1.0_ga" wich is the one I'm required to work on.

The thing is that going through the u-boot documentation I can see that DFU have to be enabled. I added the following to my .h file

#define CONFIG_USB_FUNCTION_DFU
#define CONFIG_CMD_DFU
#define CONFIG_DFU_MMC
#define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_16M
#define DFU_DEFAULT_POLL_TIMEOUT 300

But I'm getting the following errors:

common/built-in.o: In function `do_dfu':
/home/m4l490n/uboot-imx/common/cmd_dfu.c:29: undefined reference to `dfu_init_env_entities'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:35: undefined reference to `dfu_show_entities'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:41: undefined reference to `g_dnl_clear_detach'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:42: undefined reference to `g_dnl_register'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:44: undefined reference to `g_dnl_detach'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:50: undefined reference to `dfu_usb_get_reset'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:67: undefined reference to `usb_gadget_handle_interrupts'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:70: undefined reference to `g_dnl_unregister'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:72: undefined reference to `dfu_free_entities'
/home/m4l490n/uboot-imx/common/cmd_dfu.c:77: undefined reference to `g_dnl_clear_detach'
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:7696
arm-linux-gnueabihf-ld.bfd: error: required section '.rel.plt' not found in the linker script
arm-linux-gnueabihf-ld.bfd: final link failed: Invalid operation
make: *** [u-boot] Error 1

I noticed that If I remove #define CONFIG_CMD_DFU from the .h file it compiles fine but if I enter => dfu in the u-boot shell it says:

Unknown command 'dfu' - try 'help'

So the question is *Do you know what else do I need to add to enable DFU in the u-boot I'm using?

Thanks!!

Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75
m4l490n
  • 1,592
  • 2
  • 25
  • 46

1 Answers1

1
  1. To fix these linking errors:

    undefined reference to dfu_*

    enable the USB portion of the DFU USB class:

    #define CONFIG_DFU_FUNCTION
    
  2. To fix this linking error:

    undefined reference to usb_gadget_handle_interrupts

    enable your UDC controller (I'm pretty sure your platform has ChipIdea UDC controller), and also enable USB gadget:

    #define CONFIG_CI_UDC
    #define CONFIG_USBD_HS
    
    #define CONFIG_USB_GADGET
    #define CONFIG_USB_GADGET_DUALSPEED
    #define CONFIG_USB_GADGET_VBUS_DRAW 2
    
  3. To fix these linking errors:

    undefined reference to g_dnl_*

    enable and configure USB download gadget:

    #define CONFIG_USBDOWNLOAD_GADGET
    #define CONFIG_G_DNL_VENDOR_NUM     0x18d1
    #define CONFIG_G_DNL_PRODUCT_NUM    0x0d02
    #define CONFIG_G_DNL_MANUFACTURER   "FSL"
    

Now you should be able to build U-Boot successfully. Tested on configs/mx7dsabresd_defconfig (with changes to include/configs/mx7dsabresd.h). Configuration values for download gadget (G_DNL) were taken from include/configs/mx7dsabresdandroid.h.

Basically, linking problems can be solved next way. To find out what definition is missing, you can look where missing function is implemented, then look for Makefile where corresponding source file is enabled for build, and from that Makefile you can figure out which option to define, so that corresponding object-file is built and wanted function is in place at linking stage.

Sam Protsenko
  • 14,045
  • 4
  • 59
  • 75