This is a version of LinBPQ for the Raspberry Pi Pico and similar RP2040/RP2350 microcontroller Boards
This is intended for remote sites where reliability and low power consumption are important.
It is a cut down version of linbpq with no application interface and only support for KISS TNCs. Includes NETROM and a basic flash file system for configuration files.
It should be possible to configure to run on any RP2040 or RP2350 based board. I've mainly tested using a Raspberry Pi Pico, but as it costs very little more I'd now use a Pico 2 as it has twice the RAM and faster CPU. At the moment the code doesn't support wifi as that is unlikely to be available at a remote site but it could be added as an option. In this case the Pico 2 W would be a better choice than the Pico W as the wifi code used a lot of RAM.
I'm currently running it on a Raspberry Pi Pico, which uses an RP2040 chip and has 2MB flash and 264kB RAM. Half of the flash is used for a LittleFS file system which is claimed to be a fail-safe filesystem designed for microcontrollers. There are node commands to upload, list, read, delete and rename files.
Supports up to 6 serial ports, and is primarily intended for use with Nino TNCs without the USB chip, though for testing I'm using a serial to USB Host converter with a standard USB Nino.
Realtime clock (currently a DS1307). Not really needed as the only thing that uses real time are the MHU and ROUTES commands.
If connected to the USB port on a host a USB Serial port will be created. This appears as /dev/ttyACMx on Linux or COMxx on Windows. The node can be managed via a serial terminal using this port. The serial console in the Arduino IDE can be used, but I had trouble uploading files and found that putty worked better.
On initial boot, or if the main config is corrupted the system will create a dummy config with one hardware serial KISS port and if multiple USB Serial ports is enabled a USB Serial KISS port. These can be used for initial setup or if your bpq32.cfg get corrupted you should be able to upload a bpq32.cfg over rf.
You can also add a Pimoroni Clipper LTE 4G Breakout. This gives options for SMS reports and for dialup access. It can also supply the time, removing the need for an RTC.
Prebuilt binaries for Pi Pico and Pi Pico 2 are available or you can build from source.
The file system commands are FILES (list dir) READ UPLOAD DELETE RENAME. You can upload a new bpq32.cfg via a terminal on the USB serial port or over RF. Send UPLOAD then paste a config. It didn't work with the terminal in the IDE but it was fine with putty. You can read the default config with READ bpq32.cg. Commands are sysop only, so you need to enter PASSWORD first. The USB term is considered secure so you don't need to enter password info. Just PASSWORD should do it.
CLOCK - read or set RTC. If value is greater than 86400 it is treated as the current Unix Time and used to set the RTC. Otherwise it is an offest to be applied to get current RTC time.
DEBUG and CONSOLE. These display the last 2048 bytes from the DEBUG or CONSOLE outputs.
DIAL. This connects you to the 4G/LTE modem and allows you to enter AT commands.
As mentioned above you can connect a 4G Modem. This provides remote access should you be unable to connect to the node over RF.
Normally Mobile data does not give you a public IP address so you can't connect to it. To get over this you can send it an SMS message and it will call back to a preprogrammed host. I have it set up to connect to a listening session in QtTermTCP. You can define up to two host and use the SMS Message callback1 or callback2 to activate. See Board Configuration below for the needed settings.
You can also configure the code to send you an SMS message when the node restarts.
Serial ports.
Supports the hardware Serial1 and Serial2 and 4 emulated ports using the SerialPIO module. See https://www.raspberrypi.com/news/what-is-pio/ for some info about the RP2040 PIO subsystem - it is used here to create additional high performance serial ports.
Serial1 - TX GP0, Pico Pin 1, RX GP1. Pico Pin 2 Serial2 - TX GP8, Pico Pin 11, RX GP9. Pico Pin 12 Serial3 - TX GP2, Pico Pin 4, RX GP3. Pico Pin 4 Serial4 - TX GP6, Pico Pin 9, RX GP7. Pico Pin 10 Serial5 - TX GP10, Pico Pin 14, RX GP11. Pico Pin 15 Serial6 - TX GP12, Pico Pin 16, RX GP13, Pico Pin 17
Serial6 is reserved for the 4G/LTE Modem The others can be used for KISS TNCs
You can also create two additional serial devices on the USB port. These aren't needed on a live system but I find them useful for testing. The default settings have one configured as a second console and the other a KISS port.
4G/LTE:
The supplied source is configured to use a Pimoroni Clipper LTE 4G Breakout, Pin Connections are:
PWRKEY GP14, RESETPIN GP15. TXD and RXD as Serial6 above.
You will need to set the network parameters to suit the Mobile Network you are using by sending a couple of AT commands. You can do this from the node console using the dial command. AT+CGAUTH sets Authentication mode and users/password if needed. AT_CGDCONT sets the APN.
My Clipper boards came with a 1NCE SIM with 500 MB data, but it doesn't support text messaging. I use 1P Mobile which has some pretty good packages available.
For 1NCE you need APN "iot.1nce.net", PAP authenication and no user/pass.
AT+CGAUTH=1,1
AT+CGDCONT=1,"IP","iot.1nce.net"
For the 1P Mobile Network, the APN is "data.uk" and the CHAP username and password are "user" and "one2one"
AT+CGAUTH=1,2,"one2one","user"
AT+CGDCONT=1,"IP","data.uk"
You can create a file Board.cfg to set up system parameters. This is mainly needed if you have the 4G/LTE board. It is separate from the Node configuration bpq32.cfg as it is unlikely to change once set up and will allow you recover if you accidentally upload a bpq32.cfg that prevents RF access.
Available commands.
NodeCall=GE8BPQ // Will be used if bpq32.cfg is corrupt RTC=DS1307 // Sets Reat Time clock type. Options are DS1307, DS1904, PCF8523. Default is DS1307 Clipper // Enables support for Clipper board SMSDEST=07760XXXXXX // Number to send SMS alerts to SMSEvents=Restart // Events to report. At the moment the only one is Restart The next two define the hosts to call in response to the SMS messages callback1 or callback2 Callback1=nottm.g8bpq.net:pppp Callback2=skig.g8bpq.net:pppp
The config defaults to SIMPLE mode. A minimal bpq32.cfg could be
NODECALL=GE8BPQ-2 NODEALIAS=PICO PASSWORD="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" PORT TYPE=ASYNC ID=KISS Serial1 COMPORT=Serial1 SPEED=57600 QUALITY=192 ENDPORT
You can uave up to 5 serial ports Serial1 to Serial5. If you have a Clipper you cen enable MQTT reporting. eg
MQTT=1 MQTT_HOST=nottm.g8bpq.net MQTT_PORT=1234 MQTT_USER=g8bpq MQTT_PASS=password
At the moment only status reports are sent. One when the node reboots then one per hour to report still running.
On first boot, or if neither bpq32.cfg nor backup.cfg contain a valid config the following default config file is created. If there is an invalid bpq32.cfg it is first renamed bpq32.cfg.bad
SIMPLE NODECALL=DUMMY NODEALIAS=RP2040 PASSWORD=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA PORT TYPE=ASYNC ID=KISS Serial1 COMPORT=Serial1 SPEED=57600 QUALITY=0 ENDPORT
If you are building from source it would be a good idea to change the NODECALL.
Install Arduino IDE. I'm using Version 2.3.4
Open up the Arduino IDE and go to File->Preferences.
In the dialog that pops up, enter the following URL in the Additional Boards Manager URLs field:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
In Boards Manager type RP2040 and select Respberry Pi Pico/RP2040/RP2350 by Earle...
In Libraries:
install microDS18B20 and RTClib
in Tools/Board select Raspberry Pi Pico (or whatever board you are using)
in Tools/USB Stack - Select AdaFruit TinyUSB
in Tools/Flash Size - Select 1MB FS.The code size will vary depending on the board (1MB on Pico, 3 MB on Pico 2).
The first time a board it programmed it will be necessary to connect the board with the Boot button pressed.
On Windows the code should upload to be board automatically.
On Linux the build worked for me worked but the code did not automatically upload. I had to run Sketch/Export Compiled Binary and set the Pico into Bootsel mode (power up with boot button pressed).
The board appeared as /dev/sdc1 but this may vary. Mount it and copy the compiled .uf2 file to it. On my system it was in
./picoBPQ/build/rp2040.rp2040.rpipico2/picoBPQ.ino.uf2