kipr / KIPR-Development-Toolkit

This is a package that includes everything you need to start developing software for KIPR
5 stars 0 forks source link

Get the Wombat to work on a fresh OS without breaking things. #5

Open Zacharyprime opened 3 years ago

Zacharyprime commented 3 years ago

The Wombat is still on Jessie, but updating breaks a multitude of things such as the touchscreen drivers.

This is a long deprecated version of Debian (see here).

This was also discussed extensively on this issue: https://github.com/kipr/harrogate/issues/103

I highly recommend reading through that page for more information on the issues.

Edit: For those new to this thread. We are trying to get the Wombat software to build completely from a scratch version of the latest piOS. However, updating such a large version distance has caused a multitude of issues from the touchscreen drivers being incompatible with Linux 5.x.x to harrogate throwing new errors. If you are able to make any progress on these known issues, please report it here.

This gist is where I have been saving the current set of instructions for a scratch build. https://gist.github.com/Zacharyprime/c9d7918eccbbffd7f710ea69f464dd4d

Zacharyprime commented 2 years ago

I only show a couple of examples but this happens with most packages I think that the apt links for jessie are going dead. This started happening in a smaller severity a month or two ago. I tried using alternative sources with no luck. In the meantime I've been finding other ways to install the things I need.

Click to View ``` Wombat:~/dev $ sudo apt-get install apt-transport-https ca-certificates -y Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libapt-pkg4.12 The following NEW packages will be installed: apt-transport-https The following packages will be upgraded: ca-certificates libapt-pkg4.12 2 upgraded, 1 newly installed, 0 to remove and 520 not upgraded. Need to get 1,032 kB of archives. After this operation, 232 kB of additional disk space will be used. Err http://mirrordirector.raspbian.org/raspbian/ jessie/main libapt-pkg4.12 armhf 1.0.9.8.5 404 Not Found [IP: 93.93.128.193 80] Err http://mirrordirector.raspbian.org/raspbian/ jessie/main apt-transport-https armhf 1.0.9.8.5 404 Not Found [IP: 93.93.128.193 80] Err http://mirrordirector.raspbian.org/raspbian/ jessie/main ca-certificates all 20141019+deb8u4 404 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://mirrordirector.raspbian.org/raspbian/pool/main/a/apt/libapt-pkg4.12_1.0.9.8.5_armhf.deb 404 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://mirrordirector.raspbian.org/raspbian/pool/main/a/apt/apt-transport-https_1.0.9.8.5_armhf.deb 404 Not Found [IP: 93.93.128.193 80] E: Failed to fetch http://mirrordirector.raspbian.org/raspbian/pool/main/c/ca-certificates/ca-certificates_20141019+deb8u4_all.deb 404 Not Found [IP: 93.93.128.193 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? Wombat:~/dev $ sudo update-ca-certificates Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d....done. Wombat:~/dev $ sudo apt-get update Ign http://mirrordirector.raspbian.org jessie InRelease Get:1 http://archive.raspberrypi.org jessie InRelease [22.9 kB] Ign http://mirrordirector.raspbian.org jessie Release.gpg Get:2 http://archive.raspberrypi.org jessie/main armhf Packages [170 kB] Ign http://mirrordirector.raspbian.org jessie Release Get:3 http://archive.raspberrypi.org jessie/ui armhf Packages [58.6 kB] Ign http://archive.raspberrypi.org jessie/main Translation-en_GB Ign http://archive.raspberrypi.org jessie/main Translation-en Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB Ign http://archive.raspberrypi.org jessie/ui Translation-en Err http://mirrordirector.raspbian.org jessie/main armhf Packages 404 Not Found [IP: 93.93.128.193 80] Err http://mirrordirector.raspbian.org jessie/contrib armhf Packages 404 Not Found [IP: 93.93.128.193 80] Err http://mirrordirector.raspbian.org jessie/non-free armhf Packages 404 Not Found [IP: 93.93.128.193 80] Err http://mirrordirector.raspbian.org jessie/rpi armhf Packages 404 Not Found [IP: 93.93.128.193 80] Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB Ign http://mirrordirector.raspbian.org jessie/main Translation-en Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en Fetched 251 kB in 14s (17.3 kB/s) W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/main/binary-armhf/Packages 404 Not Found [IP: 93.93.128.193 80] W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/contrib/binary-armhf/Packages 404 Not Found [IP: 93.93.128.193 80] W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/non-free/binary-armhf/Packages 404 Not Found [IP: 93.93.128.193 80] W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/rpi/binary-armhf/Packages 404 Not Found [IP: 93.93.128.193 80] E: Some index files failed to download. They have been ignored, or old ones used instead. ```
Zacharyprime commented 2 years ago

