cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 USB Host config for FT232RL

SohamC
Associate II

Title edited to name the device being hosted.


Hello , 
I am currently trying to configure STM32F407 board as USB host. The code for it is given below. I am not receiving anything from the USB device(bus powered). I have a doubt that it might be related to the hardware of it(VBUS). The rest of the code is generated by the IDE itself so there is no doubt related to it. I have configured it as USB host only mode. I am new to embedded systems so any kind of help would be appreciated. Is there anything wrong with the code or any links to help me configure the USB host.
I would be glad to clarify any queries related to the above.

21 REPLIES 21

The console window does not open and hence am not able to see the errors.

Not even when you do a build?

Even when there's nothing to build (everything is up-to-date), you should at least see something like this:

AndrewNeil_0-1758792155982.png

 

More generally, something like this (from the User Manual):

AndrewNeil_1-1758792346752.png

https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf#page=126

via: https://www.st.com/en/development-tools/stm32cubeide.html#documentation

 

If you're not seeing that, then that's a separate issue - start a new thread for that.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

arm-none-eabi-gcc -o "USB_FTDI.elf" @"objects.list" -mcpu=cortex-m4 -T"F:\STM32CubeIDE_1.19.0\USB_FTDI\STM32F407ZGTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="USB_FTDI.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group

F:/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./USB_HOST/App/usb_host.o:(.bss.hUsbHostFS+0x0): multiple definition of `hUsbHostFS'; ./Core/Src/main.o:(.bss.hUsbHostFS+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:68: USB_FTDI.elf] Error 1

"make -j12 all" terminated with exit code 2. Build might be incomplete.

 

this is the error in the console window , as expected. I need help including some definitions of my driver

in the usbh_host.c file which is part of middleware(not to be edited i guess).

So the error is:

/USB_HOST/App/usb_host.o:(.bss.hUsbHostFS+0x0): multiple definition of `hUsbHostFS'; ./Core/Src/main.o:(.bss.hUsbHostFS+0x0): first defined here

 

It tells you that you have multiple definitions of the symbol hUsbHostFS, and they are in the files usb_host.o and main.o

So you need to remove one of those definitions.

 

usb_host.o  is the object file from compiling the usb_host.c source file;

main.o is the object file from compiling the main.c source file.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

SohamC_1-1758796810700.png

Now its showing some issue with build even though i removed the duplicate file. I guess the build was incomplete or something because every time am trying to run or debug , a new tab gets opened in editor showing this error.


@SohamC wrote:

Now its showing some issue with build 


What issues? Your screenshot does not show any build issues.

 


@SohamC wrote:

even though i removed the duplicate file..


Were the files actually duplicates?

The error said nothing about duplicate files - just about one definition within those files.

It was just that definition that you needed to correct.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

These are the two files related with header files made. The communication does not seem to go ahead of enumeration process. After enumeration state is reached, the state again goes to waiting for attachment and then repeats.

So is this after you fixed the duplicate definition issue?

And you now get no errors or warnings when building?

Where did the usb_ftdi.c file come from?

 

Why do you want to host a USB--to-UART adaptor anyhow?

Wouldn't it be simpler to just use a UART direct?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil wrote:

In particular, what STM32F407 board are you using


(emphasis added)

 


@SohamC wrote:

STM32F407ZGT6 


That's just a chip part number - it doesn't tell what board you are using it on.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Its the connector that is USB. So we cant use it directly. Development board is Euse M4 demo. with the chip specified. The chip is of less concern now , because the focus is to write firmware for usb host , the chipset can be any stm chip