Skip to content

The Complete Linux CLI Guide

andy diller edited this page May 3, 2024 · 15 revisions

I wrote this document after having to setup and flash a FujiNet using a Macbook M1 in a remote location- and failing. The VSC (VisualStudio) install of PIO and the ESP32 platform is just too slow and error-prone on some platforms. This is how to do it all in Linux/UNIX environment from the shell/terminal/cli.

Suitable for any UNIX style system (Linux, Darwin, WSL) - just update for your local packages, environments and paths!

The Complete Linux CLI Guide

v 1.2 - May 2024 - added notes for WSL build in W10 v 1.1 - Feb. 2024 v 1.0 - Sept. 2023

Setup Host

  • Have a UNIX style system. This has specific examples in Ubuntu but works for any UNIX style system as long as you adjust
  • If you have an older laptop sitting around-- download and copy Ubuntu LTS onto a USB stick
    • boot laptop and install full Ubuntu Desktop
  • If you have Windows 10/11 install WSL from the Microsoft Store; reboot your computer.

Configure Linux Environment

This is to your taste adjust as necessary...

sudo apt update  && sudo apt upgrade

sudo adduser `whoami` dialout
newgrp dialout

sudo snap install sublime-text --classic

sudo apt install git curl python3.10-venv cmake libmbedtls-dev -y

sudo update-alternatives --config editor
[choose wisely]

[reboot]

Installing for WSL for Windows

I had to install FujiNet-PC under Windows10 to run Altirra directly for some testing. I installed WSL for windows(10) and then needed to execute the following packages in order to get a successful build of FN-PC on the Windows system.

My build command was build.sh -cp ATARI

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libpython3-dev
sudo apt-get install python3-venv
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install libmbedtls-dev
sudo apt-get install pip
sudo pip install Jinja2
 

Then continue on....

Install PIO and Platform

With the UNIX system setup and reasonably and minimally configured it's time to install the PIO build system. It's all python. PIO should always be installed in your home directory.

  • Pull down the PIO installer from PlatformIO
cd ~
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
  • run the installer
python3 ./get-platformio.py

[a bunch of things will install....]
  • Ensure the pio command is in your PATH
export PATH=$PATH:~/.platformio/penv/bin
  • Now use the PIO command to install our 'platform' i.e. the ESP32 chip which is on the FujiNet
pio platform install espressif32

[more things will install]

If you add this line to the end of your .bashrc you'll always have pio around:

export PATH=$PATH:~/.platformio/penv/bin

Get and Setup FujiNet Firmware

Now we have PIO installed grab the FujiNet main firmware repo- and the apps repo for some fun later on...

I keep all my github repos in a sub-folder called 'code' as you see below. Feel free to use whatever folder structure you are comfortable with. Note: The PIO installation should always be from your home directory top-level, the FujiNet code repo can be anywhere.

mkdir code
cd code
git clone https://github.com/FujiNetWIFI/fujinet-firmware.git
git clone https://github.com/FujiNetWIFI/fujinet-apps.git

cd fujinet-firmware/
cp platformio-sample.ini platformio.ini
  • edit platformio.ini and choose at least one platform to build

  • Mac Note - change the serial device in platformio.ini to something like:

   /dev/cu.usbserial-XX (the XX may be unique to your system)

Using build.sh

./build.sh -h
  • shows help
./build.sh -b
  • just builds - good for a test of everything we've installed so far
./build.sh -fum
  • builds and flashes the firmware, the image (the webUI) and then monitors the USB port for debug output
  • The FujiNet should show the flash updating, it should reboot and then try to find a wifi connection.

Using build.sh -a (build the world)

./build.sh -s fujinet-atari-v1

[a local .ini will be created based on the platform.ini file]

./build.sh -a

[lots of output as all platforms are built]

  • build.sh -a -- this will build every single platform we can build for, check that it built ok and give you a summary in a file called build-results.txt in the root of the fujinet-firmware directory.

It looks something like this:

$ cat build-results.txt
Start Time: 2024-02-18 12:42:25 - ----- Starting Build the World for Fujinet


2024-02-18 12:45:14 - Built fujiapple-rev0
File 'firmware.bin' found------------------------------------------------
2024-02-18 12:47:17 - Built fujimac-rev0
File 'firmware.bin' found------------------------------------------------
2024-02-18 12:49:54 - Built fujinet-adam-v1
File 'firmware.bin' found------------------------------------------------
2024-02-18 12:52:56 - Built fujinet-atari-v1
File 'firmware.bin' found------------------------------------------------
2024-02-18 12:55:45 - Built fujinet-coco-lolin-d32-dw
File 'firmware.bin' found------------------------------------------------
2024-02-18 12:58:07 - Built fujinet-cx16
File 'firmware.bin' found------------------------------------------------
...
[more platforms]

Build FujiNet-PC

./build.sh -cp ATARI

[a bunch of cmake lines out.....]
[100%] Built target fujinet
[100%] Preparing dist directory
[100%] Built target dist
Built PC version in build/dist folder

cd build/dist
./run-fujinet

Starting FujiNet
14:46:46.292954 >
14:46:46.296802 >
14:46:46.296816 > --~--~--~--
14:46:46.296857 > FujiNet v1.3 2024-04-26 06:08:28 Started @ 27
14:46:46.296910 > Detected Hardware Version: fujinet-pc
14:46:46.296944 > SPIFFS mounted.
14:46:46.298056 > SD mounted (directory "SD").
14:46:46.298132 > fnConfig::load "fnconfig.ini"
...

Sample fnconfig.ini (for SD card)

If you cannot setup wifi via CONFIG manually you need to create a fnconfig.ini file on a SD card using your modern laptop and setup your local wifi credentials by hand.

A sample fnconfig is here to copy and use:

Sample-FNCONFIG.INI

Clone this wiki locally