1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Fix Rockchip 6.1 compilation

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-06-25 08:24:35 +02:00
parent 948aebf05a
commit 747950fd6c
67 changed files with 16078 additions and 2 deletions

View file

@ -0,0 +1,43 @@
#!/bin/sh
. /lib/functions/leds.sh
. /lib/functions/uci-defaults.sh
board=$(board_name)
boardname="${board##*,}"
board_config_update
case $board in
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2s|\
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0"
ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth1"
;;
friendlyarm,nanopi-r4s|\
friendlyarm,nanopi-r4se|\
sharevdi,guangmiao-g4c)
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
;;
friendlyarm,nanopi-r5c)
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
;;
friendlyarm,nanopi-r5s)
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "eth1"
ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "eth2"
;;
hinlink,opc-h66k|\
hinlink,opc-h68k|\
hinlink,opc-h69k)
ucidef_set_led_netdev "wan" "WAN" "blue:net" "eth0"
;;
esac
board_config_flush
exit 0

View file

@ -0,0 +1,128 @@
#!/bin/sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
rockchip_setup_interfaces()
{
local board="$1"
case "$board" in
ariaboard,photonicat|\
dilusense,dlfr100|\
ezpro,mrkaio-m68s|\
ezpro,mrkaio-m68s-plus|\
hinlink,opc-h66k|\
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2s|\
friendlyarm,nanopi-r4s|\
friendlyarm,nanopi-r4se|\
rocktech,mpc1903|\
sharevdi,h3399pc|\
sharevdi,guangmiao-g4c|\
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
ucidef_set_interfaces_lan_wan 'eth1' 'eth0'
;;
hinlink,opc-h68k|\
hinlink,opc-h69k)
ucidef_set_interfaces_lan_wan 'eth1 eth2 eth3' 'eth0'
;;
fastrhino,r66s|\
firefly,rk3568-roc-pc|\
friendlyarm,nanopi-r5c|\
radxa,e25)
ucidef_set_interfaces_lan_wan 'eth0' 'eth1'
;;
fastrhino,r68s)
ucidef_set_interfaces_lan_wan 'eth0 eth2 eth3' 'eth1'
;;
friendlyarm,nanopi-r5s)
ucidef_set_interfaces_lan_wan "eth1 eth2" "eth0"
;;
*)
ucidef_set_interface_lan 'eth0'
;;
esac
}
generate_mac_from_mmc_cid()
{
local sd_hash=$(sha256sum /sys/class/block/mmcblk*/device/cid | head -n 1)
local mac_base=$(macaddr_canonicalize "$(echo "${sd_hash}" | dd bs=1 count=12 2>/dev/null)")
echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${mac_base}")")"
}
nanopi_r4s_get_mac()
{
local interface=$1
local eeprom_path="/sys/bus/i2c/devices/2-0051/eeprom"
local address
if [ -f "$eeprom_path" ]; then
address=$(get_mac_binary "$eeprom_path" 0xfa)
if [ "$interface" = "lan" ]; then
address=$(macaddr_setbit_la "$address")
fi
else
address=$(generate_mac_from_mmc_cid)
if [ "$interface" = "lan" ]; then
address=$(macaddr_add "$address" 1)
fi
fi
echo "$address"
}
rockchip_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case "$board" in
ariaboard,photonicat|\
dilusense,dlfr100|\
ezpro,mrkaio-m68s|\
ezpro,mrkaio-m68s-plus|\
hinlink,opc-h66k|\
hinlink,opc-h68k|\
hinlink,opc-h69k|\
fastrhino,r66s|\
fastrhino,r68s|\
firefly,rk3568-roc-pc|\
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2s|\
friendlyarm,nanopi-r5s|\
friendlyarm,nanopi-r5c|\
sharevdi,h3399pc|\
sharevdi,guangmiao-g4c|\
rocktech,mpc1903)
wan_mac=$(generate_mac_from_mmc_cid)
lan_mac=$(macaddr_add "$wan_mac" +1)
;;
friendlyarm,nanopi-r4s|\
friendlyarm,nanopi-r4se)
wan_mac=$(nanopi_r4s_get_mac wan)
lan_mac=$(nanopi_r4s_get_mac lan)
;;
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
lan_mac=$(cat /sys/class/net/eth1/address)
wan_mac=$(macaddr_add "$lan_mac" -1)
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
board=$(board_name)
rockchip_setup_interfaces $board
rockchip_setup_macs $board
board_config_flush
exit 0

