gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Flash Equipment > Flash2Advance USB problems with Linux 2.6

#20597 - Ingy - Thu May 13, 2004 4:04 pm

I have a Flash2Advance USB link cable and I'm having a lot of trouble getting it to work with Linux 2.6. With kernel 2.4 I used software called if2a (http://deyv.free.fr/gba/f2a/) which worked by using the ezusb2131 drivers(http://ezusb2131.sourceforge.net/).

However, the ezusb2131 drivers won't compile properly under kernel 2.6 and the guy who wrote them believes that they are now unnecessary - their functionality is apparently replaced by fxload, which I've been playing about with a bit.

This is the result of trying to load the f2afirm.hex file on to the chip directly:

Code:
ashgrove:/home/ingy/gba/if2a-0.3a# fxload -D /proc/bus/usb/003/019 -I f2afirm.hex -vv
microcontroller type: fx
single stage:  load on-chip memory
open RAM hexfile image f2afirm.hex
stop CPU
write on-chip, addr 0x0000 len 1008 (0x03f0)
write on-chip, addr 0x03f0 len 1008 (0x03f0)
write on-chip, addr 0x07e0 len 1008 (0x03f0)
write on-chip, addr 0x0bd0 len 1008 (0x03f0)
write on-chip, addr 0x0fc0 len 1008 (0x03f0)
write on-chip, addr 0x13b0 len 1008 (0x03f0)
can't write 1008 bytes external memory at 0x17a0
unable to download f2afirm.hex


So I try again, using the firmware provided with fxload as a second-stage loader, which apparently allows me to write to external RAM or EEPROM:

Code:
ashgrove:/home/ingy/gba/if2a-0.3a# fxload -D /proc/bus/usb/003/019 -s /usr/share/usb/a3load.hex -I f2afirm.hex -vv
microcontroller type: fx
1st stage:  load 2nd stage loader
open RAM hexfile image /usr/share/usb/a3load.hex
stop CPU
write on-chip, addr 0x0357 len   23 (0x0017)
write on-chip, addr 0x01b5 len  297 (0x0129)
write on-chip, addr 0x0080 len  309 (0x0135)
write on-chip, addr 0x02de len   71 (0x0047)
write on-chip, addr 0x0003 len    3 (0x0003)
write on-chip, addr 0x0325 len   50 (0x0032)
write on-chip, addr 0x0043 len    3 (0x0003)
write on-chip, addr 0x0400 len    4 (0x0004)
write on-chip, addr 0x0000 len    3 (0x0003)
EOF on hexfile
write on-chip, addr 0x036e len   12 (0x000c)
... WROTE: 775 bytes, 10 segments, avg 77
reset CPU
open RAM hexfile image f2afirm.hex
2nd stage:  write external memory
SKIP on-chip RAM, 1008 bytes at 0x0000
SKIP on-chip RAM, 1008 bytes at 0x03f0
SKIP on-chip RAM, 1008 bytes at 0x07e0
SKIP on-chip RAM, 1008 bytes at 0x0bd0
SKIP on-chip RAM, 1008 bytes at 0x0fc0
SKIP on-chip RAM, 1008 bytes at 0x13b0
write external, addr 0x17a0 len 1008 (0x03f0)
write external, addr 0x1b90 len 1008 (0x03f0)
EOF on hexfile
write external, addr 0x1f80 len  128 (0x0080)
stop CPU
2nd stage:  write on-chip memory
write on-chip, addr 0x0000 len 1008 (0x03f0)
write on-chip, addr 0x03f0 len 1008 (0x03f0)
write on-chip, addr 0x07e0 len 1008 (0x03f0)
write on-chip, addr 0x0bd0 len 1008 (0x03f0)
write on-chip, addr 0x0fc0 len 1008 (0x03f0)
write on-chip, addr 0x13b0 len 1008 (0x03f0)
SKIP external RAM, 1008 bytes at 0x17a0
SKIP external RAM, 1008 bytes at 0x1b90
EOF on hexfile
SKIP external RAM, 128 bytes at 0x1f80
... WROTE: 8192 bytes, 9 segments, avg 910
reset CPU


