adafruit / Raspberry-Pi-Installer-Scripts

381 stars 160 forks source link

Braincraft hat not working with latest RPi kernel #187

Closed jerryneedell closed 3 years ago

jerryneedell commented 3 years ago

I tried installing the pitft display for the Braincraft hat following the guide https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi

The install went fine, but when I tried to test it with raspistill -t 0 I get nothing on the display.

It had been working prior to updating the Raspberry Pi kernel

I also noted that with the latest kernel, I do not see anything at all on the display, no console messages like I usually do, except when I reboot, there is a momentary flash of the linux console on the screen as it reboots but nothing is there once it finishes the reboot and I can't get anything to display. I do not get any errors, just no display.

I tried doing a full clean install of RaspiOS and followed the guide but get the same results.

I did follow the troubleshooting instructions and it does work if I revert the kernel back to 5.4.79 per the guide. https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi/kernel-module-troubleshooting

This does work but I was wondering if a fix was in the works to allow more recent kernel to be used.

makermelissa commented 3 years ago

Is this happening on a Pi 4 or a different one?

jerryneedell commented 3 years ago

Yes -- Pi 4 -- sorry I left that out.

jerryneedell commented 3 years ago

I am working through some of the newer kernels: sudo sh rpi-pin-kernel-firmware.sh 1.20210430-2 seems to work

makermelissa commented 3 years ago

Thank you. Yeah figuring out the latest working kernel may be the answer for now.

jerryneedell commented 3 years ago

interesting -- I installed sudo sh rpi-pin-kernel-firmware.sh 1.20210527-1 and it worked until I reinstalled the Audio -- that appears to also re-install the kernel....and broke it I am re-installing it...

jerryneedell commented 3 years ago

reinstalling sudo sh rpi-pin-kernel-firmware.sh 1.20210527-1 now works. and the Audio is still working. I have to stop for today but will try some newer kernels in the morning -- possible it is the audio script that was messing things up....

makermelissa commented 3 years ago

Awesome, thanks.

jerryneedell commented 3 years ago

So -- it appears that 20210527-1 works OK but 20210727-1 fails Note that I had the above issue when I installed the audio v5.9 per the guide after installing 20210527-1 -- it appeared to update the kernel to 20210805-1 and did not work, but I then reinstalled 20210527-1 and it is now working fine.
I am confused by this and will do more troubleshooting today, but it is working -- audio as well.

jerryneedell commented 3 years ago

I have confirmed that with kernel 20210527-1 installed and pinned running the install.sh script from the seed- voicecard folder updates the kernel to 20210805-1 so it no longer works. Reinstalling/pinning kernel 20201527-1 fixes it.
sudo sh rpi-pin-kernel-firmware.sh 1.20210527-1

jerryneedell commented 3 years ago

In the install script to pin the kernel it looks like it has the 202021126-1 version hard coded when it writes the file to /etc/apt/prefereneces.d https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/rpi-pin-kernel-firmware.sh#L38

so this file is not correct when I run sudo sh rpi-pin-kernel-firmware.sh 1.20210527-1 It is not clear to me how this file is actually used but ti looks like it should be changed.

I tried updating the /etc/apt/preferences/d/99-adafruit-pin-kernel file to replace 20201126 with 20210527 then retried the audio install, but it still upgraded the kernel.

I found some info on the apt preferences here: <http://manpages.ubuntu.com/manpages/bionic/man5/apt_preferences.5.html

but it still looks the audio install script is ignoring it.

jerryneedell commented 3 years ago

Maybe I am misinterpreting what "pinning" means. Running a sudo apt update;sudo apt full-upgrade installs the newest kernel. I guess you just have to revert the kernel any time it is updated. I thought the "pinning" prevented apt from upgrading the kernel....

makermelissa commented 3 years ago

I don't think you're misinterpreting. It should keep an older version when you attempt to update to the latest. Also, the version shouldn't be hardcoded. Good catch.

jerryneedell commented 3 years ago

The "pinning" is not working for me-- that is, every time I rerun the pitft install script, it also install the latest kernel... Then when I revert the kernel it works OK, but the screen is inverted. If I reinstall the pitft display module to then it updates the kernel....

