Jupiter Nano

by Starcat

Tiny, high-performance computer that runs Linux or the NuttX real-time operating system

View all updates Sep 10, 2021

Connecting Jupiter Nano (running NuttX) to Wi-Fi

by Adam

Thank you

A huge thank-you to all the backers who made this campaign a success! As it draws to a close, we’ll be sending updates about more software for Jupiter Nano, our manufacturing process and status, and delivery estimates when we have them. Stay tuned!

And the board and accessories are all still available from Crowd Supply, at post-campaign prices. Boards to campaign backers will ship first, then we will ship to post-campaign backers after that.

Jupiter Nano, NuttX, and Wi-Fi

Today we’re going to dive into getting Jupiter Nano running NuttX onto a wireless network.

Until recently, that hasn’t been an easy task, as there is no WPA supplicant for NuttX yet. This is a piece of software that can handle the authentication with Wi-Fi access points. People have used specialized Wi-Fi modules made for embedded systems that connect through the SPI ports. These modules are special purpose computers that run closed-source software, are relatively expensive and hard to find, and also have fairly low performance.

NuttX has good wired Internet access though, with a high-performance TCP/IP stack. So what can we do? In one of the updates, we saw how to get Jupiter Nano on the Internet using an Ethernet over USB connection. Today we’ll show how to connect the Jupiter Nano to an inexpensive Raspberry Pi Zero W computer via Ethernet over USB. Raspberry Pi Zero W’s are available for $10-$25 from online retailers.

This solution will give you a small system running the NuttX Real Time Operating System and Linux, connected to the Internet with a very fast Wi-Fi connection.

See the Resources section below for more in depth information if you need it.

What you need

  • Jupiter Nano
  • Raspberry Pi Zero W – available from Mouser and other online retailers
  • Two Micro SD cards (2 GB or larger)
  • A Micro-USB-to-Micro-USB cable with which to connect the Raspberry Pi Zero to the Jupiter Nano Native port
  • A regular Micro-USB cable with an appropriate connector on the other end – to connect to a power source, like a battery or a computer, or to use as a serial console over USB if you need that functionality

