Skip to content

Commit

Permalink
Wspr (#5)
Browse files Browse the repository at this point in the history
* Initial Commit

* Si5351 driver working

* Base WSPR solution

* WSPR works

* Cleanup

* Re-enable SPI

---------

Co-authored-by: Alistair Jordan <alistairjordan>
  • Loading branch information
alistairjordan authored Dec 4, 2023
1 parent 746d845 commit 5b2e45b
Show file tree
Hide file tree
Showing 12 changed files with 594 additions and 3 deletions.
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.
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
4 changes: 4 additions & 0 deletions sysdrv/cfg/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ $(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_OTA))
# Enable build strace
CONFIG_SYSDRV_ENABLE_STRACE=n
$(eval $(call MACRO_CHECK_ENABLE_PKG, RK_ENABLE_STRACE))

# 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
10 changes: 9 additions & 1 deletion sysdrv/tools/board/Makefile.tools.board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ tools_board-builds: \
board-build-rockchip_test \
board-build-e2fsprogs \
board-build-sysstat \
board-build-mtd_utils
board-build-mtd_utils \
board-build-wspr
@echo "build tools board done"

tools_board-clean:
Expand All @@ -23,6 +24,7 @@ tools_board-clean:
$(MAKE) -C $(SYSDRV_DIR)/tools/board/stressapptest distclean
$(MAKE) -C $(SYSDRV_DIR)/tools/board/rk_ota distclean
$(MAKE) -C $(SYSDRV_DIR)/tools/board/sysstat distclean
$(MAKE) -C $(SYSDRV_DIR)/tools/board/wspr distclean

board-build-toolkits:
$(MAKE) -C $(SYSDRV_DIR)/tools/board/toolkits
Expand Down Expand Up @@ -74,7 +76,13 @@ ifeq ($(BOOT_MEDIUM),spi_nor)
popd;
endif
endif

board-build-sysstat:
ifeq ($(ENABLE_SYSSTAT),y)
$(MAKE) -C $(SYSDRV_DIR)/tools/board/sysstat
endif

board-build-wspr:
ifeq ($(ENABLE_WSPR),y)
$(MAKE) -C $(SYSDRV_DIR)/tools/board/wspr
endif
26 changes: 26 additions & 0 deletions sysdrv/tools/board/wspr/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#ifeq ($(SYSDRV_PARAM), )
WSPR_PARAM:=../../../Makefile.param
include $(WSPR_PARAM)
#endif

export LC_ALL=C
SHELL:=/bin/bash

CURRENT_DIR := $(shell pwd)
PKG_NAME := wspr
PKG_BIN := out

all:
@test -f $(PKG_BIN)/usr/sbin/$(PKG_NAME)_noexist || (\
mkdir -p $(CURRENT_DIR)/$(PKG_BIN)/usr/sbin; \
$(SYSDRV_CROSS)-gcc -g main.c wspr.c -o $(CURRENT_DIR)/$(PKG_BIN)/usr/sbin/$(PKG_NAME); \
)
$(call MAROC_COPY_PKG_TO_SYSDRV_OUTPUT, $(SYSDRV_DIR_OUT_ROOTFS), $(PKG_BIN))
# $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL_DIR) M=$(shell pwd) $@ -j12

clean: distclean

distclean:
-rm -rf $(PKG_NAME) $(PKG_BIN)

6 changes: 6 additions & 0 deletions sysdrv/tools/board/wspr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# WSPR Transmission Code

This code is designed to transmit WSPR tones and is a largely rewritten version of:
https://github.com/alexf91/WSPR-Beacon/

The code directly interfaces with the clock sources through the unix filesystem.
32 changes: 32 additions & 0 deletions sysdrv/tools/board/wspr/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2018 Alexander Fasching
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEBUG_H
#define DEBUG_H

#include <stdio.h>
#include <stdarg.h>

static inline void debug(const char *format, ...) {
#ifdef DEBUG
va_list args;
va_start(args, format);
vprintf(format, args);
#endif
}

#endif /* DEBUG_H */
Loading

0 comments on commit 5b2e45b

Please sign in to comment.