From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1PWaFi-0006mL-3x for mharc-grub-devel@gnu.org; Sat, 25 Dec 2010 14:58:06 -0500 Received: from [140.186.70.92] (port=35570 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWaFg-0006lp-GV for grub-devel@gnu.org; Sat, 25 Dec 2010 14:58:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWaFf-0000f2-2c for grub-devel@gnu.org; Sat, 25 Dec 2010 14:58:04 -0500 Received: from mail-ww0-f67.google.com ([74.125.82.67]:65413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWaFe-0000ee-UO for grub-devel@gnu.org; Sat, 25 Dec 2010 14:58:03 -0500 Received: by wwb31 with SMTP id 31so2324937wwb.6 for ; Sat, 25 Dec 2010 11:58:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=Dzc+vXmM9aY8DcFj9F0PJCTS7m4vE8FF4rcqAmnVmUI=; b=APzt1xrb6iUsmdyZISkEQa7rCeCk1e2LHfng2SJcpTvMwT1/T+ivQTRBnlUqZJ3rTl E6WfYkP/WwNOOCdMiEaf9AXQxUxa1W4o8RvEdmCwK0pR4ptRPCUB3oPbksBPYe0V8cW/ pXfCcxRPBGoEbWSfVqdYF4hiIkWfKLbCUd7es= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=cr8i0fwrXYyMCvHmkw9k/LJZruGE/rqs41CvK6BU/1LAbrYwQq+csqE9jINJbbydSt 9C0eZ9JrtR1I7kEsnsnx/Fr72udXyvnKCqdwXANkxjwpVnBBYlyzbU9I8krdEdC2NR2o AbX4PL+jcRDy4B+TjD3Mk9jHrve6f6DT8DRZU= Received: by 10.227.167.8 with SMTP id o8mr6359533wby.166.1293307079711; Sat, 25 Dec 2010 11:57:59 -0800 (PST) Received: from [192.168.1.13] (AReims-156-1-48-106.w86-192.abo.wanadoo.fr [86.192.223.106]) by mx.google.com with ESMTPS id f35sm7123865wbf.20.2010.12.25.11.57.57 (version=SSLv3 cipher=RC4-MD5); Sat, 25 Dec 2010 11:57:58 -0800 (PST) Message-ID: <4D164CC5.1090105@gmail.com> Date: Sat, 25 Dec 2010 20:57:57 +0100 From: =?UTF-8?B?Tmljb2xhcyBkZSBQZXNsb8O8YW4=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101030 Icedove/3.0.10 MIME-Version: 1.0 To: The development of GNU GRUB , =?UTF-8?B?VmxhZGltaQ==?= =?UTF-8?B?ciAnz4YtY29kZXIvcGhjb2RlcicgU2VyYmluZW5rbw==?= References: <4D0FB8A2.5060407@gmail.com> <4D15E5C9.8000501@gmail.com> In-Reply-To: <4D15E5C9.8000501@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Subject: Re: USB bulk transfert from GRUB ? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Dec 2010 19:58:05 -0000 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 >> 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.