I am currently rebuilding the kernel for a fresh copy of raspberry Pi OS. I found that the tcs2007 drivers only show up on make menuconfig if the correct prerequisite options are selected first. The build as expected is taking quite a long time, but hopefully the touchscreen should be functional after it's done.

Some notes for concern:

(I'll keep updating this comment as I discover/rediscover problems)

Zacharyprime commented 2 years ago

Problem:

pi@raspberrypi:~/raspi/tsc2007 $ make
make -C /lib/modules/5.15.21-v7+/build M=/home/pi/raspi/tsc2007 modules
make[1]: *** /lib/modules/5.15.21-v7+/build: No such file or directory.  Stop.
make: *** [Makefile:5: all] Error 2

Solution:

sudo apt-get install raspberrypi-kernel-headers -y
rpi-source

Progress Update: I took a deep dive into how the linux kernel is setup and now I know what I'm doing for the most part when trying to build a kernel module. However, there are some tsc2007 specific header files that are supposed to be present in the linux kernel headers but are not, or at least not in the same directory as they were on v3.x.x (On v5.15.21-v7+ right now).

I'm currently working on locating a proper source for the headers I need to build the module. If I can get the touchscreen drivers to build, I don't think the rest will be nearly as difficult as this has been.

I've also started using cross compilation instead of building the kernel on the Pi every time I re-build the kernel.

Zacharyprime commented 2 years ago

Problem:

pi@raspberrypi:~/raspi/tsc2007 $ make
make -C /lib/modules/5.15.21-v7+/build M=/home/pi/raspi/tsc2007 modules
make[1]: Entering directory '/home/pi/linux-84db2c69d8dfaa3dfcc48efaff43b562fc58fa11'

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

Makefile:645: include/config/auto.conf: No such file or directory
make[1]: *** [Makefile:720: include/config/auto.conf] Error 1
make[1]: Leaving directory '/home/pi/linux-84db2c69d8dfaa3dfcc48efaff43b562fc58fa11'
make: *** [Makefile:5: all] Error 2

Solution:

sudo apt-get install --reinstall raspberrypi-kernel-headers -y
rpi-source

#if rpi-source starts asking weird y/n questions
rpi-update
rpi-source
Zacharyprime commented 2 years ago

Problem:

pi@raspberrypi:~/raspi/tsc2007 $ make
make -C /lib/modules/5.15.21-v7+/build M=/home/pi/raspi/tsc2007 modules
make[1]: Entering directory '/home/pi/linux-60652604154e70aeac81fb6155fd9d15dc39daaf'
  CC [M]  /home/pi/raspi/tsc2007/tsc2007.o
/home/pi/raspi/tsc2007/tsc2007.c:28:10: fatal error: linux/i2c/tsc2007.h: No such file or directory
   28 | #include <linux/i2c/tsc2007.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:277: /home/pi/raspi/tsc2007/tsc2007.o] Error 1
make[1]: *** [Makefile:1868: /home/pi/raspi/tsc2007] Error 2
make[1]: Leaving directory '/home/pi/linux-60652604154e70aeac81fb6155fd9d15dc39daaf'
make: *** [Makefile:5: all] Error 2

(This is what I mentioned in the earlier comment)

File Found:

pi@raspberrypi:/lib/modules/5.15.21-v7+/source/drivers/input/touchscreen $ ls | grep tsc
bcm_iproc_tsc.c
imx6ul_tsc.c
ti_am335x_tsc.c
tsc2004.c
tsc2005.c
tsc2007_core.c
tsc2007.h
tsc2007_iio.c
tsc200x-core.c
tsc200x-core.h
tsc40.c

Manually setting the include to that directory results in this:

View Output ```sh pi@raspberrypi:~/raspi/tsc2007 $ make make -C /lib/modules/5.15.21-v7+/build M=/home/pi/raspi/tsc2007 modules make[1]: Entering directory '/home/pi/linux-60652604154e70aeac81fb6155fd9d15dc39daaf' CC [M] /home/pi/raspi/tsc2007/tsc2007.o /home/pi/raspi/tsc2007/tsc2007.c:60:8: error: redefinition of ‘struct ts_event’ 60 | struct ts_event { | ^~~~~~~~ In file included from /home/pi/raspi/tsc2007/tsc2007.c:28: /lib/modules/5.15.21-v7+/source/drivers/input/touchscreen/tsc2007.h:54:8: note: originally defined here 54 | struct ts_event { | ^~~~~~~~ /home/pi/raspi/tsc2007/tsc2007.c:66:8: error: redefinition of ‘struct tsc2007’ 66 | struct tsc2007 { | ^~~~~~~ In file included from /home/pi/raspi/tsc2007/tsc2007.c:28: /lib/modules/5.15.21-v7+/source/drivers/input/touchscreen/tsc2007.h:60:8: note: originally defined here 60 | struct tsc2007 { | ^~~~~~~ /home/pi/raspi/tsc2007/tsc2007.c:87:19: error: conflicting types for ‘tsc2007_xfer’ 87 | static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd) | ^~~~~~~~~~~~ In file included from /home/pi/raspi/tsc2007/tsc2007.c:28: /lib/modules/5.15.21-v7+/source/drivers/input/touchscreen/tsc2007.h:86:5: note: previous declaration of ‘tsc2007_xfer’ was here 86 | int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd); | ^~~~~~~~~~~~ /home/pi/raspi/tsc2007/tsc2007.c:145:13: error: conflicting types for ‘tsc2007_is_pen_down’ 145 | static bool tsc2007_is_pen_down(struct tsc2007 *ts) | ^~~~~~~~~~~~~~~~~~~ In file included from /home/pi/raspi/tsc2007/tsc2007.c:28: /lib/modules/5.15.21-v7+/source/drivers/input/touchscreen/tsc2007.h:88:6: note: previous declaration of ‘tsc2007_is_pen_down’ was here 88 | bool tsc2007_is_pen_down(struct tsc2007 *ts); | ^~~~~~~~~~~~~~~~~~~ /home/pi/raspi/tsc2007/tsc2007.c: In function ‘tsc2007_probe’: /home/pi/raspi/tsc2007/tsc2007.c:305:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 305 | ts->model = pdata->model; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:306:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 306 | ts->x_plate_ohms = pdata->x_plate_ohms; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:307:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 307 | ts->max_rt = pdata->max_rt ? : MAX_12BIT; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:308:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 308 | ts->poll_delay = pdata->poll_delay ? : 1; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:309:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 309 | ts->poll_period = pdata->poll_period ? : 1; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:310:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 310 | ts->get_pendown_state = pdata->get_pendown_state; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:311:31: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 311 | ts->clear_penirq = pdata->clear_penirq; | ^~ /home/pi/raspi/tsc2007/tsc2007.c:313:11: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 313 | if (pdata->x_plate_ohms == 0) { | ^~ /home/pi/raspi/tsc2007/tsc2007.c:334:60: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 334 | put_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0); | ^~ /home/pi/raspi/tsc2007/tsc2007.c:335:60: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 335 | put_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0); | ^~ /home/pi/raspi/tsc2007/tsc2007.c:337:9: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 337 | pdata->fuzzz, 0); | ^~ /home/pi/raspi/tsc2007/tsc2007.c:339:11: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 339 | if (pdata->init_platform_hw) | ^~ /home/pi/raspi/tsc2007/tsc2007.c:340:8: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 340 | pdata->init_platform_hw(); | ^~ /home/pi/raspi/tsc2007/tsc2007.c:361:11: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 361 | if (pdata->exit_platform_hw) | ^~ /home/pi/raspi/tsc2007/tsc2007.c:362:8: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 362 | pdata->exit_platform_hw(); | ^~ /home/pi/raspi/tsc2007/tsc2007.c: In function ‘tsc2007_remove’: /home/pi/raspi/tsc2007/tsc2007.c:376:11: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 376 | if (pdata->exit_platform_hw) | ^~ /home/pi/raspi/tsc2007/tsc2007.c:377:8: error: invalid use of undefined type ‘struct tsc2007_platform_data’ 377 | pdata->exit_platform_hw(); | ^~ make[2]: *** [scripts/Makefile.build:277: /home/pi/raspi/tsc2007/tsc2007.o] Error 1 make[1]: *** [Makefile:1868: /home/pi/raspi/tsc2007] Error 2 make[1]: Leaving directory '/home/pi/linux-60652604154e70aeac81fb6155fd9d15dc39daaf' make: *** [Makefile:5: all] Error 2 ```

So I have to figure out what is supposed to be putting the header into <linux/i2c/tsc2007.h> The directory i2c doesn't even exist there. I'm guessing that it was moved between v3.x.x and v5.x.x TSC2007 isn't popular enough in the Pi community for any results to show up on google for any variant of this.

Compiler Search Locations This is where g++ is set to search: ```sh pi@raspberrypi:/usr/include/linux $ g++ -print-search-dirs install: /usr/lib/gcc/arm-linux-gnueabihf/10/ programs: =/usr/lib/gcc/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/bin/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/bin/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/bin/ libraries: =/usr/lib/gcc/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../../arm-linux-gnueabihf/lib/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../arm-linux-gnueabihf/10/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/10/../../../:/lib/arm-linux-gnueabihf/10/:/lib/arm-linux-gnueabihf/:/lib/:/usr/lib/arm-linux-gnueabihf/10/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/ ``` This is the current PATH: ```sh pi@raspberrypi:/usr/include/linux $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games ```
Zacharyprime commented 2 years ago

Here is a gist where I am keeping the instructions for how to build everything from scratch. Once I figure out the touchscreen issue I'll add those to it. This isn't meant as a shell script, this is just me copying down the chicken scratch I have been keeping on my notepad with some details filled in for beginners.

https://gist.github.com/Zacharyprime/c9d7918eccbbffd7f710ea69f464dd4d

Zacharyprime commented 2 years ago

Bad News: Debian Bullseye does not have support for qt4-default or any other qt4 packages. Currently working on a workaround but so far manually installing the .deb files or adding the buster sources does not work. https://packages.debian.org/buster/qt4-default

Edit: Qt5 now works for v27

Zacharyprime commented 2 years ago

Update: Braden helped me get past some of the issues I was having porting to Qt5. (Crossing my fingers that we can just jump straight to Qt6 without any headaches) I still will probably need to fix some class name errors that come with the change, but in the meantime there is a new roadblock.

The default debian sources do not seem to contain a package for opencv2 that works for this. We can still do it the manual way but I'd like to keep the instructions short-ish and simple if possible so that students/teachers that are interested can follow them and create their own Wombat environment from scratch.

I have to clock out soon, so next time I have time to work on this I will see how difficult it will be to port over to modern opencv4. That might be pretty tricky though as I think the opencv portions of the code might be fairly complex. The good news is this is a roadblock that I at least have a direction to go to solve it.

ayush055 started this issue a while back, if I figure out anything I'll probably put it there https://github.com/kipr/botui/issues/94

Edit: OpenCV4 now works for v27 using the libopencv-dev and libopencv-core-dev packages

Zacharyprime commented 2 years ago

With the recent ability to build botui with Qt5, I have gotten botui and most of it's dependencies to run on bullseye.

Some remaining problems:

EugeneDMyers commented 2 years ago

I've gotten harrogate build and the tsc2007 touch screen sort of works. Here's how I did it:

Harrogate:

(1) Modified package.json as follows:

  (a) under "dependencies" removed
    (i)  utf-8-validate
    (ii) bufferutil

  (b) added a new section called "overrides"

    ...
    "overrides": {
        "graceful-fs":"^4.2.9"
    }

(2) installed utf-8-validate and bufferutil as global packages

    sudo npm install -g utf-8-validate bufferutil

The server went up w/o error once I corrected the permissions issues and adding workspace.html to

            /var/local/”KIPR Software Suite"/workspace.html

was able to use the IDE and the "hello" program

================================= touchscreen:

(1) pulled, configured and built the raspberry pi kernel per the instructions here:

        https://www.raspberrypi.com/documentation/computers/linux_kernel.html

(2) ran make menuconfig and added the tsc2007 under 

       Device drivers->Input device support->Touchscreens->TSC2007 based touchscreens

(3) also took the touchscreen dts file from https://github.com/kipr/KIPR-Development-Toolkit.git

       (a) modified it as below by adding the parameters from the old tsc_raspi module

       (b) added it to linux/arch/arm/boot/dts/overlays

        -->make sure you modify the Makefile so that it gets compiled

(4) modify /boot/config.txt to include:   dtoverlay=tsc2007 

(5) build and install the kernel as per the instructions

(6) Also, add tsc2007 to /etc/modules

     (7) added 99-tsc2007.conf to /usr/share/X11/xorg.conf.d (see below)

-->When botui is started, the touchscreen sort of works.  You sometimes can get it to respond.

There are events being generated as can be seen by running:

         sudo evtest

    taping on the wombat screen causes events to appear. 

This seems to be a configuration issue or a calibration issue or both - I'm out of time to push this further for the immediate future

======================= 99-tsc2007.conf

Section "InputClass" Identifier "TSC2007 touchscreen class" MatchProduct "TSC2007 touchscreen" MatchDevicePath "/dev/input/event*" Driver "evdev" EndSection

============================ tsc2007.dts

/dts-v1/; /plugin/;

/ { compatible = "brcm,bcm2835";

    fragment@0 {
            target = <&gpio>;
            __overlay__ {
                    tsc2007_pins: tsc2007_pins {
                            brcm,pins = <25>;
                            brcm,function = <0>; /* in */
                            /*brcm,pull = <2 0>; / * pullup none */
                    };
            };
    };

    fragment@1 {
            target = <&i2c1>;
            __overlay__ {
                    #address-cells = <1>;
                    #size-cells = <0>;
                    status = "okay";

                    tsc2007: tsc2007@48 {
                            compatible = "ti,tsc2007";
                            reg = <0x48>;
                            interrupt-parent = <&gpio>;
                            interrupts = <25 0x2>; /* falling edge */
                            gpios = <&gpio 25 0>;
                            ti,x-plate-ohms = <300>;
                            ti,max_rt = <4096>;
                            ti,poll_period = <5>;
                            ti,fuzzy = <64>;
                            ti,fuzzz = <64>;
                            ti,fuzzx = <64>;
                    };
            };
    };

    __overrides__ {
            irq_pin = <&tsc2007>, "interrupts:0",
                      <&tsc2007>, "gpios:4",
                      <&tsc2007_pins>, "brcm,pins:0";
    };

}; kernel/linux/arch/arm/boot/dts/overlays/tsc2007.dts (END)

EugeneDMyers commented 2 years ago

Sorry for the terseness of my comments, if you need a detailed explanation, please let me know

Zacharyprime commented 2 years ago

This is amazing!

Thank you for the work you put into this.

erinharrington-12 commented 2 years ago

@EugeneDMyers did you run into space issues when trying to clone into https://github.com/raspberrypi/linux?

EugeneDMyers commented 2 years ago

When I built my development system, I used a 32GB SSD to get around space issues. Also, make sure you use the -l1 parameter for the clone (I thank - check the raspberry PI documentation for the kernel build - I'm in an airport so hard for me to verify) otherwise the space needed will be huge.

Zacharyprime commented 2 years ago

You might be able to build on a separate flash drive. The cross-compilation should also work.

We will need to update the SD cards if we want to do ROS for the Create3's, but I've been seeing talk of ROS that can be installed on a flash drive so maybe that will save us some trouble.

Your instructions are so close to the process I was using, I just missed the part about editing the .dts files and recompiling them. I'm working on getting my Wombat to a state that I can try to get this to work right now.

Erin has been working on this but she hasn't had much luck and I couldn't figure out what went wrong by looking through her files so hopefully a fresh careful start will be more successful.

EugeneDMyers commented 2 years ago

Building on a separate flash drive works. One tip, add ~1GB of additional swap space and don't use more than -j3 for the make. I've found instances where the swap space gets maxed out (use top in a separate window to monitor resources). Also, too many processes can cause thrashing and everything will slow to a crawl.

EugeneDMyers commented 2 years ago

The old calibration config in /usr/share/X11/xorg.conf.d does not work. Here is a pointer to what needs to be done -

https://wiki.archlinux.org/title/Talk:Calibrating_Touchscreen

I can't seem to get past three points, they have some tight parameters on positioning the pointer, so a steady hand is needed

erinharrington-12 commented 2 years ago

This really isn't for anyone to respond to, just for documentation and my sake when I have to redo things:

Zacharyprime commented 2 years ago

Erin and I both ran into a permissions issue that I haven't yet resolved. When running "make menuconfig" or the bcm2709 default config the file: scripts/basic/fixdep throws a permission denied error even when ran with sudo and when when logged in as root.

I've found mutliple github issues that report the issue, but no answers have been reported. The internet here is pretty slow and the entire repo takes around an hour or more to clone even with depth set to 1.

I'm still working on resolving the issue, but I'm quickly running out of leads.

EugeneDMyers commented 2 years ago

Try running make in debug/verbose mode. You'll get a gross amount of output - should be able to localize the fault.

Zacharyprime commented 2 years ago

I had tried that, but it didn't give much more interesting of an output.

The only extra information I got is it working through the logic to generate fixdep from fixdep.c But the output makes it seem like the creation was successful.

It seems like make is creating the file under one user and then the directory is owned by a different user. There is no change when I run as root or pi, so if that hypothesis is accurate then make is setting it's user to whatever it thinks it needs (my guess is root in that case).

I could also see the permissions coming from the fact I am building on the flash drive, maybe it's mounted under the wrong user. I'm gonna try to clear some space up so I can fit the repo in /home/pi and hope for better results.

I ended up working on RMAs yesterday afternoon so I'll have more time to work on it today.

EugeneDMyers commented 2 years ago

Okay - I was in an airport and saw the comment and quickly typed the response. When I get home from work tonight - I'll look at my transcript and see if I did anything special.

Zacharyprime commented 2 years ago

no rush, I always update the issues with my progress for myself and in case anyone takes a look and has more insight.

I got around the permissions issues by cross compiling instead. I think the piece that I was missing was the editing the .dtbs/o

I was able to recreate your state of the touchscreen, I see what you mean when you say it works sometimes. I played around with evtest and xinput_calibrator for a bit and couldn't get good results either.

I can't make out a pattern, it seems like the bottom left portion of the screen is the least responsive. It is behaving as if the polling rate on the touchscreen is not high enough.

I'll try playing with ti,poll_period = <5>; and look around for other poll setting commands.

Update: Found this source: https://www.buydisplay.com/download/manual/ER-TFT050-3_Datasheet.pdf

I didn't find a polling time but I assume the electrical response time is equivalent (12 ms)

Changing the 5 to 12 gave me better results, but still far from adequate. Maybe it's in Hz and not ms...I'll try 60Hz

-> Same results. It seems like the cursor is moving to position faster, but it's still only sometimes or in certain portions. 12ms = 84Hz so maybe it's still a low sample rate but I don't think it would make it this far off.

-> Same results if I remove the line entirely, but that could be that it is choosing a default. It looks like I need to start looking in a new direction.

EugeneDMyers commented 2 years ago

A couple of questions: (1) what is the model number of the touchscreen? the data sheet indicates two difference types of touchscreens (capacitive and resistive) also there are two variants, each having different screen dimensions (which could explain why we cannot get a response fro certain parts of the screen) (2) are we using the suggested controller? There is a datasheet for the controller and should provide us with more insight into the parameters. Update-- the TSC2007 is the controller...

This is the documentation for the driver for the controller:

https://www.ti.com/lit/an/sbaa170/sbaa170.pdf?ts=1659549752879

https://www.ti.com/lit/ug/slau199/slau199.pdf?ts=1659550210040

https://www.ti.com/lit/ds/symlink/tsc2007.pdf?ts=1659493983326

I set up the parameters for the dts file based on the drivers for the older versions, which may not be optimal for this touchscreen

BTW - when I tried it before, I got three out of the four crosses on the calibration

EugeneDMyers commented 2 years ago

I figured out what the issue is with the touchscreen- interrupts. If you check /proc/interrupts on the new os - the interrupts for the tsc2007 are always increasing. On the current OS interrupts occur only when the touchscreen is touched. I have not figured out the reason yet, most likely it is a configuration issue.

Zacharyprime commented 2 years ago

Apologies for how long it takes for me to get back. I work Mon/Tue and I have other lab tasks to do before I do software.

The screen and touch input chip (tsc2007) have not changed to my knowledge. The screen is ER-TFT050-3 which is how I got the datasheet from earlier.

However, I already looked around the datasheet for information that doesn't match the overlay used above and it seems like it is setup with the correct values. Also since the screen has not changed, I think reusing the overlay should work.

I lost the forum I saw this on, but supposedly the kernel was unstable regarding using interupts like this around v3.x.x. I don't remember the exact kernel version it listed but I know 25.6/26.1 were both on a 3.x.x kernel as well. It's possible that something has changed regarding how to setup interupts. However my later research found a more likely option.

Here are some sources that are related. I actually think the original overlay came from the first source since it's identical: https://forums.raspberrypi.com/viewtopic.php?t=224018 https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/214469/tsc2007-i2c-hangup https://www.ti.com/lit/ml/slyt292/slyt292.pdf

I wish he had given more info on what he modified to tell the kernel to disable the interupt before doing an i2c start, especially because as far as I know, those are entirely seperate portions of the kernel. He might also be talking about a regular program he wrote considering you can also handle interupts (and of course i2c) directly inside a python program.

I checked raspi-config for any options reguarding i2c or interupts but all I found was the option to enable/disable i2c.

EugeneDMyers commented 2 years ago

Thanks for the references, the one on the pen interrupt was quite valuable.

Most of the options wrt interrupts need to be handed by the driver.

I'll investigate this further as determining the cause (and fix) of the excessive interrupts should result in a functioning touchscreen.

Zacharyprime commented 2 years ago

https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/input/touchscreen/tsc2007_core.c I believe I need to add disabling the interrupt to line 35. ~I now need to figure out how interrupts are accessed inside drivers and then how to disable/enable~. I need to figure out how irq "IDs" are assigned. The functions below require an integer input.

Links saved for later: https://www.kernel.org/doc/htmldocs/kernel-api/API-disable-irq.html https://www.kernel.org/doc/htmldocs/kernel-api/API-enable-irq.html https://linux-kernel-labs.github.io/refs/heads/master/labs/interrupts.html https://www.oreilly.com/library/view/linux-device-drivers/0596005903/ch10.html

Update: https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt I think the overlay is ~targeting interrupt 25~

Later in the tsc2007_core.c disable_irq is used and there is already an object defined for the irq integer. ts->irq

EugeneDMyers commented 2 years ago

I've resolved the touchscreen/tsc2007 issue. In tsc2007.dts , change these lines:

            ......
           gpios = <&gpio 4 0>;
           ti,x-plate-ohms = <300>;
          ......

make and cp to /boot/overlay and reboot

test by using sudo evtest and you will see lots of events when you tap on the screen.

Still to be done - interface with x, it seems that this interface has changed, so some configuring will be needed.

EugeneDMyers commented 2 years ago

With the previous fix, and with Botui running, the cruser now follows the pointer around (when the pointer is touching the surface) - "clicks" still seem to be difficult. The Xorg logs indicate a driver issue.

EugeneDMyers commented 2 years ago

I have resolved all the issues wrt the Touchscreen. It works really well on my test wombat.

Here's what I did:

(1) The major issue is that there is a bug in the Linux driver for the tsc2007.

In "./drivers/input/touchscreen/tsc2007_core.c"

line 231 - return gpiod_get_value(ts->gpiod); ==>becomes==> return !gpiod_get_value(ts->gpiod);

Notice the ==>bang<== before the function call, this is how it was in the older driver. When the touchscreen is pressed, the tsc2007 drives its gpios pin to zero. To return true in this case a bang is necessary to indicate the touchscreen is being "touched."

No wonder users were having difficulty getting touchscreen using tsc2007 under Linux to work...

(2) Minor configuration fixes - the gpios mod I sent earlier was a red herring, but certainly got things to sort of work.

Here is the new overlay:

===========snip========snip======

/dts-v1/; /plugin/;

/ { compatible = "brcm,bcm2835";

    fragment@0 {
            target = <&gpio>;
            __overlay__ {
                    tsc2007_pins: tsc2007_pins {
                            brcm,pins = <25>;
                            brcm,function = <0>; /* in */
                            /*brcm,pull = <2 0>; / * pullup none */
                    };
            };
    };

    fragment@1 {
            target = <&i2c1>;
            __overlay__ {
                    #address-cells = <1>;
                    #size-cells = <0>;
                    status = "okay";

                    tsc2007: tsc2007@48 {
                            compatible = "ti,tsc2007";
                            reg = <0x48>;
                    interrupt-parent = <&gpio>;
                    interrupts = <25 0x8>; /* falling edge */
                    gpios = <&gpio 25 0>;
                    ti,x-plate-ohms = <300>;
            ti,max_rt = <4096>;
            ti,poll_period = <5>;
            ti,fuzzy = <64>;
            ti,fuzzz = <64>;
            ti,fuzzx = <64>;
                    };
            };
    };

    __overrides__ {
            irq_pin = <&tsc2007>, "interrupts:0",
                      <&tsc2007>, "gpios:4",
                      <&tsc2007_pins>, "brcm,pins:0";
    };

};

========snip======snip==========

The major change is that I changed the "interrupts = <25 0x2>" to "interrupts = <25 0x8>"

This is what was suggested by TI - 0x8 changes the interrupt to fire when the gpio pin goes low. The driver then polls the tsc2007 for information. 0x2 causes interrupts on an edge/transition, which means when the touchscreen has no pressure, the gpio pin will go high - causing a second interrupt, which is not necessary. The driver is polling the gpio pin and get out when that happens.

I also changed the x-plate-ohms to 300 - However, I do not know if this is an optimal number, simply no information to go by. But it seem to work okay with that value.

If there are any questions, please let me know.

EugeneDMyers commented 2 years ago

Additional information:

You will need to install the evdev driver (unless you want to use libinput)

sudo apt install xserver-xorg-input-evdev

This is the /usr/share/X11/xorg.conf.d/ that I used:

pi@raspberrypitest:/usr/share/X11/xorg.conf.d $ cat 40-tsc2007.conf Section "InputClass" Identifier "TSC2007 touchscreen class" MatchProduct "TSC2007 touchscreen" MatchDevicePath "/dev/input/event*" MatchIsTouchscreen "on" Driver "evdev" EndSection

EugeneDMyers commented 2 years ago

Might have to change this somewhat - there was a driver change and a pararmeter added - I will test that tonight. If that works then no need to rebuild the kernel - just the overlay.

EugeneDMyers commented 2 years ago

As promised - I have figured out how to get the Wombat touchscreen functioning w/o patching the driver. To figure this out I surveyed the patches generated over the past couple years for tsc2007_core.c and found that removal of the bang was purposeful and to get the not for the gpio line a configuration parameter was needed. Of course in true linux fashion, this fact was not documented very well...

Here is the updated overlay:

==========snip========snip============

/dts-v1/; /plugin/;

include <dt-bindings/interrupt-controller/irq.h>

include <dt-bindings/gpio/gpio.h>

include <dt-bindings/pinctrl/bcm2835.h>

/ { compatible = "brcm,bcm2835";

    fragment@0 {
            target = <&gpio>;
            __overlay__ {
                    tsc2007_pins: tsc2007_pins {
                            brcm,pins = <25>;
                            brcm,function = <BCM2835_FSEL_GPIO_IN>; /* in */
                            /*brcm,pull = <2 0>; / * pullup none */
                    };
            };
    };

    fragment@1 {
            target = <&i2c1>;
            __overlay__ {
                    #address-cells = <1>;
                    #size-cells = <0>;
                    status = "okay";

                    tsc2007: tsc2007@48 {
                            compatible = "ti,tsc2007";
                            reg = <0x48>;
                    interrupt-parent = <&gpio>;
                    interrupts = <25 IRQ_TYPE_LEVEL_LOW>; 
                    gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
                    ti,x-plate-ohms = <300>;
            ti,max_rt = <4096>;
            ti,poll_period = <5>;
            ti,fuzzy = <64>;
            ti,fuzzz = <64>;
            ti,fuzzx = <64>;
                    };
            };
    };

    __overrides__ {
            irq_pin = <&tsc2007>, "interrupts:0",
                      <&tsc2007>, "gpios:4",
                      <&tsc2007_pins>, "brcm,pins:0";
    };

};

Zacharyprime commented 2 years ago

Thank you so much for all the work you have put in Eugene!

We have restructured how software is organized and so I am going to be focused on libwallaby for a while. Tim is taking over the task of building the OS from scratch, so he will be the new point of contact for this issue.

erinharrington-12 commented 1 year ago

Thanks @EugeneDMyers and @Zacharyprime for all the help and time you've both put in to this.

@tcorbly and I have been working on the Qt6 upgrade and getting everything to work with our libraries, including this touchscreen adventure. I did everything that was talked about in the above thread and it didn't seem to quite work.

I was able to FINALLY get it to work by going into /linux/.config and instead of CONFIG_TOUCHSCREEN_TSC2007=y, I changed it to CONFIG_TOUCHSCREEN_TSC2007=m.

I have a suspicion that when doing the menuconfig I didn't set the tsc2007 input device module correctly and did it manually