On PI
-------------
echo 25 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio25/direction
echo 1 > /sys/class/gpio/gpio25/value



Soldering your Raspberry Pi Zero to your Net-Pi IDE carrier board
-------------------------------------------------------------------



Raspberry Pi setup
-------------------------

There are many guides out there for configuring your SD card and specific
Raspberry Pi Zero board.  I am not going to duplicate those instructions
here as it would be too hard to track and mirror the pace at which the
entire Raspberry Pi community is moving.  Use Google and find a distribution
and revision that feels like it suites your needs and that you are
comfortable with.  Some users may prefer a full UI so they can run an HDMI
output from their PCjr.  But I recommend using a text only console
distribution like Raspbian Lite as it will boot the IDE control daemon
quicker by default and usually before the host system polls the disk drives.

Raspbian Lite is what I use and what I recommend new users start with.

The only requirement during Raspberry Pi setup is to enable the SPI interface
so that the NetPi code can communicate both with the iCE40HX-1K FPGA and
also the configuration flash for firmware update.  If you forget or miss this
step, don't worry.  Most distributions for the Pi come with raspi-config which
allows you to enable the SPI interface after a quick reboot.

You will need to configure some basic networking functionality so you do not
have to continually connect an HDMI monitor and USB keyboard to the Pi.
Plug in a wired or wireless networking adapter known to be supported by the Pi
or use the built-in wireless interface on a Wireless Pi Zero.  Refer to your
distrubution setup (or JFGI) to configure an IP for your home networking
configuration.  Remember to enable SSH access so you can get into your Pi
and move files remotely!

Once you have a working and networked Raspberry Pi, the remainder of the
setup is fairly straight forward and documented below.

Most Pi distributions set the 'pi' user or sometimes 'root' user password
to 'raspbian'.  I recommend keeping the default as it is easy to reference
on-line and the hacking risk to your vintage machine is low.  But if you
do change the default passwords, be sure to write them down in a safe place.


Expanding your SD card

Most distributions are sized to a lowst common denominator SD card image;
typically 4-8 GB.  If you are using a SD card that is larger then the image
from which you wrote, you will need to expand the starter file system to
the size limit of your SD card so you can realize all it's storage.

Many HOWTOs talk through this step - typically using the built-in menu
option within raspi-config.  This is an ok solution.  However you may want
to take the remaining space on the SD card image and create a DOS compatible
FAT32 partition on which to store data.  This makes it easier to transfer
files to a Windows machines by removing the micro-SD card.


Making a FAT32 storage partition for images

If you do not expand the root partiton to cover the remainder of the SD
card, you can create a specific data storage partiton with fdisk.


root@raspberrypi:/# sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x574a9b25

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192    93236    85045 41.5M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      94208 62521343 62427136 29.8G 83 Linux

Command (m for help): 


To create a new partition:

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2048-62521343, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-8191, default 8191): 

Created a new partition 3 of type 'Linux' and of size 3 MiB.

Command (m for help): t
Partition number (1-3, default 3): 3
Partition type (type L to list all types): c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): w
The partition table has been altered.

You may have to reboot at this point to see the new partition device.

To create a new FAT file system:

# sudo mkfs.vfat /dev/mmcblk0p3 
mkfs.fat 4.1 (2017-01-24)
# mkdir /data

To mount it on startup, edit the /etc/fstab file and add the following line:

/dev/mmcblk0p3   /data   vfat    defaults  0   2












Updating Raspberry Pi packages and dependencies

For most of the remaining steps, root access will be required.  Commands
below are prefixed with 'sudo' to run as the super user (do).  But this
can be omitted if you are already running as root.

The first recommanded setup - regardless of distribution - is to update the
installed packages to their latest counterparts and install a few dependecies
we will need to run the NetPi-IDE firmware.

To update your Pi (on Raspbian/Debian based distros), run:

sudo apt-get update
sudo apt-get dist-upgrade


If you want to list the current packages installed on your Pi, you can use:

apt list --installed

The following packages are either required or recommended (where stated)
for NetPi operation:

Requires:
arachne-pnr         - Place and route tool for iCE40 family FPGAs
arachne-pnr-chipdb  - Chip db files for arachne-pnr
subversion - Advanced version control system
fpga-icestorm - Tools to handle the bitstream format of Lattice iCE40 FPGAs
fpga-icestorm-chipdb - Chip database files for fpga-icestorm
yosys - Framework for Verilog RTL synthesis
yosys-dev - Framework for Verilog RTL synthesis (development files)
yosys-doc - Documentation for Yosys


Recommended:
ntp            - Network Time Protocol as NetPi IDE has RTC support from Pi
ntpdate        - NTP hard fetch utility

Optional:
dosbox         - x86 DOS emulator - useful for manipulating images
mtools         - DOS FAT utilities - useful for manipulating images
nfswatch
screen         - Virtual terminal emulator