Open GadgetAngel opened 2 years ago
I am implementing the TinyFAN PCB on my Voron 2.4 build to control PWM fans for my Voron build. I have the Octopus Pro on USB-A to the Raspberry Pi 4B and the TinyFAN's RP2040-zero on port two of the USB-A of the Raspberry Pi 4B.
The instability of the USB connection from the RP2040 device to the Raspberry Pi is due to the RP2040. See https://github.com/Klipper3d/klipper/pull/4748#issue-1013362088 : I quote: “RP2040 datasheet better explains the issue, but in a nutshell the USB controller requires800us of J-state(D+ high, D- low) to transition from RESET to CONNECTED. On a busy USB bus, e.g. on a single-TT hub with other 12Mbps USB devices, this might never happen”.
Here are two work-a-rounds to this problem:
To do #1 work-a-round a couple of items are needed:
To do #2 work-a-round a couple of items are needed:
$sudo apt-get install libusb-1.0-0-dev
$git clone https://github.com/mvp/uhubctl
$cd uhubctl
$make
$sudo make install
Edit: 10/16/2022 I just tried using uhubctl to power off and power on the USB port for the RP2040.
As you can see from the above picture, my RP2040 is on port 4 of 1-1 USB hub:
$sudo uhubctl -l 1-1 -p 4 -a off
$sudo uhubctl -l 1-1 -p 4 -a on
But when I try to cycle the power on the port 4, the power will be turn off and then on again but the RP2040 will not go through the USB enumeration process again. All I get is the power is on but the USB-ID is not shown:
But if I hit the 'physical "RESET"' button I installed the RP2040, will now display a USB-ID:
Conclusion: the only work-around to this is to just install a physical "RESET" button that interrupts the 5V line going to the USB-C of the RP2040 board! Unfortunately, every time you power up your printer you will need to hit this physical "RESET" button to get the RP2040 USB-ID to appear to the Raspberry Pi.
My next idea is to attach a Digital Relay to the button to see if I can remotely control this action via software. I will update if I can get this accomplished.
To be able to RESET the RP2040 chip on the TinyFAN PCB you will need to purchase a couple of items. Some are stated in my previous comments but here is the list again with a Relay I purchased from Amazon.
1.buy a 16mm momentary button from of Amazon at https://www.amazon.com/dp/B01MQV6NJR
Now wire this all up as shown in the following diagram
Follow the instruction in "Instructions for Software RESET of RP2040 chip.txt" file Instructions for Software RESET of RP2040 chip.txt
In the end, if you follow all the instructions: every time you power off the printer and turn it back on; or reboot the printer the RP2040 USB communications will be automatically reset so that when the printer finished booting up the link to the USB serial will be present. You will also have access to a web page and additional URL so that you can control the relay via software.
You will also have access to three HTML button at URL: http:[Your Raspberry PI IP address]:7990/resetrp2040.html
You will see the following three buttons:
Instead of using rc.local to reset the RP2040 I am now using a created service called "resetrp2040"
To determine which path my python call would use I did the following:
which python
pi@LDO300kit:~ $which python /usr/bin/python3
To create the resetrp2040.service file:
sudo touch /etc/systemd/system/resetrp2040.service
To edit the resetrp2040.service file:
sudo nano /etc/systemd/system/resetrp2040.service
Add the following to the resetrp2040.service file:
[Unit]
Description=Reset RP2040 chip USB comms
DefaultDependencies=no
After=klipper.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/python3 /home/pi/rp2040/reset_rp2040.py & > /home/pi/rp2040/log.txt 2>&1
[Install]
WantedBy=multi-user.target
To enable the service do the following:
sudo systemctl enable resetrp2040.service
Now add the resetrp2040.service to the list of services that moonraker can maintain so that you can manually control the resetrp2040 services via the UI. Go to ~/printer_data/moonraker.asvc and edit the filename moonraker.asvc.
At the end of the file called " moonraker.asvc" place the following:
resetrp2040
Now reboot your raspberry pi.
Now the resetrp2040 service will run automatically on reboot
To test it out run the following:
sudo service resetrp2040 restart
Hey @GadgetAngel There is actually a solution, you can simply flash the can bootloader, check the "skr pico" issue thread. Then you can still use simply the usb connection to the pico. Means you just need the can bootloader but you don't have to use can.
I didn't tested personally that approach, but im pretty sure it solves the issue.
Otherwise afterwards, the rp2040 wasn't the best decision with this usb bug, but there aren't any/many stm32 based alternatives.
Here is the direct link to the solution, just keep in mind that the flashchip on the waveshare is the "Generic_03H". https://github.com/bigtreetech/SKR-Pico/issues/2#issuecomment-1500925079
I have built the TinyFAN PCB. I am using a waveshare RP2040-zero and everytime I reboot the Raspberry Pi 4B, the pi after reboot does not see the serial USB ID for the RP2040-zero processor.
I have to press the "RESET" button on the RP2040-zero to get the USB ID back (the Raspberry Pi 4B, can see the USB ID again). Is there a way to remotely "RESET" the RP2040.
My TinyFAN PCB is located on the bottom of the printer and I do not want to have to turn the printer over each time the Raspberry Pi 4B needs to be powered off and back on again.