after a few tries -- I finally go it rotated corrected (0) and back to the 20210527-1 kernel -- it seems happy...

I'll try playing with e pinning on an other SD Card ... nice to keep this one functional.

makermelissa commented 3 years ago

Yeah, the PiTFT script should not be able to update to the latest kernel if it is truly pinned. Can you post the contents of your /etc/apt/preferences.d/99-adafruit-pin-kernel file? I suspect it isn't being written correctly by the script.

jerryneedell commented 3 years ago
Pin: version 1.20210527-1
Pin-Priority:999

Package: libraspberrypi-bin
Pin: version 1.20210527-1
Pin-Priority:999

Package: libraspberrypi-dev
Pin: version 1.20210527-1
Pin-Priority:999

Package: libraspberrypi-doc
Pin: version 1.20210527-1
Pin-Priority:999

Package: raspberrypi-bootloader
Pin: version 1.20210527-1
Pin-Priority:999

Package: raspberrypi-kernel
Pin: version 1.20210527-1
Pin-Priority:999

Package: raspberrypi-kernel-headers
Pin: version 1.20210527-1
Pin-Priority:999

here is my modified pin script with the corrected kernel version.

# rpi-pin-kernel-firmware: Pin a specific version of the rpi kernel and firmware

set -e

if [ $# -ne 1 ]; then
    echo "Usage: $0 kernel-version"
    echo
    echo "e.g., $0 1.20201126-1"
    exit 1
fi

if ! dpkg -l raspberrypi-kernel:armhf > /dev/null 2>&1; then
    echo "This command is designed to run only on Raspbian with the armhf kernel"
    echo 99
fi

if [ `id -u` -ne 0 ]; then
    echo "If necessary, enter your password to run this script as root"
    exec sudo sh "$0" "$1"
fi

version=$1
base=http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/
packagelist="libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers"

set --
for package in $packagelist; do
    filename="${package}_${version}_armhf.deb"
    set -- "$@" "$filename"
    wget --continue -O "$filename" "$base/$filename"
done

dpkg -i "$@"

for package in $packagelist; do
    /usr/bin/printf "Package: $package\nPin: version 1.20210527-1\nPin-Priority:999\n\n"
done > /etc/apt/preferences.d/99-adafruit-pin-kernel
makermelissa commented 3 years ago

Looks correct. I think I'll just need to play around with it myself.

jerryneedell commented 3 years ago

Good luck! Let me know if you want me to try anything. BTW- 20210527-1 is working well for me. I am able to use raspistill, the tensor flow demo and the lobe demo.

makermelissa commented 3 years ago

Thanks for figuring out the latest good one.

makermelissa commented 3 years ago

Ok, after installing the drivers as the instructions, the screen was black. As some other recent issues mentioned, the backlight wasn't turning on for the display, so I opened python and ran this code:

pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import digitalio
>>> backlight = digitalio.DigitalInOut(board.D26)

The Backlight turned on and the correct info is all there, so it looks like the issue is just related to the backlight not turning on by default. This should be a fairly simple fix of modifying the device tree overlays.

jerryneedell commented 3 years ago

Nice! Is this with the latest RPi kernel installed?

makermelissa commented 3 years ago

Nice! Is this with the latest RPi kernel installed?

Yes

jerryneedell commented 3 years ago

Cool! Worked for me as well!

makermelissa commented 3 years ago

Ok, so getting the backlight to turn on by editing the DTS file hasn't been as easy as I thought.

Regarding the pinning, I was looking into that and the version than needs to be written to the pinning file is 1:1.20210527-1, but the file name is still uses 1.20210527-1. So I'm trying to see if there's an easy way to fix this without breaking compatibility.

jerryneedell commented 3 years ago

Thanks for clarifying that. If the backlight is fixed, then pinning is not necessary now, correct? It seems to be working ok as long as I manually turn on the backlight once after booting.

makermelissa commented 3 years ago

Backlight is currently not fixed. The python script was just a test to see what the actual problem was. I'm just fixing pinning for the future and so people have an easy fix for now. I'm almost done updating the guide now and just need to update one more screenshot.