makerbase-mks / MKS-Robin-E3-E3D

MKS Robin E3 E3D 32Bit Control Board 3D Printer parts with tmc2209 Uart mode driver For Creality Ender 3 CR-10
https://www.aliexpress.com/item/4000781744682.html
GNU General Public License v3.0
117 stars 99 forks source link

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

Closed ag88 closed 2 years ago

ag88 commented 2 years ago

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 https://github.com/MarlinFirmware/Marlin/pull/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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Yes, good proposal

ag88 commented 2 years ago

Oh, when new design is made for the 'old' boards, don't forget that 'BOOT0' pin design. https://github.com/makerbase-mks/MKS-Robin-E3-E3D/issues/140 https://github.com/makerbase-mks/MKS-Robin-Nano-V3.X/issues/63

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