And that seems to work fine. However, the device soon disappears from /proc/bus/usb/003/, and dmesg gives me this output:
Code:
usb 3-1: USB disconnect, address 19
usb 3-1: new full speed USB device using address 20
usb 3-1: control timeout on ep0in
usb 3-1: device not accepting address 20, error -110
usb 3-1: new full speed USB device using address 21
usb 3-1: control timeout on ep0in
usb 3-1: device not accepting address 21, error -110


And I can't access the device again without disconnecting and reconnecting it, presumably wiping the firmware. Now I'm not sure whether those "control timeout on ep0in" messages are down to a problem with the 2.6 usb subsystem, or (more likely, perhaps) because I'm largely unsure as to what I should be doing. Does anyone have experience of this / any ideas as to what I should try next?

#20714 - spooo - Sat May 15, 2004 4:44 pm

Hi,

I got if2a work with fxload.

First edit f2afirm.hex, and remove all lines containing "AAAA...".
The first one starts with ":10120000AA".
The last one starts with ":101FF000AA".
Next, plug the f2alinker, and use fxload to upload the cable firmware :

For instance :
lsusb
dev=`lsusb|grep -i ezusb|awk '{print "/proc/bus/usb/" $2 "/" $4;}' | cut -d: -f1`
/sbin/fxload -D "$dev" -I f2afirm.hex -vv -t an21

Now you can see with lsusb that the cable ID has changed from 0547:2131 to 0547:1002.

For if2a to work, you have to slightly patch it.
Modify usb.c line 24, change "firmware_loaded=0" to "firmware_loaded=1".
Recompile with "make if2a", then it should work as before (kernel module ezusb2131 is not needed anymore).

