Skip to content
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

STM32F103 / STM32F407 boards should use on-chip USB #139

Closed
ag88 opened this issue Oct 4, 2021 · 4 comments
Closed

STM32F103 / STM32F407 boards should use on-chip USB #139

ag88 opened this issue Oct 4, 2021 · 4 comments

Comments

@ag88
Copy link

ag88 commented Oct 4, 2021

hi MKS,
Your boards are quite good, but STM32F103 / STM32F407 boards should use on-chip USB support instead of using a separate USB-UART

There is a problem, as seen in this PR for Marlin
MarlinFirmware/Marlin#22529
Because STM32F103 and STM32F407 UART only has a single byte buffer. When the microcontroller is busy it can skip bytes from the host. So it becomes necessary to increase interrupt priority for the UART, this comes at a cost to interrupts to other peripherals such as HardwareTimer which drives the stepper motors (there is a risk of skipping steps)

Both STM32F103 and STM32F407 has on-chip USB support, please revise your designs to use the on-chip USB rather than using a separate USB-UART bridge.

e.g. your MKS-Nano-V3 is correctly designed
https://github.com/makerbase-mks/MKS-Robin-Nano-V3.X
https://github.com/makerbase-mks/MKS-Robin-Nano-V3.X/blob/main/hardware/MKS%20Robin%20Nano%20V3.0_004/MKS%20Robin%20Nano%20V3.0_004%20SCH.pdf
pins PA11 USB D- and PA12 USB D+ goes direct to USB.
But please update your designs so that the Nano-V1 and Robin E3 etc
https://github.com/makerbase-mks/MKS-Robin-E3-E3D
https://github.com/makerbase-mks/MKS-Robin-E3-E3D/blob/master/hardware/MKS%20Robin%20E3%20V1.1_004/MKS%20Robin%20E3%20V1.1_004%20SCH.pdf
use pins PA11 USB D- and PA12 USB D+ goes direct to USB.

USB is a reliable protocol, if the host (PC) did not get a response, it would poll again and there is a ACK response. So it won't lose bytes. But UART is not a reliable protocol, the receiver needs to keep scanning RX or it would lose bytes.

@mks-viva
Copy link
Collaborator

mks-viva commented Oct 7, 2021

First of all, thank you for your suggestions. I have a few to explain

  1. MKS Robin Nano is an old product, when it was on sale, marlin did not have USB support function, so MKS used the USB-Serial method
  2. MKS Robin E3/E3D did not take this feature into consideration
    In short, we will consider your suggestions comprehensively

@ag88
Copy link
Author

ag88 commented Oct 7, 2021

Lets update the 'old' product to 'new' versions, because those boards are popular, maybe call it Nano V1.1U usb E3 vx.yU / E3D x.yU etc. using USB direct helps to solve some 3d printing problems on STM32 boards, especially with Marlin.
This is mainly because both stm32f103 and stm32f407 only has a 1 byte uart buffer. If you send 2 bytes fast, maybe 2nd byte is missed and need to resend.
USB don't have this problem, the OS (Windows or Linux etc) controls the usb, it try to send the byte, if the board don't reply. OS auto try again and until the board gives ack and OS send next byte. It is done by polling by the host (OS).

@mks-viva
Copy link
Collaborator

mks-viva commented Oct 7, 2021

Yes, good proposal

@ag88
Copy link
Author

ag88 commented Oct 7, 2021

Oh, when new design is made for the 'old' boards, don't forget that 'BOOT0' pin design.
#140
makerbase-mks/MKS-Robin-Nano-V3.X#63

using BOOT0 pin is a common method to update firmware on stm32 boards.

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