2017-09-26 08:56 AM
Hello, all
I recently learn to use stm32 usb device
I think it's easy to build a CDC example with HAL library in CubeMX,
And I put the code into stm32f429-discvoery, it's the HS pin, but actually use FS speed
I'm successfully to connect stm32 in Linux, like I use command 'cat /dev/ttyACM0'
and I can easy to observe stm32 usb transmit data
But there is something strange and I don't know why.
When I plug the usb line and I can find /dev/ttyACM0,
I cannot direct connect it, like
'cat /dev/ttyACM0'
it will show a error info 'cat: /dev/ttyACM0: Device or resource busy'
But after about 10 seconds, it will success connect it.
Everytime I try same way, it all need 10 seconds wait,
All I setting in CubeMX for USB is default, only VBUS sensing with Enable
I'm not sure why, but it's there any possible to connect usb cdc more quickly?
#usb #cdc2017-09-26 12:09 PM
hello!
Increase the Heap size inside startup_stm32f429xx.s file
eg make it 0x1200
Regards
vf
2017-09-26 09:16 PM
Actually, I didn't find heap info in
startup_stm32f429xx.s,
So I modify this viarable in STM32F429ZITx_FLASH.ld
_Min_Heap_Size = 0x200; [TO] _Min_Heap_Size = 0x1200;
to make heap size biggerand clean build again
But after I observe, it still need 10seconds to wait, so there is no improvement,
actually I have no idea why it relative with heap size,
but still thanks you
2017-09-27 01:48 AM
Inside USBD_CDC_Init(..) function there is a malloc function which allocates about 540 Bytes memory on the Heap.
This was not taken into account from CubeMX when code generated .
So , at least you must define the Heap size taking into account theese extra Bytes, to have the USB CDC port working.
the malloc function def.
the allocation
the typedef of handle
and the size of max packet size.
It will help the comunity to solve your problem if you post your IOC file and other relative code here.
Regards
vf
2017-09-27 04:51 AM
Finally, I found it because I use Ubuntu, and there is modem manager will suspend it for a while
here is a page to tell how to prevent modem manager to keep using /dev/ttyACM0
https://linux-tips.com/t/prevent-modem-manager-to-capture-usb-serial-devices/284
now I can direct use it without wait 10 seconds =)
And really thanks you for give much info