Skip to content

Commit

Permalink
Merge branch 'main' into LoraWan_Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairjordan authored Dec 4, 2023
2 parents 3389fa0 + b5796e7 commit 0224d85
Show file tree
Hide file tree
Showing 19 changed files with 761 additions and 11 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare build environment
run: ./cicd/prepare_runner.sh
- name: Build
run: ./cicd/docker_brun.sh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: Balloon${{ github.run_id }}${{ github.run_attempt }}
release_name: Release ${{ github.sha }}
body: |
Contents of this release:
* update.img - Update image for LuckyFox pico Board.
* output.zip - Contents of output folder
draft: true
prerelease: false
- name: Upload Release Asset update.img
id: upload-release-asset-update
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output/image/update.img
asset_name: update.img
asset_content_type: application/img
- name: Upload Release Asset output.zip
id: upload-release-asset-output
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output.zip
asset_name: output.zip
asset_content_type: application/zip

45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

This project is designed to build a linux based LoraWan HAB balloon. The idea of the project is to make an advancement of the current PicoBalloon communities.

## Project Advantages/Disadvantages

As ever, re-inventing the wheel has it's own pros and cons. This section aims to answer FAQs on why this project has been built and designed.

### Advantages

* Linux based - In the past, common sense would have assumed to have used low-power/arduino based microcontrollers. However, as chips have become vastly more efficient and cheaper in recent years (OK, that's a topic for another day!). This means that it has become sensible to start building using Linux. Advantages include being able to use Linux based drivers. For example the LoraWan interface is now a standard linux socket interface, and the HAM radio module can be interfaced with sysfs!
* Ease of development - Linux will allow GDB to be run on the end device for debugging, the environment is running ADB allowing code to easily be pushed or shell to be accessed. Multiple layers of _shit_ can be abstracted... Don't understand the FSK Lora Protocol or SPI interfaces? Fine. It's just a unix socket now! :)
* Ease of build - You can repeat this project with a soldering iron, a few thin wires and a swear jar.
* Sets a new standard of MVP (Minimal Viable Product) - The SDK and simple build means it can be used as a base design for quickly bootstrapping any future projects.

### Disadvantages

* Linux based - Yeah, it's not a RTOS. Looking at the drift of WSPR.. eh, famous last words but should be fine.
* Ease of development - It vastly changes the paradigm compared to Arduino based solutions
* Ease of build - WEIGHT!!!!!! - I will work on this one.
* Complexity - While fine once you get used to it... there is a lot going on here.

## Network design decisions

There are 2 major providers of LoraWan coverage:
Expand Down Expand Up @@ -54,10 +72,14 @@ This design decision has been made for the following reasons:

Generally modern GPS modules are simply UART based, use similar chipsets and have essentially all become unified since they became integrated into smartphones. I didn't take much bother into researching this one. They should in theory neary all just be hotswappable.

*Update*: No, no they are not. Added gpsd as a common interface.

#### Camera Module

This one needs research. I just picked the smallest, lightest camera I had on hand (It came from a ESP32 kit). Might not be the best solution power wise. This section might need an update.

*Update*, who uses a 20 Pin non-conformant MIPI/CSI interface on a dev board?!? Luckfox.. Otherwise the best dev board i've ever worked with :/

## Notes on design documentation and Source code

The linux module used as the central processor is based on the LuckyFox Pico Mini B. Hence the basis of this git repository is a fork of their SDK for ease of updating any bug fixes for the board. Where there have been significant code changes, the README.md from LuckyFox have been renamed with a _luckyfox.md appendage.
Expand All @@ -68,15 +90,24 @@ I have placed design thoughts within the ./doc directory within this repository.

## Initial Prototype

The initial prototype can be seen in the image below.
The initial prototype can be seen in the images below.

![Prototype](./docs/images/prototype.jpg)
![Prototype](./docs/images/schematic.jpg)


# Project status

