hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 11:51 am

Back to slowly consuming the elephant.

First problem is the built files are on the WSL filesystem and, having looked as hard as I could, I cannot find that exposed as a Windows directory in Windows 10 Home no matter what is claimed online.

But I can copy from within WSL to a Windows directory. But not to "Program Files (x86)" where they ideally ought to end up. So more jumping through hoops it is.

First, on Windows, create a directory which is accessible to both Windows and WSL -

Code: Select all

MKDIR C:\wsl-share
MKDIR C:\wsl-share\rpiboot
Now back to WSL, in the directory from which ./build.sh was run in -

Code: Select all

cp -r ./output/* /mnt/c/wsl-share/rpiboot
That copies the files from the WSL file system to the Windows file system, so, finally back to windows, where we'll use rpiboot.exe to boot those files into our Pi Zero -

Code: Select all

rpiboot -d C:\wsl-share\rpiboot
And violas! Connect to the Virtual Serial Port created and it's "Welcome to Buildroot. extzero login:" as expected.

Seems to have worked. So, tiny steps, small nibbles - Back to WSL, and let's edit -

~/gpioexpander/gpioexpand/configs/gpioexpand_defconfig

Code: Select all

BR2_TARGET_GENERIC_HOSTNAME="extzero"
to -

Code: Select all

BR2_TARGET_GENERIC_HOSTNAME="pinkponiesandunicorns"
Run ./build.sh ( which takes just a couple of minutes ), copy the WSL files over to Windows, re-plug the Zero, run rpi-boot again, and let's see what we get.

"Welcome to Buildroot. extzero login:". Bugger. Let's try ...

Code: Select all

rm ./buildroot-2017.02/.config
Build ( again just a couple of minutes ), copy, rpiboot, rinse, repeat, rub on, rub off, and finally -

"Welcome to Buildroot. pinkponiesandunicorns login:"

The journey continues after this short break.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 5:52 pm

Within -

~/gpioexpander/gpioexpand/board/overlay/etc/init.d/S99gpioext

There are three lines -

Code: Select all

mkdir functions/ecm.usb0
echo $MAC > functions/ecm.usb0/host_addr
ln -s functions/ecm.usb0 configs/c.1
I thought "let's be reckless" and change ECM to RNDIS. ECM wasn't doing us any good anyway and we can figure out how to have multiple networks or protocols later -

Code: Select all

mkdir functions/rndis.usb0
echo $MAC > functions/rndis.usb0/host_addr
ln -s functions/rndis.usb0 configs/c.1
That didn't appear to effect any change. I decided to adjust the VID/PID to match an example I found online which uses ACM and RNDIS ...

Code: Select all

echo 0x0525 > idVendor
echo 0xa4a2 > idProduct
That caused windows to identify a new device, so at least that proves changes are being reflected in what's being built and booted into the Pi.

Windows assigned a new COM Port number for the CDC ACM, but no sign of anything 'RNDIS' in Device Manager, no devices with the familiar yellow exclamation mark, nothing additional in Networks. Windows didn't complain about not finding suitable drivers, didn't try and download drivers; it's like it wasn't told about RNDIS or ignored it.

I also tried EEM to see if that worked any better. But no. Windows 10 has Microsoft RNDIS, RNDIS6 and EEM drivers so it's probably not an issue with choice of mechanism, or protocol.

I did try adding -

~/gpioexpander/gpioexpand/board/kernelconfig-gpioexpand.fragment

Code: Select all

CONFIG_USB_CONFIGFS_EEM=y
CONFIG_USB_CONFIGFS_RNDIS=y
But no joy. Maybe that needs something tickling to get it to take. Maybe it's not something in the buildroot which exists so cannot be added ?

One thing I did note is an ifconfig on the Pi booted with ECM shows "lo" and "usb0". With RNDIS and EEM just the "lo".

The questions appear to be -

1) Are the changes being made sufficient and correct ?
2) Does buildroot as used support RNDIS or EEM ?
3) Is the buildroot including RNDIS or EEM ?
4) Is it just the Pi not presenting an RNDIS or EEM device ?

I suppose I could dig around in the buildroot files, the booted Pi, even boot the Pi as a traditional Pi gadget from SD Card and figure RNDIS or EEM connectivity out that way. But to be honest that's another detour and I'm not currently that fussed anyway as I don't need USB network connectivity for what I want to do.

If anyone has any suggestions I'll give that a try but don't want to spend more time investigating that issue myself at the moment.

Next steps for me in subverting or building on rpio-expander is to -

1) Install Python 2.7 ( and maybe 3 ), plus common libraries and user program and user libraries. Have a Python program run at start up.

2) Allow that program to use the VSP currently used for the serial shell, or add a second VSP for Python use.

3) Enabling Wi-Fi networking on a disklessly booted Pi Zero, as client rather than AP.

If anyone can think of anything which would be appropriate to consider; I'll think about that. But it seems we have got far enough that people, at least with Windows 10, can start experimenting and investigating for themselves.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 6:37 pm

A quick round-up of where we on Windows with respect to diskless Zeroes -

We can : Run rpiboot.

We Can : Boot own-rolled bootcode.bin bare metal code.

We Can : Boot own-rolled kernel.img bare metal code.

We Can : Boot the rpiboot supplied MSD device and that works.

We Can : Boot gpio-expander. We can access its shell via the CDC ACM serial port but networking over USB isn't available or isn't working yet.

We Can : Build the gpio-expander buildroot envronment, at least on Windows 10 using WSL.

We Can : Modify gpio-expander to some degree and have those changes reflected in what's booted on the PI.

The first five are admittedly things which were always possible just not to my knowledge confirmed or proven to be possible.

Still; it feels to me like we've come quite some way from not knowing what was possible. It makes me feel confident that we can develop, build and boot diskless Pi code from Windows and even communicate with that once booted.

Booting diskless application engines looks feasible. There's more to be done to achieve booting a full diskless Raspbian.

We might gain more clarity on that using a different buildroot environment. Using gpio-expander was only a means to an end, providing a proof of concept.

We might even be closer than it seems to me !

mattmiller
Posts: 1954
Joined: Thu Feb 05, 2015 11:25 pm

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 7:47 pm

Booting diskless application engines looks feasible. There's more to be done to achieve booting a full diskless Raspbian.
Well done for all your efforts so far :)

fanoush
Posts: 375
Joined: Mon Feb 27, 2012 2:37 pm

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 8:54 pm

Gettig RNDIS gadget working in Windows is discussed here http://irq5.io/2016/12/22/raspberry-pi- ... b-gadgets/

mikerr
Posts: 2729
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Fri Oct 05, 2018 10:58 pm

ejolson wrote:
Fri Sep 28, 2018 4:54 am
Lack of a free and functional NFS server means that the same technique can't work when the host is Windows 10.
There is an old windows NFS server here:
https://sourceforge.net/projects/winnfsd/

I have my sd-less pi zero accessing that NFS server on windows, and I can see it requesting files but stalling at a permission error:

Image

If I get that working it's a full raspbian booting from Windows.
Android app - Raspi Card Imager - download and image SD cards - No PC required !

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 12:09 am

fanoush wrote:
Fri Oct 05, 2018 8:54 pm
Gettig RNDIS gadget working in Windows is discussed here http://irq5.io/2016/12/22/raspberry-pi- ... b-gadgets/
That's a useful link which I'll spend more time reading later. I'm actually optimistic that if we can get the Pi to expose an RNDIS or EEM interface, Windows will just pick it up and use it. I can understand the general opinion "Composite's don't work" but my Windows XP/7/10 haven't had any problem with those per se. If they did have any in-built ECM driver I would bet everything would be working by now.

I'm starting to think it's something in Buildroot not having RNDIS and EEM exposed for the rest to use, that it's Buildroot which has to be configured for that, though I really can't find what.

But talking of which ...

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 12:10 am

But can it run Crysis ?

Not so far ... but it is running MicroPython.

That was another run round the houses and back again. One can't just install the files needed for packages and have them appear as is done with 'pigpio'. That only works for things Buildroot doesn't know about.

To add a package it does know about ( ls ./buildroot-2017.02/packages ), one has to go into buildroot-2017.02, run 'make menuconfig' set the options wanted - much like configuring a kernel build - then run 'make', then back up and another ./build.sh etc.

We're getting there. Though Python 2 and 3 ( and node.js ) look like they could be issues as they seemingly need support the toolchain apparently doesn't offer.

ejolson
Posts: 2033
Joined: Tue Mar 18, 2014 11:47 am

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 4:53 am

mikerr wrote:
Fri Oct 05, 2018 10:58 pm
ejolson wrote:
Fri Sep 28, 2018 4:54 am
Lack of a free and functional NFS server means that the same technique can't work when the host is Windows 10.
There is an old windows NFS server here:
https://sourceforge.net/projects/winnfsd/

I have my sd-less pi zero accessing that NFS server on windows, and I can see it requesting files but stalling at a permission error:

Image

If I get that working it's a full raspbian booting from Windows.
If you find a Windows NFS server that supports Unix permissions well enough to host a Linux root filesystem, I'd be very interested.

You could mount an ext4 image file using loopback over NFS if you prefer not to put the root filesystem on an iSCSI target or NBD network block device.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 11:06 am

The Sleep Pixies descended and left me with some insight on USB networking with a Pi gadget.

It is the Pi which creates the USB gadget as it boots up. If RNDIS is not being presented as a part of that it's because the Pi isn't configured to present it or cannot present it.

I suspect it's the later. And that would mean what rpiboot is sending, what buildroot has created, doesn't have support for it.

That could be because buildroot hasn't included a package which is needed, or what it does include doesn't support it when it would normally be expected to.

And the most likely culprit would seem to be the kernel, where RNDIS and EEM need to be enabled for those to be used. If the Pi is getting a kernel which doesn't support RNDIS then it cannot use them, simple as that.

So into buildroot-2017.02 and 'make linux-menuconfig'. Digging down shows USB Gadget RNDIS is already enabled via CONFIGFS which is what is being used, though EEM is not enabled. Mass Storage is enabled.

So looks like everything there is fine. I didn't want a potentially time consuming kernel rebuild or a related huge download at peak time which might trigger capping so left EEM as it is for now.

Another blind alley visited and explored but it does seem to suggest it's not an issue with the kernel itself and we now know how to tweak the kernel if we ever need to.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 11:25 am

Aha ... and this would seem to tie in with what fanoush linked to -

https://github.com/mame82/P4wnP1/blob/m ... nit_usb.sh

Seems setting things up is not as simply as just renaming "ECM" to "RNDIS". I'll give that a whirl later on.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 7:00 pm

You know what they say about stepping away from a problem to allow one's mind to reflect on things. Going for a walk is one common suggestion. I find going shopping, sitting on buses and trains usually serves that purpose.

And thus I arrive home with bags of goodies and "IPv6" in my mind.

Disable IPv6 and the previous 'recklessly changed ECM to RNDIS' version starts working. At least it's getting recognised that the Pi is using RNDIS on the Windows side. Unfortunately the Microsoft RNDIS drivers don't yet work; "This device cannot start (Code 10)".

To be honest I'd forgotten I'd changed ECM to RNDIS then to EEM and saw an EEM device appear first time. So let's revert RNDIS to EEM and see how that goes. Windows found the driver itself but the same "can't start, Code 10".

Logging into the Pi and ifconfig only shows 'lo', no 'usb0'.

I'll give the suggested recipes for making it work a whirl as there's nothing to lose. And at least we're still moving forward.

I always knew IPv6 was evil, and should have been IPv4-Plus ;)

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sat Oct 06, 2018 8:40 pm

Enabling Toolchain support for WCHAR ( cd buildroot-2017.02, make menuconfig ) allows Python to be selected for building and most of the other interpreters. It appears to be a choice between Python 2.7 or 3, not both. That's probably acceptable for most people, if they're wanting to even use Python at all.

Unfortunately Python 2.7.13 failed to compile with "unknown type name wchar_t".

One step forward, another half step back. My dream of a 'Pi Macro:Bit' is still some way off.

Though I approached this from a 'booting a diskless Pi' perspective; I'm assuming it's also useful for people wanting to use Buildroot to put something on SD Card and have bootable application engines that way ? After all it doesn't matter how the Pi is booted, via rpiboot over USB, over a wired network, or direct from SD Card, memory stick, or HDD.

In that respect I guess the scope of what I embarked on has changed somewhat. Diskless booting is just a small part of things; it's now more 'A Bluffer's Guide to Buildroot' and how to create Buildroots on Windows 10 with WSL.

I'll collate all my notes at the end and hope to produce a standalone guide rather than the jumble which I'm creating in here.

It would probably also be a good idea to take stock of where I am, where I need to go, get the adventure more focused on a particular task now.

Who would have thought one could learn so much with just a bare Pi and a USB lead :ugeek:

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sun Oct 07, 2018 4:09 pm

The Sleep Pixies attended again and left me wondering if we should put the Windows issue to one side, and instead concentrate on why it is that the Pi isn't creating an RNDIS or ECM interface. Fix that and it might automatically fix the Windows issues.

It creates an ACM serial interface, and an ECM network interface when that's specified, but not for RNDIS or EEM. That has me reflecting back on the kernel not supporting those but thought I had discounted that for RNDIS. It's odd that RNDIS (enabled) is the same as for EEM (disabled). It's a bit of a mystery.

Unfortunately I have side-tracked myself in finding a Windows XP POS system with 15" touch screen which was cheaper than a Pi Zero W and is more within my comfort zone -

http://www.pos-consumables.co.uk/store/ ... %20072.jpg

Not sure if I'm going to leave that as a Windows PC or maybe try and put a Pi in there. Maybe both; perhaps add a Windows bootable diskless Pi :D

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Sun Oct 07, 2018 11:20 pm

That POS computer is fun. All worked out the box; touch screen, VFD, runs rpiboot just fine. Interestingly it found 2708 and 2710 drivers without the faffing about I had experienced on my other XP machine, but did demand a reboot before rpiboot would complete.

So back to Pi diskless booting. I decided to see what happened if I simply added RNDIS to ACM and ECM. I also managed to get a monitor set-up to see what was happening as the Pi boots.

Interestingly; on the screen it showed 'lo', 'usb0' and 'usb1'. Login over the ACM serial and an 'ifconfig' and it shows just 'lo' and 'usb0'.

A quick check and maybe it's not getting an IP address ? Add a different one for usb1, re-do, and Ta Da! 'lo', 'usb0' and 'usb1' and Windows sees ECM and RNDIS adpters.

Let's forget that drivers don't work. Add EEM as well. Another Ta Da! 'lo', 'usb0', 'usb1' and 'usb2'. Windows sees ECM, RNDIS and EEM.

Might as well throw in an MSD device while we're on a roll.

Nope; blew everything up. The monitor showed that it couldn't configure all end points. Tried a few things including two configurations but no joy. Commenting everything MSD out and we are back to solid ground.

Build with ACM and only MSD, and it's fine, COM port and a new USB drive appears under Windows. Networking and MSD, nope.

At this point I think we need an expert in Gadget Mode and configuring via CONFIGS, because I'm just wasting endless time not knowing what I'm doing.

I guess the priority is a quick start guide so others can more easily replicate where I am up to, can start playing themselves. Anyone is welcome to join in. The prerequisites are -

* A Windows 10 PC with Windows Subsystem for Linux (WSL) installed.
* A Pi Zero / Zero W
* A USB to micro-USB cable.

Optionally, but recommended -

* A HDMI monitor for the Pi
* A terminal emulator installed on Windows ( eg Tera Term )

A Pi A or A+ might work but I'm not sure what happens once the Pi boots because they have their USB-ID pins hard-wired to 0V. I don't have either. Maybe someone might be able to try one ?

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Sun Oct 07, 2018 11:31 pm

hippy wrote:
Sun Oct 07, 2018 11:20 pm
A Pi A or A+ might work but I'm not sure what happens once the Pi boots because they have their USB-ID pins hard-wired to 0V. I don't have either. Maybe someone might be able to try one ?
I'll give those a try tomorrow but given the hardware setup I'd not expect them to work

An aside: I've had an A+ running as a MSD gadget by forcing the dual role mode in config.txt. But that's booting from an SD card.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Sun Oct 07, 2018 11:38 pm

OK, just done a very quick test with a model A.

Nothing on HDMI but windows does detect a "BCM2708 Boot" device. I guess the on board boot code/hardware ignores the hardwired mode detect line.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Sun Oct 07, 2018 11:47 pm

Just ran the same test on an A+. Same result.

Will try rpiboot from linux with them tomorrow. Not setup for trying from windows though I do have win10 with cygwin.

Incidentally, isn't there a known issue with the maximum number of simultaneous USB endpoints that can be used in raspbian? I don't have the links to hand and don't know it that will affect gadget mode but could this be the cause of the problem you're seeing with MSD, ECM, RNDIS and EEM at the same time?

And the POS looks cool.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 1:20 am

thagrol wrote:
Sun Oct 07, 2018 11:31 pm
An aside: I've had an A+ running as a MSD gadget by forcing the dual role mode in config.txt. But that's booting from an SD card.
That might make diskless possible because I recall config.txt is read during booting. The first stage bootloader obviously doesn't care, if the booted system uses config.txt that's fine, so it's just a question of whether the second stage loader doesn't care or uses the config.txt setting.

In fact that's a good reminder I ought to check in config.txt and cmdline.txt to see if there's anything in there which is working against what I'm trying to do !

Testing from Linux should be fine; if it works there it should work in Windows.

I'll check endpoints. It unbound all the network endpoints when I added MSD, so I assumed an incompatibility. Others seem to have multiples plus MSD so not sure where I'm going wrong.

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 10:56 am

@ thagrol : It was late and I forgot to say thanks for your help - Thanks !

I am also slightly changing tack; will be coming at this from a different angle for a while. I'm going to use an SD Card boot of Pirate Python and see what that produces under Raspbian and Windows -

https://github.com/pimoroni/PiratePython

As that creates multiple interfaces when it boots as well as enabling WiFi etc, it's pretty much what we want to end up with when booting disklessly. Making that a diskless boot should have some convergence with where we are heading, a step on the road to full diskless Raspbian booting, which should apply to other OS's as well.

And I realised that if we are to have a Windows System Tray usbbootgui, which auto-loads multiple 'black box Pi' when plugged in, that has to know which USB port they're plugged into and what each black box is meant to have loaded. That can probably be solved by reading the 2708 device serial number and having a mini-database of serial numbers, description and what to boot.

I don't currently know what usbbootgui supports but it's going to be easier to find out, add diagnostics, make changes and rebuild using a Pi and Raspbian rather than Windows. I already know it launches but doesn't find Pi devices under WSL.

So a couple of detours but those should help us make progress along our chosen path.

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 12:04 pm

hippy wrote:
Mon Oct 08, 2018 1:20 am
I'll check endpoints. It unbound all the network endpoints when I added MSD, so I assumed an incompatibility. Others seem to have multiples plus MSD so not sure where I'm going wrong.
Interesting. I've got code using libcomposite that provides both MSD and ECM gadgets. Linux hosts see both, windows hosts only see MSD. It's a python script intended to be at boot time.

See the USBComposite function here: https://github.com/thagrol/usb-gadget/b ... /set_id.py
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 12:08 pm

hippy wrote:
Mon Oct 08, 2018 10:56 am
@ thagrol : It was late and I forgot to say thanks for your help - Thanks !
NP
And I realised that if we are to have a Windows System Tray usbbootgui, which auto-loads multiple 'black box Pi' when plugged in, that has to know which USB port they're plugged into and what each black box is meant to have loaded. That can probably be solved by reading the 2708 device serial number and having a mini-database of serial numbers, description and what to boot.
The folks behind the cluster hat modded rpiboot to allow different files to be sent to different Pi based on which USB port it's connected to: https://8086.support/content/23/88/en/g ... cable.html

Don't know if that would help or if their changes got incorporated into raspbian.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 2:32 pm

thagrol wrote:
Mon Oct 08, 2018 12:08 pm
The folks behind the cluster hat modded rpiboot to allow different files to be sent to different Pi based on which USB port it's connected to: https://8086.support/content/23/88/en/g ... cable.html

Don't know if that would help or if their changes got incorporated into raspbian.
I think they were. If I have read it right those mods are the '-o' option which is in the RPF rpiboot source.

That allows each Pi on the Cluster HAT to get its own set of boot files. It's a good solution for the Cluster HAT which is basically a 'static configuration' where it's pre-decided what will be booted to each Pi depending on which USB port it's plugged into, it's position on the HAT. Not so good when any 'black box Pi' can be plugged into any USB port.

For example, if the Pi on Port 1 of a Cluster HAT required files which the others didn't that can be set-up. But if one swapped the Port 1 and Port 2 Pi's over it then wouldn't work unless the files in the associated directories were correspondingly swapped as well.

We really need something which can identify each Pi by a unique ID ( eg serial number ) rather than which USB port it is being plugged into.

But I'm not sure that's even possible as things currently are. Looking at the device details for the 2708 when its plugged into my Windows box there's no serial number nor anything else I can see which would differentiate one 2708 from any other. Likewise once it's converted itself to a 2710 after only loading bootcode.bin.

We would need an extra stage of bootloader which created a device which exposed a serial number to the USB subsystem.

Alternatively one would have to convince RPF/RPT/Broadcom to modify bootcode.bin to present a 2710 device with an exposed serial number.

There are ways of doing it ourselves, and I have proven it works, but discussion of that would invite claims of breach of licensing conditions, copyright infringement, or piracy, and could lead to a ban from the forum so I'm currently keeping schtum on that.

User avatar
thagrol
Posts: 876
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 4:01 pm

A and A+ results are in.

I'm using a Pi2 running stretch as the host. usbbootgui installed via apt and run manually.

On connection both the A and A+ show in lsusb as ID 0a5c:2763 Broadcom Corp. (A zero showed up as ID 0a5c:2764 Broadcom Corp.)
Hardware serial ports connected and monitored via putty on the host.

Ran usbbootgui and selected gpioexpander.

Model A
HDMI shows just the rainbow screen.
Nothing on the hardware serial connection
No broadcom device and no serial or ethernet devices in lsusb
Conclusion: given the messages displayed by usbbootgui, iot looks like a problem with the second stage boot loader.

Model A+
Boots as expected.
HDMI and serial show the same as with a Zero
No broadcom device and no serial or ethernet devices in lsusb
Conclusion: the dwc2 module is doing what the hardware tells it to and acting as a host hence the devices are not visable. However the hardware serial connection doesn't allow a login so I can't confirm this.
Fix: force the dual role mode in the config.txt supplied to the model A+. By my reading, this change should be safe and functional on a zero(w)

Edit:
On both the A and A+ the card reader functionalty stalls after "reading start.elf" with no display or serial output.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

hippy
Posts: 3914
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Diskless booting Zeroes from Windows

Mon Oct 08, 2018 6:28 pm

thagrol wrote:
Mon Oct 08, 2018 12:04 pm
See the USBComposite function here: https://github.com/thagrol/usb-gadget/b ... /set_id.py
That looks useful. Thanks again.

For the Windows people : Here's a very minimal VB.Net program which can determine when a Bootable Pi is connected and removed. Just create a new project with a TextBox1 on the form and this is all it needs -

Code: Select all

Imports System.Management ' Add this as a reference as well

Public Class Form1

    Private raspberryPiDetected As Boolean = False

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CheckForRaspberryPi()
    End Sub

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)
        If m.Msg = &H219 Then
            CheckForRaspberryPi()
        End If
    End Sub

    Private Sub CheckForRaspberryPi()
        Dim result As Boolean = DeviceFoundByName("Raspberry Pi USB boot")
        If result <> raspberryPiDetected Then
            raspberryPiDetected = result
            If raspberryPiDetected Then
                TextBox1.AppendText("Raspberry Pi Connected" + vbCrLf)
                BootLoadThePi("msd")
            Else
                TextBox1.AppendText("Disconnected" + vbCrLf)
            End If
        End If
    End Sub

    Private Function DeviceFoundByName(ByVal name As String) As Boolean
        Dim search As System.Management.ManagementObjectSearcher
        Dim item As System.Management.ManagementObject
        search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
        For Each item In search.Get()
            If CType(item("Caption"), String) = name Then
                Return True
            End If
        Next
        Return False
    End Function

    Private Sub BootLoadThePi(ByVal what As String)
        ' Dim path As String = "F:\Program Files\Raspberry Pi\"
        ' Shell("""" + path + "rpiboot.exe"" -d """ + path + what + """", AppWinStyle.NormalFocus, True)
    End Sub

End Class
Compiled with VB2008 Express and runs on XP so it should work on anything upwards but I have not tested that. That can be optimised and improved.

Basic code for having it take up residency in the System Tray when minimised. Must add a NotifyIcon and give it a *.ico -

Code: Select all

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            NotifyIcon1.Visible = True
            Me.Hide()
            NotifyIcon1.BalloonTipText = "WinRpiBoot"
            NotifyIcon1.ShowBalloonTip(500)
        End If
    End Sub

    Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        Me.Show()
        Me.WindowState = FormWindowState.Normal
        NotifyIcon1.Visible = False
    End Sub
If the BootLoadThePi() code is uncommented, 'path' adjusted as appropriate, rpiboot runs and uploads but then there's an error thrown in the search for devices, presumably as it switches from 2708 to 2710. Needs some hardening to be useful.

Return to “Advanced users”