Commit Graph

109 Commits

Author SHA1 Message Date
Hamish Willee 30e2490d5b
Docs are now in user guide and main (#19977)
* Fix links to docs in source to point to docs on main not master

* More docs and scripts that need to point to main
2022-08-01 11:39:39 +10:00
Thomas Schneider 2e36fff31d Implement option to reboot px4 using protocol_splitter format when flashing. 2021-09-09 10:12:11 +02:00
Daniel Agar 61e972ba35 px_uploader.py remove special pyserial checks that fail on some platforms 2021-05-21 08:56:12 +02:00
David Sidrane c1435c744c px_uploader:Fixes breakage for real serial ports caused by 00e6d11
The code was pitching an exception. It was invaild. That then left
   the baud rate AFU
2021-02-05 20:15:20 +01:00
Lorenz Meier 00e6d11dfa PX Uploader: Disable windowed mode
The windowed mode has been added for Windows targets originally. It gets very often incorrectly detected and slows down flashing considerably. This even applies to serial links. We are disabling it now in most circumstances.
2021-01-01 14:26:36 +01:00
Jacob Dahl 74c9ba8d55
fix px_uploader bytes and char comparison & remove python 2 support (#15859) 2020-10-13 09:30:37 +02:00
Hamish Willee 8236b8da81 Fix up doc links to point to master branch 2020-04-21 08:58:40 +02:00
Beat Küng c48c1c4cef Tools/px_uploader: exit if unsuitable board is connected
Avoids endless looping, and is mostly useful when used in automated
upload scripts.
2020-04-20 09:05:57 +02:00
Julian Oes b04f68553e Tools: use Python 3, improve import checks
In more detail:
- Change shebang to Python 3.
- Suggest installation using pip3 as user.
2020-01-16 16:25:26 +01:00
Julian Oes 5491f9b8f9 px_uploader.py: increase estimated erase time
The 9 seconds to erase a board probably still come from the FMU-v1 and
Pixhawks with only 1 MB flash. By now, many targets have 2 MB flash and
take a bit longer to erase. Therefore, we can increase the estimated
time a bit and don't need to resort to the timeout notice.
2019-11-02 09:47:54 -04:00
Julian Kent 0553d4d01e Fix px_uploader.py to work in 16.04 with Python 2.7.
Before, the pyserial check would fail before it could check for the
VERSION that the Python 2.7 version contains. This fixes it to check
for the VERSION independently.
2019-06-06 09:13:54 -04:00
Julian Oes a9c3bce20d px_uploader.py: fix version check
Presumably older versions of pyserial do not implement __version__ but
only VERSION, so we need to check for that as well.
2019-04-24 14:47:10 +02:00
Julian Oes be8ad46fc9 px_uploader.py: write timeout workaround
This is a workaround for the write timeout that we have seen for some
host computers trying to flash the firmware.

We don't know the root cause of the problem but we do observed the
following:

- For blocking writes with timeout (Pyserial write_timeout=0.5):
  write() throws SerialTimeoutException. In systrace we see that the
  select() call after write waiting for the write to be finished hangs
  and finally times out.
- For blocking writes without timeout (Pyserial write_timeout=None):
  write() hangs indefinitely. In systrace we see that the
  select() call after write waiting for the write to be finished hangs.
- For non-blocking writes:
  write() works but flush() hangs. In systrace we see that
  ioctl(fd, TCSBRK, 1) which is (correctly) triggered by termios tcdrain
  hangs.

Inspecting USB traffic using usbmon, we can see that the data which is
written actually seems to be sent and looking at responses from the
Pixhawk bootloader and the timings it looks like all the data has
arrived.

This workaround uses non-blocking writes without flushing and this
seemed to prevent the issue from happening so far.

Debugging was done in collaboration with Beat Küng and David Sidrane.
2019-03-27 14:53:00 +01:00
Julian Oes 7be05396ba px_uploader.py: check for pyserial
If we dont explicitly check for pyserial, we can have the case where the
import works but the Serial object creation fails. However, we don't see
this because we have this huge try/catch block which swallows
everything.
2019-03-27 07:55:05 +01:00
Daniel Agar abb3817d31 boards new split VENDOR_MODEL naming convention 2018-11-26 14:40:14 -08:00
Pietro De Nicolao 6d3eb0450d px_uploader.py: exit code=1 if upload was not successful (#10681) 2018-10-15 11:21:31 -04:00
Matthias Grob e167e6bec4 px_uploader: catch non-standard baud exception
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.
2018-10-02 10:01:41 +02:00
Matthias Grob ebdea6e50d px_uploader: fix code and output spacing 2018-10-02 10:01:41 +02:00
David Sidrane 89a902524a px_uploader:Revert the rebooting text to have baudrate
Using the port name is platform dependent. It may give not
  provide the correct feedback. The port can be ttyS, or ftdi
  or CDC/ACM. While it is true that buadrate does not matter on
  CDC/ACM. It is better to give more information about what the
  code is doing before filtering by the port name.
2018-07-19 11:23:15 -07:00
David Sidrane f12acd7b0f px_uploader:Platform and Timming indepentant Serial detection
The correct determination of Windowed mode is critical to
   maximise the speed on a USB based upload.

   This commit bases the detection of a Serial (FTDI) on the
   fact a CDC ACM port (USB) does not really have a baud rate.
   We bump the baud rate to 233% of the requested baud rate to
   see if the SYNC is acked. If it is Acked it must be a USB
   port and Windowed mode is turned off. This removes unnessary
   baud rate based delays from the proframing logic. If it is a
   real Serial port getSync will not get the ACK and Windowed
   mode is turned on.
2018-07-18 08:11:11 +02:00
Julian Oes 11d4c32cd4 px_uploader: fix unknown variables 2018-07-17 07:44:58 -07:00
Julian Oes 8b91a68fea px_uploader: white space PEP8 fixes 2018-07-17 07:44:58 -07:00
Lorenz Meier 57c7e1a3eb Uploader: Ensure that we are not entering windowed mode on USB links 2018-07-15 16:15:21 +02:00
David Sidrane 05936f2ff7 px_uploader.py:Speed Improvments on Serial
The __getSync was costing about 16Ms per call.
  The commit uses a window based approch allowing
  the SYNC,<results> to be read all at one time.
  and delaying for programing based on transport
  time + 1 Ms;
  THe improvment at 2Mbps is >4 minutes to ~37
  seconds
2018-07-13 17:29:31 +02:00
Daniel Agar dec03873bc px_uploader add small delay before checking CRC result 2018-07-07 15:55:53 +02:00
Hamish Willee 7402d8223b Fix up references to pixhawk.org 2018-07-02 13:11:15 +02:00
Julian Oes 193993c54f px_uploader: fix typo and Python 3 issue 2018-06-29 08:46:45 +00:00
Julian Oes b0ec64efe8 px_uploader: fixed a couple small PEP8 warnings 2018-06-29 08:46:45 +00:00
Julian Oes 48edf9b65e px_uploader: remove commented out line 2018-06-29 08:46:45 +00:00
Julian Oes 4e43cc3518 px_uploader.py fix flashing issue (#9792)
This fixes a problem where the pyserial write call gets stuck.
It happens on a specific Fedora 28 system with internal USB ports as
well as USB hubs.
It is not clear why the problem is resolved but it is clearly
reproducible that with a timeout of 0, the write can get stuck and with
a timeout > 0 it works every time.

The exception added as part of this commit makes sense but has never
been triggered in my testing.
2018-06-28 20:18:22 -04:00
Daniel Agar e78b9a063f px_uploader cleanup status messages and print used percentage 2018-06-28 19:35:36 +00:00
korigod 4dfd77a0cd cmake: add nuttx force-upload target (#9717)
If the PX4FMUv2 board does not have the v5 uploader, it's not possible
to check the silicon revision to make sure it's safe to upload the
firmware which is more than 1 MB. However, if the user is sure the
silicon revision is not affected by this errata, he can upload the
firmware using px4_uploader.py with --force argument. This commit adds
`force-upload` make target to do it more convenient way.

Signed-off-by: Andrei Korigodski <akorigod@gmail.com>
2018-06-20 10:37:01 -04:00
Matthias Grob 58dd7be12a Cygwin: enable arm nuttx upload within cygwin
In the Cygwin environment the native Windows serial COM# ports get mapped
to /dev/ttyS# for POSIX compatibility. While # is one number lower inside
the environment than the COM port number because it's 0 indexed instead
of 1.

I added the necessary handling to all the dependent parts I found which
allows uploading to /dev/ttyS# when the cygwin platform is detected.
Now the usual "make px4fmu-v4 upload" and
"./Tools/upload.sh build/px4fmu-v4_default/px4fmu-v4_default.px4" work.
2018-05-09 11:31:42 +02:00
Julian Oes d646abcee7 px_uploader: improve silicon check
- Move check to proper location, out of the try catch block for OTP.
- Add Pixhawk specific check to notify users that want to flash
  px4fmu-v3_default on Pixhawks with older v4 bootloaders that do not
  support the silicon errata check.
2018-02-04 18:14:51 +01:00
Julian Oes a1ab84e5b9 px_uploader: make rev check a bit more intuitive 2018-02-04 18:14:51 +01:00
Lorenz Meier 6d00de7b25 Uploader: Move flash size check into appropriate bootloader version region 2018-02-04 18:14:51 +01:00
Julian Oes d175a75691 px_uploader: fix Python3 upload
This fixes the error below when using Python3:

  File "Tools/px_uploader.py", line 128, in
  __init__
      self.image.append('\xff')
      TypeError: an integer is required
2018-02-03 09:33:13 -05:00
Beat Küng e11008f30e px_uploader: minor text message update 2018-01-17 10:14:04 +01:00
ritul jasuja fed06955bc Update debug message as per connection link 2018-01-17 10:10:33 +01:00
Lorenz Meier e7fe8f7268 Uploader: Enforce matching maximum flash sizes
The goal is to force developers to use the correct target with the correct flash size. This prevents criticial functionality missing and is in particular important for FMUv2/FMUv3 boards. It is unmaintainable otherwise for the Pixhawk series.
2018-01-01 09:29:55 -05:00
Lorenz Meier 9e312e8dba Uploader: Do not show timeout for larger binaries when everything is still as expected. 2017-08-13 11:36:12 +02:00
Julien Lecoeur 38fff6546d Fix python 3 compatibility in px_uploader.py 2017-06-08 07:57:00 +02:00
Lorenz Meier 5f4fb744ca Uploader: Signal GCS or other connected devices that a FiFirmware upload is pending and requires device access. 2017-06-05 22:44:21 +02:00
Julian Oes e9aef2eb95 px_uploader.py: properly loop through all baudrates
In case when the baudrate change failed, we should still try that
baudrate again in the next iteration.
2017-04-22 08:00:51 +02:00
Julian Oes 2467297acf px_uploader.py: fix exception on baudrate change
This prevents an exception happening inside the serial stack.
2017-04-22 08:00:51 +02:00
Julian Oes 12c7421be9 px_uploader.py: remove unused exception vars 2017-02-27 11:23:09 +01:00
Julian Oes 974a9a0673 px_uploader.py: enable file to be used as module
In order to use px_uploader as a module from another Python script, all
the action needs to be moved into a main() function which is only called
if the file is run directly.
2017-02-27 11:23:09 +01:00
Julian Oes 090d7ebd6b px_uploader: fix SerialException error
Sometimes right after reboot, we got a `raise SerialException(
msg.errno, "could not open port {}: {}".format(self._port, msg))`.
If this happens now, we will just try again later.
2017-02-27 11:23:09 +01:00
Julian Oes b0a8073e15 px_uploader.py: small whitespace fix
Found by PEP8 checker.
2017-02-27 11:23:09 +01:00
Julian Oes ff87d43be0 px_uploader.py: vim modeline for indent settings 2017-02-27 11:23:09 +01:00