pavel-demin / red-pitaya-notes

Notes on the Red Pitaya Open Source Instrument
http://pavel-demin.github.io/red-pitaya-notes/
MIT License
337 stars 209 forks source link

Adding WSPR transceiver to sd card with other apps #213

Closed df8oe closed 7 years ago

df8oe commented 8 years ago

Hello Pavel,

is there a howoto where I can find how to add this very nice project to my existing SD-card? I think this should be possible... I just have received my red pitaya yesterday and took a look at the card which actually contains the two default applications (and now additional the two sdr transceiver projects brought by you installed yesterday via bazaar). I am working with Linux and I am familar with doing such things manually :) Actually very interesting feature would be to upload prebuild packages via web interface so that you can add apps which are not available via bazaar...

vy73 de Andreas, DF8OE

pavel-demin commented 8 years ago

Hello Andreas,

There is no such a howto. At the moment, it's easier for me to provide a ready to use SD card image than writing such a howto.

You can have a look at the script that I'm using to build the SD card image: https://github.com/pavel-demin/red-pitaya-notes/blob/master/scripts/debian-wspr.sh

First, it copies the following files to the SD card image:

projects/sdr_transceiver_wspr/transmit-wspr-message.c
projects/sdr_transceiver_wspr/transmit-wspr-message.cfg
projects/sdr_transceiver_wspr/write-c2-files.c
projects/sdr_transceiver_wspr/write-c2-files.cfg
projects/sdr_transceiver_wspr/decode-wspr.sh
projects/sdr_transceiver_wspr/README
projects/sdr_transceiver_wspr/Makefile

Next, it installs packages and builds programs with the following commands

apt-get -y install openssh-server ca-certificates ntp ntpdate fake-hwclock \
  usbutils psmisc lsof parted curl vim wpasupplicant hostapd isc-dhcp-server \
  iw firmware-realtek firmware-ralink ifplugd ntfs-3g \
  build-essential subversion libfftw3-dev libconfig-dev parallel

svn co svn://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx/lib/wsprd
make -C wsprd CFLAGS='-O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ffast-math -fsingle-precision-constant -mvectorize-with-neon-quad' wsprd
make

Then, you'll need a couple of scripts to start and to stop the WSPR transceiver application. Something like the start.sh and stop.sh from the SDR transceiver application.

The start script should look like the following:

devcfg=/sys/devices/soc0/amba/f8007000.devcfg
test -d $devcfg/fclk/fclk0 || echo fclk0 > $devcfg/fclk_export
echo 1 > $devcfg/fclk/fclk0/enable
echo 143000000 > $devcfg/fclk/fclk0/set_rate

cat sdr_transceiver_wspr.bit > /dev/xdevcfg

(crontab -l ; echo "1-59/2 * * * * cd /dev/shm && /root/decode-wspr.sh >> decode-wspr.log 2>&1") | crontab -

The stop script should kill all the WSPR related processes (killall decode-wspr.sh write-c2-files wsprd) and somehow disable the crontab job.

Making the WSPR transceiver application compatible with the default Red Pitaya SD card would seem to be trivial to implement but unfortunately it's not so. There are some small but important details that don't fit well together. The problems that I see are the following:

Best regards,

Pavel

df8oe commented 8 years ago

Hello Pavel,

many thanks for your support. That seem to be "solvable" for me :) I will give it a try at the weekend and report what I get for results. I am in contact with Michael, DK5HH and we will discuss results, too. The application seems to me very interesting and I want to get it running as fast as possible :)

If I have done anything (scripting e.g.) which can help others I will send you a pull request.

vy 73 Andreas

df8oe commented 8 years ago

Hello Pavel,

I have investigated that all packages which are neccessary for run-time are already installed onactual rp-sd. Packages that are missing are: subversion, ntfs-3g, both -dev - packages and parallel...

I have mounted your wspr-image as loop and copied all (??) necessary binaries 8I found in /root) to actual sd-card. Now I must take a look to startup- und stop- scripts - I'll report when finished :)

vy73 Andreas

pavel-demin commented 8 years ago

For information. I've just updated the SD card image for the WSPR transceiver project and uploaded sdr_transceiver_wspr.bit that could be useful for your development.

df8oe commented 8 years ago

Yes - of course it is :) Many thanks.

My idea is to create a tarball where all binaries and scripts are included. So users only need to login via ssh, fetch tarball via scp and start "configuration script" what will be bash script using gtk. So you can enter callsign, locator, tx power and all other necessary informations. Script installs additional packages thatare needed and does changes to cron file. When started next time it allows modify settings. Script will start second time running on "screen" so that you can leave ssh connection and fetch back running script again after ssh login.

Because of I am heavy investigated in firmware grogramming for SDR standalone transceiver mcHF that will take some time but I definitely will do that.

Great work, Pavel! It works like a charm...

vy 73 Andreas

pavel-demin commented 8 years ago

There is now a new version of my SD card image based on Debian 8.4 and Red Pitaya ecosystem 0.95: http://pavel-demin.github.io/red-pitaya-notes/debian-ecosystem/

It could be used as a starting point for a SD card including WSPR and other SDR applications.

I've just realized that replacing crontab with /etc/cron.d could simplify the start and stop scripts:

start.sh:

devcfg=/sys/devices/soc0/amba/f8007000.devcfg
test -d $devcfg/fclk/fclk0 || echo fclk0 > $devcfg/fclk_export
echo 1 > $devcfg/fclk/fclk0/enable
echo 143000000 > $devcfg/fclk/fclk0/set_rate

cat sdr_transceiver_wspr.bit > /dev/xdevcfg

ln -sf /root/wspr.cron /etc/cron.d/wspr

stop.sh:

devcfg=/sys/devices/soc0/amba/f8007000.devcfg
test -d $devcfg/fclk/fclk0 || echo fclk0 > $devcfg/fclk_export
echo 1 > $devcfg/fclk/fclk0/enable
echo 125000000 > $devcfg/fclk/fclk0/set_rate

rm -f /etc/cron.d/wspr

killall decode-wspr.sh write-c2-files wsprd
df8oe commented 8 years ago

Hello Pavel,

nice new Debian image for RP - I have installed it and enjoy it :) Many thanks for your work!

I have already built wsprd on RP - works out-of-the-box. Building transmit-wspr-message throws a wanrning about argument 3 of config_lookup_string ("incompatible pointer string") - is it ok indeed?

Next I will create startup scripts and then test it :)

EDIT: Where can I find wspr.cron (needed in start.sh)?

vy 73 Andreas

pavel-demin commented 8 years ago

Where can I find wspr.cron (needed in start.sh)?

It should contain a line very similar to the crontab line:

1-59/2 * * * * root cd /dev/shm && /root/decode-wspr.sh >> decode-wspr.log 2>&1
df8oe commented 8 years ago

I tried that already - does not work...

It seems that file is not allowed to have extension ".cron".Tried now with symlink name wspr instead of wspr.cron and it works...

vy 73 Andreas

pavel-demin commented 8 years ago

Thanks for the test. I've fixed the cron.d file names in my previous comment.

df8oe commented 8 years ago

Many thanks. I will start "whispering" next week and contact Michael DK5HH with informations about this new and very good operating system image for RP.

vy 73 Andreas

pavel-demin commented 8 years ago

For information. Just found the following in man cron:

Files in this directory (/etc/cron.d) must consist solely of upper- and lower-case letters, digits, underscores, and hyphens. This means that they cannot contain any dots.

KI7MT commented 8 years ago

Hi Pavel,

I'm very interested in this thread, in particular, creating formal Debian (.deb ) packages for the various applications you've written up / designed ( unless somebody is already doing this for you of course ).

I've read through a fare bit of the ecosystem framework, but I am not clear on what is modified at the system level for each of your pitaya-note projects or if they all work together somehow.

For example, if all I wanted to run was a minimal system + Multi-Band WSPR, what steps would need to be taken from a package perspective to accomplish that. I can do the Debian packaging work, I just need to better understand the dependencies based on a default image ( e.g. a Debian / Ubuntu Bootstrap ). Once that is understood, the packages could be put together ( I think ) so an end user can simply install a Meta Package in much the same way Debian / Ubuntu desktop environments are installed using apt-get, e.g.

apt-get install ubuntu-desktop - The Ubuntu desktop system apt-get install edubuntu-desktop - educational desktop for Ubuntu apt-get install kubuntu-desktop - Kubuntu Plasma Desktop/Netbook system apt-get install lubuntu-desktop - Lubuntu Desktop environment apt-get install build-essential - Informational list of build-essential packages

and so on ..

All of those are Meta packages, which install all the packages required for a given environment / function, but the end user simply types: < sudo apt-get install ... >. There are hundreds of meta packages for development, non-Foss applications, restricted extra codecs, the lists goes on forever.

If possible, can you email me off-line to discuss this, when your time allows of course:

ki7mt@yahoo.com

Thanks

73's Greg, KI7MT

pavel-demin commented 8 years ago

Hi Greg,

Thanks for your interest in this development. My e-mail address can be found in my profile.

I'm very interested in this thread, in particular, creating formal Debian (.deb ) packages for the various applications you've written up / designed ( unless somebody is already doing this for you of course ).

As far as I know, nobody's doing the Debian packages for my Red Pitaya projects. Red Pitaya has its kind of package system with all the packages available from http://archives.redpitaya.com. They can be installed via the application marketplace web interface.

For example, if all I wanted to run was a minimal system + Multi-Band WSPR, what steps would need to be taken from a package perspective to accomplish that. I can do the Debian packaging work, I just need to better understand the dependencies based on a default image ( e.g. a Debian / Ubuntu Bootstrap ).

Here are the dependencies for the WSPR project:

As I mentioned in one of my previous comments, I still think that before packaging this application, all its scripts and programs should be merged into a single monolithic program that would be easy to start and stop. In its current form, this application won't coexist very well with other applications.

Best regards,

Pavel

KI7MT commented 8 years ago

Hi Pavel,

Thanks for the quick response. I need to study things a good bit more, but, I did notice in the Red Pitaya Changelog ( https://github.com/RedPitaya/RedPitaya/blob/master/CHANGELOG.md ) , they have migrated to Ubuntu 16.04 which allows direct access / use of Launchpad PPA and and they've switched to Systemd for various tasks.

Using Systemd may be an alternative way to control the Multi-WSPR application as well as move the uploading functionality to a service daemon, but as said above, I need to study this a good bit more.

As you said, making multi-wspr a monolithic app would certainly be beneficial. When I get things up and running on my end and do a bit of poking around, I'll email you off-line to discuss things in more detail.

73's Greg.

SpudGunMan commented 7 years ago

I see the dependencies listed - I didnt see any dependencies listed for wsprd or the huge 20gb SDK package.. wsprd is easy.. what is the components used from the xlinux SDK?

I would also like to get this code working on another (the main SD card) for RP

pavel-demin commented 7 years ago

I didnt see any dependencies listed for wsprd or the huge 20gb SDK package.. what is the components used from the xlinux SDK?

Please see my previous comment for all the dependencies. Here is a line related to wsprd:

I build wsprd on Red Pitaya. The Vivado SDK package isn't required for this.

I would also like to get this code working on another (the main SD card) for RP

Before running write-c2-files the FPGA should be reprogrammed by loading the sdr_transceiver_wspr.bit bitstream file into /dev/xdevcfg:

cat sdr_transceiver_wspr.bit > /dev/xdevcfg
SpudGunMan commented 7 years ago

Thanks for the bit file .. the old link was bad and this corrects the "bus error" that I would get otherwise.

here is a quick copy paste of commands to make this work on the official RP card.. I am looking at other ways to make this more user friendly like others.

apt-get install libc6 curl parallel ntp cron libfftw3-bin libfftw3-dev libconfig-dev subversion

git clone https://github.com/pavel-demin/red-pitaya-notes
cd red-pitaya-notes/projects/sdr_transceiver_wspr

svn co svn://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx/lib/wsprd
make -C wsprd CFLAGS='-O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ffast-math -fsingle-precision-constant -mvectorize-with-neon-quad' wsprd

make

wget https://www.dropbox.com/sh/5fy49wae6xwxa8a/AACSA6RMQm4OxU5yqfDz8-rHa/sdr/sdr_transceiver_wspr.bit
## use the start and stop scripts or this to run the appications
cat sdr_transceiver_wspr.bit > /dev/xdevcfg
pavel-demin commented 7 years ago

As it was mentioned in my first comment, all the installation commands can be found in scripts/debian-wspr.sh. I don't think that they should be duplicated in the comments of this issue.

a source for the files is.. https://github.com/pavel-demin/wsprd

This is wrong. Please don't use this repository. I'm removing my test wsprd repository and the related lines from your comment to prevent confusion.

The correct commands are in scripts/debian-wspr.sh:

git clone https://github.com/pavel-demin/red-pitaya-notes
cp red-pitaya-notes/projects/sdr_transceiver_wspr/* .

svn co svn://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx/lib/wsprd
make -C wsprd CFLAGS='-O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ffast-math -fsingle-precision-constant -mvectorize-with-neon-quad' wsprd

make
pavel-demin commented 7 years ago

There is now a new SD card image with all the pre-built applications including the WSPR transceiver. It's based on the lightweight Alpine Linux distribution.

For me, this SD card image has the following advantages:

The SD card image and some instructions can be found at the following link: http://pavel-demin.github.io/red-pitaya-notes/alpine