Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
ipq806x: add support for ASRock G10
Browse files Browse the repository at this point in the history
The ASRock G10 is a 2.4/5 GHz band 11ac "Gaming" router,
based on Qualcomm IPQ8064.

Specifications:

SoC:	Qualcomm IPQ8064
CPU:	Dual-Core A15 @ (384 - 1,400 MHz, 2C2T)
DRAM:	512 MiB (~467 MiB available)
NAND:	128 MB (Micron MT29F1G08ABBEAH4)
WLAN0:	4T4R 5 GHz Wlan (QCA9980)
WLAN1:	4T4R 2.4 GHz Wlan (QCA9980)
ETH:    5x 10/100/1000 Mbps Ethernet (QCA8337)
INPUT:  Reset Button, WPS 2.4G and WPS 5G Button
LEDS:   1 multicolor status LED
USB:    2x USB 3.0 Type-A
POWER:  12VDC/3A AC Adapter + dedicated Power Switch
UART:   Setting is 115200-8-N-1. 1x4 .1" unpopulated header
	on the PCB (J6 - very tiny silkscreen next to TX).
        Pinout: 1. 3v3 (Square - best skipped!), 2. RX, 3. GND, 4. TX

WARNING: The serial port needs a TTL/RS-232 3.3v level converter!
	 (Depending on the serial adapter RX and TX might need to
	  be swapped).

Note about the IR-Remote:
There's a 8-Bit MCU (SONIX SN8F25E21SG) which is controlling the
IR-Remote and is fed by the IR-Photodiode. The SoC can talk to
the device via I2C. The vendor's GPL archive comes with the source
of the interface driver for this as a (character driver), the main
control software is however a blob.

Installation Instructions:
 1. Download factory image to disk
 2. Apply factory image via stock web-gui

Back to stock:
 1. Login to router via ssh
 2. run "asrock_g10_back_to_factory" script from /sbin

Notes:
 - If something goes wrong durring sysupgrade, router will go back to
   factory image.
 - Asrock G10 uses partition layout from smem. So partition layout can
   be normal or alternate.
 - 900-arm-add-cmdline-override.patch was copied from 102-powerpc-add-cmdline-override.patch
   from powerpc target.

Knowledge about BOOTCONFIG partition was based on user "jmomo" post from old
OpenWrt forum (Post openwrt#50):
https://forum.archive.openwrt.org/viewtopic.php?id=65956&p=2

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
[bump to 5.4, add factory image, fix sysupgrade, convert partition
layout to smem, remove ipq-wifi-asrock-g10 and use ART, minor fixes]
Co-Authored-by: Pawel Dembicki <paweldembicki@gmail.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Tested-by: Lukasz Ostapiuk <palibrzuch@gmail.com>
  • Loading branch information
2 people authored and ynezz committed Dec 22, 2020
1 parent a65af1c commit af7148a
Show file tree
Hide file tree
Showing 13 changed files with 416 additions and 7 deletions.
9 changes: 5 additions & 4 deletions target/linux/ipq806x/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ board_config_update
board=$(board_name)

case "$board" in
asrock,g10 |\
nec,wg2600hp)
ucidef_add_switch "switch0" \
"2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0"
;;
buffalo,wxr-2533dhp |\
compex,wpq864 |\
netgear,d7800 |\
Expand Down Expand Up @@ -41,10 +46,6 @@ linksys,ea8500)
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
;;
nec,wg2600hp)
ucidef_add_switch "switch0" \
"2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0"
;;
netgear,r7800 |\
tplink,c2600)
ucidef_add_switch "switch0" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ board=$(board_name)
case "$FIRMWARE" in
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
asrock,g10)
caldata_extract "0:ART" 0x1000 0x2f20
;;
buffalo,wxr-2533dhp)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
Expand Down Expand Up @@ -47,6 +50,9 @@ case "$FIRMWARE" in
;;
"ath10k/pre-cal-pci-0001:01:00.0.bin")
case $board in
asrock,g10)
caldata_extract "0:ART" 0x5000 0x2f20
;;
buffalo,wxr-2533dhp)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
Expand Down
8 changes: 8 additions & 0 deletions target/linux/ipq806x/base-files/etc/init.d/bootcount
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

START=99

. /lib/upgrade/asrock.sh

boot() {
case $(board_name) in
asrock,g10)
asrock_bootconfig_mangle "bootcheck"
if [ $? -eq 0 ]; then
reboot
fi
;;
edgecore,ecw5410)
fw_setenv bootcount 0
;;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
. /lib/functions.sh

preinit_set_mac_address() {
case $(board_name) in
asrock,g10)
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address)
ip link set dev eth0 address "${lan_mac}"
ip link set dev eth1 address "${wan_mac}"
;;
esac
}

boot_hook_add preinit_main preinit_set_mac_address
55 changes: 55 additions & 0 deletions target/linux/ipq806x/base-files/lib/upgrade/asrock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
. /lib/functions.sh


asrock_bootconfig_mangle() {
local mtdnum="$( find_mtd_index 0:BOOTCONFIG )"

if [ -z "$mtdnum" ]; then
echo "cannot find bootconfig mtd partition"
return 1
fi
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k

local partition_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
local upgrade_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"

if [ $1 = "bootcheck" ]; then
if [ ! -s $upgrade_byte ]; then
dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
else
return 1
fi
elif [ $1 = "sysupgrade" ]; then
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56
fi

if [ -s $partition_byte ]; then
printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
else
printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52
fi

mtd write /tmp/mtd$mtdnum /dev/mtd$mtdnum
return 0
}

asrock_upgrade_prepare() {
local ubidev="$( nand_find_ubi ubi )"

#Set upgrade flag. If something goes wrong, router will boot with
#factory firmware.
asrock_bootconfig_mangle 'sysupgrade'

if [ $? -ne 0 ]; then
echo "cannot find bootconfig mtd partition"
exit 1
fi

# Just delete these partitions if present and use
# OpenWrt's standard names for those.
ubirmvol /dev/$ubidev -N ubi_rootfs &> /dev/null || true
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
}
4 changes: 4 additions & 0 deletions target/linux/ipq806x/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ platform_check_image() {

platform_do_upgrade() {
case "$(board_name)" in
asrock,g10)
asrock_upgrade_prepare
nand_do_upgrade "$1"
;;
buffalo,wxr-2533dhp)
buffalo_upgrade_prepare_ubi
CI_ROOTPART="ubi_rootfs"
Expand Down
16 changes: 16 additions & 0 deletions target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

. /lib/upgrade/asrock.sh

case $(board_name) in
asrock,g10)
asrock_bootconfig_mangle "factory"
if [ $? -eq 0 ]; then
reboot
fi
;;
*)
echo "Unsupported hardware."
;;
esac

1 change: 1 addition & 0 deletions target/linux/ipq806x/config-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ CONFIG_CC_HAS_KASAN_GENERIC=y
CONFIG_CLKDEV_LOOKUP=y
CONFIG_CLKSRC_QCOM=y
CONFIG_CLONE_BACKWARDS=y
CONFIG_CMDLINE_OVERRIDE=y
CONFIG_COMMON_CLK=y
CONFIG_COMMON_CLK_QCOM=y
CONFIG_COMPAT_32BIT_TIME=y
Expand Down
Loading

0 comments on commit af7148a

Please sign in to comment.