Skip to content

Commit

Permalink
Add Console4A screen rotate configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nekorouter committed Dec 29, 2023
1 parent f9411aa commit 013c043
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 4 deletions.
8 changes: 8 additions & 0 deletions addons/LicheeConsole4A/display-setup.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Exec=/opt/display-setup.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=DisplaySetup
Comment=map the touchscreen to the right device and setup display layout
36 changes: 36 additions & 0 deletions addons/LicheeConsole4A/display-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# thank ice
if (cat /proc/device-tree/model | grep LicheeConsole4A);
then
xinput set-prop 'ydx' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
ROTATE=1
else
ROTATE=0
fi

if [ -z "$DISPLAY" ]
then
export DSIPLAY=:0.0
fi

xinput_dev="pointer:Goodix Capacitive TouchScreen"

if [ ! -d "/sys/class/drm/card0-DSI-1" ]; then
xrandr --output HDMI-1 --auto --primary
#echo off > /sys/class/drm/card0-DSI-1/status
else
HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
if [ "${HDMI_STATUS}" = "disconnected" ]; then
if [ "${ROTATE}" = "1" ]; then
xrandr --output DSI-1 --auto --rotate right --primary
xinput map-to-output "$xinput_dev" DSI-1
fi
elif [ "${HDMI_STATUS}" = "connected" ]; then
xrandr --output HDMI-1 --auto --primary
if [ "${ROTATE}" = "1" ]; then
xrandr --output DSI-1 --auto --rotate right --below HDMI-1
xinput map-to-output "$xinput_dev" DSI-1
fi
fi
fi
11 changes: 11 additions & 0 deletions addons/LicheeConsole4A/ssd-power-cycle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# if you need use ssd as root, you need add this script into your initramfs
# todo: move into uboot or kernel

cd /sys/class/gpio/
echo 313 > export
cd gpio313
echo out > direction
echo 0 > value
echo 1 > value
26 changes: 22 additions & 4 deletions mkrootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ ROOT_MOUNTPOINT=""
# == kernel variables ==
KERNEL_lpi4a="linux-headers-5.10.113-lpi4a linux-image-5.10.113-lpi4a linux-perf-thead"
KERNEL_ahead="linux-headers-5.10.113-ahead linux-image-5.10.113-ahead linux-perf-thead"
KERNEL_console="linux-headers-5.10.113-lpi4a linux-image-5.10.113-lpi4a linux-perf-thead"
KERNEL=$(eval echo '$'"KERNEL_${BOARD}")

BASE_TOOLS="binutils file tree sudo bash-completion u-boot-menu initramfs-tools openssh-server network-manager dnsmasq-base libpam-systemd ppp wireless-regdb wpasupplicant libengine-pkcs11-openssl iptables systemd-timesyncd vim usbutils libgles2 parted exfatprogs systemd-sysv mesa-vulkan-drivers"
BASE_TOOLS="binutils file tree sudo bash-completion u-boot-menu initramfs-tools openssh-server network-manager dnsmasq-base libpam-systemd ppp wireless-regdb wpasupplicant libengine-pkcs11-openssl iptables systemd-timesyncd vim usbutils libgles2 parted exfatprogs systemd-sysv mesa-vulkan-drivers pkexec"
XFCE_DESKTOP="xorg xserver-xorg-video-thead xfce4 desktop-base lightdm xfce4-terminal tango-icon-theme xfce4-notifyd xfce4-power-manager network-manager-gnome xfce4-goodies pulseaudio pulseaudio-module-bluetooth alsa-utils dbus-user-session rtkit pavucontrol thunar-volman eject gvfs gvfs-backends udisks2 dosfstools e2fsprogs libblockdev-crypto2 ntfs-3g polkitd blueman xarchiver"
GNOME_DESKTOP="gnome-core avahi-daemon desktop-base file-roller gnome-tweaks gstreamer1.0-libav gstreamer1.0-plugins-ugly libgsf-bin libproxy1-plugin-networkmanager network-manager-gnome"
KDE_DESKTOP="kde-plasma-desktop"
Expand Down Expand Up @@ -112,7 +113,11 @@ make_bootable()
# Add update-u-boot config
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_PROMPT=\"2\"' >> /etc/default/u-boot"
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_MENU_LABEL=\"RevyOS GNU/Linux\"' >> /etc/default/u-boot"
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_PARAMETERS=\"console=ttyS0,115200 rootwait rw earlycon clk_ignore_unused loglevel=7 eth=$ethaddr rootrwoptions=rw,noatime rootrwreset=yes\"' >> /etc/default/u-boot"
if [ "${BOARD}" == "console" ]; then
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_PARAMETERS=\"console=ttyS0,115200 rootwait rw earlycon clk_ignore_unused loglevel=7 eth=$ethaddr rootrwoptions=rw,noatime rootrwreset=yes fbcon=rotate:1\"' >> /etc/default/u-boot"
else
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_PARAMETERS=\"console=ttyS0,115200 rootwait rw earlycon clk_ignore_unused loglevel=7 eth=$ethaddr rootrwoptions=rw,noatime rootrwreset=yes\"' >> /etc/default/u-boot"
fi
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_FDT_DIR=\"/dtbs/linux-image-\"' >> /etc/default/u-boot"
chroot "$CHROOT_TARGET" sh -c "echo 'U_BOOT_ROOT=\"root=/dev/mmcblk0p3\"' >> /etc/default/u-boot"

