Skip to content

Commit ba45d60

Browse files
committed
rockchip: add support for Herospeed RV1126 IMX415 Base
The Herospeed RV1126 IMX415 "Base" is an IP camera built on a Rockchip 38x38 V10 EMMC DDR3 board, which is also found in cameras of other makes and is therefore described by a separate dtsi. The stock firmware identifies itself as ONVIF manufacturer "HeroSpeed", firmware family RV1126_IMX415_BASE. This adds the 32-bit armv7 subtarget for the Cortex-A7 based RV11xx SoCs. The camera keeps its stock U-Boot, which boots an Android boot image from one of two boot/system slots. Hardware -------- SoC: Rockchip RV1126, 4x Cortex-A7 RAM: 1 GiB DDR3 Flash: eMMC, 8 GB class, two boot/system slots Ethernet: 1x 10/100 Mbit/s, JL1101 PHY on RMII Sensor: Sony IMX415, 4 lane MIPI CSI-2 RTC: PCF8563 LEDs: white illumination LEDs on one PWM output (V4L2 flash) Buttons: none UART: 1.8 V TTL on UART2, 1500000 baud 8N1, 90-degree JST-SH connector at the bottom edge of the board, facing the edge and hidden underneath the MIPI CSI cable Power: PoE (IEEE 802.3af) or 12 V 1 A DC through the barrel connector on the cable whip Installation ------------ 1. Open the web interface of the stock firmware (192.168.1.168 by default) and log in as admin. 2. Upload openwrt-rockchip-armv7-herospeed_rv1126-imx415-squashfs- factory-RV1126_IMX415.fls on the firmware upgrade page. 3. The camera reboots into OpenWrt at 192.168.1.1. Later upgrades use the sysupgrade image, which is written to the inactive slot. The stock firmware can be restored from OpenWrt with "sysupgrade -F -n" and the original .FLS file. MAC address ----------- eth0 uses the label MAC, stored as MAC=xx:xx:xx:xx:xx:xx in net.conf on the ext4 "param" partition. U-Boot passes a different, derived address to Linux, which is replaced by the stored one. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
1 parent 4c5d026 commit ba45d60

12 files changed

Lines changed: 1345 additions & 1 deletion

File tree

‎target/linux/generic/config-6.18‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ CONFIG_CRYPTO_CTR=y
12301230
# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set
12311231
# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set
12321232
# CONFIG_CRYPTO_DEV_QCE is not set
1233+
# CONFIG_CRYPTO_DEV_ROCKCHIP is not set
1234+
# CONFIG_CRYPTO_DEV_ROCKCHIP_DEBUG is not set
12331235
# CONFIG_CRYPTO_DEV_S5P is not set
12341236
# CONFIG_CRYPTO_DEV_SAFEXCEL is not set
12351237
# CONFIG_CRYPTO_DEV_SAHARA is not set
@@ -3415,8 +3417,10 @@ CONFIG_LDISC_AUTOLOAD=y
34153417
# CONFIG_LDM_PARTITION is not set
34163418
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y
34173419
# CONFIG_LD_HEAD_STUB_CATCH is not set
3420+
# CONFIG_LEDS_AAT1290 is not set
34183421
# CONFIG_LEDS_AN30259A is not set
34193422
# CONFIG_LEDS_APU is not set
3423+
# CONFIG_LEDS_AS3645A is not set
34203424
# CONFIG_LEDS_AW200XX is not set
34213425
# CONFIG_LEDS_AW2013 is not set
34223426
# CONFIG_LEDS_BCM6328 is not set
@@ -3437,9 +3441,11 @@ CONFIG_LEDS_CLASS_MULTICOLOR=y
34373441
# CONFIG_LEDS_IS31FL319X is not set
34383442
# CONFIG_LEDS_IS31FL32XX is not set
34393443
# CONFIG_LEDS_KTD202X is not set
3444+
# CONFIG_LEDS_KTD2692 is not set
34403445
# CONFIG_LEDS_LM3530 is not set
34413446
# CONFIG_LEDS_LM3532 is not set
34423447
# CONFIG_LEDS_LM355x is not set
3448+
# CONFIG_LEDS_LM3601X is not set
34433449
# CONFIG_LEDS_LM3642 is not set
34443450
# CONFIG_LEDS_LM3692X is not set
34453451
# CONFIG_LEDS_LM3697 is not set
@@ -3455,8 +3461,11 @@ CONFIG_LEDS_CLASS_MULTICOLOR=y
34553461
# CONFIG_LEDS_LP8860 is not set
34563462
# CONFIG_LEDS_LP8864 is not set
34573463
# CONFIG_LEDS_LT3593 is not set
3464+
# CONFIG_LEDS_MAX77693 is not set
34583465
# CONFIG_LEDS_MLXCPLD is not set
34593466
# CONFIG_LEDS_MLXREG is not set
3467+
# CONFIG_LEDS_MT6360 is not set
3468+
# CONFIG_LEDS_MT6370_FLASH is not set
34603469
# CONFIG_LEDS_NCP5623 is not set
34613470
# CONFIG_LEDS_NIC78BX is not set
34623471
# CONFIG_LEDS_NS2 is not set
@@ -3467,14 +3476,20 @@ CONFIG_LEDS_CLASS_MULTICOLOR=y
34673476
# CONFIG_LEDS_PCA995X is not set
34683477
# CONFIG_LEDS_PWM is not set
34693478
# CONFIG_LEDS_PWM_MULTICOLOR is not set
3479+
# CONFIG_LEDS_QCOM_FLASH is not set
34703480
# CONFIG_LEDS_REGULATOR is not set
3481+
# CONFIG_LEDS_RT4505 is not set
3482+
# CONFIG_LEDS_RT8515 is not set
3483+
# CONFIG_LEDS_SGM3140 is not set
34713484
# CONFIG_LEDS_SPI_BYTE is not set
34723485
# CONFIG_LEDS_ST1202 is not set
34733486
# CONFIG_LEDS_SUN50I_A100 is not set
3487+
# CONFIG_LEDS_SY7802 is not set
34743488
# CONFIG_LEDS_SYSCON is not set
34753489
# CONFIG_LEDS_TCA6507 is not set
34763490
# CONFIG_LEDS_TI_LMU_COMMON is not set
34773491
# CONFIG_LEDS_TLC591XX is not set
3492+
# CONFIG_LEDS_TPS6131X is not set
34783493
CONFIG_LEDS_TRIGGERS=y
34793494
# CONFIG_LEDS_TRIGGER_ACTIVITY is not set
34803495
# CONFIG_LEDS_TRIGGER_ACTPWR is not set

‎target/linux/rockchip/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
55
BOARD:=rockchip
66
BOARDNAME:=Rockchip
77
FEATURES:=ext4 usb usbgadget gpio fpu rootfs-part boot-part squashfs
8-
SUBTARGETS:=armv8
8+
SUBTARGETS:=armv8 armv7
99

1010
KERNEL_PATCHVER:=6.18
1111

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
. /lib/functions.sh
2+
. /lib/functions/system.sh
3+
. /lib/functions/uci-defaults.sh
4+
5+
herospeed_param_mac_get()
6+
{
7+
local mac part
8+
9+
part=$(find_mmc_part param mmcblk0)
10+
[ -n "$part" ] || return
11+
12+
mkdir -p /tmp/param
13+
mount -t ext4 -o ro,noload "$part" /tmp/param || return
14+
mac=$(sed -n 's/^MAC=//p' /tmp/param/net.conf)
15+
umount /tmp/param
16+
17+
macaddr_canonicalize "$mac"
18+
}
19+
20+
rockchip_setup_interfaces()
21+
{
22+
local board="$1"
23+
24+
case "$board" in
25+
herospeed,rv1126-imx415)
26+
ucidef_set_interface_lan 'eth0'
27+
;;
28+
esac
29+
}
30+
31+
rockchip_setup_macs()
32+
{
33+
local board="$1"
34+
local lan_mac
35+
36+
case "$board" in
37+
herospeed,rv1126-imx415)
38+
lan_mac=$(herospeed_param_mac_get)
39+
;;
40+
esac
41+
42+
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr 'lan' "$lan_mac"
43+
}
44+
45+
board_config_update
46+
board=$(board_name)
47+
rockchip_setup_interfaces "$board"
48+
rockchip_setup_macs "$board"
49+
board_config_flush
50+
51+
exit 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh /etc/rc.common
2+
3+
START=99
4+
5+
boot() {
6+
local slot
7+
8+
. /lib/functions.sh
9+
. /lib/upgrade/rkab.sh
10+
11+
case "$(board_name)" in
12+
herospeed,rv1126-imx415)
13+
slot="$(rkab_slot_current)"
14+
[ -n "$slot" ] && rkab_mark_successful "$slot"
15+
;;
16+
esac
17+
}
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
REQUIRE_IMAGE_METADATA=1
2+
RAMFS_COPY_BIN="tr"
3+
4+
HEROSPEED_FLS_HEADER_LEN=24
5+
HEROSPEED_FLS_ENTRY_LEN=256
6+
HEROSPEED_FLS_ENTRY_MAGIC=74565
7+
8+
herospeed_fls_u32_get() {
9+
local bytes
10+
11+
bytes="$(dd if="$1" bs=1 skip="$2" count=4 2>/dev/null |
12+
hexdump -v -e '1/1 "%u "')"
13+
set -- $bytes
14+
echo $(($1 | ($2 << 8) | ($3 << 16) | ($4 << 24)))
15+
}
16+
17+
herospeed_fls_str_get() {
18+
dd if="$1" bs=1 skip="$2" count="$3" 2>/dev/null | tr -d '\000'
19+
}
20+
21+
herospeed_fls_entry_pos() {
22+
echo $((HEROSPEED_FLS_HEADER_LEN + HEROSPEED_FLS_ENTRY_LEN * $1))
23+
}
24+
25+
herospeed_fls_match() {
26+
[ "$(wc -c < "$1")" -ge "$HEROSPEED_FLS_HEADER_LEN" ] || return 1
27+
[ "$(herospeed_fls_str_get "$1" 0 8)" = RV1126 ] || return 1
28+
[ "$(herospeed_fls_str_get "$1" 8 8)" = IMX415 ]
29+
}
30+
31+
herospeed_part_size() {
32+
echo $(($(cat "/sys/class/block/${1##*/}/size") * 512))
33+
}
34+
35+
herospeed_fls_check_image() {
36+
local file="$1" size count i pos name len offset other part
37+
local have_boot= have_system=
38+
39+
[ "$#" -gt 1 ] && return 1
40+
size="$(wc -c < "$file")"
41+
[ "$(herospeed_fls_u32_get "$file" 16)" -eq "$size" ] || return 1
42+
count="$(herospeed_fls_u32_get "$file" 20)"
43+
[ "$count" -gt 0 ] || return 1
44+
[ $((HEROSPEED_FLS_HEADER_LEN + HEROSPEED_FLS_ENTRY_LEN * count)) \
45+
-le "$size" ] || return 1
46+
other="$(rkab_slot_other "$(rkab_slot_current)")"
47+
[ -n "$other" ] || other=a
48+
49+
i=0
50+
while [ "$i" -lt "$count" ]; do
51+
pos="$(herospeed_fls_entry_pos "$i")"
52+
name="$(herospeed_fls_str_get "$file" "$pos" 128)"
53+
len="$(herospeed_fls_u32_get "$file" $((pos + 128)))"
54+
offset="$(herospeed_fls_u32_get "$file" $((pos + 132)))"
55+
i=$((i + 1))
56+
57+
[ "$(herospeed_fls_u32_get "$file" $((pos + 140)))" -eq \
58+
"$HEROSPEED_FLS_ENTRY_MAGIC" ] || return 1
59+
[ $((offset + len)) -le "$size" ] || return 1
60+
61+
case "$name" in
62+
uboot)
63+
;;
64+
boot|system)
65+
part="$(find_mmc_part "${name}_$other" "$RKAB_DISK")"
66+
[ -n "$part" ] || return 1
67+
[ "$len" -le "$(herospeed_part_size "$part")" ] || {
68+
echo "FLS entry $name does not fit $part" >&2
69+
return 1
70+
}
71+
[ "$name" = boot ] && have_boot=1
72+
[ "$name" = system ] && have_system=1
73+
;;
74+
/var/cfg/*)
75+
case "$name" in
76+
*..*) return 1 ;;
77+
esac
78+
;;
79+
*)
80+
echo "unsupported FLS entry $name" >&2
81+
return 1
82+
;;
83+
esac
84+
done
85+
86+
[ -n "$have_boot" ] && [ -n "$have_system" ]
87+
}
88+
89+
herospeed_fls_entry_write() {
90+
local file="$1" name="$2" dest="$3" count i pos
91+
92+
count="$(herospeed_fls_u32_get "$file" 20)"
93+
i=0
94+
while [ "$i" -lt "$count" ]; do
95+
pos="$(herospeed_fls_entry_pos "$i")"
96+
i=$((i + 1))
97+
[ "$(herospeed_fls_str_get "$file" "$pos" 128)" = "$name" ] ||
98+
continue
99+
dd if="$file" of="$dest" bs=1M iflag=skip_bytes,count_bytes \
100+
skip="$(herospeed_fls_u32_get "$file" $((pos + 132)))" \
101+
count="$(herospeed_fls_u32_get "$file" $((pos + 128)))" \
102+
2>/dev/null
103+
return $?
104+
done
105+
return 1
106+
}
107+
108+
herospeed_fls_var_install() {
109+
local file="$1" dev mnt=/tmp/herospeed-var count i pos name dest
110+
111+
dev="$(find_mmc_part var "$RKAB_DISK")"
112+
[ -n "$dev" ] || return 1
113+
mkdir -p "$mnt"
114+
mount -t ext4 "$dev" "$mnt" || return 1
115+
116+
count="$(herospeed_fls_u32_get "$file" 20)"
117+
i=0
118+
while [ "$i" -lt "$count" ]; do
119+
pos="$(herospeed_fls_entry_pos "$i")"
120+
i=$((i + 1))
121+
name="$(herospeed_fls_str_get "$file" "$pos" 128)"
122+
case "$name" in
123+
/var/cfg/*) ;;
124+
*) continue ;;
125+
esac
126+
dest="$mnt/${name#/var/}"
127+
mkdir -p "${dest%/*}"
128+
herospeed_fls_entry_write "$file" "$name" "$dest" || {
129+
umount "$mnt"
130+
return 1
131+
}
132+
chmod 0755 "$dest"
133+
done
134+
135+
sync
136+
umount "$mnt"
137+
}
138+
139+
herospeed_fls_do_upgrade() {
140+
local file="$1" other kern root
141+
142+
other="$(rkab_slot_other "$(rkab_slot_current)")"
143+
[ -n "$other" ] || other=a
144+
kern="$(find_mmc_part "boot_$other" "$RKAB_DISK")"
145+
root="$(find_mmc_part "system_$other" "$RKAB_DISK")"
146+
147+
[ -n "$kern" ] && [ -n "$root" ] || return 1
148+
dd if=/dev/zero of="$kern" bs=512 count=8 2>/dev/null || return 1
149+
sync
150+
herospeed_fls_entry_write "$file" system "$root" || return 1
151+
sync
152+
herospeed_fls_entry_write "$file" boot "$kern" || return 1
153+
sync
154+
herospeed_fls_var_install "$file" || return 1
155+
rkab_mark_active "$other"
156+
}
157+
158+
herospeed_ab_check_image() {
159+
local members
160+
161+
herospeed_fls_match "$1" && {
162+
herospeed_fls_check_image "$@"
163+
return $?
164+
}
165+
166+
[ "$#" -gt 1 ] && return 1
167+
members="$(tar tf "$1" 2>/dev/null)" || return 1
168+
echo "$members" | grep -q '^sysupgrade-[^/]*/kernel$' || return 1
169+
echo "$members" | grep -q '^sysupgrade-[^/]*/root$' || return 1
170+
return 0
171+
}
172+
173+
herospeed_ab_do_upgrade() {
174+
local slot other
175+
176+
herospeed_fls_match "$1" && {
177+
herospeed_fls_do_upgrade "$1"
178+
return $?
179+
}
180+
181+
slot="$(rkab_slot_current)"
182+
other="$(rkab_slot_other "$slot")"
183+
[ -n "$other" ] || other=a
184+
CI_ROOTDEV="$RKAB_DISK"
185+
CI_KERNPART="boot_$other"
186+
CI_ROOTPART="system_$other"
187+
emmc_do_upgrade "$1"
188+
rkab_mark_active "$other"
189+
}
190+
191+
platform_check_image() {
192+
local board=$(board_name)
193+
194+
case "$board" in
195+
herospeed,rv1126-imx415)
196+
herospeed_ab_check_image "$@"
197+
return $?
198+
;;
199+
*)
200+
return 1
201+
;;
202+
esac
203+
}
204+
205+
platform_do_upgrade() {
206+
local board=$(board_name)
207+
208+
case "$board" in
209+
herospeed,rv1126-imx415)
210+
herospeed_ab_do_upgrade "$1"
211+
;;
212+
*)
213+
default_do_upgrade "$1"
214+
;;
215+
esac
216+
}
217+
218+
platform_copy_config() {
219+
local board=$(board_name)
220+
221+
case "$board" in
222+
herospeed,rv1126-imx415)
223+
emmc_copy_config
224+
;;
225+
esac
226+
}

0 commit comments

Comments
 (0)