Making PlutoSDR Fully Standalone: Auto-Run Custom Scripts on Boot

Making PlutoSDR Fully Standalone: Auto-Run Custom Scripts on Boot

Configure your PlutoSDR to execute custom scripts or programs automatically on boot — no firmware recompilation required. A one‑time setup for truly headless, standalone operation.

The Problem: Manual Execution After Every Boot

Using the Linaro toolchain, you can cross‑compile programs for the PlutoSDR's ARM core from an Ubuntu host. However, each run still requires:

  1. Cross‑compiling on the host
  2. Transferring the binary via scp to the PlutoSDR
  3. SSH into the PlutoSDR's Linux system
  4. Manually executing the program

This is only a semi‑standalone workflow — not very elegant for embedded applications.

Goal: A fully independent PlutoSDR that automatically runs your program on power‑up, without any host interaction after initial setup.

The Solution: init.d Autorun Hook

According to official firmware issue #74, starting from firmware version v0.36, PlutoSDR includes a built‑in autorun script capability. The file /etc/init.d/S98autorun contains:

#!/bin/sh
#
# Script to check for and run user-supplied /mnt/jffs2/autorun.sh
#

case "$1" in
  start)
    if test -f /mnt/jffs2/autorun.sh; then
        source /mnt/jffs2/autorun.sh
    fi
    ;;
  stop)
    ;;
  restart|reload)
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit $?

On every boot, this script checks for the existence of /mnt/jffs2/autorun.sh. If present, it executes it. In other words, anything you place in /mnt/jffs2/autorun.sh will run automatically each time the PlutoSDR powers on.

Quick Test: Creating an Autorun Script

Let's verify the mechanism. First, check the current contents of /root (initially empty):

$ pwd
/root
$ ls

Now create the autorun script:

vi /mnt/jffs2/autorun.sh

Add the following content (creates two empty files in /root):

touch /root/foobar
touch /root/123

Save and exit (:wq in vi).

Power‑cycle the PlutoSDR (unplug and reconnect power). After boot, SSH back in and verify:

$ pwd
/root
$ ls
123     foobar

The autorun script executed successfully on boot!

Persistent Storage for Your Programs

One remaining challenge: the PlutoSDR's Linux system reverts most file changes after reboot. Files created in /root or other directories disappear. How can you store your compiled binary persistently?

Answer: The /mnt/jffs2 directory uses a jffs2 (Journaling Flash File System) that does persist across reboots. Place your compiled executables here, and they will survive power cycles.

Workflow for a fully standalone application:

  1. Cross‑compile your program on the host machine using the Linaro toolchain
  2. scp the binary to /mnt/jffs2/ on the PlutoSDR
  3. Create /mnt/jffs2/autorun.sh that executes your binary (with full path)
  4. Make the script executable: chmod +x /mnt/jffs2/autorun.sh
  5. Power‑cycle — your program now runs automatically on every boot
Pro tip: You can also store configuration files, data logs, or additional resources in /mnt/jffs2. Everything placed there will persist across reboots.

Example: Auto‑Running a Custom SDR Application

Suppose you've cross‑compiled a program called my_sdr_app. The setup would look like:

# Copy binary to persistent storage
scp my_sdr_app root@192.168.2.1:/mnt/jffs2/

# Create autorun script
ssh root@192.168.2.1
echo '#!/bin/sh' > /mnt/jffs2/autorun.sh
echo '/mnt/jffs2/my_sdr_app' >> /mnt/jffs2/autorun.sh
chmod +x /mnt/jffs2/autorun.sh

# Reboot to test
reboot

After reboot, my_sdr_app will execute automatically — no host computer needed.

Important Notes

  • This method works on PlutoSDR firmware v0.36 and later. Check your version with cat /etc/issue.
  • The autorun script runs as root, so you have full system access.
  • If your program runs continuously (e.g., a server or data logger), consider adding an ampersand (&) to background it, or use a process manager.
  • To stop automatic execution, simply delete or rename /mnt/jffs2/autorun.sh.

Troubleshooting

  • Script not executing? Verify the file is at the exact path /mnt/jffs2/autorun.sh and has execute permissions (chmod +x).
  • Binary not found? Use absolute paths in your script (e.g., /mnt/jffs2/my_app instead of ./my_app).
  • Want to see boot logs? Connect via serial console or check /var/log/messages after boot.

Hardware Support

This technique applies to the PlutoSDR platform. For a ready‑to‑use PlutoSDR with full frequency support (70MHz–6GHz) and Gigabit Ethernet:



Previous post Next post

Hinterlasse einen Kommentar