Skip to content

Commit

Permalink
Add rk3568 ec-x
Browse files Browse the repository at this point in the history
  • Loading branch information
unifreq committed Nov 29, 2023
1 parent 4378ebb commit 9effc0e
Show file tree
Hide file tree
Showing 20 changed files with 438 additions and 0 deletions.
17 changes: 17 additions & 0 deletions files/bootfiles/rockchip/rk3568/ec-x/armbianEnv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
verbosity=7
bootlogo=true
fdtfile=rockchip/rk3568-ec-x.dtb
rootdev=/dev/mmcblk0p2
rootfstype=btrfs
rootflags=compress=zstd:6
console=serial
consoleargs=console=ttyS2,1500000
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
docker_optimizations=on
earlycon=on
earlyconargs=earlycon=uart8250,mmio32,0xfe660000
extraargs=
extraboardargs=net.ifnames=0
overlay_prefix=rk3568
overlays=
user_overlays=
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#-----------------------------------------------------------------
# Armbian first run configuration
# Set optional end user configuration
# - Rename this file from /boot/armbian_first_run.txt.template to /boot/armbian_first_run.txt
# - Settings below will be applied only on 1st run of Armbian
#-----------------------------------------------------------------

#-----------------------------------------------------------------
# General:
# 1 = delete this file, after first run setup is completed.

FR_general_delete_this_file_after_completion=1

#-----------------------------------------------------------------
#Networking:
# Change default network settings
# Set to 1 to apply any network related settings below

FR_net_change_defaults=0

# Enable WiFi or Ethernet.
# NB: If both are enabled, WiFi will take priority and Ethernet will be disabled.

FR_net_ethernet_enabled=1
FR_net_wifi_enabled=0

#Enter your WiFi creds
# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption.

FR_net_wifi_ssid='MySSID'
FR_net_wifi_key='MyWiFiKEY'

# Country code to enable power ratings and channels for your country. eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

FR_net_wifi_countrycode='GB'

#If you want to use a static ip, set it here

FR_net_use_static=0
FR_net_static_ip='192.168.0.100'
FR_net_static_mask='255.255.255.0'
FR_net_static_gateway='192.168.0.1'
FR_net_static_dns='8.8.8.8 8.8.4.4' #2 entries max, seperated by a space.
#-----------------------------------------------------------------
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added files/bootfiles/rockchip/rk3568/ec-x/boot.bmp
Binary file not shown.
74 changes: 74 additions & 0 deletions files/bootfiles/rockchip/rk3568/ec-x/boot.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# DO NOT EDIT THIS FILE
#
# Please edit /boot/armbianEnv.txt to set supported parameters
#

setenv load_addr "0x39000000"
setenv overlay_error "false"
# default values
setenv rootdev "/dev/mmcblk0p1"
setenv verbosity "1"
setenv console "both"
setenv bootlogo "false"
setenv rootfstype "ext4"
setenv rootflags "rw,errors=remount-ro"
setenv docker_optimizations "on"
setenv earlycon "off"

echo "Boot script loaded from ${devtype} ${devnum}"

if test -e ${devtype} ${devnum} ${prefix}armbianEnv.txt; then
load ${devtype} ${devnum} ${load_addr} ${prefix}armbianEnv.txt
env import -t ${load_addr} ${filesize}
fi

if test "${logo}" = "disabled"; then setenv logo "logo.nologo"; fi

if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=tty1"; fi
if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "${consoleargs} console=tty1"; fi
if test "${earlycon}" = "on"; then setenv consoleargs "${earlyconargs} ${consoleargs}"; fi
if test "${bootlogo}" = "true"; then setenv consoleargs "bootsplash.bootfile=bootsplash.armbian ${consoleargs}"; fi

# get PARTUUID of first partition on SD/eMMC the boot script was loaded from
if test "${devtype}" = "mmc"; then part uuid mmc ${devnum}:1 partuuid; fi

setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} rootflags=${rootflags} ${consoleargs} consoleblank=0 loglevel=${verbosity} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"

if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi

load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image

load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
for overlay_file in ${user_overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then
echo "Applying user provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
if test "${overlay_error}" = "true"; then
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
else
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-fixup.scr; then
echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
source ${load_addr}
fi
if test -e ${devtype} ${devnum} ${prefix}fixup.scr; then
load ${devtype} ${devnum} ${load_addr} ${prefix}fixup.scr
echo "Applying user provided fixup script (fixup.scr)"
source ${load_addr}
fi
fi
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

# Recompile with:
# mkimage -C none -A arm -T script -n 'flatmax load script' -d /boot/boot.cmd /boot/boot.scr
Binary file added files/bootfiles/rockchip/rk3568/ec-x/boot.scr
Binary file not shown.
8 changes: 8 additions & 0 deletions files/openwrt-update-rockchip
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ case $MYDEVICE_NAME in
fi
SOC="r68s"
;;
"RK3568 EC-X")
if [ -n "${CURRENT_FDTFILE}" ]; then
MYDTB_FDTFILE="${CURRENT_FDTFILE}"
else
MYDTB_FDTFILE="rk3568-ec-x.dtb"
fi
SOC="ec-x"
;;
"HINLINK OPC-H66K Board"|"Hlink H66K")
if [ -n "${CURRENT_FDTFILE}" ] && [ "${CURRENT_FDTFILE}" != "rk3568-opc-h66k.dtb" ];then
MYDTB_FDTFILE="${CURRENT_FDTFILE}"
Expand Down
18 changes: 18 additions & 0 deletions files/rk3568/ec-x/balance_irq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# /etc/balance_irq
# 用于中断设备的负载均衡
# 用法:
# 首先, 用 cat /proc/interrupts 进行观察
# 如果某个cpu负载过重,可以把对应的中断设备迁移到其它cpu
# /proc/interrupt格式:
# 最左列:中断号
# 第 2 至第 2+cpus 列:cpu单核上产生的中断数量
# 最右列:对应的设备名
#
# 本配置文件格式:
# 第1列: 设备名
# 第2列: 期望绑定在第几个cpu (从1开始)
#
# 配置文件改好,运行 balethirq.pl 即时生效

