Nard SDK

Not Another Raspberry Distribution

Nard GNU/Linux is a software development kit (SDK) for Raspberry Pi. Unlike "ordinary" Linux distributions Nard is intended entirely for the development of MOTS embedded systems running day and night for years in remote locations. And you are more or less expected to add your unique custom application on top of the Nard platform.

Nard operates in a Raspberry Pi like a Live USB in a PC. During boot everything is uploaded to RAM and executed from there. You may even remove/hot swap the SD-card from a running system at any time and it will continue to operate just fine! The SD-card is only accessed upon request by your custom application.

Lightweight GNU/Linux platform.

Hot swap support for SD-cards and USB devices.

Automatic allocation of SD-card free space for application storage.

Automatic repair of SD-card filesystems in the event of power loss during writing.

Raspbian emulation.

Complete remote upgradability with minimum downtime as well as preventive actions against a power cut in the middle of the upgrade.

Each device can be configured in the field with a standard Windows laptop (fast deployment).

Each device can be found on the network, even if the IP-address is unknown.

Online cloud image test service.

Console login with a hot pluggable USB null modem cable for field service.

Watchdog

Toolchain (compiler) tuned for the Raspberry ARM CPU.

Highly automated build system, perfect for Continuous Integration.

Committed to stability, simplicity, long term maintainability and lightweight design (perfect for the Compute Module Pi).

Several product examples. For instance; a web browser kiosk.

Network boot without SD card nor NFS-root.





$ tar -xzf nard.tar.gz

nard

├─ apps # Applications (incl Linux kernel)

├─ images # The final output goes here

├─ Makefile

├─ platform # Dir for each product and RPi model here

├─ Rules.mk # Common make "library"

└─ util # Toolchain (compiler)

$ cd nard

$ make skeleton

$ ls -l images/ # Finished outputs

For the impatient here is a pre-built demo image for all Pi models up to 3B+. However, if you have ever done C/C++ compiling before; read on. You can easily create your own image. After unpacking the tarball you get this tree: There are only a few directorys to keep things simple. Hold on with delving into the tree – we will do it later on. Instead you should now start building a product example:

The first run require an hour or so to finish on a quad core machine. Typical pre-requisites includes gcc, bison, flex, makedepend, automake etc. i.e the "usual" tools for compiling software packages. They are available in all major Linux distributions (Ubuntu, Fedora, Suse) should you need to install them. Detailed help can be found in the Trouble Shooting section.

Every product Nard can build has a recipe for what it's composed of. Product and board recipes stack on top of each other. The generic board recipes act as templates for the specifics. In the figure below everything originates from default. raspi_x_revx is an abbreviation for Raspberry Pi all models all revisions. It extends the previous recipe but may as well override it, should it need to. raspi_b_rev2 is short for model B revision 2. Products in the need of dual I2C channels may for instance use this recipe (revision 1 had only one channel). If you know object oriented programing you will have no problem grasping these dependencies.



export BOARD ?= raspi_b_revx



# List of applications this product needs. Packages

# will be built in the listed order (unless you

# explicitly define the dependencies).

PKGS_APPS += linux-kernel/linux-rpi-3.10.y

PKGS_APPS += bftpd/bftpd-4.2

# The HW we will run onexport BOARD ?= raspi_b_revx# List of applications this product needs. Packages# will be built in the listed order (unless you# explicitly define the dependencies).PKGS_APPS += bftpd/bftpd-4.2

A recipe is a simple Makefile. It's self explanory so here is a small example:

The variable PKGS_APPS defines what should be installed in the target. The example above adds Linux kernel 3.10.xx and a FTP server. Each layered recipe can add additional applications and in fact you will by default (from raspi_x_revx) also get a SSH server, BusyBox and some other tools one likely needs in an embedded system. All applications added to PKGS_APPS must reside in the apps directory.

$ sudo -s # Become root

$ zcat images/sdcard.img.gz >/dev/mmcblk0 # Your SD-card path

$ sync # Flush

Once the example product has finished building it's time to write your custom image to a SD-card. Any SD-card of at least 2 GB size will suffice (only 35 MB will become occupied). Warning, it will be fully erased in the process! Insert the card in your PC and run:

This image write is done only once. Next rebuild can be upgraded via the network.

Attach the Raspberry board to the same Ethernet network as your PC. Put the SD-card (from step above) in the Raspberry Pi card slot. Connect power to start the Pi up. The board LEDs will come to life as it boots up. When the green ACT led flashes on and off slowly it has finished booting. (About 20 seconds from power-on.)



Screenshot of first boot from fresh new SD-card.

$ make ssh

Easily log in to your board with a pre-setup custom SSH command. From the build environment run:

