This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM4378: Touchscreen calibration problem

Part Number: AM4378

Tool/software: Linux

Dear,

We designed a board broadly based on AM437x-gp-evm. We use SDK 4.01 and the product has usb based touch screen.

Touch screen is working now. But i am not able to calibrate touch screen. I followed below method from serial console to perform calibration.

rm /etc/udev/rules.d/ws-calibrate.rules
 rm /run/media/mmcblk0p1/ws-calibrate.rules
 reboot

I tried below ways also.

root@am437x-evm: cd /run/media/mmcblk0p1/
root@am437x-evm: export TSLIB_CALIBFILE=/run/media/mmcblk0p1/pointercal
root@am437x-evm: ts_calibrate

But ts_calibrate does not recognise by the system. It says " -sh:ts_calibrate: command not found"

How do i calibrate touch screen in weston based graphics system?

Regards,

Winiston.P

  • Hello Winiston,

    Take a look at the How to Recalibrate the Touchscreen wiki.

    EDIT 8/30/2018: It looks like you followed most of the steps. Try relaunching Weston by issuing "/etc/init.d/weston start" if the other steps in the "Weston based Graphic System" section are not working for you.

    Regards,

    Nick

  • Dear Nick,

    I followed the link which you given below.

    and i just deleted "ws-calibrate.rules"  files and rebooted the system as given below

    rm /etc/udev/rules.d/ws-calibrate.rules
     rm /run/media/mmcblk0p1/ws-calibrate.rules
     reboot


    I did not get any calibration screen at boot up which means i am not able to calibrate my touch screen.

    After deleting "ws-calibrate.rules" from relevant location, As you said I manually relaunching Weston by issuing "/etc/init.d/weston start" . But I have not succeeded.

    Is there any way to manually initiate calibration ?

    Regards,
    Winiston.P

  • Hello Winiston,

    Testing an AM437x EVM running SDK 4.1:
    The first time I booted I got the white screen with red crosses to calibrate the touchscreen.
    I did
    rm /etc/udev/rules.d/ws-calibrate.rules
    rm /run/media/... did not find any additional ws-calibrate.rules on my particular board
    reboot
    at this point, I did get the white calibration screen with red crosses again, and I calibrated the touchscreen.

    I could manually initiate calibration by doing
    rm /etc/udev/rules.d/ws-calibrate.rules
    /etc/init.d/weston start
    at this point, I got the white calibration screen. After calibration, the screen remained black
    reboot
    When the board restarted, it did not give me a calibration screen, and behaved as expected.

    Regards,
    Nick
  • Dear Nick,

    I have also followed the same way by removing "ws-calibrate.rules" by "rm /etc/udev/rules.d/ws-calibrate.rules" .

    I rebooted again. But it did not ask any white calibration screen.

    I have removed by  "rm /etc/udev/rules.d/ws-calibrate.rules" . and initiate weston by "/etc/init.d/weston start". But i did not get any calibration screen.

    I have copied entire file system contents without "ws-calibrate.rules"  to one more sd card and used one more new touch screen controller. Then also I did not get any calibration screen.

    We used egalaxy touch screen controller outside the board and connected via USB. Touch calibrated data may be stored on the touch screen controller. Is there any possibility, touch screen controller over ride the file system so that after deleting "ws-calibrate.rules" also, system does not go for calibrationmode.

    Should i initiate or delete any file from any where in the file system to re-calibrate touch screen?

    Regards,

    Winiston.P

  • Dear Nick,

    I am waiting for your reply..

    Regards,
    Winiston.P
  • Hello Winiston,

    I apologize for the delay. Monday was a holiday in the US. TI cannot help you with eGalax's touch screen controller. If it is doing anything with the touch screen calibration, you would need to contact them for support.

    I am asking around to see if anyone has additional ideas.

    Regards,
    Nick
  • Hello Winiston,

    Is the touchscreen being detected?

    Here's my output on AM437x GPEVM:
    root@am437x-evm:~# ls /dev/input/
    by-path event0 event1 mice mouse0 touchscreen0

    but touchscreen0 would go away if I removed the touchscreen from the board.

    Regards,
    Nick

  • Hello Winiston,

    Did you figure this out, or do you need additional support?

    Regards,
    Nick
  • Dear Nick,

    I could not figure it out. Still problem persists. It detected as touch screen and it works but calibration is not good. So i want to calibrate my touch screen. The problem is, it does not go to calibration mode.

     As per TI wiki, i removed files from two places as given below.

     rm /etc/udev/rules.d/ws-calibrate.rules
     rm /run/media/mmcblk0p1/ws-calibrate.rules
     reboot

    Still it does not go for calibration mode.
    Egalax support says that it is related to your linux issue.

    How do i enter into calibration mode? If you need more information, Let me know.

    Regards,
    Winiston.P
  • Hello Winiston,

    Just letting you know I am trying to look at reasons it might not bring up calibration mode or how to enter it. No updates yet.

    Regards,
    Nick
  • Hello Winiston,

    Please add some echo statements to the shell script "weston" under /etc/init.d so we can get some more information about how the script executes.

    Regards,
    Nick
  • Dear Nick,
    I added script to weston. It executes properly and touch screen also works. But i could not calibrate the screen.
    Still i am waiting for the solution.

    Regards,
    Winiston.P
  • Hello Winiston,

    The weston script is in charge of calling the touchscreen calibration. See this part:

    # Check if SD card has a calibration rules file
            SD_CALUDEV_FILE=/run/media/mmcblk0p1/ws-calibrate.rules
            if [ "$SD_MOUNTED" = "1" -a -f "$SD_CALUDEV_FILE" ] ; then
                # Copy it over to udev location
                cp "$SD_CALUDEV_FILE" "$WS_CALUDEV_FILE"
            else
                # Run a calibration app and save output to udev rules
                echo    "Calibrating touchscreen (first time only)"
                echo
                echo    "*** To continue, please complete the touchscreen calibration"
                echo -n "*** by touching the crosshairs on the LCD screen"
                sleep 1
                CAL_VALUES=`weston-calibrator|cut -c21-`
                echo 'SUBSYSTEM=="input", ENV{WL_CALIBRATION}="'$CAL_VALUES'"' > $WS_CALUDEV_FILE
                echo "."
                # Copy it back to SD
                if [ "$SD_MOUNTED" = "1" ] ; then
                    cp "$WS_CALUDEV_FILE" "$SD_CALUDEV_FILE"
                fi
            fi
    

    Please insert some additional "echo" statements to this part of the script (e.g., in each part of the if/else statement) so we can see whether the calibration command is being executed as expected. Feel free to add echo statements to other parts of the script you are curious about if you think they might be related to your issue.

    Regards,

    Nick

  • Dear Nick,

    My touch screen is not detected as "touchscreen0 " under /dev/input. when i connect touchscreen, it detect as "event0" . But it takes around 6 sec to show as "event0" after it boots.

    My weston content as given below.

    #!/bin/sh
    #
    ### BEGIN INIT INFO
    # Provides: weston
    # Required-Start: $local_fs $remote_fs
    # Required-Stop: $local_fs $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    ### END INIT INFO

    killproc() {
    pid=`/bin/pidof $1`
    [ "$pid" != "" ] && kill $pid
    }

    read CMDLINE < /proc/cmdline
    for x in $CMDLINE; do
    case $x in
    weston=false)
    echo "Weston disabled"
    exit 0;
    ;;
    esac
    done

    case "$1" in
    start)
    . /etc/profile
    sleep 2

    # Weston for some reason dies if these environment variables are set
    unset WAYLAND_DISPLAY

    # This is all a nasty hack
    if test -z "$XDG_RUNTIME_DIR"; then
    export XDG_RUNTIME_DIR=/run/user/root
    fi

    if [ ! -d "$XDG_RUNTIME_DIR" ] ; then
    mkdir --parents $XDG_RUNTIME_DIR
    chmod 0700 $XDG_RUNTIME_DIR
    fi

    openvt -c 4 -f runWeston

    # If there's no touchscreen device available, done
    if [ ! -e /dev/input/touchscreen0 ] ; then
    exit 0
    fi

    # If it was already calibrated, done
    if [ -f "$WS_CALUDEV_FILE" ] ; then
    exit 0
    fi

    # Check if SD card is mounted
    mount | grep /run/media/mmcblk0p1 | grep vfat > /dev/null 2>&1
    if [ "$?" = "0" ] ; then
    SD_MOUNTED="1"
    else
    SD_MOUNTED="0"
    fi

    # Check if SD card has a calibration rules file
    SD_CALUDEV_FILE=/run/media/mmcblk0p1/ws-calibrate.rules
    if [ "$SD_MOUNTED" = "1" -a -f "$SD_CALUDEV_FILE" ] ; then
    # Copy it over to udev location
    cp "$SD_CALUDEV_FILE" "$WS_CALUDEV_FILE"
    else
    # Run a calibration app and save output to udev rules
    echo "Calibrating touchscreen (first time only)"
    echo
    echo "*** To continue, please complete the touchscreen calibration"
    echo -n "*** by touching the crosshairs on the LCD screen"
    sleep 1
    CAL_VALUES=`weston-calibrator|cut -c21-`
    echo 'SUBSYSTEM=="input", ENV{WL_CALIBRATION}="'$CAL_VALUES'"' > $WS_CALUDEV_FILE
    echo "."
    # Copy it back to SD
    if [ "$SD_MOUNTED" = "1" ] ; then
    cp "$WS_CALUDEV_FILE" "$SD_CALUDEV_FILE"
    fi
    fi

    # Reload and re-run udev rules and restart weston
    udevadm control --reload
    udevadm trigger
    killproc weston
    sleep 2
    openvt -c 4 -f runWeston
    ;;

    stop)
    echo "Stopping Weston"
    killproc weston
    ;;

    restart)
    $0 stop
    sleep 2
    $0 start
    ;;

    *)
    echo "usage: $0 { start | stop | restart }"
    ;;
    esac

    exit 0

    Is there any mistake in my weston (/etc/init.d/weston)file ? I tried to run "weston-calibrator" manually. But it does not save calibrated data. 

    Alternatively, Is it possible to run "weston-calibrator" manually and save it?

    Regards,

    Winiston

  • Hello Winiston,

    1) Did you add echo commands within each of the script's if statements to test how your weston script is behaving? If not, please do. That would help us figure out what is going on in the script.
    2) It looks like the weston script exits if /dev/input/touchscreen0 does not exist. Have you tried adding a check for /dev/input/event0?

    Regards,
    Nick
  • Update:

    The number of events created can vary based on what is plugged into your board. It looks like "/etc/udev/rules.d/touchscreen.rules" looks through the events to see if any of them are a touchscreen, then creates a symbolic link to that event named /dev/input/touchscreen0. You probably need to add a line to the touchscreen.rules file so that it knows to create a symbolic link to your touchscreen event.

    Regards,
    Nick
  • Hey,

    You can refer the below article to calibrate your touch screen

    processors.wiki.ti.com/index.php/How_to_Recalibrate_the_Touchscreen

    Regards,

    Adrian Gates

    System Admin - CloudDesktopOnline

  • Dear Nick,

    As you said, touchscreen0 does not exist. I added echo command in each function of weston script and found the root cause.

    I commented out touchscreen0 checking lines in the wseton script. Now it started working.

    Thanks for your extreme help.

    Regards,

    Winiston.P

  • Hello Winiston,

    Glad you got it working. For anyone else reading this thread who is not getting touchscreen0 to populate, you can modify the /etc/udev/rules.d/touchscreen.rules file to create a symbolic link named touchscreen0 for your screen.

    In order to use modalias information for event X in a rule in the touchscreen.rules file, get the information for ATTRS{modalias} from /sys/class/input/eventX/device/modalias

    Regards,
    Nick