Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ OpenIPC AIO Thinker SSC338Q IMX335 NOR_16M done
OpenIPC AIO UltraSight SSC338Q IMX415 RTL8812AU_USB NOR_16M done
OpenIPC URLLC SSC338Q NOR_16M done
Qtech QVC-IPC-136W HI3518EV200 OV9732 RTL8188EU_USB NOR_16M done
Reolink E340/E1 Zoom NT98566 OS05A10 RTL8812CU_USB NAND testing, hardware IPC_566SD664M5MP (E340 and E1 Zoom, both 5MP; the 4K models are not covered), video-ok, wifi-ok, pan/tilt and zoom/focus ok, autofocus not yet
Rostelecom IPC8232SWC-WE HI3516EV300 SP2305 RTL8188FU_USB NAND done
RunCam WiFiLink SSC338Q IMX415 NOR_16M done
RVi-1NCMW2028 (2.8) HI3516EV300 SC2330 RTL8188FU_USB NAND testing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The board has no crystal for the battery-backed RTC, which runs at about a
# quarter of real time. The DRTC counts while the chip is powered.
CONFIG_DRTC_DRV_NA51055=y
# CONFIG_RTC_DRV_NA51055 is not set
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Architecture
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_ARM_FPU_VFPV3=y
BR2_ARM_INSTRUCTIONS_THUMB2=y

# Toolchain
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/openipc/firmware/releases/download/$(OPENIPC_TOOLCHAIN).tgz"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-openipc-linux-musleabihf"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y

# Kernel
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/openipc/linux/archive/$(OPENIPC_KERNEL).tar.gz"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/nt98566.nand.config"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/nt98566-reolink-ipc-566sd664m5mp.config"
BR2_LINUX_KERNEL_UIMAGE=y
BR2_LINUX_KERNEL_XZ=y

# Filesystem
BR2_PACKAGE_BUSYBOX_CONFIG="$(BR2_EXTERNAL)/package/busybox/busybox.config"
BR2_PACKAGE_DOSFSTOOLS=y
BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y
BR2_PACKAGE_EXFATPROGS=y
BR2_PACKAGE_MTD=y
BR2_PACKAGE_MTD_UBIUTILS=y
BR2_PACKAGE_UBOOT_TOOLS=y
BR2_PACKAGE_ZLIB=y
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
BR2_PACKAGE_WIREGUARD_LINUX_COMPAT=y
BR2_PACKAGE_WIREGUARD_TOOLS=y
BR2_TARGET_ROOTFS_CPIO=y
# 128 MiB SPI NAND, OpenIPC's NAND layout: one UBI partition, volumes rootfs
# (UBIFS, /boot/uImage inside) and rootfs_data (overlay). 128 KiB PEB, 2 KiB page.
BR2_TARGET_ROOTFS_UBI=y
BR2_TARGET_ROOTFS_UBI_SUBSIZE=2048
BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y
BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/ubinize-nand.cfg"
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x1f000

# OpenIPC
BR2_OPENIPC_SOC_VENDOR="novatek"
BR2_OPENIPC_SOC_MODEL="nt98566"
BR2_OPENIPC_SOC_FAMILY="nt9856x"
BR2_OPENIPC_VARIANT="ultimate"
BR2_OPENIPC_FLASH_SIZE="64"

# Packages
BR2_PACKAGE_DROPBEAR_OPENIPC=y
BR2_PACKAGE_EXFAT_OPENIPC=y
BR2_PACKAGE_IPCTOOL=y
BR2_PACKAGE_LAME_OPENIPC=y
BR2_PACKAGE_LIBCURL_OPENIPC=y
BR2_PACKAGE_LIBCURL_OPENIPC_CURL=y
# BR2_PACKAGE_LIBCURL_OPENIPC_PROXY_SUPPORT is not set
# BR2_PACKAGE_LIBCURL_OPENIPC_COOKIES_SUPPORT is not set
# BR2_PACKAGE_LIBCURL_OPENIPC_EXTRA_PROTOCOLS_FEATURES is not set
BR2_PACKAGE_LIBEVENT_OPENIPC=y
BR2_PACKAGE_LIBOGG_OPENIPC=y
BR2_PACKAGE_MAJESTIC_FONTS=y
BR2_PACKAGE_MAJESTIC_WEBUI=y
BR2_PACKAGE_MAJESTIC=y
BR2_PACKAGE_MAJESTIC_AF=y
BR2_PACKAGE_MBEDTLS_OPENIPC=y
BR2_PACKAGE_MOTORS=y
BR2_PACKAGE_NOVATEK_OSDRV_NT9856X=y
BR2_PACKAGE_NOVATEK_OPENSDK=y
BR2_PACKAGE_OPUS_OPENIPC=y
BR2_PACKAGE_OPUS_OPENIPC_FIXED_POINT=y
BR2_PACKAGE_VTUND_OPENIPC=y
BR2_PACKAGE_YAML_CLI=y
BR2_PACKAGE_ZEROTIER_ONE=y

