Prepare SD card (Unix)

In order to run the PiSkyScan we are going to need a “headless” Pi.
Normally people would setup the Pi with a keyboard screen and mouse, setup headless mode and then remove keyboard screen and mouse.

The following sets up an SD card that should avoid the need for the screen, keyboard and mouse.

We are going to build an SD card that boots into ssh mode and connects to your local Wifi.

Download latest NOOBS zip file.

Download the latest NOOBS file into Download directory.

https://downloads.raspberrypi.org/NOOBS_latest

Extract the file

(Note this assumes Download directory is at ~/Downloads)

cd 
cd Downloads
mkdir NOOBS

unzip NOOBS_v2_4_2.zip -d NOOBS

Remove Unwanted OS’s

The idea here is that we want the os directory just to have Raspian in it.

rm -rf ./NOOBS/os/LibreELEC_RPi
rm -rf ./NOOBS/os/LibreELEC_RPi2

Quick check that we only have Raspian left.

ls -altr ./NOOBS/os

Should look like this

total 12
drwxr-xr-x 3 piskyscan piskyscan 4096 Jul  5 13:16 Raspbian
drwxrwxr-x 5 piskyscan piskyscan 4096 Jul  7 19:18 ..
drwxr-xr-x 3 piskyscan piskyscan 4096 Jul  7 19:19 .

Setup silent install

Add silentinstall to end of command first line.

cat << EOF > ./NOOBS/recovery.cmdline
runinstaller quiet ramdisk_size=32768 root=/dev/ram0 init=/init vt.cur_default=1 elevator=deadline silentinstall
EOF

Setup ssh and network access

For this you will need you network name and password.
This is a bit of a hack, but couldn’t get the legitimate methods to work!
Also note this sets up ssh and connects to your network USING THE DEFAULT PI PASSWORD.
(Couldn’t get that bit to work either).
We will change that in a minute.

Now we need to edit a file.

gedit ./NOOBS/os/Raspbian/partition_setup.sh 

At the end of this file are two lines

umount /tmp/1
umount /tmp/2

Just before those lines enter the following.

(Please change mySSID to your network name and MyPassword to your network password).

touch  /tmp/1/ssh
cat << END >  /tmp/1/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
 
network={
    ssid="MySSID"
    psk="MyPassword"
}
 
END

Save the file and exit.

Load onto SD card.

Take your brand new SD card (if you want to use a 32G or bigger SD card there is a special place in hell reserved for you. Might write it up later once I can script what you need to do!).

Easiest way is to use a GUI to copy all the files under ~/Downloads/NOOBS/ to the top level of the sd card.
Check that the top level of the sd card looks like this.


drwxr-xr-x  3 piskyscan piskyscan     4096 Mar 10 15:38 defaults
drwxr-xr-x  2 piskyscan piskyscan     8192 Mar 17 04:33 overlays
-rw-r--r--  1 piskyscan piskyscan    15346 Mar 17 04:33 bcm2710-rpi-cm3.dtb
-rw-r--r--  1 piskyscan piskyscan    15992 Mar 17 04:33 bcm2710-rpi-3-b.dtb
-rw-r--r--  1 piskyscan piskyscan    15356 Mar 17 04:33 bcm2709-rpi-2-b.dtb
-rw-r--r--  1 piskyscan piskyscan    14000 Mar 17 04:33 bcm2708-rpi-cm.dtb
-rw-r--r--  1 piskyscan piskyscan    14273 Mar 17 04:33 bcm2708-rpi-b-plus.dtb
-rw-r--r--  1 piskyscan piskyscan    14010 Mar 17 04:33 bcm2708-rpi-b.dtb
-rw-r--r--  1 piskyscan piskyscan    14778 Mar 17 04:33 bcm2708-rpi-0-w.dtb
-rw-r--r--  1 piskyscan piskyscan     9728 Mar 17 04:36 riscos-boot.bin
-rw-r--r--  1 piskyscan piskyscan     2432 Mar 17 04:36 INSTRUCTIONS-README.txt
-rw-r--r--  1 piskyscan piskyscan  2730832 Mar 17 04:37 recovery7.img
-rw-r--r--  1 piskyscan piskyscan 28110848 Mar 17 04:38 recovery.rfs
-rw-r--r--  1 piskyscan piskyscan  2659960 Mar 17 04:38 recovery.img
-rw-r--r--  1 piskyscan piskyscan        0 Mar 17 04:38 RECOVERY_FILES_DO_NOT_EDIT
-rw-r--r--  1 piskyscan piskyscan   655012 Mar 17 04:38 recovery.elf
-rw-r--r--  1 piskyscan piskyscan      314 Mar 17 04:38 BUILD-DATA
-rw-r--r--  1 piskyscan piskyscan    50268 Mar 17 04:38 bootcode.bin
drwxr-xr-x  3 piskyscan piskyscan     4096 Jul  7 20:15 os
-rw-r--r--  1 piskyscan piskyscan      113 Jul  7 20:16 recovery.cmdline
drwxr-x---+ 6 root root     4096 Jul  7 20:24 ..
drwxr-xr-x  5 piskyscan piskyscan     4096 Jul  7 20:27 .

Unmount the sd card (important to unmount sd cards before physically removing).

Remove the sd card.

I have avoided formatting the sd card and suggest you do to!
If you cant avoid doing that, you need 1 partition formatted to FAT32 (and I would make that partition <= 16G)

 

Try card in Pi

Plug in the sd card to your Pi.
If you have a monitor that you can plug into the Pi, plug it in. If you dont, cross fingers.
Plug in the power to your Pi.

If you have the monitor installed, you should see the Pi running through the install process.
This takes about 15 minutes and you will end up on the desktop with a warning box about ssh and default password. You should also see that the network is connected to your wifi. Success!

If you dont have a monitor, firstly check that you can see a flashing green led on the Pi.
If you only see red led’s then its likely the sd card is failing to boot (most likely formatting issues with sd card).

I would suggest that after about 15 mins you check your router for a machine called raspberry on the network.
On my system the router interface is at http://192.168.1.254/

Or you can use nmap

sudo apt-get install nmap

sudo nmap -sP 192.168.1.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'

If you have other Pi’s on the network then probably best to run the nmap before Pi reboots and afterwards and look for what has changed.

If you can see it then things have probably worked. Take a note of the ip address, you will need it next.