The same change may be applied to original f2a (http://www.emulinks.de/f2a/).

I'll release an updated version of if2a very soon.

#20720 - twink - Sat May 15, 2004 11:33 pm

thanks for this great post =D, was just trying to figure out how to do this yesterday.

#20722 - Ingy - Sun May 16, 2004 12:42 am

After a quick test with if2a -M and writing a test file to the cartridge, I can conclude that everything is working perfectly again.

spooo, my hat is off. Thank you!

#21002 - Gnurou - Fri May 21, 2004 2:18 pm

Hi,

I've just got my f2a USB linker and am trying to use it with Linux 2.6 using these instructions - unfortunately I'm not as lucky as you guys!

I've modified the firmware and usb.c as described. I'm successful uploading the firmware too. However, once I try flashing nothing happens and all is get is a serie of messages like:

usb_bulk_write: error writing to bulk endpoint 4: Connection timed out

Any suggestion/advices? The cardridge is a FlashAdvancePro.

Thanks in advance.

#21021 - Gnurou - Fri May 21, 2004 6:29 pm

Ok, it was, guess what, just me being plain stupid.

I didn't know the GBA should be turned OFF when running the program, then turned on when instructed. It was my first try at GBA flashing. So shame on me! ^_^

I had an extra step to do however. When uploading the modified firmware, hotplug gives the device to the "usbtest" (?) driver. I have to remove it before running if2a, otherwise it claims that the device is busy. I'm on Mandrake 10 here.

One weird thing still. Betweek every flash, I have to unplug the f2a linker, re-plug it, and reload the firmware. Trying two flashes without unplugging the f2a results in the second run staying still, without any message at all.

Anyway - my apologies for the useless post. Spoo, thanks for your great work on if2a, with it I can flash my devs from the comfort of my favorite OS!

#21576 - em4853 - Tue Jun 01, 2004 3:39 am

I tried as advised but when i try to run:

/sbin/lsusb
dev=`/sbin/lsusb|grep -i ezusb|awk '{print "/proc/bus/usb/" $2 "/" $4;}' | cut -d: -f1`
/sbin/fxload -D "$dev" -I f2afirm.hex -vv -t an21

i get the error:

Unknown line at line 58
Unknown line at line 2296
Unknown line at line 2297
Unknown line at line 2298
....
Unknown line at line 2333
Unknown line at line 2334
Unknown line at line 2335

(there are quite a few of those)

Please tell me any advice you can give!

#29309 - startail - Wed Nov 17, 2004 1:56 pm

Code:

Problem Solved...
usbtest                16524  0 <- Caused the Driver to be locked to the USBTest Modules

Still have to re-plug, reload firmwire, unload usbtest to be able to flash everything one more time.


I'm running Fedora 3 with a kompiled kernel of my own of 2.6.9.
It could be so that I'm missing a module or something. Maybe someone can help me out here.

I did just as show abow and loaded everything. But when running
./if2a -M this is what I see...

"Please turn OFF then ON your GBA with SELECT and START held down."

then I just get a prompt again without it connecting to the GBA.



Here's a debug log with -vv
Code:

info: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
post-boot: 0804B970 00B97573 00C03FF4 00B3E57F 00000002 0804B970 00000042 0804B970 00000042 BFFFF820 00B3E75C 00C04460 0804B970 00000042 BFFFF830 00C044A7
info: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Firmware uploaded.
Trying address 0x8040000...
Trying address 0x8088000...
Trying address 0x80d0000...
Trying address 0x8118000...
Trying address 0x8160000...
Trying address 0x81b0000...
Trying address 0x81f8000...
Trying address 0x8240000...
Trying address 0x8288000...
Trying address 0x82d0000...
Trying address 0x8318000...
Trying address 0x8360000...
Trying address 0x83b0000...
Trying address 0x83f8000...
Trying address 0x8440000...
Trying address 0x8488000...
Trying address 0x84d0000...
Trying address 0x8518000...
Trying address 0x8560000...
Trying address 0x85b0000...
Trying address 0x85f8000...
Trying address 0x8640000...
Trying address 0x8688000...
Trying address 0x86d0000...
Trying address 0x8718000...
Trying address 0x8760000...
Trying address 0x87b0000...
Trying address 0x87f8000...
Trying address 0x8840000...
Trying address 0x8888000...
Trying address 0x88d0000...
Trying address 0x8918000...
Trying address 0x8960000...
Trying address 0x89b0000...
Trying address 0x89f8000...
Trying address 0x8a40000...
Trying address 0x8a88000...
Trying address 0x8ad0000...
Trying address 0x8b18000...
Trying address 0x8b60000...
Trying address 0x8bb0000...
Trying address 0x8bf8000...
Trying address 0x8c40000...
Trying address 0x8c88000...
Trying address 0x8cd0000...
Trying address 0x8d18000...
Trying address 0x8d60000...
Trying address 0x8db0000...
Trying address 0x8df8000...
Trying address 0x8e40000...
Trying address 0x8e88000...
Trying address 0x8ed0000...
Trying address 0x8f18000...
Trying address 0x8f60000...
Trying address 0x8fb0000...
Trying address 0x8ff8000...
Trying address 0x9040000...
Trying address 0x9088000...
Trying address 0x90d0000...
Trying address 0x9118000...
Trying address 0x9160000...
Trying address 0x91b0000...
Trying address 0x91f8000...
Trying address 0x9240000...
Trying address 0x9288000...
Trying address 0x92d0000...
Trying address 0x9318000...
Trying address 0x9360000...
Trying address 0x93b0000...
Trying address 0x93f8000...
Trying address 0x9440000...
Trying address 0x9488000...
Trying address 0x94d0000...
Trying address 0x9518000...
Trying address 0x9560000...
Trying address 0x95b0000...
Trying address 0x95f8000...
Trying address 0x9640000...
Trying address 0x9688000...
Trying address 0x96d0000...
Trying address 0x9718000...
Trying address 0x9760000...
Trying address 0x97b0000...
Trying address 0x97f8000...
Trying address 0x9840000...
Trying address 0x9888000...
Trying address 0x98d0000...
Trying address 0x9918000...
Trying address 0x9960000...
Trying address 0x99b0000...
Trying address 0x99f8000...
Trying address 0x9a40000...
Trying address 0x9a88000...
Trying address 0x9ad0000...
Trying address 0x9b18000...
Trying address 0x9b60000...
Trying address 0x9bb0000...
Trying address 0x9bf8000...
Trying address 0x9c40000...
Trying address 0x9c88000...
Trying address 0x9cd0000...
Trying address 0x9d18000...
Trying address 0x9d60000...
Trying address 0x9db0000...
Trying address 0x9df8000...
Trying address 0x9e40000...
Trying address 0x9e88000...
Trying address 0x9ed0000...
Trying address 0x9f18000...
Trying address 0x9f60000...
Trying address 0x9fb0000...
Trying address 0x9ff8000...


Loaded modules are:
Code:

usbtest                16524  0
shfs                   48016  3
nls_utf8                2176  1
vmnet                  27184  0
vmmon                  43736  0
md5                     4224  1
ipv6                  230784  12
autofs4                17412  0
i2c_dev                 9344  0
i2c_core               22416  1 i2c_dev
rfcomm                 33948  0
l2cap                  22020  5 rfcomm
ipt_REJECT              7040  1
ipt_state               1920  1
ip_conntrack           43412  1 ipt_state
iptable_filter          2944  1
ip_tables              16640  3 ipt_REJECT,ipt_state,iptable_filter
button                  6672  0
battery                 8964  0
hci_usb                12416  2
bluetooth              43268  7 rfcomm,l2cap,hci_usb
ac                      4868  0
uhci_hcd               29328  0
hw_random               5396  0
nvidia               3466780  12
snd_intel8x0           31016  0
snd_ac97_codec         63568  1 snd_intel8x0
snd_pcm_oss            49832  0
snd_mixer_oss          17920  1 snd_pcm_oss
snd_pcm                86664  2 snd_intel8x0,snd_pcm_oss
snd_timer              22916  1 snd_pcm
snd_page_alloc          9608  2 snd_intel8x0,snd_pcm
snd_mpu401_uart         6912  1 snd_intel8x0
snd_rawmidi            22820  1 snd_mpu401_uart
snd_seq_device          7816  1 snd_rawmidi
snd                    51044  9 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
soundcore               9056  1 snd
8139too                23424  0
mii                     4992  1 8139too
floppy                 57168  0
reiserfs              243796  4


messages says:
Code:

Nov 17 13:50:30 tailz kernel: usb 2-2.1: usbfs: process 4291 (if2a) did not claim interface 0 before use

#29315 - Vince - Wed Nov 17, 2004 7:16 pm

Hello,

I have had a report on french forums about the same problem as yours on a 2.6.8.1 Mdk kernel. It is interesting you post here because I had been starting to think it was a MDK-related problem.

Concerning the french person having the problem, we are heading to a HW-related issue (sometimes it works after reboot, most of the time it does not)

In your special case, first try to remove the usbtest module (where does the quote at the beginning of your post come from ?) and let me know if that improves the situation. I suspect it to stick to your F2A instead of the if2a program since it is a module that is used with EZ-USB devices (as is F2A) to test various aspects of USB on Linux.

There is also a bug in if2a where we should loop and wait for the F2A reply. Instead, we just test the reply once (around lines 838 or so of if2a.c, see commented source line). The problem is that when the F2A does not reply anything (as this is the case here, see info: field of debug logs), execution continues whereas we should wait for a real reply.

Cheers,

Vince

#29345 - Ingy - Thu Nov 18, 2004 12:13 pm

For the record, I'm getting the same thing with Ubuntu, kernel 2.6.8.1. That is, if2a failing and these kind of messages:

usbfs: process 4291 (if2a) did not claim interface 0 before use

#29350 - Vince - Thu Nov 18, 2004 7:03 pm

Howdy,

The "usbfs: process 4291 (if2a) did not claim interface 0 before use" used to happen on 2.4 kernels as well and is not harmful, unless initialization of USB devices has changed with 2.6 kernels (which I doubt).

As I said, look for and remove usbtest from your list of modules, this may help solving the problem.

Vince