# Reolink IPC_566SD664M5MP: Wi-Fi on a USB RTL8812CU module
BR2_PACKAGE_RTL88X2CU_OPENIPC=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_NL80211=y
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
# Without Ethernet, the camera takes its Wi-Fi network from a QR code held to the
# lens (S97qrscan)
BR2_PACKAGE_QUIRC_OPENIPC=y
BR2_PACKAGE_REOLINK_IPC_566SD664M5MP_BOARD=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Settings for sysupgrade; see OpenIPC/firmware general/overlay/etc/default/sysupgrade.

# The Reolink U-Boot that runs first on every boot looks in `download` for its
# own update blob, which starts with "SPUB". It applies a valid one, and skips
# anything else without touching it, a UBI image included. OpenIPC does not use
# the partition, and at 27.5 MiB it holds the NAND rootfs that the camera's
# 52 MB of Linux RAM cannot hold beside majestic and the Wi-Fi driver.
STAGE_MTD=download
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Pan/tilt head and IR-cut filter: MS32006 on I2C 2. The head has no limit
# switches. It calibrates against its stops at start, and again after 58800 steps
# on an axis (Reolink's threshold), since the count drifts with missed steps.
device=/dev/i2c-2
address=0x10
pan_travel=7360
tilt_travel=1240
calibrate=1
calibrate_after_steps=58800
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Zoom/focus lens: AN41908 on SPI 1 (registered by the
# reolink-ipc-566sd664m5mp-board module), move strobe VD_FZ on GPIO 227, no
# done signal.
spidev=/dev/spidev1.0
spi_mode=3
spi_hz=4000000
hisilicon=0
strobe_gpio=227
zoom_units=16
focus_units=20
zoom_reverse=1
zoom_travel=1044
# The far focus stop is about 1298 steps from the near stop, measured on this
# lens. Reolink's driver config gives 1550, which drives focus into the stop.
focus_travel=1290
zoom_home=wide
# Reolink sells the lens as 2.8-8 mm with 3x optical zoom. Measured on the
# picture, the centre of the frame at the tele stop is 1.88 times its size at
# the wide stop, and the tele stop sits just past zoom_travel.
zoom_mag=1.88
# The zoom gear has about 25 steps of slack. A zoom-out ends 40 steps further
# wide and comes back, so the zoom rests approached from wide, the side the
# track table below was measured from.
zoom_out_overshoot=40
home=1
stop_clear=8
wait_stream=0
# majestic reads no focus statistic from the Novatek ISP yet
autofocus=0
# Focus for a subject 3 m away at each zoom position, measured on this lens.
track=8:872,158:659,308:450,443:313,593:208,750:133,900:92,1044:67
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[MAP]
path_1 = 1 #Path 1 Enable
path_2 = 0 #Path 2 Disable
path_3 = 0 #Path 3 Disable
path_4 = 0 #Path 4 Disable
path_5 = 0 #Path 5 Disable
path_6 = 0 #Path 6 Disable
path_7 = 0 #Path 7 Disable
path_8 = 0 #Path 8 Disable

[PRESET]
id_0_expt_time = 10000 #10000us
id_0_gain_ratio = 1000 #1x gain

[DIRECTION]
id_0_mirror = 1 #mirror
id_0_flip = 0 #no flip

[POWER]
id_0_mclk = 0 #CTL_SEN_CLK_SEL_SIEMCLK
id_0_pwdn_pin = 0xFFFFFFFF #no pwdn pin, C_GPIO:+0x0; P_GPIO:+0x20; S_GPIO:+0x40; L_GPIO:0x60
id_0_rst_pin = 0x41 #S_GPIO_1, C_GPIO:+0x0; P_GPIO:+0x20; S_GPIO:+0x40; L_GPIO:0x60
id_0_rst_time = 1 #1ms
id_0_stable_time = 1 #1ms

[I2C]
id_0_i2c_id = 0 #SEN_I2C_ID_1
id_0_i2c_addr = 0x36 #0x6C >> 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set_gpio() {
[ "$2" -eq 1 ] && gpio set $1 || gpio clear $1
sleep 1
}

# The RTL8812CU is powered from GPIO 133, which the board's U-Boot drives low
if [ "$1" = "rtl88x2cu-nt98566-reolink-ipc-566sd664m5mp" ]; then
set_gpio 133 1
modprobe 88x2cu
exit $?
fi

exit 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
#
# Reolink IPC_566SD664M5MP (E340 5MP, E1 Zoom 5MP), on first boot
#
fw_setenv upgrade 'https://github.com/OpenIPC/builder/releases/download/latest/nt98566_ultimate_reolink-ipc-566sd664m5mp-nand.tgz'
fw_setenv sensor os05a10
fw_setenv wlandev rtl88x2cu-nt98566-reolink-ipc-566sd664m5mp

# The lens drives zoom and focus; the MS32006 head beside it pans, tilts and
# moves the IR-cut filter. Their boards are described in /etc/ms41908.conf and
# /etc/ms32006.conf. The WebUI finds the PTZ backend through ptz_control.
fw_setenv ptz_control ms41908
cli -s .system.plugins true
cli -s .ptz.enabled true
cli -s .ptz.actuator ms41908
cli -s .ptz.head ms32006

# The sensor's 2592x1944 frame, cropped to 4:3 at 2560x1920
cli -s .video0.size 2560x1920
cli -s .video0.crop 16x12x2560x1920
cli -s .video1.size 640x480

cli -s .audio.enabled true
cli -s .audio.outputEnabled true
cli -s .audio.speakerPin 234
cli -s .rtsp.backchannel true

cli -s .nightMode.lightMonitor true
cli -s .nightMode.backlightPin 134

# The factory MAC: Reolink keeps it as text in the sp partition ("CSPS", then
# XML with <TmpMacAddr>). Stored as ethaddr, where the network scripts take it.
sp=$(grep '"sp"' /proc/mtd | cut -d: -f1)
if [ -n "$sp" ]; then
mac=$(nanddump -l 2048 "/dev/$sp" 2>/dev/null | strings |
sed -n 's/.*<TmpMacAddr>\([0-9A-Fa-f:]\{17\}\)<\/TmpMacAddr>.*/\1/p' | head -n 1 | tr 'A-F' 'a-f')
case "$mac" in
[0-9a-f][02468ace]:??:??:??:??:??)
[ "$mac" = 00:00:00:00:00:00 ] || fw_setenv ethaddr "$mac"
;;
esac
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
# Reolink IPC_566SD664M5MP board setup. S30customizer runs this on every boot, before the
# network, the vendor modules and majestic.
#
# The board module (package reolink-ipc-566sd664m5mp-board) holds SP2_CLK, the
# 15 MHz reference the MS32006 pan/tilt driver steps from, and registers the
# AN41908 lens driver on SPI 1 as /dev/spidev1.0. majestic-af drives both
# chips; without the module the head does not move and the lens has no device
# node.
modprobe reolink_ipc_566sd664m5mp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/etc/sensors/imx415.yaml
/etc/sensors/sc401ai.yaml
/etc/sensors/sc430ai.yaml
/etc/sensors/sc501ai.yaml
/etc/sensors/sen_sc200ai.cfg
/etc/sensors/sen_sc2232h.cfg
/etc/sensors/sen_sc2239.cfg
/etc/sensors/sen_sc2335.cfg
/etc/sensors/sen_sc3335.cfg
/etc/sensors/sen_sc401ai.cfg
/etc/sensors/sen_sc4210.cfg
/etc/sensors/sen_sc4238.cfg
/etc/sensors/sen_sc430ai.cfg
/etc/sensors/sen_sc4335p.cfg
/etc/sensors/sen_sc450ai.cfg
/etc/sensors/sen_sc500ai.cfg
/etc/sensors/sen_sc501ai.cfg
/etc/sensors/sen_sc8238.cfg
/etc/sensors/sen_imx415.cfg
#
/etc/sensors/profiles/isp_imx415_0.cfg
/etc/sensors/profiles/isp_imx415_1.cfg
/etc/sensors/profiles/isp_sc2239_0.cfg
/etc/sensors/profiles/isp_sc2239_1.cfg
/etc/sensors/profiles/isp_sc401ai_0.cfg
/etc/sensors/profiles/isp_sc401ai_1.cfg
/etc/sensors/profiles/isp_sc430ai_0.cfg
/etc/sensors/profiles/isp_sc430ai_1.cfg
/etc/sensors/profiles/isp_sc4335p_0.cfg
/etc/sensors/profiles/isp_sc4335p_1.cfg
/etc/sensors/profiles/isp_sc501ai_0.cfg
/etc/sensors/profiles/isp_sc501ai_1.cfg
13 changes: 13 additions & 0 deletions package/reolink-ipc-566sd664m5mp-board/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config BR2_PACKAGE_REOLINK_IPC_566SD664M5MP_BOARD
bool "reolink-ipc-566sd664m5mp-board"
depends on BR2_LINUX_KERNEL
help
Board module for the Reolink IPC_566SD664M5MP (E340 and E1 Zoom,
both 5MP; NT98566). It holds the SP2_CLK reference the pan/tilt
driver (MS32006) steps from, and registers the zoom/focus lens
driver on SPI 1 as spidev, which the device tree from the
Reolink loader does not describe. majestic-af drives both chips
from userspace. The device's muxes.sh loads it at boot.

comment "reolink-ipc-566sd664m5mp-board needs a Linux kernel to be built"
depends on !BR2_LINUX_KERNEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
################################################################################
#
# reolink-ipc-566sd664m5mp-board
#
################################################################################

REOLINK_IPC_566SD664M5MP_BOARD_SITE_METHOD = local
REOLINK_IPC_566SD664M5MP_BOARD_SITE = $(REOLINK_IPC_566SD664M5MP_BOARD_PKGDIR)/src
REOLINK_IPC_566SD664M5MP_BOARD_LICENSE = GPL-2.0

$(eval $(kernel-module))
$(eval $(generic-package))
1 change: 1 addition & 0 deletions package/reolink-ipc-566sd664m5mp-board/src/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-m += reolink_ipc_566sd664m5mp.o
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Reolink IPC_566SD664M5MP (E340 and E1 Zoom, both 5MP; NT98566): the board
* pieces that the device tree from the Reolink loader does not describe. The
* motors are driven from userspace by majestic-af; this module only gives it
* what it cannot set up itself.
*
* - The pan/tilt and IR-cut driver (MS32006 on I2C 2) steps from a 15 MHz
* reference on SP2_CLK. Nothing else claims that clock, so the clock
* framework gates it off at boot; it is held here.
* - The zoom/focus lens driver (AN41908 family) is on SPI 1 with no device
* tree node. It is registered as spidev with the bus settings of the vendor's
* lens driver: mode 3, LSB first, chip select active high.
*/
#include <linux/clk.h>
#include <linux/module.h>
#include <linux/spi/spi.h>

static struct clk *sp2_clk;
static struct spi_device *lens;

static int __init reolink_ipc_566sd664m5mp_init(void)
{
struct spi_board_info info = {
.modalias = "spidev",
.max_speed_hz = 4000000,
.bus_num = 1,
.chip_select = 0,
.mode = SPI_MODE_3 | SPI_LSB_FIRST | SPI_CS_HIGH,
};
struct spi_master *master;
int ret;

sp2_clk = clk_get(NULL, "sp2_clk");
if (IS_ERR(sp2_clk))
return PTR_ERR(sp2_clk);
ret = clk_prepare_enable(sp2_clk);
if (ret)
goto put_clk;

master = spi_busnum_to_master(info.bus_num);
if (!master) {
ret = -ENODEV;
goto disable_clk;
}
lens = spi_new_device(master, &info);
put_device(&master->dev);
if (!lens) {
ret = -ENODEV;
goto disable_clk;
}
return 0;

disable_clk:
clk_disable_unprepare(sp2_clk);
put_clk:
clk_put(sp2_clk);
return ret;
}

static void __exit reolink_ipc_566sd664m5mp_exit(void)
{
spi_unregister_device(lens);
clk_disable_unprepare(sp2_clk);
clk_put(sp2_clk);
}

module_init(reolink_ipc_566sd664m5mp_init);
module_exit(reolink_ipc_566sd664m5mp_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Reolink IPC_566SD664M5MP board: pan/tilt clock and lens on SPI 1");