-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
amlogic
132 lines (121 loc) · 6.12 KB
/
amlogic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
# STAGE1
flash_uboot(){
if [ $EMMC -eq 1 ]; then
dd if=${OUTPUT}/u-boot.bin of="${IMAGE_LOOP_DEV}" bs=512 seek=1;
else
dd if=${OUTPUT}/u-boot.bin.sd.bin of="${IMAGE_LOOP_DEV}" conv=fsync bs=1 count=442;
dd if=${OUTPUT}/u-boot.bin.sd.bin of="${IMAGE_LOOP_DEV}" conv=fsync bs=512 skip=1 seek=1;
fi
}
flash_vendor-uboot(){
if [[ "$BOARD" == "odroidc1" ]]; then
dd if=${OUTPUT}/bl1.bin of="${IMAGE_LOOP_DEV}" bs=1 count=442 conv=fsync;
dd if=${OUTPUT}/bl1.bin of="${IMAGE_LOOP_DEV}" bs=512 skip=1 seek=1 conv=fsync;
dd if=${OUTPUT}/u-boot.bin of="${IMAGE_LOOP_DEV}" bs=512 seek=64 conv=fsync;
dd if=/dev/zero of="${IMAGE_LOOP_DEV}" seek=1024 count=32 bs=512 conv=fsync;
fi
if [[ "$FAMILY_EXT" == "odroid" ]]; then
dd if=${PRECOMPILED_UBOOT_DIR}/u-boot.bin of="${IMAGE_LOOP_DEV}" conv=fsync,notrunc bs=512 seek=1;
fi
}
# STAGE2
radxazero_firmware(){
ARIA2="aria2c -c --download-result=hide --console-log-level=error --disable-ipv6=true --summary-interval=0 --show-files=false"
echo ""
echo "Adding Radxa Zero firmware ..."
cd ~
git clone -b radxa https://github.com/pyavitz/firmware.git
if [[ -f "firmware/README.md" ]]; then
rm -f firmware/README.md;
fi
cp -fr firmware/* /lib/firmware
if [[ -f "fw-0a5c_21e8.hcd" ]]; then
mv fw-0a5c_21e8.hcd /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd;
cp /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd /lib/firmware/brcm/BCM20702A1-0a5c-21e8.hcd;
chown root:root /lib/firmware/brcm/BCM20702A1-0a5c-21e8.hcd;
chown root:root /lib/firmware/brcm/BCM20702A0-0a5c-21e8.hcd;
fi
if [[ -f "UPDATE.mem" ]]; then
install -Dm644 UPDATE.mem /lib/firmware/renesas_usb_fw.mem;
rm -f UPDATE.mem;
fi
rm -fdr firmware
git clone -q -b realtek https://github.com/pyavitz/firmware.git
cp -fr firmware/* /lib/firmware
rm -fdr firmware
mkdir -p /lib/firmware/rtl_nic
wget -cq https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware.git/+archive/refs/heads/main/rtl_nic.tar.gz -P /lib/firmware/rtl_nic
if [[ -f "/lib/firmware/rtl_nic/rtl_nic.tar.gz" ]]; then
tar xf /lib/firmware/rtl_nic/rtl_nic.tar.gz -C /lib/firmware/rtl_nic
rm -f /lib/firmware/rtl_nic/rtl_nic.tar.gz
fi
${ARIA2} https://github.com/LibreELEC/meson-firmware/archive/refs/heads/master.tar.gz
tar xf meson-firmware-master.tar.gz
mkdir -p /lib/firmware/meson
cp -fr meson-firmware-master/meson/* /lib/firmware/meson
rm -fdr meson-firmware-master*
mkdir -p /lib/firmware/ene-ub6250
cd /lib/firmware/ene-ub6250
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/ms_init.bin
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/ms_rdwr.bin
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/msp_rdwr.bin
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/sd_init1.bin
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/sd_init2.bin
${ARIA2} https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware/+/main/ene-ub6250/sd_rdwr.bin
chown -R root:root /lib/firmware/ene-ub6250
cd ~
}
odroid_udev_rules(){
tee /etc/udev/rules.d/10-odroid.rules <<EOF
# Misc video rules
KERNEL=="event*", SUBSYSTEM=="input", MODE="0777"
# Automatic Disk Scheduler
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0",ATTR{queue/scheduler}="noop"
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1",ATTR{queue/scheduler}="deadline"
ACTION=="add|change", KERNEL=="mmcblk[0-9]", ATTR{queue/rotational}=="0",ATTR{queue/scheduler}="noop"
EOF
}
ac2xx_udev_rules(){
# udev rules
echo "# SDCARD" > /etc/udev/rules.d/10-openvfd-led.rules
echo 'ACTION=="add", SUBSYSTEM=="mmc", ENV{MMC_TYPE}=="SD", RUN+="/bin/sh -c echo sd > /sys/class/leds/openvfd/led_on"' >> /etc/udev/rules.d/10-openvfd-led.rules
echo 'ACTION=="remove", SUBSYSTEM=="mmc", ENV{MMC_TYPE}=="SD", RUN+="/bin/sh -c echo sd > /sys/class/leds/openvfd/led_off"' >> /etc/udev/rules.d/10-openvfd-led.rules
echo "# USB" >> /etc/udev/rules.d/10-openvfd-led.rules
echo 'ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", RUN+="/bin/sh -c echo usb > /sys/class/leds/openvfd/led_on"' >> /etc/udev/rules.d/10-openvfd-led.rules
echo 'ACTION=="remove", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", RUN+="/bin/sh -c echo usb > /sys/class/leds/openvfd/led_off"' >> /etc/udev/rules.d/10-openvfd-led.rules
sed -i "s/echo sd > \/sys\/class\/leds\/openvfd\/led_on/'echo sd > \/sys\/class\/leds\/openvfd\/led_on'/g" /etc/udev/rules.d/10-openvfd-led.rules
sed -i "s/echo sd > \/sys\/class\/leds\/openvfd\/led_off/'echo sd > \/sys\/class\/leds\/openvfd\/led_off'/g" /etc/udev/rules.d/10-openvfd-led.rules
sed -i "s/echo usb > \/sys\/class\/leds\/openvfd\/led_on/'echo usb > \/sys\/class\/leds\/openvfd\/led_on'/g" /etc/udev/rules.d/10-openvfd-led.rules
sed -i "s/echo usb > \/sys\/class\/leds\/openvfd\/led_off/'echo usb > \/sys\/class\/leds\/openvfd\/led_off'/g" /etc/udev/rules.d/10-openvfd-led.rules
echo "# HDMI" >> /etc/udev/rules.d/10-openvfd-led.rules
echo 'ACTION=="change", SUBSYSTEM=="drm", ENV{DEVNAME}=="/dev/dri/card0", RUN+="/usr/local/sbin/hdmi-led-trigger"' >> /etc/udev/rules.d/10-openvfd-led.rules
# hdmi helper script
cat <<EOF > /usr/local/sbin/hdmi-led-trigger
#!/bin/bash
sleep .90
if [[ grep -w "enabled" "/sys/class/drm/card0-HDMI-A-1/enabled" ]] > /dev/null 2>&1; then
echo "hdmi" > /sys/class/leds/openvfd/led_on
else
echo "hdmi" > /sys/class/leds/openvfd/led_off
fi
exit 0
EOF
sed -i 's/grep -w "enabled" "\/sys\/class\/drm\/card0-HDMI-A-1\/enabled"/`grep -w "enabled" "\/sys\/class\/drm\/card0-HDMI-A-1\/enabled"`/g' /usr/local/sbin/hdmi-led-trigger
chmod +x /usr/local/sbin/hdmi-led-trigger
}
make_uimage(){
mkdir -p /etc/initramfs/post-update.d/
cat <<EOF > "/etc/initramfs/post-update.d/99-uimage"
#!/bin/bash
if [ -f /boot/uImage ]; then
rm -f /boot/uImage
fi
if [ -f /boot/Image ]; then
mkimage -A arm -O linux -T kernel -C none -a 0x2080000 -e 0x2080000 -n "Linux" -d /boot/Image /boot/uImage > /dev/null 2>&1
fi
exit 0
EOF
chmod +x /etc/initramfs/post-update.d/99-uimage
chown root:root /etc/initramfs/post-update.d/99-uimage
}