From: "Nicolas de Pesloüan" <nicolas.2p.debian@gmail.com>
To: "The development of GNU GRUB" <grub-devel@gnu.org>,
"Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
Subject: Re: USB bulk transfert from GRUB ?
Date: Sat, 25 Dec 2010 20:57:57 +0100 [thread overview]
Message-ID: <4D164CC5.1090105@gmail.com> (raw)
In-Reply-To: <4D15E5C9.8000501@gmail.com>
On 12/25/2010 01:38 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 12/20/2010 09:12 PM, Nicolas de Pesloüan wrote:
Hi Vladimir, thanks for your feedback.
>> Some USB devices require a specific command to be sent (using USB bulk
>> transfer) before they switch
>> to "storage mode". Such devices are switched by USBmodeSwitch
>> (http://www.draisberghof.de/usb_modeswitch/), after the operating
>> system start. USBmodeSwitch use
>> libusb to send the right command to the right USB endpoint, depending
>> on the ID of the USB device.
>>
>> In order to be able to boot from such devices, one needs to switch the
>> device early, before the operating system is started. I think GRUB2
>> should be the right place for this.
>>
>> For as far as I understand, libusb is available from inside GRUB2,
> No it's not. We use our own routines for USB transfers. Have a look at
> include/grub/usb.h. E.g:
> grub_usb_err_t
> grub_usb_bulk_write (grub_usb_device_t dev,
> int endpoint, grub_size_t size, char *data);
Ok, that sounds good, at least for a "small" try.
>> so it shouldn't be really difficult to add a command to initiate a
>> given bulk transfert to a given USB endpoint. (My understanding is
>> that no such command already exists).
> grub_usb_bulk_write does exactly this. However it's not to be exported
> as a command
Whould you support adding such command?
usb_bulk_write <usbid> <endpoint> <string>
>> Contrary to USBModeSwitch that use a database at runtime to decide how
>> to switch the device, it is probably easier to decide this at
>> grub-mkconfig time, using the same database.
>>
> Doing any USB detection at grub-mkconfig time is a bad idea. USB is in
> flux and you can't possibly know e.g. the address of target device on
> runtime. On the other hand it should be easy to write a parser for
> device_reference.txt.
Yes, you are right. I didn't plan to try and use a fixed USB address. But, it sounds reasonable to
assume that, for a given user, the device is always the same (usb id). So, the usb id of the device,
the endpoint number and the string to send to the endpoint could be selected at grub-mkconfig time
and given as arguments to the grub command I plan to create.
> It's also probably easier to write something that small from scratch than to port it (all the
> value is in the database, not code). Another question is how much autoconfigured it should be.
> Some people may prefer these devices be in non-storage mode as usually the only thing they store
> are useless buggy drivers.
The kind of device I know provides two different modes:
- default mode, where the device is seen as a CD reader and gives access to a virtual CD that hold
the Windows drivers for the device. (Mostly useless, from a non Windows point of view).
- switched mode, where the device is seen as a 3G modem plus a micro-SD card reader. I plan to boot
from this micro-SD card.
From a grub point of view, deciding to switch or to stay to the default mode depends on whether the
"kernel" one plan to boot is located on a normal device or one a device that need to be switched
prior to be usable.
So the switch command should only be incorporated into the menu entry that is designed to boot on
the switchable device that hold the micro-SD card.
And by the way, it is possible to virtually "burn" an ISO image into the device, so it is possible
to use the virtual CD reader to hold grub. But that is another story.
Nicolas.
next prev parent reply other threads:[~2010-12-25 19:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 20:12 USB bulk transfert from GRUB ? Nicolas de Pesloüan
2010-12-25 12:38 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-12-25 19:57 ` Nicolas de Pesloüan [this message]
2010-12-25 20:13 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-12-25 22:32 ` Nicolas de Pesloüan
2010-12-25 23:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-12-26 10:26 ` Nicolas de Pesloüan
2010-12-26 10:47 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-12-26 11:46 ` Nicolas de Pesloüan
2010-12-26 12:05 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-12-26 16:39 ` Nicolas de Pesloüan
2010-12-28 8:01 ` Nicolas de Pesloüan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D164CC5.1090105@gmail.com \
--to=nicolas.2p.debian@gmail.com \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).