Your PC will then scan the local Ethernet subnet for targets running Nard and automatically login with a key it recently built. If multiple Nard boards are found you will get a list to choose from. Should it doesn't work you can log in with telnet as well. The default credentials is username=root and password=pass.

If your network setup is malfunctioning or you have a model A/0 Raspberry Pi you may login via a USB-to-Serial dongle as well:

Connect the dongle to the Raspberry Pi USB host port. Connect a null modem cable between the dongle and your PC serial port. Open a terminal program on your PC, set it to 115,200 8N1 and press enter.

When Nard has booted up it's ready for remote unattended upgrades. From your build environment in your PC, run this command:

$ make upgrade

It will scan the local network subnet for your board and upload your build with FTP firsthand and via SSH secondhand. A script in Nard will verify the uploaded files, replace the SD-card contents and reboot if everything was OK. When number of remote devices becomes large though you might need automation separated from Nard:

$ scp -i product_ssh_key sdcard.tar.gz <IP-addres>:/tmp

$ ssh -i product_ssh_key <IP-addres> /sbin/upgrade-os.sh

These PC command will achieve an upgrade as well but is cross platform, scriptable and independent of Nard installed. Thus deployment to large sets can be done using Windows as well. The SSH key is copied from intermediate/ and the tarball from images/.

/settings/network

- Use static or dynamic (DHCP) IP address?

- WiFi password and SSID?

By default DHCP is used.

- Use static or dynamic (DHCP) IP address? - WiFi password and SSID? By default DHCP is used. /settings/nodeid

- Human readable description of device (optional)

- Manually assigned (optional) fixed ID

These optional values will help you separate your devices apart. If you have many devices connected to the same network and all of them use DHCP it's hard to identify a specific unit. In those cases, run the command make scan from within the development environment and you will get a list of all nearby devices and their corresponding description/ID. Very coveted by field service engineers.



- Human readable description of device (optional) - Manually assigned (optional) fixed ID These optional values will help you separate your devices apart. If you have many devices connected to the same network and all of them use DHCP it's hard to identify a specific unit. In those cases, run the command make scan from within the development environment and you will get a list of all nearby devices and their corresponding description/ID. Very coveted by field service engineers. /settings/hostname

Name of the device as used by the OS. Will show up in the list when performing a make scan as well. Defaults to the product name + cpu serial number if left empty.

Name of the device as used by the OS. Will show up in the list when performing a make scan as well. Defaults to the product name + cpu serial number if left empty. /settings/rc.local

An optional shell script executed at the end of the boot process. Can for example launch a "master" daemon in just one unit of a Raspberry Pi cluster where as for the rest all cluster units share the same SD-card image.

Add start-stop-daemon -bSx /opt/my-app

Unique device settings (such as static IP-address) for each of your devices should be put in the directory /settings in the FAT partition of the SD-card. A field engineer can then easily configure each device during deployment with a standard Windows laptop. There are four small files that optionaly need adaptions. They are well commented inside but briefly described here too:

Modifications of the settings can be performed remotely as well. Login with a serial cable or SSH, edit them with vi /boot/settings/nodeid and issue a reboot.

To get command line help: $ make help

Unpack the SDK archive to your local PC harddrive. Don't use a network share, it's to slow. Even if you're on a fast LAN it's still nothing compared to your local disk. Instead, let the revision control system (git/svn) do the backup handling.

PC harddrive. Don't use a network share, it's to slow. Even if you're on a fast LAN it's still nothing compared to your local disk. Instead, let the revision control system (git/svn) do the backup handling. Neither GUI nor keyboard is available by default. In fact, you may leave the HDMI unconnected because there is nothing to see (exception mediaplayer). Instead, if you want a console, either go for the UART in the I/O expansion header P1 or connect a standard USB-to-Serial dongle to the Raspberry Pi USB port. You may then connect a null modem cable between your PC and the USB-to-Serial dongle to get a login prompt.

Further reading

What can one use Nard for?

Get your copy here

First check Trouble Shooting and then Questions and Answers. If you can't find what you need there then join the mailing list and ask for help there. Feedback and comments are welcome too! We would like to know how you find Nard. Do you like it? Have a wish-list etc? Commercial support can be arranged if necessary but is no arrogation.

Nard SDK is a Donationware variant. Business firms selling +100 Nard based units annually are expected to donate for the continued maintenance, security updates and development. An amount in the range of USD $200 USD: BTC: 3AsK4t2e1XuEbuRHkjTnLZkLcSECBDuoW9 for each hundred unit sold would be appreciated. Bitcoin is accepted as an alternative. Copyright ©

2014 – 2019 Ronny Nilsson

Nard is an unofficial SDK, not associated with the Raspberry Pi Foundation and Raspberry Pi is a trademark of the Raspberry Pi Foundation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Nard SDK comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.