OESF Portables Forum

Everything Else => Sharp Zaurus => Model Specific Forums => Distros, Development, and Model Specific Forums => Archived Forums => Cxx0 Hardware => Topic started by: omega on June 10, 2004, 07:34:08 am

Title: C860 as usb host by software?
Post by: omega on June 10, 2004, 07:34:08 am
Hi,

I have been wondering about this for a while now. Since USB is bidirectional, is there a way to emulate a usb host in software using the client port on the c860?

I understand that there would be no power supply available on the client port, but this could be implemented in a cable. Apart from this though, what other hardware features are missing from a client side implementation of USB? Is there normally a hardware generated clock signal provided by the host?  

The reason i\'m thinking of this is that normally it is not conceivable to use a client usb device as a host - but in this case the client is intelligent and not a passive device like a camera, etc...
Title: C860 as usb host by software?
Post by: omega on July 02, 2004, 10:45:11 am
*** BUMP ***

So any ideas? I was looking around but didn't see anything so far...
Title: C860 as usb host by software?
Post by: scoutme on July 02, 2004, 05:16:14 pm
gonna find something on the net..

I'll let you know
Title: C860 as usb host by software?
Post by: lardman on September 07, 2004, 04:01:46 pm
I hate to bring this up again... ;-)

I was looking at how usb dongles (the kind of thing you have to use to work some software) work today (fairly random) and came around to this topic again.

Can someone explain once and for all why it's not possible to implement a USB host with the hardware built into the Z (that is my understanding of what people think, but there's always a little chink in the argument exposed by my lack of understanding)?

My understanding is that most of the USB host can actually be implemented in software; therefore is there enough hardware to make this possible (I realise this would require a fair bit of development and number-crunching power in the software, but I'm just trying to get my head around it)?

Of course most of this functionality is normally built into the hardware, but is there even the fainest glimmer of a possibility of being able to run/emulate it in code?

Cheers,


Si
Title: C860 as usb host by software?
Post by: lardman on September 08, 2004, 10:08:20 am
What is the bit of hardware which is the USB client (e.g. is there a USB client chip)? Or is this handled directly by the CPU (I read somewhere that PXA chips have some USB functionality built-in)?


Si
Title: C860 as usb host by software?
Post by: tz on September 08, 2004, 04:45:03 pm
I won't go into deep theoretical possibilities (changing the USB ports to digitial I/O, adding RTLinux (real-time extensions) and bit-banging the USB host signals).

The USB controller is in the ARM chip.  AFAIK it does NOT have a host mode, and is USB 1.1 which does NOT have a bidirectional mode.  One of the (IMO) errors of USB is that it wasn't peer-to-peer, it *required* a host, and could only communicate host initiated transactions to a peripheral.

The timing and protocol are different depending on Host/Target.  Some chips (like the one in the Ratoc CF card) can be configured to be either host or target.  Most can't, including the onboard USB controller on the Z.

I don't know if "bit banging" is possible (I use my sound port as a UART for GPS), but the USB "controller" is only designed to handle the target half of the USB protocol.  So it can't initiate, only respond.  The new USB 2.0 chips that can do peer-to-peer have the extra modes and registers to make this work.

So you can't put the onchip USB controller into a state where it would send the correct protocol to communicate to another USB target device.

By "bit banging", I mean implementing a software USB host that sets or clears bits in an output port register within the USB timing specs.

Another problem is power - the host or hub provides it.  You would have to hack in a 5 volt power to both target devices from somewhere.

Theoretically, someone could come up with a USB "null modem" that would be a pair of hosts with some intelligence that would simply echo USB Serial (and maybe network) across the two host ports.
Title: C860 as usb host by software?
Post by: iamasmith on September 08, 2004, 05:20:42 pm
Woah,

Don't like the sound of trying to implement the bitbanging stuff for USB.

I had some experience of writing this sort of assembler stuff in my early career. Without clocking hardware to rely on to measure intervals you are into tight assembler, counting cycles to produce timing loops, complete loss of portability etc.
Not a good combination for a Linux driver.

I know the SL-6000 has Host USB HW, so it may feature in a future model.... anyone know if the PXA270 has USB 2 features ??? - There's rumours that's a likely processor for the SL-C9x0 series...

- Andy
Title: C860 as usb host by software?
Post by: lardman on September 08, 2004, 06:02:11 pm
Quote
The USB controller is in the ARM chip.

Okay, are there any specs for the hardware/api/asm instructions that anyone knows of? And is this the PXA or the SA, or both?

Quote
Another problem is power - the host or hub provides it. You would have to hack in a 5 volt power to both target devices from somewhere.

The power's not a major issue - it's always possible to supply that externally, and with a battery powered device this is always going to be a possible issue anyway. I was really interested in what you call "bit-banging" and whether this would be possible.

I've been doing some digging of my own, but still need to learn more; but from what you say it's the timing (or rather being able to provide the timing signals or signals at the correct times, etc.) which will cause the issues?

I agree with iamasmith that if it comes down to having to clock the hardware speed and adjust the assembly accoringly to ensure that the timing is correct it's really a non-starter, but I live in hope that this might not be necessary ;-)

My real issue is that I don't know what the hardware differences are between the host and client chips and their functionality; the same goes for the software (I need to dig out the kernel source and take a look).

Quote
The new USB 2.0 chips that can do peer-to-peer have the extra modes and registers to make this work.

Yes, I realise this, but it was my understanding that only basic hardware is actually needed and that the rest can be performed in software (should one so desire - and I'm certainly interested ;-))

Quote
Theoretically, someone could come up with a USB "null modem" that would be a pair of hosts with some intelligence that would simply echo USB Serial (and maybe network) across the two host ports.

Or would it be easier to implement the On-the-go part of the USB spec (which can still runa t slow speed iirc), as this should be more similar to the current client setup than a complete host.


Si

P.S.

Quote
I won't go into deep theoretical possibilities (changing the USB ports to digitial I/O, adding RTLinux (real-time extensions) and bit-banging the USB host signals).

I'd be interested, as, I'm sure, would others. I'm always happy to learn :-)
Title: C860 as usb host by software?
Post by: omega on September 09, 2004, 04:15:21 am
I would also be interested... I'm bit banging a few io ports on my microcontroller project at the moment... not easy but doable...

We could of course get a serial to usb host chip and try and drive it from the serial port on the zaurus... ah yes i can just see the speed now.  half an hour to download a song from the harddrive! probably enough to read an ebook by though! lol
Title: C860 as usb host by software?
Post by: lardman on September 09, 2004, 06:44:43 am
Quote
We could of course get a serial to usb host chip and try and drive it from the serial port on the zaurus... ah yes i can just see the speed now. half an hour to download a song from the harddrive! probably enough to read an ebook by though! lol

I thought about this and dismissed it as I thought exposing the USB host to the kernel would be a pain; however it might not be that bad - anyone have any ideas?

How happy would the kernel be? My reasoning is that the serial port and 'usb host' exist at the same level of abstraction in the kernel, therefore it (the kernel) might not be happy using one to implement the other; perhaps the kernel would have to completely ignore the serial port so it could be used as the 'usb host' only?

Just some random thoughts... ;-)


Si
Title: C860 as usb host by software?
Post by: omega on September 09, 2004, 06:51:56 am
hold on, hold on! serial port is just too slow don't you think? I was just joking.....
Title: C860 as usb host by software?
Post by: lardman on September 09, 2004, 07:22:10 am
Quote
hold on, hold on! serial port is just too slow don't you think?

It may not be very useable, but surely it's about what's possible?

In any case does it matter how fast the port appears to be? Will the USB client device refuse to communicate if the 'host' is running too slowly? If so, then I agree that it's a waste of time, otherwise it's still an interesting thought.


Si
Title: C860 as usb host by software?
Post by: Foxdie on September 10, 2004, 05:34:50 am
How about a "middle man" box? A combined USB Host / Client to allow 2 USB clients to talk? I think if this existed it would require a driver installed on the Zaurus but it could work.
Title: C860 as usb host by software?
Post by: iamasmith on September 10, 2004, 05:37:37 am
Quote
How about a "middle man" box? A combined USB Host / Client to allow 2 USB clients to talk? I think if this existed it would require a driver installed on the Zaurus but it could work.
Would this be cheaper than the USB Master CF cards ??, The CF Card gives power too (I think).

Anyone had experience of these ?
Title: C860 as usb host by software?
Post by: lardman on September 10, 2004, 06:47:50 am
Quote
How about a "middle man" box? A combined USB Host / Client to allow 2 USB clients to talk? I think if this existed it would require a driver installed on the Zaurus but it could work.

Yes this is also a good idea, but it's starting to look expensive (I'd guess) and time consuming, both in terms of physical manufacture and driver writing. Might just be easier to reach into pocket and buy one of those ratoc cards (less fun though ;-).

This is going slightly off topic now, but where would one buy one of these (the cheapest place?), and are there any other similar cards out there (there was an interpocket card which has now been discontinued and another TwinParadox SolarExpress card which has been awaiting release for a long, long time).


Si
Title: C860 as usb host by software?
Post by: drag0 on December 12, 2004, 04:15:27 am
For file copying anyway, take a look at this Addontech 2Copy2:

http://www.addontech.net/products/2copy2/ (http://www.addontech.net/products/2copy2/)

..it should work with Sharp C860 as well, since it has a mass-storage mode (though I didn't get it working right away, only had C for 2 days so haven't tinkered much yet).

It's not very expensive, something like $50 or so. Works with batteries.
Doubles as a 'laptop' to move your digital photos from the memory card to your external harddrive. =)

I have one of these 2Copy2s lying around somewhere at work, maybe I'll find it and try it out.
Title: C860 as usb host by software?
Post by: thseiler on December 13, 2004, 06:05:46 pm
Quote
I have been wondering about this for a while now. Since USB is bidirectional, is there a way to emulate a usb host in software using the client port on the c860?
I don't think that this is possible. The state machines in PXA255 usb controller are hardwired, and it is not possible to change them to support host functions (like enumeration, etc...)

But if you *really really really* want a real USB Host / OTG function in your Zaurus C7XX, I think it would be possible to add an Philips ISP1161A USB host controller
http://www.semiconductors.philips.com/pip/ISP1161ABD.html (http://www.semiconductors.philips.com/pip/ISP1161ABD.html)

For this to work, one would have to
* get a ISP1161A
* open the Zaurus (shrudder)
* Find a volume of free space (7 x 7 x 1.4 mm to put the chip)
* Identify the following signals on the main board
   GND, VCC33 (power for the chip)
   D0...D15   (16 bit Data Bus)
   A0, A1      (two adress Lines)
   RD, WR    (Write / Read Control Lines)
   INT          (somewhere )
   RESET      (Reset)
   CS           (A unused Chip select ??? )
* wire them to the apropriate pins of ISP1161A (total of 23 wires)
* patch the kernel to include the OHCI interfaces
* put the usb lines somehow outside of the zaurus.

I do not say that this is easy, but I think once this works, it sould be possible to craft a mod, that is reasonably unintrusive and hides itself inside space between the Z and the large battery cover.

Problems:
* we need a memory map and details about the banking of all Zaurus C7XX models.
* we need to hijack 4 memory adresses for this
* we need a Chip Select ?
* Waranty is void...
* The connector has to be taken to the outside world somwhere...
* Power (5 volts)

Benefits:
* 12 MBit/s USB host, 12MBit/s USB Client
* all the usb hardware that is supported by linux.

Does anybody know of a super small, flat  usb wifi dongle that is supported by linux?
because the ISP 1611A has *two* host ports....

Any thoughts, comments ?

tom
Title: C860 as usb host by software?
Post by: vputz on December 13, 2004, 09:26:40 pm
Quote
It may not be very useable, but surely it's about what's possible?

Okay, I have absolutely nothing useful to contribute to this thread, but this quote from Lardman pretty much, in my mind, encapsulates the Zaurus and its community.  Man, I love these things (grin).

-->VPutz
Title: C860 as usb host by software?
Post by: thseiler on December 14, 2004, 09:57:21 am
Quote
But if you *really really really* want a real USB Host / OTG function in your Zaurus C7XX, I think it would be possible to add an Philips ISP1161A USB host controller
I have thought about this a bit more...

Bus:
Many of the needed signals are accessible on the P2ROM of the zaurus. Its the chip that contains the Bios, service menus and diag menus, and is read only, so no risk of accitently deleting the bios. This leaves us with the folloing signals to investigate:

RESET: is not really needed; to reset the chip into known state, one can simply turn the Z off and on
INT: any GPIO pin of PXA255 can be used to generate an interrupt, we have to find a free one
DMA: there are two external DMA lines in PXA255, both of which are multiplexed with a GPIO line. I think they use the pins for keyboard multiplexing....

Room:
the P2ROM is packed in 44TSOP package. This is a very thin package, and there is room left above it. It should be possible to put the ISP1161 directly on this chip. (I wonder if we manage to find a socket that allows us to "plug" onto the P2Rom chip ?)

Price:
I have found pricing of the Chip in single quantities via Arrow is 13 euros.
To this, we would need to add a connector, and some passive elements, a
quarz and a connector. Estimative BOM of arounf 25 euros.

Power:
The zaurus is charged with 5.0 Volts. The USB socket provides 5.0 volts !
Coincidence or Destany  :-)
So this mod would give you a real USB host port as long as your Z is plugged into mains. On battery, the port would degrade into USB On the Go mode, and not
provide power, but would still allow to access Digicams and other equipment with
its own power source.

Connector :
The usb lines have to go outside the zaurus somewhere. But where ???
Should we hijack Sharps USB lines of the Docking Port ?
Or add a new port somewhere ?

tom
Title: C860 as usb host by software?
Post by: thseiler on December 14, 2004, 10:28:00 am
Other suggestion, and this time it requires no change to the Z:

I think that it is possible to build a small black box, not unlike the one of CE-UC1 standart USB cable from SHARP.

In this box, there would be a ISP1161 and a 16 bit microcontroller.
The ISP1161 Host #1 would connect to the normal Zaurus USB client.
The ISP1161 Host #2 would be available as a normal USB Host Port.
The ISP1161 Client port would be connected to the same USB Host Port.

This cable can work as normal cable to sync your PDA, charge it and so on...
Additionally when your mains is plugged in, you can use it as USB Host
and when your running from battery, as USB on the go, and connect to other devices that have power integrated, like Digital Still Cammeras.

The problem is, that it would never reach USB's 12Mbit/s peak performance.
I don't know how fast/slow it will be.

tom
Title: C860 as usb host by software?
Post by: thseiler on December 14, 2004, 10:35:48 am
For the kernel side of things, there is a module for OHCI for ISP1161 in kernel 2.4
The device has 4 registers, 2 for the client and 2 for the host controller.

All we would need to to is to "emulate" the ISP1161 by changing the functions used to access these 4 registers, and the invent a protocol to transfer register accesses to the 16 bit microcontroller in the blackbox.

I don't know it it is doable, i think i prefer the build in solution, its simpler to do a driver for it.

tom
Title: C860 as usb host by software?
Post by: thseiler on December 19, 2004, 08:28:42 am
regarding power,

There are ways to provide the 5 volts even when not connected to mains.
i.e. a step up converter chip could generate the 5 volts from the li-ion battery.

I still have to figure out how to generate a CS signal...

tom
Title: C860 as usb host by software?
Post by: wrider on March 23, 2005, 03:48:17 am
Interesting, you all guys are genius!
Title: C860 as usb host by software?
Post by: omega on March 23, 2005, 04:51:48 am
It's possible that there is 5v power available somewhere in the c860, apparently the c3000 has it on its host port.  I like the external solution.... I will have time after May...   16bit microcontroller? What about 14-bit... I have a lot of experience by now programming PICs in assembly (esp 16F877A).