Skip to content

Commit

Permalink
rockchip: add NanoPi R2S support
Browse files Browse the repository at this point in the history
Hardware
--------
RockChip RK3328 ARM64 (4 cores)
1GB DDR4 RAM
2x 1000 Base-T
3 LEDs (LAN / WAN / SYS)
1 Button (Reset)
Micro-SD slot
USB 2.0 Port

Installation
------------
Uncompress the OpenWrt sysupgrade and write it to a micro SD card using
dd.

MAC-address
-----------
The vendor code supports reading a MAC address from an EEPROM connected
via i2c0 of the SoC. The EEPROM (address 0x51) should contain the MAC
address in binary at offset 0xfa. However, my two units didn't come with
such an EEPROM soldered on. The EEPROM should be placed between the SoC
and the GPIO pins on the board. (U10)

Generating rendom MAC addresses works around this issue. Otherwise, all
boards running the same image have identical MAC addresses.

Signed-off-by: David Bauer <mail@david-bauer.net>
  • Loading branch information
blocktrron committed Jul 28, 2020
1 parent b72f7c6 commit b7a9a18
Show file tree
Hide file tree
Showing 9 changed files with 609 additions and 6 deletions.
20 changes: 20 additions & 0 deletions target/linux/rockchip/armv8/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

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

board=$(board_name)
boardname="${board##*,}"

board_config_update

case $board in
friendlyarm,nanopi-r2s)
ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0"
ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth1"
;;
esac

board_config_flush

exit 0
42 changes: 36 additions & 6 deletions target/linux/rockchip/armv8/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
#!/bin/sh

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

board_config_update
rockchip_setup_interfaces()
{
local board="$1"

case "$board" in
friendlyarm,nanopi-r2s)
ucidef_set_interfaces_lan_wan 'eth1' 'eth0'
;;
*)
ucidef_set_interface_lan 'eth0'
;;
esac
}

rockchip_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""

case "$(board_name)" in
*)
ucidef_set_interface_lan 'eth0'
;;
esac
case "$board" in
friendlyarm,nanopi-r2s)
wan_mac=$(macaddr_random)
lan_mac=$(macaddr_add "$wan_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
2 changes: 2 additions & 0 deletions target/linux/rockchip/armv8/config-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ CONFIG_REGMAP_MMIO=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FAN53555=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_GPIO=y
CONFIG_REGULATOR_PWM=y
CONFIG_REGULATOR_RK808=y
CONFIG_RELOCATABLE=y
Expand Down Expand Up @@ -482,6 +483,7 @@ CONFIG_UNINLINE_SPIN_UNLOCK=y
CONFIG_USB=y
CONFIG_USB_COMMON=y
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_DUAL_ROLE=y
CONFIG_USB_DWC3_HOST=y
CONFIG_USB_DWC3_OF_SIMPLE=y
CONFIG_USB_EHCI_HCD=y
Expand Down
11 changes: 11 additions & 0 deletions target/linux/rockchip/image/armv8.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

define Device/friendlyarm_nanopi-r2s
DEVICE_VENDOR := FriendlyARM
DEVICE_MODEL := NanoPi R2S
SOC := rk3328
UBOOT_DEVICE_NAME := nanopi-r2s-rk3328
IMAGE/sysupgrade.img.gz := boot-common | boot-script nanopi-r2s | pine64-img | gzip | append-metadata
DEVICE_PACKAGES := kmod-usb-net kmod-usb-net-rtl8152
endef
TARGET_DEVICES += friendlyarm_nanopi-r2s

define Device/pine64_rockpro64
DEVICE_VENDOR := Pine64
DEVICE_MODEL := RockPro64
Expand Down
8 changes: 8 additions & 0 deletions target/linux/rockchip/image/nanopi-r2s.bootscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
part uuid mmc ${devnum}:2 uuid

setenv bootargs "console=ttyS2,1500000 earlycon=uart8250,mmio32,0xff130000 root=PARTUUID=${uuid} rw rootwait"

load mmc ${devnum}:1 ${fdt_addr_r} rockchip.dtb
load mmc ${devnum}:1 ${kernel_addr_r} kernel.img

booti ${kernel_addr_r} - ${fdt_addr_r}
Loading

0 comments on commit b7a9a18

Please sign in to comment.