Dangerous Prototypes

Other projects => Open Bench Logic Sniffer => Topic started by: zelea2 on January 08, 2011, 12:45:15 am

Title: fw_update is not working in linux
Post by: zelea2 on January 08, 2011, 12:45:15 am
I have tried both the already available binary and the one I've built from the repository and they are not
working in Linux. The Linux ols-loader works just fine. Bellow is the output of fw_update first the Linux version and
then the Windows one:

=== Linux ===

$ lsusb
Bus 006 Device 046: ID 04d8:fc90 Microchip Technology, Inc.

$ ./fw_update -pid 0x4d8 -vid 0xfc90 -ver
fw_update Version: 0.2.0
U2IO BootLoader Version reading: FAILED.
Segmentation fault

$ ./fw_update -pid 0x4d8 -vid 0xfc90 -e
U2IO flash erasing: FAILED.
Device is not found.
Operation aborted.

=== Windows ===

C:>fw_update -vid 0x04d8 -pid 0xfc90 -ver
fw_update Version: 0.2.0
U2IO BootLoader Version reading: DONE.
BootLoader Version: 0.2.2

C:>fw_update -e -w -m flash -vid 0x04D8 -pid 0xFC90 -ix OLSv1-firmware-v2.1.hex

U2IO flash erasing: DONE.
U2IO flash programming: DONE.
RESET Device
Operation successfully completed.

C:>pause
Title: Re: fw_update is not working in linux
Post by: ian on January 08, 2011, 08:31:34 am
Hello, thanks for the bug report, sorry you're have problems with the upgrade utility. Which versions have you tried? The latest working versions for all platforms should be in this thread

http://dangerousprototypes.com/forum/in ... pic=1443.0 (http://dangerousprototypes.com/forum/index.php?topic=1443.0)
Title: Re: fw_update is not working in linux
Post by: robots on January 08, 2011, 03:46:31 pm
Are you sure you have the permission to access the usb device ? 

Device not found would hint that the program cannot see the device you specified. Try with sudo (on your own risk of course). I have no idea in which group you have to be - strongly depends on distro you use
Title: Re: fw_update is not working in linux
Post by: zelea2 on January 10, 2011, 04:27:25 pm
Quote
Are you sure you have the permission to access the usb device ?

It doesn't make any difference if I am running as root.
As stated before I'm using the latest SVN version from here:
svn checkout http://gadgetforge.gadgetfactory.net/sv ... bootloader (http://gadgetforge.gadgetfactory.net/svn/butterflylogic/trunk/bootloader)

It segfaults in PicBootloader::close
[00/00/0000 00:00:00] !!! Err: Assertion: m_hDevice != INVALID_HANDLE_VALUE  File: pic_bootloader.cpp, Line: 556

The following strace might help; I think the culprit is the failed IOCTL. What is that IOCTL supposed to do?
I'm running an up-to-date version of Debian unstable so I think Ubuntu should behave the same.
Is it an option in the kernel that I am missing like raw hid support ?

$ grep USB .config | grep -v "^#"
CONFIG_USB_IRDA=m
CONFIG_BT_HCIBTUSB=m
CONFIG_I2C_TINY_USB=m
CONFIG_SND_USB=y
CONFIG_SND_USB_AUDIO=m
CONFIG_USB_HID=m
CONFIG_USB_HIDDEV=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
CONFIG_USB_ARCH_HAS_EHCI=y
CONFIG_USB=y
CONFIG_USB_DEVICEFS=y
CONFIG_USB_DEVICE_CLASS=y
CONFIG_USB_MON=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_UHCI_HCD=y
CONFIG_USB_ACM=m
CONFIG_USB_PRINTER=m
CONFIG_USB_STORAGE=m
CONFIG_USB_SERIAL=m
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_BELKIN=m
CONFIG_USB_SERIAL_FTDI_SIO=m
CONFIG_USB_SERIAL_IR=m
CONFIG_USB_SERIAL_GARMIN=m
CONFIG_USB_SERIAL_MCT_U232=m
CONFIG_USB_SERIAL_PL2303=m
CONFIG_USB_SERIAL_OPTION=m
CONFIG_USB_CYPRESS_CY7C63=m

# id
uid=0(root) gid=0(root) groups=0(root)
# lsusb
Bus 006 Device 048: ID 04d8:fc90 Microchip Technology, Inc.

# strace ./fw_update -pid 0x4d8 -vid 0xfc90 -ver
[...]
open("/dev/bus/usb/006/048", O_RDWR)    = 3
ioctl(3, USBDEVFS_IOCTL or USBDEVFS_IOCTL32, 0xbfa7c494) = -1 ENOTTY (Inappropriate ioctl for device)
close(3)                                = 0
open("/dev/bus/usb/006/001", O_RDWR)    = 3
ioctl(3, USBDEVFS_IOCTL or USBDEVFS_IOCTL32, 0xbfa7c494) = 3
close(3)                                = 0
U2IO BootLoader Version reading: FAILED.i"..., 82
) = 82
time(NULL)                              = 1294672659
open("/etc/localtime", O_RDONLY)        = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3661, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=3661, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb780f000
read(3, "TZif277"..., 4096) = 3661
_llseek(3, -26, [3635], SEEK_CUR)       = 0
read(3, "nGMT0BST,M3.5.0/1,M10.5.0n", 4096) = 26
close(3)                                = 0
munmap(0xb780f000, 4096)                = 0
open("log.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb780f000
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
_llseek(3, 0, 0, SEEK_SET)            = 0
write(3, "[00/00/0000 00:00:00] !!! Err: A"..., 113) = 113
close(3)                                = 0
munmap(0xb780f000, 4096)                = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault
Title: Re: fw_update is not working in linux
Post by: robots on January 10, 2011, 04:50:42 pm
[quote author="zelea2"]
The following strace might help; I think the culprit is the failed IOCTL. What is that IOCTL supposed to do?
I'm running an up-to-date version of Debian unstable so I think Ubuntu should behave the same.
Is it an option in the kernel that I am missing like raw hid support ?
[/quote]

Ioctl is another operation like read/write, but usually preforms some parameter changing.

You dont need any hidraw driver, as all the traffic is managed by libusb. It is strange, because i cannot use the boot-loader either (was able to last month or so), let me check whats wrong.

This problem is just adding to my desire to write some "normal"/better client for the bootloader :-) (will do on Wednesday after exam)
Title: Re: fw_update is not working in linux
Post by: robots on January 12, 2011, 11:17:20 pm
As promised, In less than 2 hours I have simple program that can write/read/erase OLS' pic flash. I have, however, a bug in it and it did ERASE/overwrite my bootloader !!!

Tomorrow I will post working version, once I figure out how to flash my bootloader back without pickit :)
Title: Re: fw_update is not working in linux
Post by: ian on January 12, 2011, 11:45:40 pm
You can use the Bus Pirate. There is a tutorial on the wiki.
Title: Re: fw_update is not working in linux
Post by: robots on January 13, 2011, 12:29:49 pm
I did that, in fact I used the pirate pic loader which works fine! (not looking at the binary initialization code)
Title: Re: fw_update is not working in linux
Post by: gebhardt on January 26, 2014, 12:38:27 pm
Hi,

this is just a me-too post :-( , mentioning that even with the current git

commit ef622b2038dab8eecc85d98a30aeca3130b9d432
Author: Dobrica Pavlinusic <...>
Date:  Mon Apr 1 16:04:05 2013 +0200

source, compiled with

LIBS=-lusb ./configure --with-usb-includes=/usr/include
make

I get the same error as zelea2 .

# ./fw_update -e -w -v -m all -vid 0x04D8 -pid 0xFD0B -ix /tmp/firmware/USBIRToy.v22.hex
U2IO flash erasing: FAILED.
Device is not found.
Operation aborted.

My OS is ubuntu 12.04 LTS, i386
libusb++-0.1-4c2                              2:0.1.12-20       
libusb++-dev                                  2:0.1.12-20       
libusb-0.1-4                                  2:0.1.12-20       
libusb-1.0-0                                  2:1.0.9~rc3-2ubuntu1
libusb-1.0-0-dev                              2:1.0.9~rc3-2ubuntu1
libusb-dev                                    2:0.1.12-20       
libusbmuxd1                                  1.0.7-2ubuntu0.1   

A system trace reveals an "Inappropriate ioctl" error

open("/dev/bus/usb/003/003", O_RDWR)    = 3
ioctl(3, USBDEVFS_IOCTL or USBDEVFS_IOCTL32, 0xbfb6f1e0) = -1 ENOTTY (Inappropriate ioctl for device)

/dev/bus/usb/003/003 points to:
Bus 003 Device 003: ID 04d8:fd08 Microchip Technology, Inc.

Cheers, Thomas
Title: Re: Re: fw_update is not working in linux
Post by: MickM on January 26, 2014, 07:46:15 pm
Hi;
  maybe this will help'
Code: [Select]
**** Ubuntu pre-reqs  ****
See also : https://github.com/GadgetFactory/OpenBench-Logic-Sniffer

sudo apt-get install libusb-1.0-0-dev


**** Build new loader ****
See:
https://github.com/robots/ols-fwloader
http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1654&start=90
http://dangerousprototypes.com/docs/Logic_Sniffer:_Comprehensive_update_application


Build ols_fw_loader
--------------------

Checkout sw
git clone http://github.com/robots/ols-fwloader

Build sw
cd ols-fwloader

For git repository first run:
autoreconf --install

./configure
make
sudo make install

Note: Installs ols_fwloader in /usr/local/bin
 



**** UPDATE PIC ****

Write Pic FW
--------------
sudo ols_fwloader  -f BOOT -n -P /dev/ttyACM0 -W -w PIC_firmware/OLSv1.firmware.v3.0.hex

Found OLS HW: 1, FW: 2.3, Boot: 2
Found flash: WINBOND W25X40
OLS switched to bootloader mode
Bootloader version 0.2.2
Bootloader version 0.2.2
Reading file 'PIC_firmware/OLSv1.firmware.v3.0.hex'
Erasing flash ...
Writing flash ... (0x0800 - 0x3c00)


Verify Pic FW
--------------
sudo ols_fwloader  -f BOOT -n -P /dev/ttyACM0 -V -w PIC_firmware/OLSv1.firmware.v3.0.hex

Found OLS HW: 1, FW: 3.0, Boot: 2
Found flash: WINBOND W25X40
OLS switched to bootloader mode
Bootloader version 0.2.2
Bootloader version 0.2.2
Checking flash ... (0x0800 - 0x3c00)
Verified OK! :)





**** Update FPGA ****

Write FPGA FW
--------------
sudo ols_fwloader  -f APP -P /dev/ttyACM0 -W -t BIN -w FPGAROM/logic_sniffer_3.07-Demon-Core.bit

Found OLS HW: 1, FW: 3.0, Boot: 2
Found flash: WINBOND W25X40
Reading file 'FPGAROM/logic_sniffer_3.07-Demon-Core.bit'
Erasing flash ...
Chip erase ... done :)
Will write 662 pages
.....................


Verify FPGA FW
----------------
sudo ols_fwloader  -f APP -P /dev/ttyACM0 -V -t BIN -w FPGAROM/logic_sniffer_3.07-Demon-Core.bit

Found OLS HW: 1, FW: 3.0, Boot: 2
Found flash: WINBOND W25X40
Checking flash ...
.....................
Verify OK


Selftest
----------------
sudo ols_fwloader -P /dev/ttyACM0 -f APP -S

Found OLS HW: 1, FW: 3.0, Boot: 2
Found flash: WINBOND W25X40
done...
Passed self-test :)


**** Linux install UDEV Rules ****

See:
----------------
http://dangerousprototypes.com/docs/Logic_Sniffer_quick_start_guide#Hardware_installation_2


#File /etc/udev/rules.d/ols.rules
#Rules for Openbench Logix Snifferslogic. Creates a nice link to the ols
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fc92", MODE="0666", SYMLINK+="OpenLogicSniffer"


sudo restart udev




 

Mick M
Title: Re: fw_update is not working in linux
Post by: gebhardt on January 27, 2014, 09:52:49 pm
Hello MickM,

thank you very much for your reply!
Honestly I'm confused about the different fwloader programs.

I'm owning an IR USB Toy.

First I stumbled upon the thread 3697
"fw_update not working in linux or OS X"
Then google lead me to this thread (1628). I did not
realize that this thread treats the Open Bench Logic Sniffer
since its subject "fw_update is not working in linux"
was almost identical and the fw_update cli syntax and the
error messages are identical to the output which I get.

The code that you mention above, compiles to an executable "ols_fwloader"
which has a different command line syntax than fw_update.

How does ols_fwloader relate to fw_loader? Shouldn't I use fw_loader?

Somwhat puzzled, Thomas

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01062101280session_write_close ( )...(null):0
20.01092232856ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01092233632Database_MySQL->query( ).../DatabaseHandler.php:119
40.05572372352Database_MySQL->error( ).../Db-mysql.class.php:273