Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate usbboot into Etcher #1541

Closed
jviotti opened this issue Jun 23, 2017 · 18 comments
Closed

Integrate usbboot into Etcher #1541

jviotti opened this issue Jun 23, 2017 · 18 comments

Comments

@jviotti
Copy link
Contributor

jviotti commented Jun 23, 2017

See https://github.com/raspberrypi/usbboot
See https://www.raspberrypi.org/documentation/hardware/computemodule/cm-emmc-flashing.md

usbboot is a small C program that is able to mount the eMMC of a Raspberry Pi as a mass storage device, to which Etcher can flash to, effectively flashing directly to the internal storage.

Let's see if we can build a Node.js add-on around it (so we don't have to spawn anything), and then integrate with Etcher as follows:

  • Try to find Pi devices connected to the computer during the drive listing loop
  • If the user selects such device, usbboot will run and mount the device when the user clicks "Flash"
@jviotti
Copy link
Contributor Author

jviotti commented Jun 23, 2017

We need to investigate how the Windows version works. Apparently, the same C program is compiled under Cygwin, but we have to double check.

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 24, 2017 via email

@lurch
Copy link
Contributor

lurch commented Jun 24, 2017

Try to find Pi devices connected to the computer during the drive listing loop

It's been a while since I've used usbboot, but IIRC that wouldn't be possible. I think the usage-pattern is to set the ComputeModule into Slave-boot mode by setting a jumper, then start usbboot, and then finally power up the CM. There's then some kind of USB-handshaking done between the CM and usbboot (also called rpiboot), and rpiboot sends the CM its boot image (firmware) which makes it appear as a USB MassStorageDevice. Although I guess it might be possible to split up the 'all-in-one' action of rpiboot into separate stages... I guess it depends if there's any timing-requirements.

Let's see if we can build a Node.js add-on around it

A quick search finds https://github.com/schakko/node-usb and https://github.com/tessel/node-usb so that should be possible.

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 24, 2017 via email

@lurch
Copy link
Contributor

lurch commented Jun 24, 2017

I think so, yeah. But I don't think we should run always run usbboot automatically, but instead maybe from a button-click.
I think I remember you mentioning elsewhere that node.js / Electron apps are single-threaded, which might mean that the Etcher interface can't do anything else while it's waiting for usbboot to discover a newly-connected CM?

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 24, 2017 via email

@lurch
Copy link
Contributor

lurch commented Jun 24, 2017

Ah-ha, I managed to find the comment I was thinking of: #638 (comment)

So I guess they're not single-threaded, but dual-threaded ;-) (unless we spawn a background process and communicate with it via IPC)

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 24, 2017 via email

@lurch
Copy link
Contributor

lurch commented Jun 24, 2017

AIUI WebWorkers only work in Electron apps, and so we couldn't use them in the etcher-cli? And I think we're aiming to have the GUI and CLI counterparts functionally equivalent?

I haven't read up on the details, but (I think) I've got a vague feeling for how the node.js event-loop works; but in the specific case of usbboot I don't think we get an event, but instead need to busy-loop, waiting for the CM USB IDs to appear? https://github.com/raspberrypi/usbboot/blob/master/main.c#L491 (but perhaps that could be done with some kind of timer)
Although perhaps https://github.com/tessel/node-usb#usbonattach-functiondevice--- would allow us to make proper use of the event-loop. *shrug*

@jviotti
Copy link
Contributor Author

jviotti commented Jun 26, 2017

Yeah, Electron web-workers have node.js integration, while typical web workers don't. I do think we should split usbboot into the code that scans the compatible drives (which we can run in a loop in drivelist), and the code that mounts it (which we can run once when the user clicks "Flash").

I took a look at the drive scanning code, and doesn't seem hard to include into drivelist, and in a proper cross platform way.

@lurch
Copy link
Contributor

lurch commented Jun 26, 2017

But IIRC we don't know how big the eMMC attached to the CM is, until after we've sent it it's boot-code to get it to show up as a MSD.

@jviotti
Copy link
Contributor Author

jviotti commented Jun 26, 2017

I see. I guess we can show it as "size unknown", until we start flashing?

@lurch
Copy link
Contributor

lurch commented Jun 26, 2017

Yeah, I guess that'd be one way of doing it. I guess we should also abort the Flash if we were trying to flash a 6GB image and then discover the eMMC is only 4GB.

@jviotti
Copy link
Contributor Author

jviotti commented Jun 26, 2017

I think we could detect the model of the board (I think usbboot took a look at the serial), and if we recognize the model, then we should be able to know the eMMC size in advance, right?

@lurch
Copy link
Contributor

lurch commented Jun 26, 2017

I think usbboot might be able to tell the difference between a Pi1 and a Pi3 based on the USB IDs, but I don't think you can tell the difference between a CM3 Lite (no MMC), a CM3 (4GB MMC be default) or an NEC CM3 (16GB MMC).
Also, I can't remember right now but think usbboot also works with the Model A+ and PiZero, in which case there can obviously be any size SD card attached.

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 26, 2017 via email

@alexandrosm
Copy link
Contributor

alexandrosm commented Jun 26, 2017 via email

@jviotti
Copy link
Contributor Author

jviotti commented Jun 26, 2017

Right. We should formalize a framework where integrations have a .scan(), .flash(), .validate() interface, or something like that.

jviotti added a commit that referenced this issue Aug 10, 2017
This commit installs v1.3.0 from GitHub, since that version was never
published to NPM, and is the only one that works with Visual Studio 2015
(see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 10, 2017
This commit installs v1.3.0 from GitHub, since that version was never
published to NPM, and is the only one that works with Visual Studio 2015
(see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 11, 2017
This commit installs v1.3.0 from GitHub, since that version was never
published to NPM, and is the only one that works with Visual Studio 2015
(see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 11, 2017
This commit installs v1.3.0 from GitHub, since that version was never
published to NPM, and is the only one that works with Visual Studio 2015
(see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 11, 2017
This commit installs v1.3.0 from GitHub, since that version was never
published to NPM, and is the only one that works with Visual Studio 2015
(see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 11, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 11, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 14, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 15, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

Change-Type: minor
See: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 16, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi through USB and eventually
mounts it as a block device we can write to.

Change-Type: minor
Fixes: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 16, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi through USB and eventually
mounts it as a block device we can write to.

Change-Type: minor
Fixes: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 16, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi through USB and eventually
mounts it as a block device we can write to.

Change-Type: minor
Fixes: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 23, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi through USB and eventually
mounts it as a block device we can write to.

Change-Type: minor
Fixes: #1541
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 24, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 24, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 24, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 25, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 25, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 25, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 25, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 25, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 28, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Oct 4, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Oct 4, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Oct 4, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Oct 5, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Oct 6, 2017
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see node-usb/node-usb#109).

The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.

This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.

The flow is the following:

- On each scan, the usbboot scanner will try to get a usbboot compatible
  USB device to the next "phase", until they are all transformed to
  block devices the user can flash to as usual

Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: #1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants