Fri, 18 Jan 2019 12:33:39 +0100
[hp34970a] fixes and improvements on the protocol description
================================================== Updating the Prologix USB-GPIB firmware on Linux ================================================== :author: David Douard :Category: Electronics :Tags: test equipment, GPIB, Prologix Prologix_ sell several low cost GPIB controllers. I have one their old deprecated dongle "GPIB-USB Controller 4.2" and had fun with it with my pygpibtoolkit_ project. It's a very simple dongle consisting in an Atmel ATMega164P microcontroller and a FTDI FT245FL chip for the USB<->RS232 convertion. .. image:: {filename}images/prologix/prologix_4.2_small.jpg :alt: The Prologix GPIB-USB controller. Unfortunately, it's no longer available (I find this unfortunate because it was really cheap, and very useful for hobbyist like me). Upgrading the buggy firmware ============================ My controller had the version 5.2 of the firmware, which really is buggy. For example if a device on the GPIB bus is continuously sending data and the controller is in "auto" mode (in which it automatically perform a reading of the available data), then it was impossible to send it commands anymore. Unfortunately, the Prologix web site only describe the product as "No longer in production". There is still an available FAQ_ and the `user manual`_, but the firmware update procedure is not described any more. However, the `directory serving all the firmwares`_ for their products still have the firmwares for this device. The latest published version is the `4.2-6.95`_ (in fact, it's the version 6.95 of the firware for the version 4.2 of the USB-GPIB controller). The content of this archive is: .. code-block:: bash unzip -l ~/Downloads/gpib-usb-4.2-6.95.zip Archive: /home/david/Downloads/gpib-usb-4.2-6.95.zip Length Date Time Name --------- ---------- ----- ---- 244837 2007-07-08 23:57 avrdude.conf 186880 2007-07-08 23:57 avrdude.exe 31162 2010-09-21 10:57 m16.hex 31542 2010-09-21 10:57 m164.hex 61440 2010-06-16 18:21 PxUpdate.exe 409 2009-01-21 11:00 readme.txt --------- ------- 556270 6 files Obviously, Windows stuff only, and no documentation on how to upgrade the device on Linux. But the fact it uses avrdude_ is good sign it might be possible to find solutions on Linux. According the names of the hex files, it seems there have 2 versions of the hardware, one with a ATMega16 and one with a ATMega164P (mine uses a 164P). Now, the question is: how is the AVR programmed? There are dozens of 'backends' available on avrdude. Doing a ``string`` on the main exe in the archive, PxUpdate.exe, shows a few interesting things, especially this: .. code-block:: bash strings PxUpdate.exe | grep -i avr avrdude.exe -p %s -P \\.\COM%d -c avr109 -u -e -U flash:w:%s AVRBOOT So we know the command line used by this firmware update tool, and we known it uses the AVR's bootloader as decribed in the AVR109_ application note. But any attempt to read the content of the flash using: .. code-block:: bash avrdude -p m164p -c avr109 -U flash:r:flash.hex:i fails stating the avr does not respond: .. code-block:: bash avrdude -P /dev/ttyUSB0 -p m164p -c avr109 -v -v -U flash:r:flash2.hex:i avrdude: Version 6.1, compiled on Sep 11 2014 at 20:00:34 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/etc/avrdude.conf" User configuration file is "/home/david/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyUSB0 Using Programmer : avr109 AVR Part : ATmega164P Chip Erase delay : 55000 us PAGEL : PD7 BS2 : PA0 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 4 10 128 0 no 512 4 0 9000 9000 0xff 0xff flash 33 6 128 0 yes 16384 128 128 4500 4500 0xff 0xff lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00 Programmer Type : butterfly Description : Atmel AppNote AVR109 Boot Loader Connecting to programmer: .avrdude: ser_recv(): programmer is not responding avrdude: butterfly_recv(): programmer is not responding So there is something else required to put the device under firmware upgrade state. I was wondering if there is an undocumented controller command (anything starting with ``++`` is interpreted as a controller command), so I searched for the ``++`` string in ``PxUpdate.exe``: .. code-block:: bash strings PxUpdate.exe | grep ++ Microsoft Visual C++ Runtime Library ++rst No magic undocumented command, but a reset of the controller is performed by this tool. Let's try this: .. code-block:: bash stty -F /dev/ttyUSB0 speed 115200 cs8 -cstopb -parenb echo -en '++rst\r' > /dev/ttyUSB0; avrdude -P /dev/ttyUSB0 -p m164p -c avr109 -v -v -U flash:r:flash2.hex:i avrdude: Version 6.1, compiled on Sep 11 2014 at 20:00:34 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/etc/avrdude.conf" User configuration file is "/home/david/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyUSB0 Using Programmer : avr109 AVR Part : ATmega164P Chip Erase delay : 55000 us PAGEL : PD7 BS2 : PA0 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 4 10 128 0 no 512 4 0 9000 9000 0xff 0xff flash 33 6 128 0 yes 16384 128 128 4500 4500 0xff 0xff lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00 Programmer Type : butterfly Description : Atmel AppNote AVR109 Boot Loader Connecting to programmer: . Found programmer: Id = "AVRBOOT"; type = S Software Version = 1.0; Hardware Version = 1.0 Programmer supports auto addr increment. Programmer supports buffered memory access with buffersize=128 bytes. Programmer supports the following devices: Device code: 0x76 avrdude: devcode selected: 0x76 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e940a avrdude: safemode: Fuse reading not support by programmer. Safemode disabled. avrdude: reading flash memory: Reading | ################################################## | 100% 0.26s avrdude: writing output file "flash2.hex" avrdude done. Thank you. **Much better!** Now I can upgrade the firmware: .. code-block:: bash echo -en '++rst\r' > /dev/ttyUSB0; avrdude -P /dev/ttyUSB0 -p m164p -c avr109 -v -v -U flash:w:m164.hex Et voilĂ ! The Prologix GPIB-USB interface is upgraded to the latest available software. From what I've seen so far, it seems more stable (at least I can read data from my HP5442A and HP3456A in "fast" mode without loosing my GPIB controller.) .. _`4.2-6.95`: http://prologix.biz/downloads/gpib-usb-4.2-6.95.zip .. _Prologix: http://prologix.biz/ .. _FAQ: http://prologix.biz/gpib-usb-4.2-faq.html .. _`user manual`: http://prologix.biz/downloads/PrologixGpibUsbManual-4.2.pdf .. _pygpibtoolkit: https://www.logilab.org/project/pygpibtoolkit .. _`directory serving all the firmwares`: http://prologix.biz/downloads/ .. _avrdude: http://savannah.nongnu.org/projects/avrdude/ .. _avr109: http://www.atmel.com/Images/doc1644.pdf