Skip to content

Commit c656292

Browse files
committed
simplify patches
1 parent eaebf95 commit c656292

25 files changed

Lines changed: 1009 additions & 86 deletions

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Automated builds of OpenWrt for FriendlyARM NanoPi R2S & R4S boards
2828

2929
### Configuration
3030
- OpenWRT master Vanilla / Kernel 5.10
31-
- ImmortalWRT patches for Rockchip target NanoPi R2S (rk3328) / NanoPi R4S support (rk3399)
31+
- Minimal set of ImmortalWRT patches added for Rockchip target NanoPi R2C/R2S (rk3328) / NanoPi R4S support (rk3399)
3232

3333
### Applications
3434
- A useful set of applications from official OpenWrt package feed
@@ -38,6 +38,8 @@ Automated builds of OpenWrt for FriendlyARM NanoPi R2S & R4S boards
3838

3939

4040
## Changelog
41+
#### 2022-08-19
42+
- (22.03) Rework patches to be closer to Vanilla OpenWrt (only tested on R4S 4GB)
4143
#### 2022-08-18
4244
- (22.03) Update scripts to fix pbr missing
4345
#### 2022-08-17
File renamed without changes.

openwrt-22.03/patches/immortalwrt/package/libs/mbedtls/patches/100-Implements-AES-and-GCM-with-ARMv8-Crypto-Extensions.patch renamed to openwrt-22.03/patches/package/mbedtls/patches/100-Implements-AES-and-GCM-with-ARMv8-Crypto-Extensions.patch

File renamed without changes.

openwrt-22.03/patches/immortalwrt/package/kernel/r8168/Makefile renamed to openwrt-22.03/patches/package/r8168/Makefile

File renamed without changes.

openwrt-22.03/patches/immortalwrt/package/kernel/r8168/patches/001-r8168-add-LED-configuration-from-OF.patch renamed to openwrt-22.03/patches/package/r8168/patches/001-r8168-add-LED-configuration-from-OF.patch

File renamed without changes.

openwrt-22.03/patches/immortalwrt/package/kernel/r8168/patches/002-r8168-add-support-for-kernel-over-5.10.patch renamed to openwrt-22.03/patches/package/r8168/patches/002-r8168-add-support-for-kernel-over-5.10.patch

File renamed without changes.

openwrt-22.03/patches/snd-usb-caiaq.makefileaddon

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
. /lib/functions/leds.sh
3+
. /lib/functions/uci-defaults.sh
4+
5+
board=$(board_name)
6+
boardname="${board##*,}"
7+
8+
board_config_update
9+
10+
case $board in
11+
friendlyarm,nanopi-r2c|\
12+
friendlyarm,nanopi-r2s)
13+
ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0"
14+
ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth1"
15+
;;
16+
friendlyarm,nanopi-r4s)
17+
ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
18+
ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
19+
;;
20+
esac
21+
22+
board_config_flush
23+
24+
exit 0
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
. /lib/functions/uci-defaults.sh
3+
. /lib/functions/system.sh
4+
5+
rockchip_setup_interfaces()
6+
{
7+
local board="$1"
8+
9+
case "$board" in
10+
friendlyarm,nanopi-r2c|\
11+
friendlyarm,nanopi-r2s|\
12+
friendlyarm,nanopi-r4s)
13+
ucidef_set_interfaces_lan_wan 'eth1' 'eth0'
14+
;;
15+
*)
16+
ucidef_set_interface_lan 'eth0'
17+
;;
18+
esac
19+
}
20+
21+
nanopi_r2s_generate_mac()
22+
{
23+
local sd_hash=$(sha256sum /sys/class/block/mmcblk0/device/cid)
24+
local mac_base=$(macaddr_canonicalize "$(echo "${sd_hash}" | dd bs=1 count=12 2>/dev/null)")
25+
echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${mac_base}")")"
26+
}
27+
28+
rockchip_setup_macs()
29+
{
30+
local board="$1"
31+
local lan_mac=""
32+
local wan_mac=""
33+
local label_mac=""
34+
35+
case "$board" in
36+
friendlyarm,nanopi-r2c|\
37+
friendlyarm,nanopi-r2s)
38+
wan_mac=$(nanopi_r2s_generate_mac)
39+
lan_mac=$(macaddr_add "$wan_mac" 1)
40+
;;
41+
friendlyarm,nanopi-r4s)
42+
wan_mac=$(get_mac_binary "/sys/bus/i2c/devices/2-0051/eeprom" 0xfa)
43+
lan_mac=$(macaddr_setbit_la "$wan_mac")
44+
;;
45+
esac
46+
47+
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
48+
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
49+
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
50+
}
51+
52+
board_config_update
53+
board=$(board_name)
54+
rockchip_setup_interfaces $board
55+
rockchip_setup_macs $board
56+
board_config_flush
57+
58+
exit 0
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
[ "$ACTION" = add ] || exit
4+
5+
get_device_irq() {
6+
local device="$1"
7+
local line
8+
local seconds="0"
9+
10+
# wait up to 10 seconds for the irq/device to appear
11+
while [ "${seconds}" -le 10 ]; do
12+
line=$(grep -m 1 "${device}\$" /proc/interrupts) && break
13+
seconds="$(( seconds + 2 ))"
14+
sleep 2
15+
done
16+
echo ${line} | sed 's/:.*//'
17+
}
18+
19+
set_interface_core() {
20+
local core_mask="$1"
21+
local interface="$2"
22+
local device="$3"
23+
24+
[ -z "${device}" ] && device="$interface"
25+
26+
local irq=$(get_device_irq "$device")
27+
28+
echo "${core_mask}" > /proc/irq/${irq}/smp_affinity
29+
}
30+
31+
case "$(board_name)" in
32+
friendlyarm,nanopi-r2c|\
33+
friendlyarm,nanopi-r2s)
34+
set_interface_core 2 "eth0"
35+
set_interface_core 4 "eth1" "xhci-hcd:usb3"
36+
;;
37+
friendlyarm,nanopi-r4s)
38+
set_interface_core 10 "eth0"
39+
set_interface_core 20 "eth1"
40+
;;
41+
esac
42+

0 commit comments

Comments
 (0)