November 07, 2024, 11:36:16 PM

Serial line via audio jack

Started by grmpf, March 04, 2018, 06:56:03 PM

Previous topic - Next topic

grmpf

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

According to the schematic it's Pin L9 ...


grmpf

Quote from: deesix on March 05, 2018, 12:41:12 AM
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

Sorry for not being clear. Let me quote what I think answers your question.

Quote from: grmpfhow 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: LubOlimexThere 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
#!/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

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


deesix

Quote from: Brian on March 14, 2018, 01:56:30 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.


afzal

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

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

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

> 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.