How to set it up

  1. Download the Raspbian SD card image

  2. Write the image to an SD card

  3. Download and install Balena Etcher - this is a program that can write SD Card images

  4. Download and write the Starcat Apache NuttX image

  5. Configure the Raspberry Pi Zero W to…

    1. Connect to your Wi-Fi network

      • Create a file on the root partition called /etc/wpa_supplicant/wpa_supplicant.conf. Put the following text in it, changing the country, Wi-Fi ssid, and psk (password) to the ones for your network (if you are in the USA, your code is US):

            ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
            country=<Insert 2 letter ISO 3166-1 country code here>
            update_config=1
        
            network={
             ssid="<Name of your wireless LAN>"
             psk="<Password for your wireless LAN>"
            }
        

        (More info: Raspberry Pi documentation: Configuring Networking

    2. Route TCP/IP packets

      Edit the file on the rootfs volume called /etc/sysctl.conf; uncomment the following line:

          #net.ipv4.ip_forward=1
      

      So it reads:

          net.ipv4.ip_forward=1
      

      Save the file.

    3. Be a USB host (instead of the default, being a USB device)

      Edit the file cmdline.txt on the root directory of boot partition to read:

      console=serial0,115200 console=tty1 root=PARTUUID=1e787c50-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,cdc_ether,usbnet
      

      This loads the following Linux driver loadable modules: cdc_ether and usbnet, needed to do Ethernet over USB.

    4. Use USB network devices

      Now copy the usbnet Linux driver loadable module usbnet.ko to the following directory on the rootfs partition:

      /lib/modules/5.10.17+/kernel/drivers/net/usb/usbnet.ko
      

      This module is not supplied by default with the Raspberry Pi OS, so must be compiled and supplied separately. It’s compiled for Linux kernel version 5.10.17+, so if you’re running something different you’ll need to compile it yourself. Email jupiter-nano@starcat.io for more info if you need help with this.

    5. Run an SSH server

      Create an empty file on the root directory of the boot partition called ssh. That tells the OS to start an ssh server.

    6. Have the netusb.sh script that sets up routing and network address translation (NAT)

  6. Set up the hardware connections

    1. Insert the SD Cards into their respective computers.

    2. Connect the Micro-B to Micro-B USB cable

      Connect the Raspberry Pi Zero W USB port (not PWR) to the Jupiter Nano Native USB port

    3. Connect the other Micro-B USB to other flavor of USB connector (Type A, Micro-B, etc.) to your power source and to either Raspberry Pi Zero W’s PWR port or the Jupiter Nano console port.

    4. Wait for both computers to boot.

  7. Verify the Raspberry Pi Zero W is on the Internet

         pi@raspberrypi:~ $ ping -c 1 www.google.com
         PING www.google.com (172.217.14.196) 56(84) bytes of data.
         64 bytes from sea30s01-in-f4.1e100.net (172.217.14.196): icmp_seq=1 ttl=117 time=3.79 ms
    
         --- www.google.com ping statistics ---
         1 packets transmitted, 1 received, 0% packet loss, time 0ms
         rtt min/avg/max/mdev = 3.790/3.790/3.790/0.000 ms
    
  8. Configure the Raspberry Pi Zero W routes and network address translation (NAT) rules

         pi@raspberrypi:~ $ sudo ./netusb.sh wlan0 usb0 on
         default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.221 metric 303 
         169.254.0.0/16 dev usb0 scope link src 169.254.15.88 metric 204 
         192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.221 metric 303 
    
         usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
                 inet6 fe80::de3f:6c9a:d1b5:6cee  prefixlen 64  scopeid 0x20<link>
                 ether 02:00:00:11:22:33  txqueuelen 1000  (Ethernet)
                 RX packets 5  bytes 140 (140.0 B)
                 RX errors 0  dropped 0  overruns 0  frame 0
                 TX packets 36  bytes 5545 (5.4 KiB)
                 TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    
         RTNETLINK answers: File exists
         Error: Invalid prefix for given prefix length.
         default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.221 metric 303 
         10.0.0.0/24 dev usb0 proto kernel scope link src 10.0.0.1 
         10.0.0.2 dev usb0 scope link src 10.0.0.1 
         192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.221 metric 303 
    
         PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
         64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.980 ms
    
         --- 10.0.0.2 ping statistics ---
         1 packets transmitted, 1 received, 0% packet loss, time 0ms
         rtt min/avg/max/mdev = 0.980/0.980/0.980/0.000 ms
    
    
    
  9. Verify the Jupiter Nano is on the Internet

    Connect a USB Micro-B cable to the Jupiter Nano Console port, start a serial terminal program like picocom (replace the /dev/ttyACM0 with whatever device it is on your system):

        picocom -b 115200 /dev/ttyACM0 --imap lfcrlf
        nsh>
    
        nsh>  ping -c 1 www.google.com
        PING 142.250.69.196 56 bytes of data
        56 bytes from 142.250.69.196: icmp_seq=0 time=10 ms
        1 packets transmitted, 1 received, 0% packet loss, time 1010 ms
    

You are done!

Now you have an RTOS system with fast Wi-Fi Internet access. There are programs in the NuttX Applications repository that show how to write NuttX applications that can do hard realtime tasks and access the Internet at the same time – the TCP/IP stack is preemptable.

Questions? Email jupiter-nano@starcat.io for help or more info.

-adam

Resources

About the Author

Adam

adamfeuer  ·   Seattle, WA


$15,674 raised

of $3,250 goal

482% Funded! Order Below

Product Choices

$99

Jupiter Nano

High-performance SAMA5D27C-LD1G development board that runs Linux or NuttX


$13

microSD Card With Operating System

A 2 GB microSD card, pre-loaded with NuttX or Linux, ready to boot your Jupiter Nano


$19

Custom USB Cable for Port B

Native USB Port B Panel mount cable - Female USB Type-A to female IDC header connector


$7

Micro-USB Cable

A Micro-USB to USB Type-A cable chosen for the fit of its connector housing

Credits

Starcat

Electronics R&D company specializing in open source hardware and high performance biosignals acquisition equipment; creator of the HackEEG shield successfully launched on Crowd Supply in 2020


Adam Feuer

See Also

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects: