Skip to content

SerialUSB and FreeRTOS setup/startup order example #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atrips opened this issue May 12, 2020 · 3 comments
Closed

SerialUSB and FreeRTOS setup/startup order example #29

atrips opened this issue May 12, 2020 · 3 comments

Comments

@atrips
Copy link

atrips commented May 12, 2020

Hello,

I'm trying to use SerialUSB w/ FreeRTOS but I have issue to start tasks before SerialUSB initialized.

Let's consider example code: https://github.com/stm32duino/STM32FreeRTOS/blob/master/examples/frBlinkPrint/frBlinkPrint.ino
Problem is that while(!Serial) {} blocking till ACMx device not connected. I tried to setup serial from task but without success. ACM device seems to not initialized right and not visible from OS.

Thanks.

@fpistm fpistm transferred this issue from stm32duino/Arduino_Core_STM32 May 12, 2020
@fpistm
Copy link
Member

fpistm commented May 12, 2020

Hi @atrips
you can try this;
#16 (comment)

anyway, I will not able to help on this.

@fpistm
Copy link
Member

fpistm commented May 19, 2020

Hi @atrips
I've tested the frBlinkPrint.ino and SerialUSB and did not have any issue with USB connected.
If your issue is that it's block to while(!Serial); then remove it. It is to ensure the Serial is up and running which is a good idea, anyway up to you do your own implementation and FreeRTOS config.
I've tested with default memman and then without while(!Serial);' it works until I connect the USB. But defining #define configMEMMANG_HEAP_NB 3` in STM32FreeRTOSConfig_extra.h works fine when I plugged the USB later as mentioned in #16.

So, I close it.

@fpistm fpistm closed this as completed May 19, 2020
@atrips
Copy link
Author

atrips commented May 19, 2020

Hello @fpistm ,

Thank you for the time you waste investigate the issue. I did not reply because I was not sure make my tests right. So...

Having while(!Serial); and #define configMEMMANG_HEAP_NB 3 gives me proper OS level USB initialization but tasks does not starts till ACM device connected (from some app).

Commenting while(!Serial); results:

[422541.924949] usb 3-5.4.4.4: new full-speed USB device number 19 using xhci_hcd
[422542.028102] usb 3-5.4.4.4: New USB device found, idVendor=0666, idProduct=5740, bcdDevice= 2.00
[422542.028106] usb 3-5.4.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[422542.028109] usb 3-5.4.4.4: Product: BPILL_F103C8 CDC in FS Mode
[422542.028111] usb 3-5.4.4.4: Manufacturer: Atrips
[422542.028113] usb 3-5.4.4.4: SerialNumber: 326331693436
[422547.195618] usb 3-5.4.4.4: can't set config #1, error -110

NOTE:
I'm using platformio w/ following config:

...
build_flags =
    -fexceptions
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
    -D USBCON
;    -D USBD_USE_CDC
	-D HAL_PCD_MODULE_ENABLED
	-D USBD_VID=0x0666
	-D USBD_PID=0x0042
	-D USB_MANUFACTURER="\"Atrips\""
	-D USB_PRODUCT="\"BPILL_F103C8\""
...

Edit:
My goal is to have RTOS tasks/timers/... running and USB Device available at OS level at startup. ACMx device to be used only if/when needed/connected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants