8/11/2014

iPXE, demo of USB Ethernet Adapter support

Checkout from a github fork of iPXE, to which USB Host controller and USB Device support for UHCI has been added and test with an AX88772A (Asix) USB to Ethernet Adapter.



# git clone -b usb-net-drivers https://github.com/johntwillis/ipxe
# vi /ipxe/src/config/config.c
# make bin/asix.iso
# qemu -cdrom bin/asix.iso -bootp http://192.168.2.125/gtest/gtest.gpxe -usbdevice host:0b95:772a -net nic -net user -serial file:logfile.log
From USB Device to iPXE boot image, here is how it was all connected for testing.
[USB to Ethernet Adapter]
attached to:>
[Windows 7 desktop]
attached to:>
[VMware Player 5.0.2]
attached to:>
[CentOS 5.10]
attached to:>
[QEMU]
attached to:>
[SeaBIOS VM]
attached to:>
[iPXE.iso -> bin/asix.iso]

As per the video the most interesting bit was getting the [Linker] to pull in the [USB Host Stack] modules

There is probably a better way to do this, but this documents what needs to be done, until I can grasp how to make it more automatic.

It should also be noted that the Make [target] by default is [iPXE] which appears to only link in PCI devices or devices that already existed in the code base.

An improvement would be to add the [USB Host Stack] and the USB Device drivers as part of that default target.

UHCI is the Intel version of a USB 1.1 controller.

OHCI is the Compaq version of USB 1.1 controller.

UHCI is implemented and tested in this code and tested in the video.

I do not currently have an OHCI platform on which to test, but will be looking into finding an OHCI pci card.

I have two other USB to Ethernet Adapters, and plan to write USB device drivers for them.

Notice how the target is [ bin/asix.iso ]

The "bin" portion is where to place the resulting target image after compilation and linking.

The "asix" portion is the name of the USB Device driver to "make sure" is in the image, since it is not created by default with simply [ # Make ] or [ # Make bin/ipxe.iso ] it must be targeted "specifically"

The "iso" portion is the resulting image format and designates how it is to be used. The alternative images will probably work, but the target for ".usb" will not work in QEMU unless "Padding" is added to the resulting image. Therefore the ".iso" image format was used for testing.

Also "for testing" the image must be supplied its bootstrap control file via the dhcp option

Tftpd32 by Ph. Jounin
DHCP (tab)
boot file: http://192.168.2.125/gtest/gtest.gpxe

Contents of the boot file
[gtest.gpxe]
#!gpxe
kernel http://192.168.2.125/gtest/bz2bzImage.0 root=100 
initrd http://192.168.2.125/gtest/initrd.bz2
boot

# qemu -cdrom bin/asix.iso -bootp http://192.168.2.125/gtest/gtest.gpxe -usbdevice host:0b95:772a -net nic -net user -serial file:logfile.log

Although the "bootp" option is required for QEMU to follow the image and attempt to boot from network, the actual information in that option is not used.

Likewise the "-net nic" and "-net user" options must be passed but are not used.

The "-serial file:logfile.log" merely captures the debug output from the booting image to a file, so it can be opened in an editor and scrolled through later. The "-serial" option also require the iPXE src/config/console.h file to have the #define CONSOLE_SERIAL option uncomment so that support is compiled in. This is merely for testing, normally it only adds size to the image and if debugging is not taking place it is not useful.

The  -usbdevice host:0b95:772a option is QEMU's mthod of USB Pass through from the CentOS 5.10 "host" through to the SeaBIOS virtual machine.

To compile a [Debug] image which will provide output during the image run.

# Make bin/asix.iso DEBUG=uhci_hcd,usbcore,asix

Can be quite helpful.

In the video a debug version is not compiled.