From 924f8476ce101a9ab762dd7b89ce02268b9787d8 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sat, 28 Nov 2020 20:49:31 -0800 Subject: [PATCH 1/7] Point to latest commit of rgb matrix library --- rgb-matrix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index 9408801..962a92d 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -7,8 +7,8 @@ # we reference a specific commit (update this as needed): GITUSER=https://github.com/hzeller REPO=rpi-rgb-led-matrix -COMMIT=21410d2b0bac006b4a1661594926af347b3ce334 -# Previously: COMMIT=e3dd56dcc0408862f39cccc47c1d9dea1b0fb2d2 +COMMIT=84e1465e9ea5ed000011d05369c5287eaa361ad7 +# Previously: COMMIT=21410d2b0bac006b4a1661594926af347b3ce334 if [ $(id -u) -ne 0 ]; then echo "Installer must be run as root." From ecafd163212fb7623bc0e8ee7d2afe8d54873536 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sun, 23 Feb 2025 21:00:22 -0800 Subject: [PATCH 2/7] Look in the proper place for the config file on bookworm OS --- rgb-matrix.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index 2241e8f..a011926 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -21,6 +21,13 @@ fi HAS_PYTHON2=$( [ ! $(which python2) ] ; echo $?) HAS_PYTHON3=$( [ ! $(which python3) ] ; echo $?) +# Bookworm moved the config file from /boot/config.txt to /boot/firmware/config.txt +# Check to see where it is to ensure the config changes are written to the right place. +CONFIG_FILE=/boot/firmware/config.txt +if [ ! -f $CONFIG_FILE ]; then + CONFIG_FILE=/boot/config.txt +fi + clear echo "This script installs software for the Adafruit" @@ -267,7 +274,7 @@ if [ $INSTALL_RTC -ne 0 ]; then # Enable I2C for RTC raspi-config nonint do_i2c 0 # Do additional RTC setup for DS1307 - reconfig /boot/config.txt "^.*dtoverlay=i2c-rtc.*$" "dtoverlay=i2c-rtc,ds1307" + reconfig $CONFIG_FILE "^.*dtoverlay=i2c-rtc.*$" "dtoverlay=i2c-rtc,ds1307" apt-get -y remove fake-hwclock update-rc.d -f fake-hwclock remove sudo sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set @@ -276,10 +283,10 @@ fi if [ $QUALITY_MOD -eq 0 ]; then # Disable sound ('easy way' -- kernel module not blacklisted) - reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=off" + reconfig $CONFIG_FILE "^.*dtparam=audio.*$" "dtparam=audio=off" else # Enable sound (ditto) - reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=on" + reconfig $CONFIG_FILE "^.*dtparam=audio.*$" "dtparam=audio=on" fi # PROMPT FOR REBOOT -------------------------------------------------------- From ebd22ddb2cc6a6fe69bd1ff9c2af04658c6af3e5 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sun, 23 Feb 2025 21:16:26 -0800 Subject: [PATCH 3/7] Make the Python version checks actually work --- rgb-matrix.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index a011926..a796511 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -216,10 +216,10 @@ echo "Updating package index files..." apt-get update echo "Downloading prerequisites..." -if [ $HAS_PYTHON2 ]; then +if [ "$HAS_PYTHON2" = 1 ]; then apt-get install -y --force-yes python2.7-dev python-pillow fi -if [ $HAS_PYTHON3 ]; then +if [ "$HAS_PYTHON3" = 1 ]; then apt-get install -y --force-yes python3-dev python3-pillow fi @@ -239,24 +239,24 @@ USER_DEFINES="" # USER_DEFINES+=" -DLED_ROWS=${MATRIX_HEIGHTS[$MATRIX_SIZE]}" #fi if [ $QUALITY_MOD -eq 0 ]; then - if [ $HAS_PYTHON2 ]; then + if [ "$HAS_PYTHON2" = 1 ]; then # Build and install for Python 2.7... make clean make install-python HARDWARE_DESC=adafruit-hat-pwm USER_DEFINES="$USER_DEFINES" PYTHON=$(which python2) fi - if [ $HAS_PYTHON3 ]; then + if [ "$HAS_PYTHON3" = 1 ]; then # Do over for Python 3... make clean make install-python HARDWARE_DESC=adafruit-hat-pwm USER_DEFINES="$USER_DEFINES" PYTHON=$(which python3) fi else USER_DEFINES+=" -DDISABLE_HARDWARE_PULSES" - if [ $HAS_PYTHON2 ]; then + if [ "$HAS_PYTHON2" = 1 ]; then # Build then install for Python 2.7... make clean make install-python HARDWARE_DESC=adafruit-hat USER_DEFINES="$USER_DEFINES" PYTHON=$(which python2) fi - if [ $HAS_PYTHON3 ]; then + if [ "$HAS_PYTHON3" = 1 ]; then # Do over for Python 3... make clean make install-python HARDWARE_DESC=adafruit-hat USER_DEFINES="$USER_DEFINES" PYTHON=$(which python3) From 023c4e7969d6b12e41c4d185c36b15479abd0726 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sun, 23 Feb 2025 21:18:58 -0800 Subject: [PATCH 4/7] update --force-yes deprecated apt-get flag --- rgb-matrix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index a796511..8f99f5d 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -217,10 +217,10 @@ apt-get update echo "Downloading prerequisites..." if [ "$HAS_PYTHON2" = 1 ]; then - apt-get install -y --force-yes python2.7-dev python-pillow + apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages python2.7-dev python-pillow fi if [ "$HAS_PYTHON3" = 1 ]; then - apt-get install -y --force-yes python3-dev python3-pillow + apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages python3-dev python3-pillow fi echo "Downloading RGB matrix software..." From f33f980bd881d53efdd2a039798056040fe95b30 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sun, 23 Feb 2025 22:30:40 -0800 Subject: [PATCH 5/7] Add option for adding isolcpus to improve display performance on multi-core Pi --- rgb-matrix.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index 8f99f5d..2d1db80 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -21,12 +21,19 @@ fi HAS_PYTHON2=$( [ ! $(which python2) ] ; echo $?) HAS_PYTHON3=$( [ ! $(which python3) ] ; echo $?) -# Bookworm moved the config file from /boot/config.txt to /boot/firmware/config.txt +NUM_CORES=$( nproc --all ) +ISOLCPU_CMD=isolcpus=3 + +# Bookworm moved the config and cmdline files from /boot/ to /boot/firmware/ # Check to see where it is to ensure the config changes are written to the right place. CONFIG_FILE=/boot/firmware/config.txt if [ ! -f $CONFIG_FILE ]; then CONFIG_FILE=/boot/config.txt fi +CMDLINE_FILE=/boot/firmware/cmdline.txt +if [ ! -f $CMDLINE_FILE ]; then + CONFIG_FILE=/boot/cmdline.txt +fi clear @@ -53,6 +60,7 @@ fi INTERFACE_TYPE=0 INSTALL_RTC=0 QUALITY_MOD=0 +ISOL_CPU=0 #SLOWDOWN_GPIO=5 #MATRIX_SIZE=3 @@ -95,6 +103,11 @@ QUALITY_OPTS=( \ "Convenience (sound on, no soldering)" \ ) +ISOLCPUS_OPTS=( \ + "Do not reserve core for driving display" \ + "Reserve core for driving display (recommended)" \ +) + #SLOWDOWN_OPTS=( \ # "0" \ # "1" \ @@ -171,6 +184,18 @@ echo "What is thy bidding?" selectN "${QUALITY_OPTS[@]}" QUALITY_MOD=$? +if [ $NUM_CORES -gt 3 ]; then + echo + echo "Your pi has ${NUM_CORES} CPU cores." + echo "You can choose to dedicate one just to driving the display." + echo "This will make the display less suseptible to glitches when" + echo "the system is doing other heavy tasks. Do you wish to isolate" + echo "one core for this purpose?" + selectN "${ISOLCPUS_OPTS[@]}" + ISOL_CPU=$? + +fi + # VERIFY SELECTIONS BEFORE CONTINUING -------------------------------------- echo @@ -185,6 +210,7 @@ if [ $QUALITY_MOD -eq 0 ]; then echo "Reminder: you must SOLDER a wire between GPIO4" echo "and GPIO18, and internal sound is DISABLED!" fi +echo "Isolate CPU for Display Driving: ${ISOLCPUS_OPTS[$ISOL_CPU]}" echo echo -n "CONTINUE? [y/n] " read @@ -289,6 +315,14 @@ else reconfig $CONFIG_FILE "^.*dtparam=audio.*$" "dtparam=audio=on" fi +if [ $ISOL_CPU -eq 1 ]; then + # Enable CPU core isolation + grep -qw $ISOLCPU_CMD $CMDLINE_FILE || echo -n " $ISOLCPU_CMD" >> $CMDLINE_FILE +else + # Disable CPU core isolation + sed -i -e "s/\b${ISOLCPU_CMD}\b//g" -e 's/ */ /g' -e 's/^ //;s/ $//' $CMDLINE_FILE +fi + # PROMPT FOR REBOOT -------------------------------------------------------- echo "Done." From ab142f6ab6313d35e083fb3a4293defb76df8b00 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Sun, 23 Feb 2025 23:14:56 -0800 Subject: [PATCH 6/7] kernel module needs to be blacklisted, or the rgb-matrix software will not start. --- rgb-matrix.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index 2d1db80..d3be23c 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -308,12 +308,17 @@ if [ $INSTALL_RTC -ne 0 ]; then fi if [ $QUALITY_MOD -eq 0 ]; then - # Disable sound ('easy way' -- kernel module not blacklisted) + # Disable sound reconfig $CONFIG_FILE "^.*dtparam=audio.*$" "dtparam=audio=off" + # The rgb-matrix software also checks for the module to be blacklisted. + echo "blacklist snd_bcm2835" | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf > /dev/null else - # Enable sound (ditto) + # Enable sound reconfig $CONFIG_FILE "^.*dtparam=audio.*$" "dtparam=audio=on" + # Remove kernel blacklist if present + sudo rm -f /etc/modprobe.d/blacklist-rgb-matrix.conf fi +sudo update-initramfs -u if [ $ISOL_CPU -eq 1 ]; then # Enable CPU core isolation From 3c1c357a48241a3c35837db13ab4378d7bf70ff0 Mon Sep 17 00:00:00 2001 From: Jeremy Blum Date: Mon, 24 Feb 2025 19:08:35 -0800 Subject: [PATCH 7/7] Update to latest commit of source repo (tested and confirmed working) --- rgb-matrix.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rgb-matrix.sh b/rgb-matrix.sh index d3be23c..e738cb7 100755 --- a/rgb-matrix.sh +++ b/rgb-matrix.sh @@ -7,7 +7,8 @@ # we reference a specific commit (update this as needed): GITUSER=https://github.com/hzeller REPO=rpi-rgb-led-matrix -COMMIT=a3eea997a9254b83ab2de97ae80d83588f696387 +COMMIT=62986e65dec25451a37531896be087664a49929b +# Previously: COMMIT=a3eea997a9254b83ab2de97ae80d83588f696387 # Previously: COMMIT=45d3ab5d6cff6e0c14da58930d662822627471fc # Previously: COMMIT=21410d2b0bac006b4a1661594926af347b3ce334 # Previously: COMMIT=e3dd56dcc0408862f39cccc47c1d9dea1b0fb2d2