Building LoRaSerial Firmware
The open source LoRaSerial firmware builds under Windows and Linux. Use the following procedures to setup the environment and perform the build:
Ubuntu Build Environment
The following setup and build instructions were tested on Ubuntu 22.04.1. The build can run on a physical or virtual CPU. The following section describes how to setup a virtual machine. Further sections describe the build environment and how to perform the build.
Virtual Machine
Execute the following commands in the VirualBox application to create a virtual machine:
- Click on the Machine menu item
- Click on the New submenu item
- Specify the machine Name, e.g.: Sparkfun_LoRaSerial_22.04.1
- Select Type, e.g.: Linux
- Select Version, e.g.: Ubuntu (64-bit)
- Click the Next> button
- Select the memory size: 7168
- Click the Next> button
- Click on Create a virtual hard disk now
- Click the Create button
- Select VDI (VirtualBox Disk Image)
- Click the Next> button
- Select Dynamically allocated
- Click the Next> button
- Select the disk size: 128 GB
- Click the Create button
- Click on the Settings button
- Click on Storage
- Click the empty CD icon
- On the right-hand side, click the CD icon
-
Click on Choose a disk file... An operating system is needed for the virtual machine to enable it to run applications. Download one of the following operating system images (.iso files):
-
Windows
-
Choose one of the .iso files downloaded above
- Click the Open button
- Click on Network
- Under 'Attached to:' select Bridged Adapter
- Click the OK button
- Click the Start button
- Install the operating system
-
Log into the operating system
-
For Ubuntu:
- Click on Activities
- Type terminal into the search box
-
In the terminal window a. sudo apt install -y net-tools openssh-server b. ifconfig
Write down the IP address
-
On the PC (Linux) in a terminal window a. ssh-keygen -t rsa -f ~/.ssh/SparkFun_LoRaSerial_22.04.1 b. ssh-copy-id -o IdentitiesOnly=yes -i ~/.ssh/SparkFun_LoRaSerial_22.04.1 <username>@<IP address> c. ssh -Y <username>@<IP address>
Execute the following commands to create the build environment for the SparkFun LoRaSerial Firmware:
- sudo adduser $USER dialout
- sudo shutdown -r 0
Reboot to ensure that the dialout privilege is available to the user
- sudo apt update
- sudo apt install -y git gitk git-cola minicom python3-pip
- sudo pip3 install pyserial
- mkdir ~/SparkFun
- cd ~/SparkFun
- nano serial-57600.sh
Insert the following text into the file:
#!/bin/bash
# serial-57600.sh
#
# Shell script to read the serial data from the LoRaSerial USB port
#
# Parameters:
# 1: ttyACMn
#
sudo minicom -b 57600 -8 -D /dev/$1 < /dev/tty
- chmod +x serial-57600.sh
Get the SparkFun LoRaSerial Firmware sources
- mkdir ~/SparkFun/LoRaSerial
- cd ~/SparkFun/LoRaSerial
- git clone https://github.com/sparkfun/SparkFun_LoRaSerial .
Install the Arduino IDE
- mkdir ~/SparkFun/arduino
- cd ~/SparkFun/arduino
- wget https://downloads.arduino.cc/arduino-1.8.15-linux64.tar.xz
- tar -xvf ./arduino-1.8.15-linux64.tar.xz
- cd arduino-1.8.15/
- sudo ./install.sh
- arduino
Setup the Arduino Build Environment
Install the ARM Cortex-M0+ tools. See SAMD21 MiniDev Hookup Guide for more documentation.
- Click on Tools in the menu bar
- Click on Board
- Click on Board Manager ...
- Scroll down to Arduino SAMD Boards (32-bits ARM Cortex-M0+)
- Click on Arduino SAMD Boards (32-bits ARM Cortex-M0+)
- Select version 1.8.13
- Click on the install button
- Click on the close button
Install the SparkFun Board Packages
- Click on File in the menu bar
- Click on Preferences
- Go down to the Additional Boards Manager URLs text box
- Only if the textbox already has a value, go to the end of the value or values and add a comma
- Add the link: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/main/IDE_Board_Manager/package_sparkfun_index.json
- Note the value in Sketchbook location
- Click the OK button
- Click on Tools in the menu bar
- Click on Board
- Click on Board Manager ...
- Scroll down and click on SparkFun SAMD Boards (dependency: Arduino SAMD Boards 1.8.1)
- Select version 1.8.9
- Click on the install button
- Click on the close button
- Click on Tools in the menu bar
- Click on Board
- Click on SparkFun SAMD (32-bits ARM Cortex-M0+) Boards
- Click on SparkFun LoRaSerial
Install the required libraries
The following procedure installs the libraries needed to successfully build the LoRaSerial firmware.
- Click on Tools in the menu bar
- Click on Manage Libraries...
-
For each library:
a. Enter the library name into the search box b. Scroll down the list if necessary to locate the specified libray c. Click on the library d. Select the specified version e. Click on the install button
-
Install the following libraries:
a. Crypto, v0.4.0 a. FlashStorage_SAMD, v1.3.2 a. JC_Button, v2.1.2 a. RadioLib, v5.1.2 a. SAMD_TimerInterrupt, v1.9.0
-
Click on File in the menu bar
- Click on Quit
External Libraries
The WDT library is not registered with the Arduino IDE. It must be added outside of the Arduino IDE environment. Install the external libraries adding them to the Sketchbook location noted above.
- cd ~/Arduino/libraries
- mkdir WDTZero
- cd WDTZero/
- git clone https://github.com/javos65/WDTZero.git .
Build the LoRaSerial Firmware
Use the following procedure to get the project ready to build
- arduino
- Click on File in the menu bar
- Click on Open
- Select the project file: ~/SparkFun/LoRaSerial/Firmware/LoRaSerial/LoRaSerial.ino
- Click on the Open button
- Click on Tools in the menu bar
- Verify that Board lists "SparkFun LoRaSerial"
Connect the LoRaSerial Device
- Plug the LoRaSerial device into a USB port on the PC
- In the arduino program, click on Tools
- Click on Ports
- Select the port for the LoRaSerial device
Compile
- Click on Sketch in the menu bar
- Click on Verify/Compile
- Using an editor or the Arduino IDE ake any source file changes until the Sketch (program) compiles cleanly
Upload the Firmware
- Click on Sketch
- Click on Upload
Arduino CLI
The firmware can be compiled using Arduino CLI. This makes compilation fairly platform independent and flexible. All release candidates and firmware releases are compiled using Arduino CLI using a github action. You can see the source of the action here, and use it as a starting point for Arduino CLI compilation.