Skip to content

bugs in USBSerial & usbd_conf.c #436

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
stefaandesmet2003 opened this issue Feb 12, 2019 · 4 comments
Closed

bugs in USBSerial & usbd_conf.c #436

stefaandesmet2003 opened this issue Feb 12, 2019 · 4 comments

Comments

@stefaandesmet2003
Copy link

  • Arduino IDE version: 1.8.8
  • STM32 core version: github latest
  • OS: linux ubuntu
  • board: bluepill
    The 2 main issues i have :
  1. USBSerial gives errors because the pma buffers for the CDC_OUT_EP endpoint is not correctly initialized in usbd_conf.c. Errors I have : hard fault when usb is plugged out and back in; dtr/rts not set correctly, serial monitor in arduino plugin in vscode corrupts the pma buffer (still don't understand why.., because cat /dev/ttyACM0 and arduino serial monitor work ok)
    This code solves the issue :
    // defines have to align with usbdc_cdc.h #define CDC_IN_EP 0x81U /* EP1 for data IN */ #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ HAL_PCDEx_PMAConfig(pdev->pData, 0x00, PCD_SNG_BUF, 0x40); HAL_PCDEx_PMAConfig(pdev->pData, 0x80, PCD_SNG_BUF, 0x80); HAL_PCDEx_PMAConfig(pdev->pData, CDC_IN_EP, PCD_SNG_BUF, 0xC0); HAL_PCDEx_PMAConfig(pdev->pData, CDC_OUT_EP, PCD_SNG_BUF, 0x110); HAL_PCDEx_PMAConfig(pdev->pData, CDC_CMD_EP, PCD_SNG_BUF, 0x100);

  2. CDC_Flush() can be called without CDC driver initialized, resulting in address 0 reference in USBD_CDC_SetTxBuffer.
    This happens for instance when doing UsbSerial.print(...) with usb disconnected until the internal buffer fills up and code calls CDC_Flush(), or when calling UsbSerial.flush()

  3. what's the advantage of using a timer for USBSerial? It can be implemented without by flushing to PMA on every write. It looks like unnecessary use of a timer peripheral (implementation in mbed or Roger Clark's repo)

@fpistm
Copy link
Member

fpistm commented Feb 12, 2019

@stefaandesmet2003
did you test with #419 which includes several improvements?

@stefaandesmet2003
Copy link
Author

unfortunately no ! will definitely try.

@stefaandesmet2003
Copy link
Author

nice work! that branch solves my problems. The cdc_queue works well, blocks the write function once the queue is full; i guess that's intended behaviour.
issue closed :)
Thanks,
Stefaan

@fpistm
Copy link
Member

fpistm commented Feb 12, 2019

Welcome.
All congratulations go to @makarenya ;)
I've only reformat PR.

@fpistm fpistm closed this as completed Feb 12, 2019
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