-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Pixhawk4 fails to connect to the bootloader #10429
Comments
Any update to this issue.? |
For now I am using an older version of the px_uploader.py script and it works fine. https://github.com/PX4/Firmware/blob/11d4c32cd42ab47394e039d9acc05960da6c1332/Tools/px_uploader.py piece of code specificaly, just copied it into Firmware/Tools/px_uploader.py. |
I can confirm, the uploader seems broken on master 😞
That's a good workaround but it needs to be fixed. If someone finds the problem I appreciate any help. I'll look into it as soon as possible... |
JFYI There was already a maybe hard to find issue by me because I had the same problem: #10375 |
So 57c7e1a attempted to prevent the use of some windowed upload mode intended for FTDI UART connections when uploading over USB. On Cygwin it caused exactly the opposite and window mode afterwards gets used over USB which results in 4+ times the upload time (Pixhawk 4 with current master 39s -> 167s). The problem is detection of USB because it simply assumes that if the port name contains "/dev/ttyS" it's UART (57c7e1a#diff-25f54baafa76ba3cdb603067311ad2c0R222) but on Cygwin every Windows COM port gets mapped to /dev/ttyS[COM number - 1]. f12acd7 (which I identified earlier as the commit that breaks correct bootloader recognition) tries to fix the windowed mode problem by trying different baudrates (f12acd7#diff-25f54baafa76ba3cdb603067311ad2c0R334) and from that information detect UART vs USB. Now I know the context but still have to debug to find the root cause why it currently fails. TLDR To make it work again (with fast speed) you just need to comment out this line: https://github.com/PX4/Firmware/blob/master/Tools/px_uploader.py#L553 |
https://github.com/PX4/Firmware/blob/master/Tools/px_uploader.py#L339 sets some odd baudrate and I don't know why but on Cygwin that line does something strange:
@davids5 Any ideas that might help? 😇 |
@MaEtUgR - Wow! Could you try 110 baud as the test rate, and then retest on linux as well? |
@davids5 Thanks for your response! If I hardcode
I have to take that back, I couldn't believe it myself and of course just found an error in my except block that lead to the strange runtime behaviour. The actual exception of the line is Is the "magic trick" that on USB you could theoretically set an arbitrary baudrate and the UART drivers will only allow the standard rates supported by the clock deviders? So we're looking for a baudrate that is arbitrary enough such that UART modules do not have a clock devider for it but not too arbitrary such that python on Cygwin still allows it? Like maybe 110? I tried 50, 75, 134, 150 and they give exception |
@MaEtUgR -
Yes to some degree. The magic is that on a USB the CDC ACM driver the buadrate does not have any effect. This is because the data is never converted to NRZ data again. It would be on a USB to serial cable, but not on a CDCACM device. The change baudrate command just tells the target there is the new rate. But none of that affects the speed. On real serial port the target is typically set to 115000 bps. (or some high rate like 1-2 mbps) If we send a SYNC and EOT at 2.33 times the assumed baud rate the SYNC and EOT can not be received and there will be no response. But on USB it works.
It is not the clock divider per say, it is the bps setting that is in effect on the target. In this case the target is at 115200 and, the host is at 110 bps (90 Ms per bit) or 300 bps (33 ms per bit). On a real serial port the 90Ms start bit will look like a break to a target at 115200 bps (8.68 uS perbit) so the SYNC EOT can not be received and there will be no response. I chose to go 2.33 times to avoid having issues with the "Enter bootloader mode Via break" feature here: https://github.com/PX4/Bootloader/blob/master/main_f4.c#L275-L334 Because there is a possibility of the break detection being active in a bootloader, a higher rate like 57,600 We will still have a potential problem with target using 1-2 Mbps. 57,600's start bit will still look like a break. Could restrict that feature to only be enabled on targets with baud rates < 1 Mbps? |
You build the V5 bootloader with 1 mbps and connect a FTDI cable to the telem 1. Then windowed mode should be used, switch to USB and non windowed mode should be used. |
to fix Cygwin upload. It failed silently but when catching it prints "non-standard baudrates are not supported on this platform". Discussion about platform independet FTDI detection is in issue #10429.
to fix Cygwin upload. It failed silently but when catching it prints "non-standard baudrates are not supported on this platform". Discussion about platform independet FTDI detection is in issue #10429.
to fix Cygwin upload. It failed silently but when catching it prints "non-standard baudrates are not supported on this platform". Discussion about platform independet FTDI detection is in issue #10429.
@davids5 Sorry I don't have the hardware to test and make sure the FTDI check still works with 110 or other lower baudrate. I came up with a woraround just catching the exception which fixes the most common and therefore urgent Windows use case. If you're still willing to change the change the odd baudrate check to a normal but too low baudrate and I should test something on Windows please let me know. |
@MaEtUgR if the problem is solved and it is working, for all user by correctly choosing the correct window mode, that is really all we need. |
@Tanop74 It looks almost ok. Don't worry about the "non-standard ... USB connection" warning, I should rewrite it to make clear it's just a warning. Could you try:
Also look at the device manager while you plug your pixhawk board, it should pop up as COMX and if you don't flash anything as COMY with Y one number higher than X shortly after. When you are flashing you need to start the uploader and plug it such that the bootloader (COMX, the first just after plugging) gets recognized. I hope this helps, maybe sometime I'll do a video for most comprehensive docs... |
@davids5 Sure, I don't know how many users would use the FTDI cable to flash normally from the desktop under Windows. That's probably what's not supported right now. |
Hello Matthias,
I have finally chosen to reinstall everything in Ubuntu and it now works well.
Thanks for your feedback
Arnaud
|
When I try to upload my own code, or even a simple example to the pixhawk 4, It goes into and endless loop when trying to locate the bootloader.
Steps to the loop:
"Attempting reboot on (port name) with baudrate=57600..."
"If the board does not respond, check the connection to the Flight Controller"
What I expect to get is that it will reach the port of the pixhawk and upload the code.
I tried cahnging a cable.
I tried pressing in the usb connectiong
I tried switching a port
-cygwin toolchain
Did anyone else had this problem? Knows how to fix it?
The uploading script is under Firmware/Tools/px_uploader.py
Tahkns in advance
The text was updated successfully, but these errors were encountered: