Welcome, Guest

Author Topic: Serial line via audio jack  (Read 1047 times)

grmpf

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Serial line via audio jack
« on: March 04, 2018, 06:56:03 PM »
Hi,

how do I enable the Teres I serial line on the audio jack at Linux runtime? I would like to use it for the serial device /dev/ttyS0 and connect it to a 3.3V-TTL-leveled external serial device. I suppose there must be either a GPIO port for the "#DEBUGSELECT" which I can control by the Linux kernel or at least a kernel parameter to switch it.

Thanks
Jörg

lambda

  • Full Member
  • ***
  • Posts: 151
  • Karma: +11/-0
    • Support my work
Re: Serial line via audio jack
« Reply #1 on: March 05, 2018, 12:07:27 AM »
According to the schematic it's Pin L9 ...

deesix

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
Re: Serial line via audio jack
« Reply #2 on: March 05, 2018, 12:41:12 AM »
how do I enable the Teres I serial line on the audio jack at Linux runtime?

See https://www.olimex.com/forum/index.php?topic=5955.msg24394#msg24394

grmpf

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Serial line via audio jack
« Reply #3 on: March 05, 2018, 04:58:51 PM »
See https://www.olimex.com/forum/index.php?topic=5955.msg24394#msg24394

Thanks, but this thread answers the question how to turn *off* the serial output during u-boot phase, but not how to turn *on* serial output during Linux runtime. And yes, PL9 is the Pin for #DEBUGSELECT but _how_ do I switch the Pin during Linux runtime? in the DTS file I do not find this Pin. If I would know the Pin number of /sys/class/gpio I could export the Pin and try switching it using the sysfs interface.

So my question is still open: Is there a way to turn on the serial line of the audio jack during Linux runtime?

Regards
Jörg

deesix

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
Re: Serial line via audio jack
« Reply #4 on: March 06, 2018, 06:10:07 PM »
Sorry for not being clear. Let me quote what I think answers your question.

Quote from: grmpf
how do I enable the Teres I serial line on the audio jack at Linux runtime? [...] I suppose there must be either a GPIO port for the "#DEBUGSELECT" which I can control by the Linux kernel or at least a kernel parameter to switch it.

Quote from: LubOlimex
There is a script in the official image that can be executed via the command line to switch between the [debug/audio] modes. This would allow you to use the audio jack for debugging even after the kernel had started (you lose audio out of course) - it is I believe "debug_switch.sh" or something.

It's /usr/local/sbin/debug_switch.sh
Code: [Select]
#!/bin/bash
UENV_PATH="/boot/uEnv.txt"
set -e

if [ "$(id -u)" -ne "0" ]; then
        echo "This script requires root."
        exit 1
fi
case $1 in

        on) sed -i.bak '/debug=/c\debug=on' $UENV_PATH
            echo "Debug on headphone port enabled. Please reboot !"
            ;;
       off) sed -i.bak '/debug=/c\debug=off' $UENV_PATH
            echo "Debug on headphone port disabled. Please reboot !"
            ;;
        *)
        echo "Unknown option! Usage: ./debug_swirch on|off "
        esac

lambda

  • Full Member
  • ***
  • Posts: 151
  • Karma: +11/-0
    • Support my work
Re: Serial line via audio jack
« Reply #5 on: March 07, 2018, 01:03:01 PM »
This script doesn't help too much, because it requires a reboot - ie it is still not switching at run time ...

I don't recall the formula for converting pin names to gpio numbers in detail, but it is of the form gpio = major*N+minor.

minor = 9
major = {A=0, B=1, ...}
N i don't remember at the moment, but should be easy to find via web search ...

HTH,
Harald

Brian

  • Newbie
  • *
  • Posts: 12
  • Karma: +3/-0
Re: Serial line via audio jack
« Reply #6 on: March 14, 2018, 01:56:30 PM »

deesix

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
Re: Serial line via audio jack
« Reply #7 on: March 15, 2018, 04:03:35 PM »
There it is: https://github.com/d3v1c3nv11/teres1-debug.git

I found the "jack connection" diagram a bit confusing. I guess you're labeling the connections as "where to connect on the other end" instead of "what's the function from the point of view of the laptop". To me, it's more natural the later.

In my experience, TX is on the ring, but you label it as RX. From TERES, with headphones you can hear it on the right-hand channel.

I think you may want to clarify it. Thanks.

olimex

  • Administrator
  • Hero Member
  • *****
  • Posts: 772
  • Karma: +20/-3

afzal

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Serial line via audio jack
« Reply #9 on: March 16, 2018, 03:37:54 PM »
the usb debug cable in the picture has only 3 connection (TRS, tip ring sleeve), but the socket on board has 4 (meant for TRRS jack). Initially here for debug console, a TRS jack was used & serial port was abusing me ;), all strange chars. Then checking the schematics, realized that it was TRRS, upon using TRRS jack serial console was working properly. As the TRS jack was inserted, 2 ring ones might have got shorted here & caused the problem.  Not sure whether the TRS one mentioned avoid the shorting, perhaps dimesion of the one here is slightly different  (that actually should not happen as they are standard 3.5mm ones), don't know, just thinking loud.

afzal

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Serial line via audio jack
« Reply #10 on: March 17, 2018, 05:29:15 PM »
To add, when TRS jack was used first, it used to hang (saw someone mentioning similar in forum or irc archive), with TRRS jack no such issues.

Though now i could stand of my own w.r.t debug serial (i.e. ability to have proper serial console using TRRS jack), it would be better to have a confirmatifon from Olimex that TRRS jack is the one to be used.

LubOlimex

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1713
  • Karma: +43/-2
Re: Serial line via audio jack
« Reply #11 on: March 19, 2018, 09:36:29 AM »
Both TRS and TRRS jacks should be ok. When you use TRS jack, the MIC input of the laptop is shorted to GND. When you use TRRS, the MIC in goes to the headphones (handsfree) MIC. The jacks we tested here are fine. TS and TRRRS are not ok.

> serial port was abusing me ;), all strange chars.

What baud did you try?

> As the TRS jack was inserted, 2 ring ones might have got shorted here & caused the problem.

I doubt it but in the world of electronics anything is possible.
Technical support and documentation manager at Olimex

afzal

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Serial line via audio jack
« Reply #12 on: March 19, 2018, 05:15:01 PM »
> What baud did you try?

115200, i am sure baud rate is not the problem here, because when TRRS jack is used serial console works properly, problem (strange chars) comes only when TRS jack is used.

It could be possible that the TRS jack used here is slightly off in physical dimension from the standard.

Any way as i am able to use console properly using TRRS jack, no issues now for me and Thanks Olimex for the reply.