# lan
eth0 4
13 changes: 13 additions & 0 deletions files/rk3568/ec-x/board.d/00_model
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (C) 2015 OpenWrt.org
# Copyright (C) 2016 Yousong Zhou <[email protected]>

. /lib/functions/uci-defaults.sh

board_config_update

ucidef_set_board_id "rk3568,ec-x"
ucidef_set_model_name "RK3568 EC-X"

board_config_flush

exit 0
15 changes: 15 additions & 0 deletions files/rk3568/ec-x/board.d/01_led
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# Copyright (C) 2015 OpenWrt.org
#

. /lib/functions/uci-defaults.sh

board_config_update

ucidef_set_led_default "work" "WORK" "blue:work" "1"
ucidef_set_led_netdev "lan" "LAN" "blue:net" "eth0"

board_config_flush

exit 0
56 changes: 56 additions & 0 deletions files/rk3568/ec-x/board.d/99-default_network
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# The phy interfaces for EC-X:
# eth0(1gb) rockchip gmac for lan

. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

board_config_update

generate_mac()
{
# https://gist.githubusercontent.com/aallan/b4bb86db86079509e6159810ae9bd3e4/raw/846ae1b646ab0f4d646af9115e47365f4118e5f6/mac-vendor.txt
# The MAC address range registered by realtek manufacturers is as follows:
local mac_grp_0="00:20:18:"
local mac_grp_1="00:4f:49:"
local mac_grp_2="00:60:52:"
local mac_grp_3="00:e0:4c:"
local mac_grp_4="52:54:00:"
local mac_grp_5="52:54:ab:"
local mac_grp_cnt=6

# get the sd/emmc unique id
local sd_hash
if [ -f "/sys/class/block/mmcblk1/device/cid" ];then
sd_hash=$(sha256sum /sys/class/block/mmcblk1/device/cid | cut -f1)
elif [ -f "/sys/class/block/mmcblk0/device/cid" ];then
sd_hash=$(sha256sum /sys/class/block/mmcblk0/device/cid | cut -f1)
else
sd_hash=$(dd if=/dev/zero bs=1 count=68 | sha256sum | cut -f1)
fi

# get mac address head
local dice=${mac_grp_cnt}$(echo $sd_hash | tr -d '[a-f]' | cut -b 1-6)
local idx=$((dice % mac_grp_cnt))
eval local mac_head="\$mac_grp_${idx}"

# get mac address tail
# sd_hash length: max 64
local mac_tail=$(echo $sd_hash|cut -b 16-17)":"$(echo $sd_hash|cut -b 26-27)":"$(echo $sd_hash|cut -b 42-43)

echo "${mac_head}${mac_tail}"
}

# Init LAN and WAN
json_is_a network object && exit 0

LAN_MAC=$(generate_mac)
ucidef_set_interface_lan 'eth0'
ucidef_set_interface_macaddr "lan" $LAN_MAC
if [ -d "/sys/class/net/eth1" ];then
ucidef_set_interface_wan 'eth1'
ucidef_set_interface_macaddr "wan" $WAN_MAC
fi

board_config_flush

exit 0
Binary file added files/rk3568/ec-x/bootloader.bin
Binary file not shown.
2 changes: 2 additions & 0 deletions files/rk3568/ec-x/mkbootscr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/bin/mkimage -C none -A arm -T script -n 'flatmax load script' -d ../../bootfiles/rockchip/rk3568/ec-x/boot.cmd ../../bootfiles/rockchip/rk3568/ec-x/boot.scr
1 change: 1 addition & 0 deletions files/rk3568/ec-x/modules.d/mt7915e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mt7915e
1 change: 1 addition & 0 deletions files/rk3568/ec-x/modules.d/mt7921e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mt7921e
1 change: 1 addition & 0 deletions files/rk3568/ec-x/modules.d/option
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option
1 change: 1 addition & 0 deletions files/rk3568/ec-x/modules.d/pwm-fan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pwm_fan
1 change: 1 addition & 0 deletions files/rk3568/ec-x/modules.d/rk_crypto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rk_crypto2
3 changes: 3 additions & 0 deletions files/rk3568/ec-x/modules.d/snd-rk3568
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
snd_soc_simple_card_utils
snd_soc_simple_card
snd_soc_rockchip_i2s
Loading

0 comments on commit 9effc0e

Please sign in to comment.