Expand Down Expand Up @@ -141,7 +146,7 @@ after_mkrootfs()
chroot "$CHROOT_TARGET" sh -c "useradd -m -s /bin/bash -G adm,cdrom,floppy,sudo,input,audio,dip,video,plugdev,netdev,bluetooth,lp debian"
chroot "$CHROOT_TARGET" sh -c "echo 'debian:debian' | chpasswd"

if [ "${BOARD}" == "lpi4a" ]; then
if [ "${BOARD}" == "lpi4a" ] || [ "${BOARD}" == "console" ]; then
echo "lpi4a specific: Add sipeed user"
chroot "$CHROOT_TARGET" sh -c "useradd -m -s /bin/bash -G adm,cdrom,floppy,sudo,input,audio,dip,video,plugdev,netdev,bluetooth,lp sipeed"
chroot "$CHROOT_TARGET" sh -c "echo 'sipeed:licheepi' | chpasswd"
Expand Down Expand Up @@ -170,6 +175,11 @@ after_mkrootfs()
cp -rp addons/lpi4a-bt/rootfs/usr/local/bin/rtk_hciattach rootfs/usr/local/bin/
cp -rp addons/etc/systemd/system/auto-hciattach.service rootfs/etc/systemd/system/
fi
if [ "${BOARD}" == "console" ]; then
echo "console specific: Add AIC8800 Bluetooth Service"
# Add Bluetooth firmware and service
cp -rp addons/etc/systemd/system/auto-hciattach.service rootfs/etc/systemd/system/
fi

# Add firstboot service
cp -rp addons/etc/systemd/system/firstboot.service rootfs/etc/systemd/system/
Expand All @@ -178,7 +188,7 @@ after_mkrootfs()
# Install system services
chroot "$CHROOT_TARGET" sh -c "systemctl enable pvrsrvkm"
chroot "$CHROOT_TARGET" sh -c "systemctl enable firstboot"
if [ "${BOARD}" == "lpi4a" ]; then
if [ "${BOARD}" == "lpi4a" ] || [ "${BOARD}" == "console" ]; then
echo "lpi4a specific: Enable auto-hciattach Service"
chroot "$CHROOT_TARGET" sh -c "systemctl enable auto-hciattach"
fi
Expand Down Expand Up @@ -222,6 +232,14 @@ EOF
chroot "$CHROOT_TARGET" sh -c "ln -s /usr/share/images/ruyisdk/ruyi-1-1920x1080.png /usr/share/images/desktop-base/desktop-background"
chroot "$CHROOT_TARGET" sh -c "ln -s /usr/share/images/ruyisdk/ruyi-2-1920x1080.png /usr/share/images/desktop-base/login-background.svg"

# Copy files for Console4A
if [ "${BOARD}" == "console" ]; then
echo "Console4A specific: Copy files for Console4A"
cp -rp addons/LicheeConsole4A/* rootfs/opt/
# Install autostarts
cp -rp addons/LicheeConsole4A/display-setup.desktop rootfs/etc/xdg/autostart/
fi

# refresh so libs
chroot "$CHROOT_TARGET" sh -c "rm -v /etc/ld.so.cache"
chroot "$CHROOT_TARGET" sh -c "ldconfig"
Expand Down

0 comments on commit 013c043

Please sign in to comment.