* It boots into linux and doesn't blow up.
* DTS Updated for correct pin attribution
* GPS Works
* Starnights LoraWan module upgraded to work with Linux 5.10
* Lora and LoraWan Kernel Modules Building & Inserting
* Basically the entire code base is missing.
* [_COMPLETED_] It boots into Linux/Buildroot system.
* [_COMPLETED_] SPI working with Semtec sx1276 FSK Modem.
* [_COMPLETED_] I2C working with Si5351 Pulse Generator.
* [_COMPLETED_] UART working with uBlox GPS Module.
* [_COMPLETED_] GPS Works, gpsd installed.
* [_COMPLETED_] CI/CD Works.
* [_TESTING_] WSPR Working, Still requires real-world tests.
* [_IN PROGRESS_] Lora works, LoraWan not tested, added EU region, missing others in kernel driver.
* [_TODO_] "Glue" shell scripts to tack everything together.
* [_TODO_] CSI Camera Interface with CSI/MIPI camera.
* [_TODO_] Camera Images to Lorawan Packets.
* [_TODO_] LoraWan MAC to IPv4 Bridge.
* [_TODO_] Reduce physical weight (Daughter Board?)
5 changes: 5 additions & 0 deletions cicd/docker_brun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set -e

sudo docker run --privileged --mount type=bind,source="$(pwd)",target=/balloon luckfoxtech/luckfox_pico:1.0 /bin/bash /balloon/build.sh

zip output.zip output
25 changes: 25 additions & 0 deletions cicd/prepare_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set -e

# Install binfmt-support and zip
sudo apt install -y binfmt-support qemu-user-static zip

# Install docker
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Do submodule checkout
git submodule init
git submodule update --depth=1
29 changes: 29 additions & 0 deletions docs/WSPR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# WSPR Design

## Introduction

WSPR is a stands for Weak Signal Propogation Reporter, more information can be found at [https://www.sigidwiki.com/wiki/WSPR]https://www.sigidwiki.com/wiki/WSPR

WSPR is designed to be able to report incredibly weak signals, and has various base points for detection around the world. This allows communication at an extremely slow speed for location data to provide telemetry. This can be seen on WSPRNet.

[http://www.wsprnet.org/drupal/WSPRnet/map]WSPRNet

For use the protocol requires an amateur radio license. For this project, I have aquired one for use of WSPRNet, however anyone using this project will need to aquire a license for themselves in order to use this technology.

## Base Design

### Code

The project is based on [https://github.com/alexf91/WSPR-Beacon/]alexf91/WSPR-Beacon however has been completely rewritten.

The initial code was designed for an Arduino based solution with a USB interface. The re-write here disregards the code apart from the WSPR encoding library.

A special mention here is [https://github.com/threeme3/WsprryPi]threeme3/WsprryPi. I's not used in this project, but was vastly helpful for design purposes.

### Electronics

The WSPR part of the project requires an oscillator to function at around 14MHz.

For this it was chosen to use the si5351, for the good community support, and the ease of the i2c interface.

Technically, it a low pass filter should be added, but given the harmonics of a square wave and the transmission power, for this indiviual use case, I would consider unnecessary.
Binary file added docs/images/schematic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions docs/images/schematic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<mxfile host="app.diagrams.net" modified="2023-11-25T22:53:09.270Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" etag="ORIoZZMIWaURs2VqVCU3" version="22.1.3" type="device">
<diagram name="Page-1" id="xXQSwJtIRi74mmdLVUvR">
<mxGraphModel dx="880" dy="470" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="K1NoG9OSjYkEAMSQnG4f-4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="K1NoG9OSjYkEAMSQnG4f-1" target="K1NoG9OSjYkEAMSQnG4f-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-5" value="UART2" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="K1NoG9OSjYkEAMSQnG4f-4">
<mxGeometry x="-0.5077" y="-2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="K1NoG9OSjYkEAMSQnG4f-1" target="K1NoG9OSjYkEAMSQnG4f-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-7" value="SPI0" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="K1NoG9OSjYkEAMSQnG4f-6">
<mxGeometry x="0.2133" y="-2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="K1NoG9OSjYkEAMSQnG4f-1" target="K1NoG9OSjYkEAMSQnG4f-10">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-1" value="LuckFox-Pico-Mini-B" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="220" y="100" width="160" height="160" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-2" value="uBlox-Neo6M" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="470" y="100" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-3" value="sx1276" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="30" y="100" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-8" value="Notes - Reset to GND" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="20" y="190" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-9" value="Both devices connected to 3.3v on MPU" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="184" y="270" width="230" height="30" as="geometry" />
</mxCell>
<mxCell id="K1NoG9OSjYkEAMSQnG4f-10" value="CSI (WiP)" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="220" width="160" height="60" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
5 changes: 4 additions & 1 deletion local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ if ./build.sh ; then
sudo cp -rf output/image ~/nfs/image
else
echo "Build failure, not copying"
fi
fi

# Note to self, compiling a single thing is a lot easier when you add the toolchain!
# export PATH=/home/aj/lorawan-balloon/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin:$PATH
7 changes: 6 additions & 1 deletion sysdrv/cfg/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ $(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_OTA))
CONFIG_SYSDRV_ENABLE_STRACE=n
$(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_STRACE))


# Enable build lorawan-bridge
CONFIG_SYSDRV_ENABLE_LORAWAN_BRIDGE=y
$(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_LORAWAN_BRIDGE))
$(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_LORAWAN_BRIDGE))

# Enable build WSPR
CONFIG_SYSDRV_ENABLE_WSPR=y
$(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_WSPR))
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
regulator-name = "gpio1_pd0";
regulator-always-on;
};

clocks {
/* 25MHz reference crystal */
ref25: ref25M {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <25000000>;
};
};
};

&sfc {
Expand Down Expand Up @@ -67,14 +76,85 @@
// status = "disabled";
//};


// /**********I2C**********/
&i2c3 {
status = "okay";
pinctrl-0 = <&i2c3m1_xfer>;
clock-frequency = <100000>;
/* Si5351a msop10 i2c clock generator */
si5351a: clock-generator@60 {
compatible = "silabs,si5351a-msop";
reg = <0x60>;
#address-cells = <1>;
#size-cells = <0>;
#clock-cells = <1>;

/* connect xtal input to 25MHz reference */
clocks = <&ref25>;
clock-names = "xtal";

/* connect xtal input as source of pll0 and pll1 */
silabs,pll-source = <0 0>, <1 0>;

/*
* overwrite clkout0 configuration with:
* - 8mA output drive strength
* - pll0 as clock source of multisynth0
* - multisynth0 as clock source of output divider
* - multisynth0 can change pll0
* - set initial clock frequency of 74.25MHz
*/
clkout0 {
reg = <0>;
silabs,drive-strength = <8>;
silabs,multisynth-source = <0>;
silabs,clock-source = <0>;
silabs,pll-master;
/* clock-frequency = <74250000>;*/
};

/*
* overwrite clkout1 configuration with:
* - 4mA output drive strength
* - pll1 as clock source of multisynth1
* - multisynth1 as clock source of output divider
* - multisynth1 can change pll1
*/
clkout1 {
reg = <1>;
silabs,drive-strength = <4>;
silabs,multisynth-source = <1>;
silabs,clock-source = <0>;
pll-master;
};

/*
* overwrite clkout2 configuration with:
* - xtal as clock source of output divider
*/
clkout2 {
reg = <2>;
silabs,clock-source = <2>;
};
};

};

&pinctrl {
i2c3 {
/omit-if-no-ref/
i2c3m1_xfer: i2c3m1-xfer {
rockchip,pins =
/* i2c3_scl_m1 */
<1 RK_PD3 3 &pcfg_pull_up>,
/* i2c3_sda_m1 */
<1 RK_PD2 3 &pcfg_pull_up>;
};
};
};

// /**********SPI**********/
/**********SPI**********/
&spi0 {
status = "okay";
pinctrl-names = "default";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,4 @@ CONFIG_DEBUG_FS=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_FTRACE is not set
# CONFIG_RUNTIME_TESTING_MENU is not set
CONFIG_COMMON_CLK_SI5351=y
Loading

0 comments on commit 0224d85

Please sign in to comment.