Jump to content
IGNORED

Building fujinet-pc from scratch under Linux


Recommended Posts

This thread aims to document the process of building fujinet-pc in a Linux environment.  As usual, there will be many ways of accomplishing this, so comments, questions, and suggestions are welcome.

 

There is an assumption being made that the person seeking to build fujinet-pc is comfortable with working in a Linux shell (commandline) environment.  It's not necessary to be the best in the world at it by any means, but being familiar with package management tools, sudo, running shell scripts, etc. is necessary.

 

It's also worth mentioning that the environment I'm primarily building this in is Raspberry Pi OS on a Raspberry Pi 3B.  Depending on the architecture and Linux distribution in use, some parts of the process may be different to how it has been detailed below.  If you run into any issues, by all means ask for assistance - just make sure to detail the Linux distribution in use, the architecture you're building under (x86, x64, ARM, etc.) and we'll help with figuring it out.  MacOS is not covered by these instructions.


With that said, open a terminal and start by making sure that three requirements are satisfied first:

 

  • Python3
    • Python3 may already be installed on your system.  To test if it is, type `python3 --version' at a shell prompt and hit Return.  If you see output along the lines of 'Python 3.x.x', you're good to go.  If not, check if it's available from your distribution's package manager (which it almost certainly will be).
  • Platformio
    • Unless you're doing python development, chances are that this one isn't installed.  Check your package manager to see if it's available; if it is, go ahead and install it.  If the package manager doesn't include it, see https://platformio.org/install/cli for information on how to obtain and install it.
  • jinja2
    • Also not likely to have been installed unless doing Python development.  It can be installed using either the system's package manager or pip.  See https://pypi.org/project/Jinja2/ for details.
  • git
    • If git isn't installed, the system's package manager will again come to the rescue.  For a quick check, type 'git --version' at a shell prompt; if you don't see a line similar to 'git version 2.39.3 (Apple Git-145)', this would be a good time to install it.

 

Build tools such as g++, cmake, libraries, etc. will also need to be present.  These are typically installed by default on most distributions, but not always.   Pro-tip: missing packages can cause the build process to fail, so if a build error refers to something missing or not found, install the necessary packages (where appropriate) and try again.


Having got that out of the way, it's time to set up a directory to build out of.  From the terminal, issue the following command:

 

mkdir ~/build && cd ~/build


Next, clone the fujinet-firmware git repo and change directory into it:

 

git clone https://github.com/FujiNetWIFI/fujinet-firmware && cd fujinet-firmware


Running the 'build.sh' script in that directory will start the build process, but the target 8-bit platform needs to be specified first:

 

For Atari:
	./build.sh -p ATARI

For Apple:
	./build.sh -p APPLE

 

The capital letters are intentional.  There are no other target platforms at this time; simply choose the one that sounds more appealing if yours isn't covered.

 

At this point, the build process should have started.  Go grab a snack.  If any errors occur, copy and paste them into this thread and we'll try to help you figure out what went wrong.


Now that the software is built, we can move on to installing, configuring, and running it.  There are a few housekeeping tasks that need to take place first.


The first step is to create a user and group for fujinet to run as:

 

sudo adduser --system --no-create-home --shell /sbin/nologin --group fujinet


Next, the fujinet binary needs to be copied to a suitable location for it to run from.  This example uses /usr/local/bin, but anywhere appropriate on your system can be used:

 

sudo mv build/dist/fujinet /usr/local/bin


Third, the support files used by the fujinet binary need to be put somewhere convenient.  Again, /usr/local/etc is used for this but can be changed to suit:

 

sudo mkdir /usr/local/etc/fujinet-pc && sudo cp -rp build/dist/* /usr/local/etc/fujinet-pc


Moving on, ownership of the support file directory needs to be changed:

 

chown -R fujinet: /usr/local/etc/fujinet-pc


Edit the fnconfig.ini file to reflect the environment fujinet-pc is being run in:

 

sudo <name of your favourite editor here> /usr/local/etc/fujinet-pc/fnconfig.ini

 

fujinet-pc is now essentially installed and ready to go.  To test it, issue the following command, changing pathnames as needed:

 

/usr/local/bin/fujinet -c /usr/local/etc/fujinet-pc/fnconfig.ini -s /usr/local/etc/fujinet-pc/SD


A bunch of text should go scrolling up the terminal window, and if you point a browser to http://<your IP address>:8000, you should see the fujinet-pc web interface.  To return to the shell prompt, hit CTRL-C.  


If the test run was successful, congratulations!  You now have a working fujinet-pc installation.  But what if you want to start and stop it a bit more conveniently in the future?  This is where creating a unit file comes in.

 

Without going too far off into the weeds, if your machine uses systemd to control the starting and stopping of services, it uses unit files to manage those processes.  There are other ways of doing this, but as most distributions currently use systemd, this is the one that we'll focus on here.


The first order of business is to create a unit file.  Again, adjust the pathname as needed to reflect your system:

 

sudo touch /lib/systemd/system/fujinet-pc.service


Open the file that was just created for editing, and copy and paste the following into it.  Be sure to once again change pathnames as necessary before saving the file:

 

[Unit]
Description=Start fujinet-pc as a service
After=syslog.target network-online.target remote-fs.target

[Service]
User=fujinet
ExecStart=/usr/local/bin/fujinet -c /usr/local/etc/fujinet-pc/fnconfig.ini -s /usr/local/etc/fujinet-pc/SD
WorkingDirectory=/usr/local/etc/fujinet-pc
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target


systemd needs to be made aware of the new unit file.  Issue the following command:

 

sudo systemd daemon-reload


Now go ahead and try starting fujinet-pc:

 

sudo systemctl start fujinet-pc


If this returns you straight back to a shell prompt, that's expected.  Now issue the following:

 

sudo systemctl status fujinet-pc


Check the output for a line similar to the following:

 

Active: active (running) since Sat 2024-03-23 11:23:45 CDT; 6h ago


That indicates that fujinet-pc is running, and should again be reachable through a browser at http://<your IP address>:8000 .  To stop fujinet-pc, issue the following:

 

sudo systemctl stop fujinet-pc


If changes are made to fnconfig.ini while fujinet-pc is running, it can be restarted in order to pick up the changes:

 

sudo systemctl restart fujinet-pc


Note that the above commands will only allow fujinet-pc to run while you are logged in.  To make it start at boot:

 

sudo systemctl enable fujinet-pc


And, predictably, if you don't want it to start at boot, the following will take care of that:

 

sudo systemctl disable fujinet-pc

 

 

Hopefully this has been useful to anyone looking to build fujinet-pc.  Again, comments, questions, and suggestions are most welcome.

  • Thanks 1
Link to comment
Share on other sites

Nice, thank you! :)

 

I will add, build instructions on fujinet-pc project page can help with installing dependencies, software and libraries needed for build:

https://github.com/FujiNetWIFI/fujinet-pc?tab=readme-ov-file#building

These instructions should be included soon into main documentation/wiki. I'm sorry for inconvenience.

 

AFAIK Platformio is not needed to build fujinet-pc, it is used to build firmware for hardware. Please let me know if you get any missing platformio/pio related errors when trying to build fujinet-pc without platformio being installed.

 

-jan

 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, apc said:

AFAIK Platformio is not needed to build fujinet-pc, it is used to build firmware for hardware. Please let me know if you get any missing platformio/pio related errors when trying to build fujinet-pc without platformio being installed.

 

I'll have to go back when I have a bit more time and re-check, but something is sticking in my head about a build failure without platformio installed.  Can't remember exactly what the errors were, but installing platformio fixed that dependency issue.

Link to comment
Share on other sites

4 hours ago, Schadret said:

I needed to install the following to get it to work under Ubuntu (from apc's README FujiNetWIFI/fujinet-pc: FujiNet firmware port to Linux, MacOS and Windows (github.com)), otherwise there were mbedtls errors compiling.

 

sudo apt install libexpat-dev libmbedtls-dev

 

There are almost certainly package dependencies in all of this that were missed.  The system it was being built on is used for testing ARM builds of various packages before they're deployed, so I'm sure that libexpat-dev and libmbedtls-dev (or their Raspbian equivalents) were already installed.  Can't remember having to satisfy any requirements for those two.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...