View file

@ -0,0 +1,56 @@
#!/bin/sh
[ "$ACTION" = add ] || exit
get_device_irq() {
local device="$1"
local line
local seconds
# wait up to 10 seconds for the irq/device to appear
for seconds in $(seq 0 9); do
line=$(grep -m 1 "${device}\$" /proc/interrupts) && break
sleep 1
done
echo ${line} | sed 's/:.*//'
}
set_interface_core() {
local core_mask="$1"
local interface="$2"
local device="$3"
[ -z "${device}" ] && device="$interface"
local irq=$(get_device_irq "$device")
echo "${core_mask}" > /proc/irq/${irq}/smp_affinity
}
case "$(board_name)" in
fastrhino,r66s|\
friendlyarm,nanopi-r5c|\
firefly,rk3568-roc-pc)
set_interface_core 2 "eth0"
set_interface_core 4 "eth1"
;;
friendlyarm,nanopi-r2c|\
friendlyarm,nanopi-r2s|\
xunlong,orangepi-r1-plus|\
xunlong,orangepi-r1-plus-lts)
set_interface_core 2 "eth0"
set_interface_core 4 "eth1" "xhci-hcd:usb3"
;;
friendlyarm,nanopi-r4s|\
friendlyarm,nanopi-r4se|\
sharevdi,guangmiao-g4c)
set_interface_core 10 "eth0"
set_interface_core 20 "eth1"
;;
friendlyarm,nanopi-r5s)
set_interface_core 0 "eth0"
set_interface_core 2 "eth1"
set_interface_core 4 "eth2"
;;
esac

View file

@ -0,0 +1,6 @@
#!/bin/sh
if [ "${ACTION}" = "add" ]; then
usbmode -s && sleep 5
[ -n "$(cat /proc/net/wireless | grep wlan)" ] && wifi config && wifi
fi

View file

@ -0,0 +1,15 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=99
. /lib/functions/system.sh
boot() {
case $(board_name) in
rongpin,king3399)
echo 50 > /sys/class/gpio/export && echo high > /sys/class/gpio/gpio50/direction
echo 56 > /sys/class/gpio/export && echo high > /sys/class/gpio/gpio56/direction
;;
esac
}

View file

@ -0,0 +1,7 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
set network.globals.packet_steering=1
commit network
EOF
exit 0

View file

@ -0,0 +1,16 @@
move_config() {
local partdev
. /lib/upgrade/common.sh
if export_bootdevice && export_partdevice partdev 1; then
if mount -o rw,noatime "/dev/$partdev" /mnt; then
if [ -f "/mnt/$BACKUP_FILE" ]; then
mv -f "/mnt/$BACKUP_FILE" /
fi
umount /mnt
fi
fi
}
boot_hook_add preinit_mount_root move_config

View file

@ -0,0 +1,86 @@
platform_check_image() {
local diskdev partdev diff
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
return 1
}
get_partitions "/dev/$diskdev" bootdisk
#extract the boot sector from the image
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
get_partitions /tmp/image.bs image
#compare tables
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
if [ -n "$diff" ]; then
echo "Partition layout has changed. Full image will be written."
ask_bool 0 "Abort" && exit 1
return 0
fi
}
platform_copy_config() {
local partdev
if export_partdevice partdev 1; then
mount -o rw,noatime "/dev/$partdev" /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
fi
}
platform_do_upgrade() {
local diskdev partdev diff
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
return 1
}
sync
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
get_partitions "/dev/$diskdev" bootdisk
#extract the boot sector from the image
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
get_partitions /tmp/image.bs image
#compare tables
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
else
diff=1
fi
if [ -n "$diff" ]; then
get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
# Separate removal and addtion is necessary; otherwise, partition 1
# will be missing if it overlaps with the old partition 2
partx -d - "/dev/$diskdev"
partx -a - "/dev/$diskdev"
return 0
fi
#iterate over each partition from the image and write it to the boot disk
while read part start size; do
if export_partdevice partdev $part; then
echo "Writing image to /dev/$partdev..."
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
else
echo "Unable to find partition $part device, skipped."
fi
done < /tmp/partmap.image
#copy partition uuid
echo "Writing new UUID to /dev/$diskdev..."
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
}