Using FUZIX on Raspberry Pi Pico

Using FUZIX on Raspberry Pi Pico

FUZIX was created by British computer scientist Alan Cox as a lightweight Unix operating system for small computers. It was originally written for the 8-bit Zilog Z80 processor.

David Given has ported FUZIX to various architectures and has recently released a port for the RP2040 microchip of the Raspberry Pi Pico.

Given describes FUZIX as an “old-school Unix clone”. “It runs in very small space while being expandable to computers with a reasonable amount of RAM (like megabytes), while providing a pretty decent old-school Unix environment with multiple processes, the classic Bourne shell, and so on.”

FUZIX uses only one core of the Raspberry Pi Pico and runs user executables with 64KB of code and data, up to 15 processes, a Unix file system, SD card support, and a serial console on the Raspberry Pi Pico’s UART0.

Here’s how to get FUZIX running on a Raspberry Pi or another Linux-based computer with the Raspberry Pi Pico.

Compiling FUZIX from Source

Compiling FUZIX is not complicated. If you haven’t set up the toolchain for the Raspberry Pi Pico yet, install it by running the following commands in the terminal. If wget is not installed, run sudo apt install wget. Then download the setup script and execute it.

wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
chmod +x pico_setup.sh
./pico_setup.sh

Then, get the source code from the FUZIX repository.

git clone https://github.com/davidgiven/FUZIX.git
cd FUZIX
git checkout rpipico
cd Kernel/platform-rpipico/

Modify the first line of the Makefile to set the path to the pico-sdk. For example:

export PICO_SDK_PATH = /home/pi/pico/pico-sdk

Now you can compile the FUZIX UF2 file and root file system.

make world -j
./update-flash.sh

If all goes well, the UF2 file will appear in build/fuzix.uf2, and there will be a filesystem.img file in the current working directory.

Using FUZIX on Raspberry Pi Pico

Now, you can upload the UF2 file to the Pico in the usual way, refer to https://pico.org.cn/.

1. Hold down the BOOTSEL button and plug the Pico into the USB port of the Raspberry Pi or PC. 2. The Pico will be recognized as a mass storage device. 3. Place the downloaded UF2 file onto the RPI-RP2 volume.

The volume will unmount automatically, and the Raspberry Pi Pico will start running Unix.

Creating a Bootable SD Card

The filesystem.img image file obtained above does not have booting capabilities. Below is how to build a file system on a Raspberry Pi or other similar Linux platform.

First, find a microSD card. Since we only need 34MB, almost any capacity will do. Here, a 4GB card is used. Insert it into the card reader and connect it to the PC. Build the partition table required for FUZIX. This includes two partitions: 1. A 2MB swap partition 2. A 32MB root partition (where the root file system, i.e., filesystem.img, will be copied).

Use the lsblk command; if you have a blank unformatted card, it will show as /dev/sda.

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1  3.7G  0 disk 
mmcblk0     179:0    0 14.9G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.6G  0 part /
$

If it is a formatted card, it will look like this.

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1  3.7G  0 disk 
└─sda1        8:1    1  3.7G  0 part /media/pi/USB
mmcblk0     179:0    0 14.9G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.6G  0 part /
$

The mounted /media/pi/USB is the MBR partition of the FAT formatted SD card.

To unmount the SD card, simply use the command to unmount.

$ umount /dev/sda1

Then, using the lsblk command, it will look like this.

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1  3.7G  0 disk 
└─sda1        8:1    1  3.7G  0 part 
mmcblk0     179:0    0 14.9G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.6G  0 part /
$

At this point, we can delete the current partition table by zeroing the first part of the card and removing the “start of disk” structure.

$ sudo dd if=/dev/zero of=/dev/sda bs=512 count=1

After running lsblk again, you will see that sda1 partition has been deleted. Next, we will create a new partition table using fdisk. Enter the following:

$ sudo fdisk /dev/sda

Enter the fdisk prompt. Then type o to create a new DOS disk label.

Command (m for help): o
Created a new DOS disklabel with disk identifier 0x6e8481a2.

Type n to create a new partition.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-7744511, default 2048): 2048
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7744511, default 7744511): +2M 
Created a new partition 1 of type 'Linux' and of size 2 MiB.

Depending on the initial state of the disk, the system may prompt that the partition contains a vfat signature. If asked, press Y to confirm.

Now we will set the partition type to 7F.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 7F
Changed type of partition 'Linux' to 'unknown'.

Create a 2MB swap partition.

Next, create the second partition, a 32MB root file system.

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

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

Then type p at the fdisk prompt.

Command (m for help): p
Disk /dev/sda: 3.7 GiB, 3965190144 bytes, 7744512 sectors
Disk model: STORAGE DEVICE  
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: 0xe121b9a3

Device     Boot Start   End Sectors Size Id Type
/dev/sda1        2048  6143    4096   2M 7f unknown
/dev/sda2        6144 71679   65536  32M 83 Linux

Type w to write and save the partition table.

Finally, copy the filesystem.img file into the 32MB partition.

$ sudo dd if=filesystem.img of=/dev/sda2
65535+0 records in
65535+0 records out
33553920 bytes (34 MB, 32 MiB) copied, 14.1064 s, 2.4 MB/s
$

It’s time to eject the SD card and connect it to the breadboard!

Wiring on the Breadboard

If you are developing on a Raspberry Pi and have not previously tried using UART serial on the Raspberry Pi, refer to section 4.5 of the Getting Started guide.

Using FUZIX on Raspberry Pi Pico

Connect the Raspberry Pi, Raspberry Pi Pico, and SD card module as shown in the diagram.

Using FUZIX on Raspberry Pi Pico

If you are developing on a laptop, you can use a module like SparkFun FTDI Basic Breakout to connect the UART serial to the computer.

Whichever way, the pin correspondence between the Raspberry Pi Pico and the SD card module is the same, as follows:

Using FUZIX on Raspberry Pi Pico

After connecting, eject the formatted microSD card and insert it into the SD card module. Then power on the Raspberry Pi Pico, and FUZIX will automatically start.

Connecting to FUZIX

If you are using a Raspberry Pi to connect to the Pico, you need to enable UART serial communication first.

$ sudo raspi-config

Choose Interfacing OptionsSerial, when prompted “Would you like a login shell to be accessible over serial?” select “No”, and then “Would you like the serial port hardware to be enabled?” select “Yes”.

Using FUZIX on Raspberry Pi Pico

When you exit raspi-config, you need to select “Yes” and reboot the Raspberry Pi.

You can also use minicom to connect to FUZIX:

$ sudo apt install minicom
$ minicom -b 115200 -o -D /dev/serial0

If you are using macOS or Windows, you can use minicom, screen, or any common terminal program.

If you don’t see any output at this point, please unplug the Raspberry Pi Pico and plug it back in.

Using FUZIX on Raspberry Pi Pico

Finally, enter the date and time, and when the login prompt appears, log in as root without a password. Begin your journey of exploration with FUZIX!

Links in the text can be clicked to read the original article at the end.

Using FUZIX on Raspberry Pi Pico

More exciting content

Making a motorcycle dashboard with Raspberry Pi

Making a smart pet feeder with Raspberry Pi

Creating a smart planetary observer based on Raspberry Pi

Handmade metal wireframe X-wing clock

Arduino + 280 LEDs DIY music spectrum light

DIY Stanford Pupper 12 DOF Quadruped Robot Dog

Barrier: PC and Raspberry Pi keyboard and mouse sharing solution

Using FUZIX on Raspberry Pi Pico

Leave a Comment

×