Are you lucky? No USB to serial converter needed!

All model B-V2 (and model A) owners can set-up their svxlink system without the need of an external USB-2-serial converter. All raspi versions offer a built-in serial port, but only the data signals (RXD/TXD) are available on the GPIO header (see http://elinux.org/RPi_Low-level_peripherals). With the arrival of the version 2 boards things improved. A new connector P5 was introduced. It is right next to the extension header P1, but as shipped there are no pins equipped.

Details on the P5 header can be found at http://www.raspberrypi-spy.co.uk/2012/09/raspberry-pi-p5-header/

Of interest to us are the pins 5+6 (GPIO30+GPIO31). The chip on the raspi allows different mappings as can be found at http://elinux.org/RPi_BCM2835_GPIOs . As can be seen there, GPIO30+GPIO31 can be switch to be RTS0/CTS0 in mode “ALT3”.

To use the IO pins we first need to “free” the serial port for our usage. The default configuration of the linux image uses the built in serial port to dump kernel messages and as a way to log into your raspi.

From /boot/cmdline.txt we need to remove the following options:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

We also need to stop the system to spin up a terminal on the serial port. For this we put the following statement in /etc/inittab into comment (add # in front of the line):

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200

OK, the serial port is ours, but we still need a tool to switch the GPIO assignment.

# as pi user, 
cd /home/pi
mkdir rpi-tools
cd rpi-tools/
# if you have not yet installed git, this must be done upfront
# see comments section below on how to do this
git clone https://github.com/rewolff/bw_rpi_tools.git
cd bw_rpi_tools/gpio
# depending on the version or status of the tools you might need to fix the Makefile
# see comments section below
make
sudo make install

We can now check the current pin assignment:

sudo gpio_list

To reassign the pins to the RTS/CTS function we use the following command:

sudo gpio_setfunc 31 ALT3
sudo gpio_setfunc 30 ALT3

To make this restart safe, we put the command into /etc/rc.local:

# enable CTS+RTS on P5 header for onboard serial
/usr/local/bin/gpio_setfunc 31 ALT3
/usr/local/bin/gpio_setfunc 30 ALT3

Bingo. We can now use the built-in serial port in the svxlink configuration by referring to the device: /dev/ttyAMA0 . In svxlink.conf we use:

SERIAL_PORT=/dev/ttyAMA0

Until the advent of direct raspi GPIO support in svxlink above few lines will be of help.

WARNING: When connecting external circuitry to the raspi GPIO pins, please be reminded that the Raspberry Pi only support 3.3V signal level. So in the best interest of your raspi keep this in mind!

Advertisements

21 thoughts on “Are you lucky? No USB to serial converter needed!

  1. peter

    Ah, it was my problem too!
    But there is another one….
    ….because I want to write a Python-program that will control our repeater system.
    This program should use the Pi’s GPIO too – CarrierDetect, PowerON/OFF , PTT, thermal-
    -switch, etc…. In this situation no link-radio is needed for echolink-extension of the repeater,
    the Pi’s audio in/out will connected directly to the repeaters audio router, and its control ports.
    So, this is the reason , because I have to know shurely : does this modification, that routes
    RTS/CTS functions to 30,31 GPIO-pins, affect only these ( 30,31 ) ports?
    The commands, you wrote, are pin-specified by the ALT-3 table – but what happens
    the functionality of other GPIO ports? … will remain, as default – or not?

    Reply
  2. dl8scu Post author

    Hi Peter,

    yes, the commands I show above will only alter the behaviour of the GPIO Pins 30,31. The other GPIO pins will not be affected.

    Once you’ve got the tools installed you can use the “gpio_list” command to show the current assignment. If you do this before and after the gpio_setfunc calls you can verify that the other pin assignments remained unchanged.

    73 de Holger

    Reply
  3. w6web

    I followed the instructions above and I hooked up the ptt to the RTS GPIO 31, the problem I am having is that this port is high by default. This means that the radio ststarts transmitting right away and svxlink actually switches the ptt off when TX is on.

    Does any one else have this problem? What did you do to fix it?

    Reply
  4. dl8scu Post author

    How about using another transistor as signal inverter and change the pin control in svxlink,conf to inverse polarity?

    I use two transistors on the PTT line (one as inverter) and the following parameters in svxlink.conf:
    PTT_PORT=/dev/ttyAMA0
    PTT_PIN=DTRRTS

    I hope this helps,
    73 de Holger

    Reply
  5. ciro

    I try to install following the istruction, but the there are same error during the make install

    pi@raspberrypi ~/rpi-tools/bw_rpi_tools/gpio $ sudo make install
    cp gpio_list clrdisplay mon_display moveto writedisplay i2c_identify /usr/local/bin
    cp: cannot stat `gpio_list’: No such file or directory
    cp: cannot stat `clrdisplay’: No such file or directory
    cp: cannot stat `mon_display’: No such file or directory
    cp: cannot stat `moveto’: No such file or directory
    cp: cannot stat `writedisplay’: No such file or directory
    cp: cannot stat `i2c_identify’: No such file or directory
    make: *** [install] Error 1
    pi@raspberrypi ~/rpi-tools/bw_rpi_tools/gpio $

    than i have not found the command gpio_setfunc in the /usr/local/bin/

    Please can help me

    Iz8ozy
    ciro

    Reply
  6. Ian

    Ciro I found that if you goto /rpi-tools/bw_rpi_tools/bw_tool and do a make there you can then get the sudo make install to partially work enough to get the gpio_list working -No luck yet for the setfunc

    Reply
    1. ciro

      correct

      i have found the same problems.

      But the gpio_list is only for showing the gpio setting in accord of bmc spec. The real tools for setting the gpio don’t working

      bye
      ciro

      Reply
  7. Ian

    Yes that is a big nuisance isn’t it – so far all the usb to serial cables I am using are not stable enough for lengthy unattended use on my svxlink node.

    Reply
  8. dl8scu Post author

    Hi Ian and ciro,

    it seems there have been quite a few updates on the tools package, one of which broke the Makefile and as a result symbolic links that should be created are not.

    In the Makefile change the line:
    cp $(BINARIES) $(SCRIPTS) $(BINDIR)
    to
    cp $(BINARIES) $(BINDIR)

    before the make install type:
    make
    followed by the command shown above:
    sudo make install

    If you now look into the (default) install directory /usr/local/bin you will find:
    a) the file: gpio_list
    b) a soft link: gpio_setfunc -> /usr/local/bin/gpio_list
    and some more soft links.

    Hope this fixes your problems.
    73,
    Holger

    Reply
  9. dl8scu Post author

    BTW,
    if one does not already have git support installed, that must be done upfront:

    # might be required
    sudo apt-get update
    # get git support
    sudo apt-get install git-core
    # …follow the prompt

    Regards,
    Holger

    Reply
  10. Ian

    Thank you Holger for your prompt reply –all is now going perfectly — all I have to do now is find a smaller sound card and I have the pocket size node I am trying to achieve.

    Reply
  11. dl8scu Post author

    Hi Ian,

    that’s good to hear. For my svxlink node I’ve tried various USB sound cards. I’m very happy with the ASUS XonarU3. It’s well supported by Alsa and it’s still reasonable small. Downside is its price.

    As with ALL sound cards I’ve tried there is still an issue with temporary delayed audio on my duplex setup.

    73,
    Holger

    Reply
  12. Ian

    Wouldn’t it be nice if you could wave a magic wand and get exactly what you wanted? We all know what specifications we need in sound card as well as anything else but we have to try a few first. Thanks for your advice about the ASUS.

    Reply
  13. G0FHM

    I cannot get svxlink to run either with PL2303 adapter or via GPIO! Whatever I enter in svxlink.conf (be it /dev/ttyAMA0 or /dev/ttyUSB0) I just get an error:
    Starting logic: SimplexLogic
    Loading RX: Rx1
    Loading TX: Tx1
    open serial port: No such file or directory
    *** ERROR: Could not initialize TX “Tx1”
    *** ERROR: Could not initialize Logic object “SimplexLogic”. Skipping…
    *** ERROR: No logics available. Bailing out…
    Nobody prepared to offer any solutions on the svxlink-devel mailing list! (PL2303 works with thelinkbox fine!)

    Can anybody help?

    73 de G0FHM

    Reply
  14. Peter; DO1PBL

    Hi Holger,
    What’s about GPIO17, Marked at ALT3 as RTS0 too.
    Is it also useable after switching to ALT3 ?
    No soldering required ;.)
    73 Peter

    Reply
  15. Pingback: Странная логика :Записки айтишника-радиолюбителя

  16. Christian

    Hallo Holger,

    Viel dank fur ihre helfe..;
    I have this result, which seems correct:
    sudo gpio_list
    0 ALT0 ALT0 INP INP INP OUT OUT INP INP INP
    10 INP INP INP INP ALT0 ALT0 OUT INP INP INP
    20 INP OUT INP INP INP INP INP INP INP INP
    30 ALT3 ALT3 INP INP INP INP INP INP INP INP
    40 ALT0 INP INP INP INP ALT0 INP INP ALT3 ALT3
    50 ALT3 ALT3 ALT3 ALT3 INP

    But
    svxlink
    SvxLink v1.3.0 (Jun 15 2014) Copyright (C) 2003-2013 Tobias Blomberg / SM0SVX

    SvxLink comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
    welcome to redistribute it in accordance with the terms and conditions in the
    GNU GPL (General Public License) version 2 or later.

    Using configuration file: /etc/svxlink/svxlink.conf
    — Using sample rate 48000Hz

    Starting logic: SimplexLogic
    Loading RX: Rx1
    Loading TX: Tx1
    open serial port: No such file or directory
    *** ERROR: Could not initialize TX “Tx1”
    *** ERROR: Could not initialize Logic object “SimplexLogic”. Skipping…
    *** ERROR: No logics available. Bailing out…

    My configuration is in local directory ~/svxlink.xx.xx/svxlink.conf

    [GLOBAL]
    MODULE_PATH=/usr/lib/svxlink
    LOGICS=SimplexLogic
    CFG_DIR=svxlink.d
    TIMESTAMP_FORMAT=”%c”
    CARD_SAMPLE_RATE=48000
    #LOCATION_INFO=LocationInfo
    #LINKS=LinkToR4

    [SimplexLogic]
    TYPE=Simplex
    RX=Rx1
    TX=Tx1
    MODULES=ModuleHelp,ModuleParrot,ModuleEchoLink,ModuleTclVoiceMail
    CALLSIGN=MYCALL
    SHORT_IDENT_INTERVAL=60
    LONG_IDENT_INTERVAL=60
    #IDENT_ONLY_AFTER_TX=4
    #EXEC_CMD_ON_SQL_CLOSE=500
    EVENT_HANDLER=/usr/share/svxlink/events.tcl
    DEFAULT_LANG=en_US
    RGR_SOUND_DELAY=0
    REPORT_CTCSS=136.5
    #TX_CTCSS=ALWAYS
    MACROS=Macros
    FX_GAIN_NORMAL=0
    FX_GAIN_LOW=-12
    #ACTIVATE_MODULE_ON_LONG_CMD=4:EchoLink
    #QSO_RECORDER=8:QsoRecorder
    #ONLINE_CMD=998877

    [RepeaterLogic]
    TYPE=Repeater
    RX=Rx1
    TX=Tx1
    MODULES=ModuleHelp,ModuleParrot,ModuleEchoLink,ModuleTclVoiceMail
    CALLSIGN=MYCALL
    SHORT_IDENT_INTERVAL=10
    LONG_IDENT_INTERVAL=60
    #IDENT_ONLY_AFTER_TX=4
    #EXEC_CMD_ON_SQL_CLOSE=500
    EVENT_HANDLER=/usr/share/svxlink/events.tcl
    DEFAULT_LANG=en_US
    RGR_SOUND_DELAY=0
    REPORT_CTCSS=136.5
    #TX_CTCSS=SQL_OPEN
    MACROS=Macros
    #SEL5_MACRO_RANGE=03400,03499
    FX_GAIN_NORMAL=0
    FX_GAIN_LOW=-12
    #QSO_RECORDER=8:QsoRecorder
    #NO_REPEAT=1
    IDLE_TIMEOUT=30
    OPEN_ON_1750=1000
    #OPEN_ON_CTCSS=136:2000
    #OPEN_ON_DTMF=*
    #OPEN_ON_SQL=5000
    #OPEN_ON_SEL5=01234
    #OPEN_SQL_FLANK=OPEN
    #OPEN_ON_SQL_AFTER_RPT_CLOSE=10
    IDLE_SOUND_INTERVAL=3000
    #SQL_FLAP_SUP_MIN_TIME=1000
    #SQL_FLAP_SUP_MAX_COUNT=10
    #ACTIVATE_MODULE_ON_LONG_CMD=4:EchoLink
    #IDENT_NAG_TIMEOUT=15
    #IDENT_NAG_MIN_TIME=2000
    #ONLINE_CMD=998877

    [LinkToR4]
    CONNECT_LOGICS=RepeaterLogic:94:SK3AB,SimplexLogic:92:SK3CD
    #DEFAULT_ACTIVE=1
    TIMEOUT=300
    #AUTOACTIVATE_ON_SQL=RepeaterLogic

    [Macros]
    1=EchoLink:9999#
    9=Parrot:0123456789#
    03400=EchoLink:9999#

    [QsoRecorder]
    REC_DIR=/var/spool/svxlink/qso_recorder
    #MIN_TIME=1000
    MAX_TIME=3600
    SOFT_TIME=300
    MAX_DIRSIZE=1024
    #DEFAULT_ACTIVE=1
    #TIMEOUT=300
    #QSO_TIMEOUT=300
    #ENCODER_CMD=/usr/bin/oggenc -Q \”%f\” && rm \”%f\”

    [Voter]
    TYPE=Voter
    RECEIVERS=Rx1,Rx2,Rx3
    VOTING_DELAY=200
    BUFFER_LENGTH=0
    #REVOTE_INTERVAL=1000
    #HYSTERESIS=50
    #SQL_CLOSE_REVOTE_DELAY=500
    #RX_SWITCH_DELAY=500

    [MultiTx]
    TYPE=Multi
    TRANSMITTERS=Tx1,Tx2,Tx3

    [NetRx]
    TYPE=Net
    HOST=remote.rx.host
    TCP_PORT=5210
    AUTH_KEY=”Change this key now!”
    CODEC=S16
    #SPEEX_ENC_FRAMES_PER_PACKET=4
    #SPEEX_ENC_QUALITY=4
    #SPEEX_ENC_BITRATE=15000
    #SPEEX_ENC_COMPLEXITY=2
    #SPEEX_ENC_VBR=0
    #SPEEX_ENC_VBR_QUALITY=4
    #SPEEX_ENC_ABR=15000
    #SPEEX_DEC_ENHANCER=1
    #OPUS_ENC_FRAME_SIZE=20
    #OPUS_ENC_COMPLEXITY=10
    #OPUS_ENC_BITRATE=20000
    #OPUS_ENC_VBR=1

    [NetTx]
    TYPE=Net
    HOST=remote.tx.host
    TCP_PORT=5210
    AUTH_KEY=”Change this key now!”
    CODEC=S16
    #SPEEX_ENC_FRAMES_PER_PACKET=4
    #SPEEX_ENC_QUALITY=4
    #SPEEX_ENC_BITRATE=15000
    #SPEEX_ENC_COMPLEXITY=2
    #SPEEX_ENC_VBR=0
    #SPEEX_ENC_VBR_QUALITY=4
    #SPEEX_ENC_ABR=15000
    #SPEEX_DEC_ENHANCER=1
    #OPUS_ENC_FRAME_SIZE=20
    #OPUS_ENC_COMPLEXITY=10
    #OPUS_ENC_BITRATE=20000
    #OPUS_ENC_VBR=1

    [Rx1]
    TYPE=Local
    AUDIO_DEV=alsa:plughw:0
    AUDIO_CHANNEL=0
    SQL_DET=VOX
    SQL_START_DELAY=0
    SQL_DELAY=0
    SQL_HANGTIME=2000
    #SQL_EXTENDED_HANGTIME=1000
    #SQL_EXTENDED_HANGTIME_THRESH=15
    #SQL_TIMEOUT=600
    VOX_FILTER_DEPTH=20
    VOX_THRESH=1000
    #CTCSS_MODE=2
    CTCSS_FQ=136.5
    #CTCSS_SNR_OFFSET=0
    #CTCSS_OPEN_THRESH=15
    #CTCSS_CLOSE_THRESH=9
    #CTCSS_BPF_LOW=60
    #CTCSS_BPF_HIGH=270
    ##SERIAL_PORT=/dev/ttyAMA0
    #SERIAL_PORT=/dev/ttyS0
    ##SERIAL_PIN=CTS:SET
    #SERIAL_SET_PINS=DTR!RTS
    #EVDEV_DEVNAME=/dev/input/by-id/usb-SYNIC_SYNIC_Wireless_Audio-event-if03
    #EVDEV_OPEN=1,163,1
    #EVDEV_CLOSE=1,163,0
    #GPIO_SQL_PIN=gpio30
    #SIGLEV_DET=TONE
    SIGLEV_SLOPE=1
    SIGLEV_OFFSET=0
    #TONE_SIGLEV_MAP=100,84,60,50,37,32,28,23,19,8
    SIGLEV_OPEN_THRESH=30
    SIGLEV_CLOSE_THRESH=10
    DEEMPHASIS=0
    #SQL_TAIL_ELIM=300
    #PREAMP=6
    PEAK_METER=1
    DTMF_DEC_TYPE=INTERNAL
    DTMF_MUTING=1
    DTMF_HANGTIME=100
    DTMF_SERIAL=/dev/ttyS0
    #DTMF_MAX_FWD_TWIST=8
    #DTMF_MAX_REV_TWIST=4
    #1750_MUTING=1
    #SEL5_DEC_TYPE=INTERNAL
    #SEL5_TYPE=ZVEI1

    [Tx1]
    TYPE=Local
    AUDIO_DEV=alsa:plughw:0
    AUDIO_CHANNEL=0
    PTT_PORT=/dev/ttyAMA0
    PTT_PIN=DTRRTS
    #PTT_PORT=/dev/ttyS0
    #PTT_PIN=DTRRTS
    #PTT_PIN=CTS:RTS
    #SERIAL_SET_PINS=DTR!RTS
    #PTT_HANGTIME=1000
    TIMEOUT=300
    TX_DELAY=500
    #CTCSS_FQ=136.5
    #CTCSS_LEVEL=9
    PREEMPHASIS=0
    DTMF_TONE_LENGTH=100
    DTMF_TONE_SPACING=50
    DTMF_TONE_AMP=-18

    [LocationInfo]
    APRS_SERVER_LIST=euro.aprs2.net:14580
    #STATUS_SERVER_LIST=aprs.echolink.org:5199
    #LON_POSITION=12.10.00E
    #LAT_POSITION=51.10.00N
    #CALLSIGN=EL-DL0ABC
    #FREQUENCY=438.875
    #TX_POWER=8
    #ANTENNA_GAIN=6
    #ANTENNA_HEIGHT=20m
    #ANTENNA_DIR=-1
    PATH=WIDE1-1
    BEACON_INTERVAL=10
    #TONE=136
    COMMENT=SvxLink by SM0SVX (svxlink.sourceforge.net)

    Ich bedanke in voraus für mir zu helfen.
    Christian

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s