Add support for opirv2

This commit is contained in:
baiywt 2024-12-02 13:58:41 +08:00
parent 161170a67d
commit c5b3b1df70
39 changed files with 12973 additions and 13 deletions

Binary file not shown.

Binary file not shown.

View File

@ -63,6 +63,7 @@ function main(){
[[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "current" ]] && OVERLAYDIR="/boot/dtb/sunxi/overlay"; [[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "current" ]] && OVERLAYDIR="/boot/dtb/sunxi/overlay";
[[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "next" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay"; [[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "next" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
[[ "$LINUXFAMILY" == "rockchip-rk356x" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay"; [[ "$LINUXFAMILY" == "rockchip-rk356x" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay";
[[ "$LINUXFAMILY" == "ky" ]] && OVERLAYDIR="/boot/dtb/ky/overlay";
# detect desktop # detect desktop
check_desktop check_desktop
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Orange Pi configuration utility ... " 5 45 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Orange Pi configuration utility ... " 5 45

View File

@ -0,0 +1,8 @@
BOARD_NAME="Orange Pi R2S"
BOARDFAMILY="ky"
BOOTCONFIG="x1_defconfig"
KERNEL_TARGET="current"
SKIP_BOOTSPLASH="yes" # Skip boot splash patch, conflicts with CONFIG_VT=yes
BOOT_FDT_FILE="ky/x1_orangepi-r2s.dtb"
DISTRIB_TYPE_CURRENT="noble"
REVISION="1.0.0"

View File

@ -0,0 +1,9 @@
BOARD_NAME="Orange Pi RV2"
BOARDFAMILY="ky"
BOOTCONFIG="x1_defconfig"
MODULES="bcmdhd"
KERNEL_TARGET="current"
SKIP_BOOTSPLASH="yes" # Skip boot splash patch, conflicts with CONFIG_VT=yes
BOOT_FDT_FILE="ky/x1_orangepi-rv2.dtb"
DISTRIB_TYPE_CURRENT="noble"
REVISION="1.0.0"

2
external/config/bootenv/ky.txt vendored Normal file
View File

@ -0,0 +1,2 @@
verbosity=1
bootlogo=false

57
external/config/bootscripts/boot-ky.cmd vendored Normal file
View File

@ -0,0 +1,57 @@
# DO NOT EDIT THIS FILE
#
# Please edit /boot/orangepiEnv.txt to set supported parameters
#
setenv load_addr "0x9000000"
setenv overlay_error "false"
# default values
setenv verbosity "1"
setenv console "both"
setenv bootlogo "false"
setenv rootfstype "ext4"
setenv docker_optimizations "on"
setenv earlycon "on"
echo "Boot script loaded from ${devtype} ${devnum}"
#if test -e ${devtype} ${devnum} ${prefix}orangepiEnv.txt; then
load ${devtype} ${devnum} ${load_addr} ${prefix}orangepiEnv.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 "console=ttyS0,115200 ${consoleargs}"; fi
if test "${earlycon}" = "on"; then setenv consoleargs "earlycon=sbi ${consoleargs}"; fi
if test "${bootlogo}" = "true"; then setenv consoleargs "bootsplash.bootfile=bootsplash.orangepi ${consoleargs}"; fi
setenv bootargs "mtdparts=${mtdparts} root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} clk_ignore_unused swiotlb=65536 workqueue.default_affinity_scope=system 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 rm /soc/lcd_backlight phandle
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/ky/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
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
# Recompile with:
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

41
external/config/cli/noble/main/packages vendored Executable file → Normal file
View File

@ -1,21 +1,44 @@
alsa-utils
bash-completion
bc bc
chrony chrony
cpufrequtils console-setup
debconf-utils cron
device-tree-compiler curl
dbus-user-session
dialog dialog
debconf-utils
debsums
dosfstools
fake-hwclock fake-hwclock
fdisk
figlet figlet
fping htop
iputils-ping
init
initramfs-tools
iproute2
iw
jq
logrotate
less
linux-base
lsof
man-db
mmc-utils
ncurses-term ncurses-term
nocache nano
openssh-server openssh-server
parted parted
psmisc psmisc
python3-apt rsync
smartmontools rsyslog
sysfsutils sudo
systemd-resolved
toilet toilet
tzdata
u-boot-tools u-boot-tools
usbutils usbutils
python-is-python3 wget
wireguard-tools
wpasupplicant

View File

@ -0,0 +1,2 @@
debsums
cracklib-runtime

View File

@ -0,0 +1,58 @@
anacron
apt-xapian-index
at-spi2-core
colord
cups
dbus-x11
dmz-cursor-theme
dconf-cli
eject
foomatic-db-compressed-ppds
fonts-noto-cjk
fonts-ubuntu
fonts-ubuntu-console
gdebi
gnome-control-center
gnome-disk-utility
gnome-desktop3-data
gnome-keyring
gnome-menus
gnome-screenshot
gnome-disk-utility
gnome-system-monitor
gnome-terminal
gnome-packagekit
gnome-session
gnome-shell
gnome-shell-extension-appindicator
gvfs-backends
inputattach
libnotify-bin
gdm3
lm-sensors
nautilus
nautilus-extension-gnome-terminal
pavucontrol
printer-driver-all
profile-sync-daemon
pulseaudio
pulseaudio-module-bluetooth
software-properties-gtk
synaptic
system-config-printer
terminator
tracker
tracker-extract
tracker-miner-fs
upower
x11-apps
x11-session-utils
x11-utils
x11-xserver-utils
xarchiver
xdg-user-dirs
xdg-user-dirs-gtk
xfonts-base
xserver-xorg
xwayland
zenity

View File

@ -0,0 +1,52 @@
# overwrite stock lightdm greeter configuration
if [ -d /etc/orangepi/lightdm ]; then cp -R /etc/orangepi/lightdm /etc/; fi
if [ -f /etc/lightdm/slick-greeter.conf ]; then sed -i 's/orangepi-lightdm\/orangepi-default.png/warty-final-ubuntu.png/g' /etc/lightdm/slick-greeter.conf; fi
if [ -f /etc/lightdm/lightdm.conf.d/11-orangepi.conf ]; then sed -i "s/user-session.*/user-session=gnome-wayland/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf; fi
# Disable Pulseaudio timer scheduling which does not work with sndhdmi driver
if [ -f /etc/pulse/default.pa ]; then sed "s/load-module module-udev-detect$/& tsched=0/g" -i /etc/pulse/default.pa; fi
# set wallpapper to armbian
keys=/etc/dconf/db/local.d/00-bg
profile=/etc/dconf/profile/user
install -Dv /dev/null $keys
install -Dv /dev/null $profile
# set default shortcuts
echo "
[org/gnome/shell]
favorite-apps = ['terminator.desktop', 'org.gnome.Nautilus.desktop', 'chromium-browser.desktop', 'thunderbird.desktop', 'code.desktop', 'Zoom.desktop']
[org/gnome/settings-daemon/plugins/power]
sleep-inactive-ac-timeout='0'
sleep-inactive-ac-type='nothing'
sleep-inactive-battery-timeout='0'
sleep-inactive-battery-type='nothing'
power-button-action='interactive'
[org/gnome/desktop/session]
idle-delay=uint32 0
[org/gnome/desktop/background]
picture-uri='file:///usr/share/backgrounds/orangepi/orangepi-default.png'
picture-options='zoom'
primary-color='#456789'
secondary-color='#FFFFFF'
[org/gnome/desktop/screensaver]
picture-uri='file:///usr/share/backgrounds/orangepi/orangepi-default.png'
picture-options='zoom'
primary-color='#456789'
secondary-color='#FFFFFF'" >> $keys
echo "user-db:user
system-db:local" >> $profile
dconf update
#compile schemas
if [ -d /usr/share/glib-2.0/schemas ]; then
glib-compile-schemas /usr/share/glib-2.0/schemas
fi

View File

@ -0,0 +1,164 @@
# install lightdm greeter
cp -R "${EXTER}"/packages/blobs/desktop/lightdm "${destination}"/etc/orangepi
# install default desktop settings
mkdir -p "${destination}"/etc/skel
cp -R "${EXTER}"/packages/blobs/desktop/skel/. "${destination}"/etc/skel
#install cinnamon desktop bar icons
mkdir -p "${destination}"/usr/share/icons/orangepi
cp "${EXTER}"/packages/blobs/desktop/desktop-icons/*.png "${destination}"/usr/share/icons/orangepi
# install wallpapers
mkdir -p "${destination}"/usr/share/backgrounds/orangepi/
cp "${EXTER}"/packages/blobs/desktop/desktop-wallpapers/*.png "${destination}"/usr/share/backgrounds/orangepi
# install wallpapers
mkdir -p "${destination}"/usr/share/backgrounds/orangepi-lightdm/
cp "${EXTER}"/packages/blobs/desktop/lightdm-wallpapers/*.png "${destination}"/usr/share/backgrounds/orangepi-lightdm
# install logo for login screen
mkdir -p "${destination}"/usr/share/pixmaps/orangepi
cp "${EXTER}"/packages/blobs/desktop/icons/orangepi.png "${destination}"/usr/share/pixmaps/orangepi
#generate wallpaper list for background changer
mkdir -p "${destination}"/usr/share/gnome-background-properties
cat <<EOF > "${destination}"/usr/share/gnome-background-properties/orangepi.xml
<?xml version="1.0"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>OrangePi black-pyscho</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi bluie-circle</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi blue-monday</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi blue-penguin</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi gray-resultado</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi green-penguin</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi green-retro</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi green-wall-penguin</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi 4k-neglated</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi neon-gray-penguin</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi plastic-love</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi purple-penguine</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi purplepunk-resultado</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi red-penguin-dark</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi red-penguin</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi light</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi dark</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi uc</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
<wallpaper deleted="false">
<name>OrangePi clear</name>
<filename>/usr/share/backgrounds/orangepi/orangepi-default.png</filename>
<options>zoom</options>
<pcolor>#ffffff</pcolor>
<scolor>#000000</scolor>
</wallpaper>
</wallpapers>
EOF

View File

@ -0,0 +1 @@
supported

File diff suppressed because it is too large Load Diff

103
external/config/sources/families/ky.conf vendored Normal file
View File

@ -0,0 +1,103 @@
ARCH="riscv64"
LINUXCONFIG="linux-ky-${BRANCH}"
LINUXFAMILY="ky"
SERIALCON="ttyS0"
BOOTSCRIPT='boot-ky.cmd:boot.cmd'
BOOTENV_FILE='ky.txt'
KERNEL_COMPILER='riscv64-unknown-linux-gnu-'
UBOOT_COMPILER='riscv64-unknown-linux-gnu-'
OVERLAY_PREFIX='x1'
OFFSET=30
case "${BRANCH}" in
current)
BOOTBRANCH='branch:v2022.10-ky'
KERNELBRANCH="branch:orange-pi-6.6-ky"
KERNELPATCHDIR="ky-${BRANCH}"
UBOOT_TARGET_MAP=";;bootinfo_sd.bin bootinfo_emmc.bin bootinfo_spinor.bin FSBL.bin u-boot-env-default.bin u-boot-opensbi.itb"
;;
esac
uboot_custom_postprocess()
{
:
}
write_uboot_platform()
{
if [[ -b "${2}boot0" ]]; then
echo 0 > /sys/block/${2##*/}boot0/force_ro
dd if=${1}/bootinfo_emmc.bin of=${2}boot0 >/dev/null 2>&1 && sync
dd if=${1}/FSBL.bin of=${2}boot0 seek=512 bs=1 >/dev/null 2>&1 && sync
echo 1 > /sys/block/${2##*/}boot0/force_ro
fi
dd if=$1/bootinfo_sd.bin of=$2 seek=0 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/FSBL.bin of=$2 seek=256 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/u-boot-env-default.bin of=$2 seek=768 conv=notrunc status=none >/dev/null 2>&1
dd if=$1/u-boot-opensbi.itb of=$2 seek=1664 conv=notrunc status=none >/dev/null 2>&1
}
write_uboot_platform_mtd()
{
if [[ -b /dev/mtdblock0 ]]; then
dd if=$1/bootinfo_spinor.bin of=/dev/mtdblock0 >/dev/null 2>&1 && sync
dd if=$1/FSBL.bin of=/dev/mtdblock2 seek=0 bs=1 >/dev/null 2>&1 && sync
dd if=$1/u-boot-env-default.bin of=/dev/mtdblock3 seek=0 bs=1 >/dev/null 2>&1 && sync
dd if=$1/u-boot-opensbi.itb of=/dev/mtdblock5 seek=0 bs=1K >/dev/null 2>&1 && sync
fi
}
family_tweaks()
{
rsync -a --chown=root:root "${EXTER}"/packages/bsp/ky/* ${SDCARD}/
run_on_sdcard "DEBIAN_FRONTEND=noninteractive apt-get install -y gdisk dnsmasq util-linux-extra smartmontools can-utils v4l-utils cmake python3-pip"
if [[ ${DESKTOP_ENVIRONMENT} == gnome ]]; then
run_on_sdcard "DEBIAN_FRONTEND=noninteractive apt-get install -y gnome-screenshot tightvncserver gnome-bluetooth"
sed -i 's/# *AutomaticLoginEnable = true/AutomaticLoginEnable = true/' ${SDCARD}/etc/gdm3/custom.conf
sed -i 's/# *AutomaticLogin = user1/AutomaticLogin = orangepi/' ${SDCARD}/etc/gdm3/custom.conf
echo -e "\n[Install]\nWantedBy=multi-user.target" >> ${SDCARD}/lib/systemd/system/gdm3.service
#cp $EXTER/packages/blobs/desktop/desktop-wallpapers/orangepi-default.png ${SDCARD}/usr/share/backgrounds/warty-final-ubuntu.png
fi
if [[ $RELEASE == noble && ${SELECTED_CONFIGURATION} == desktop ]]; then
local packages_to_install
packages_to_install_common=("ddk" "camera" "mpp")
packages_to_install=("mesa" "glmark2" "gst" "ffmpeg" "mpv")
packages_to_install+=("libv4l" "chromium" "npu" "docker" "adbd" "gnome")
run_on_sdcard "DEBIAN_FRONTEND=noninteractive apt-get install -y vlc fonts-liberation libu2f-udev xdg-utils"
for package in ${packages_to_install_common[@]}; do
dpkg_install_debs_chroot $EXTER/cache/sources/ky_packages/common/$package
done
for package in ${packages_to_install[@]}; do
dpkg_install_debs_chroot $EXTER/cache/sources/ky_packages/$RELEASE/$package
done
rm $SDCARD/root/*.deb >/dev/null 2>&1
fi
if [[ $BUILD_DESKTOP == yes ]]; then
sed -i "s/auto-profiles = yes/auto-profiles = no/" ${SDCARD}/usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf
echo "load-module module-alsa-sink device=hw:0,0 sink_name=HDMI-Playback sink_properties=\"device.description='HDMI Audio'\"" >> ${SDCARD}/etc/pulse/default.pa
echo "load-module module-alsa-sink device=hw:1,0 sink_name=AudioCodec-Playback sink_properties=\"device.description='Audio Codec'\"" >> ${SDCARD}/etc/pulse/default.pa
echo "set-default-sink HDMI-Playback" >> ${SDCARD}/etc/pulse/default.pa
fi
if [[ "${BOARD}x" == orangepirv2x ]]; then
nvram=$EXTER/cache/sources/orangepi-firmware-git
[[ -f ${nvram}/nvram_ap6256.txt-$BOARD ]] && cp ${nvram}/nvram_ap6256.txt-${BOARD} ${SDCARD}/lib/firmware/nvram_ap6256.txt
fi
chroot "${SDCARD}" /bin/bash -c "sudo usermod -aG docker ${OPI_USERNAME}"
install_wiringop
}

View File

@ -10,6 +10,8 @@ ARCH="riscv64"
LINUXCONFIG="linux-starfive2-${BRANCH}" LINUXCONFIG="linux-starfive2-${BRANCH}"
LINUXFAMILY="starfive2" LINUXFAMILY="starfive2"
IMAGE_PARTITION_TABLE='gpt'
SKIP_EXTERNAL_TOOLCHAINS='yes'
SRC_CMDLINE="console=tty0 console=ttyS0,115200 earlycon rootwait" SRC_CMDLINE="console=tty0 console=ttyS0,115200 earlycon rootwait"
SERIALCON="ttyS0" SERIALCON="ttyS0"

View File

@ -12,8 +12,6 @@ ARCH='riscv64'
ARCHITECTURE='riscv' ARCHITECTURE='riscv'
KERNEL_SRC_ARCH='riscv' KERNEL_SRC_ARCH='riscv'
QEMU_BINARY='qemu-riscv64-static' QEMU_BINARY='qemu-riscv64-static'
IMAGE_PARTITION_TABLE='gpt'
SKIP_EXTERNAL_TOOLCHAINS='yes'
GIT_SERVER="https://github.com/orangepi-xunlong" GIT_SERVER="https://github.com/orangepi-xunlong"
KERNEL_IMAGE_TYPE="Image" KERNEL_IMAGE_TYPE="Image"

View File

@ -0,0 +1 @@
15c8eb90a4ba8139a034149e6fd74528 ky-toolchain-linux-glibc-x86_64-v1.0.1.tar.xz

View File

@ -0,0 +1 @@
15c8eb90a4ba8139a034149e6fd74528

View File

@ -413,6 +413,19 @@ prepare_board() {
/opt/media-ctl-pipeline.sh -d /dev/media0 -i csiphy0 -s ISP0 -a start /opt/media-ctl-pipeline.sh -d /dev/media0 -i csiphy0 -s ISP0 -a start
/opt/ISP/stf_isp_ctrl -m imx219mipi -j 0 -a 1 & /opt/ISP/stf_isp_ctrl -m imx219mipi -j 0 -a 1 &
;; ;;
orangepirv2)
rfkill unblock all
/usr/bin/brcm_patchram_plus --enable_hci --no2bytes --tosleep 200000 \
--baudrate 1500000 --patchram /lib/firmware/BCM4345C5.hcd /dev/ttyS2 &
;;
orangepir2s)
echo ff > /sys/class/net/enP2p1s0/queues/rx-0/rps_cpus
echo ff > /sys/class/net/enP1p1s0/queues/rx-0/rps_cpus
echo 4096 > /sys/class/net/enP2p1s0/queues/rx-0/rps_flow_cnt
echo 4096 > /sys/class/net/enP1p1s0/queues/rx-0/rps_flow_cnt
;;
esac esac

View File

@ -31,7 +31,7 @@ elif grep -q 'sun5i' /proc/cpuinfo; then DEVICE_TYPE="a13";
else DEVICE_TYPE="a20"; fi else DEVICE_TYPE="a20"; fi
BOOTLOADER="${CWD}/${DEVICE_TYPE}/bootloader" BOOTLOADER="${CWD}/${DEVICE_TYPE}/bootloader"
case ${LINUXFAMILY} in case ${LINUXFAMILY} in
rk3328|rk3399|rockchip64) rk3328|rk3399|rockchip64|rockchip-rk356x|rockchip-rk3588|ky)
FIRSTSECTOR=32768 FIRSTSECTOR=32768
;; ;;
*) *)

View File

@ -0,0 +1,8 @@
#!/bin/sh
# Copy firmware file to initrd
#
mkdir -p "${DESTDIR}"/lib/firmware
cp -rf /lib/firmware/esos.elf "${DESTDIR}"/lib/firmware
exit 0

View File

@ -0,0 +1,69 @@
{
"tuning_server_enable":1,
"show_fps":1,
"auto_run": 1,
"cpp_node": [
{
"name": "cpp0",
"enable": 1,
"format":"NV12",
"src_from_file": 1,
"src_path":"/tmp/cpp_case_in_data/1920x1080/",
"size_width":1920,
"size_height":1080,
},
{
"name": "cpp1",
"enable": 0,
"format":"NV12",
"src_from_file": 0,
"src_path":"/vendor/etc/camera/",
"size_width":1920,
"size_height":1080,
},
],
"isp_node":[
{
"name": "isp0",
"enable": 1,
"work_mode":"online",
"format":"NV12",
"out_width":1920,
"out_height":1080,
"sensor_name":"ov13855_spm",
"sensor_id" : 0,
"sensor_work_mode":0,
"fps":30,
"src_file":"/tmp/1920x1080_raw12_long_packed.vrf",
"bit_depth": 12,
"in_width":1920,
"in_height":1080,
},
{
"name": "isp1",
"enable": 0,
"work_mode":"offline_capture",
"format":"NV12",
"out_width":1600,
"out_height":1200,
"src_file":"/tmp/1920x1080_raw12_long_packed.vrf",
"bit_depth": 12,
"in_width":1920,
"in_height":1080,
"sensor_name":"gc2375h_spm",
"sensor_id" : 1,
"sensor_work_mode":0,
"fps":30,
},
]
}

View File

@ -0,0 +1,69 @@
{
"tuning_server_enable":1,
"show_fps":1,
"auto_run": 1,
"cpp_node": [
{
"name": "cpp0",
"enable": 1,
"format":"NV12",
"src_from_file": 1,
"src_path":"/tmp/cpp_case_in_data/1920x1080/",
"size_width":1920,
"size_height":1080,
},
{
"name": "cpp1",
"enable": 0,
"format":"NV12",
"src_from_file": 0,
"src_path":"/vendor/etc/camera/",
"size_width":1920,
"size_height":1080,
},
],
"isp_node":[
{
"name": "isp0",
"enable": 1,
"work_mode":"online",
"format":"NV12",
"out_width":1920,
"out_height":1080,
"sensor_name":"ov13855_spm",
"sensor_id" : 2,
"sensor_work_mode":0,
"fps":30,
"src_file":"/tmp/1920x1080_raw12_long_packed.vrf",
"bit_depth": 12,
"in_width":1920,
"in_height":1080,
},
{
"name": "isp1",
"enable": 0,
"work_mode":"offline_capture",
"format":"NV12",
"out_width":1600,
"out_height":1200,
"src_file":"/tmp/1920x1080_raw12_long_packed.vrf",
"bit_depth": 12,
"in_width":1920,
"in_height":1080,
"sensor_name":"gc2375h_spm",
"sensor_id" : 1,
"sensor_work_mode":0,
"fps":30,
},
]
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,852 @@
#!/bin/bash
# In busybox ash, should use /bin/sh, but bianbu cannot use /bin/sh
name=`basename $0`
SCRIPT_VERSION="v0.5-SUPPORTROLESW"
CONFIG_FILE=$HOME/.usb_config
# USB Descriptors
VENDOR_ID="0x361c"
PRODUC_ID="0x0007"
MANUAF_STR="Ky"
PRODUC_STR="Ky Composite Device"
SERNUM_STR="20211102"
SN_PATH="/proc/device-tree/serial-number"
[ "$BOARD_SN" ] || BOARD_SN=$( [ -e $SN_PATH ] && tr -d '\000' < $SN_PATH )
[ "$BOARD_SN" ] && SERNUM_STR=$BOARD_SN
CONFIGFS=/sys/kernel/config
GADGET_PATH=$CONFIGFS/usb_gadget/ky
GFUNC_PATH=$GADGET_PATH/functions
GCONFIG=$GADGET_PATH/configs/c.1
[ "$USB_UDC" ] || USB_UDC=$(ls /sys/class/udc | awk "NR==1{print}")
# MSC Debug Ramdisk
RAMDISK_PATH=/var/sdcard
TMPFS_FOUND=`mount | grep tmpfs | grep -v devtmpfs | awk '{print $3}' | grep '/dev/shm' | wc -l`
[ "$TMPFS_FOUND" -eq 1 ] && RAMDISK_PATH=/dev/shm/sdcard
TMPFS_FOUND=`mount | grep tmpfs | grep -v devtmpfs | awk '{print $3}' | grep '/tmp' | wc -l`
[ "$TMPFS_FOUND" -eq 1 ] && RAMDISK_PATH=/tmp/sdcard
# SCSI Target
NAA="naa.6001405c3214b06a"
CORE_DIR=$CONFIGFS/target/core
USB_GDIR=$CONFIGFS/target/usb_gadget
# Global variables to record configured functions
MSC=disabled
UAS=disabled
UAS_ARG=""
MSC_ARG=""
ADB=disabled
UVC=disabled
RNDIS=disabled
FUNCTION_CNT=0
DEBUG=
usage()
{
echo "$name usage: "
echo ""
echo -e "Support Select functions in $CONFIG_FILE:"
echo -e "\tWrite <func>:<arg> line in $CONFIG_FILE, then run:"
echo -e "\t$name [start|stop|reload|config]"
echo -e "Or Select functions manually:"
echo -e "\t$name <function1>(,<function2>...)"
echo -e "Set USB connection:"
echo -e "\t$name [pause|resume]"
echo -e "\n$name info: show gadget info"
echo -e "\nhint: udc is automatically selected, you can"
echo -e "\toverride udc with env USB_UDC_IDX=[integer]/USB_UDC=[str]"
echo -e "Set USB role-switch:"
echo -e "\t$name role <rolesw-name> [host|device]"
echo ""
echo "Functions and arguments supported:"
echo -e "\tmsc(:dev/file) Mass Storage(Bulk-Only)."
echo -e "\tuas(:dev/file) Mass Storage(UASP)."
echo -e "\tadb Android Debug Bridge over USB."
echo -e "\tuvc Webcam."
echo -e "\trndis RNDIS NIC function."
echo -e "\nKy gadget-setup tool $SCRIPT_VERSION"
echo ""
}
gadget_info()
{
echo "$name: $1"
}
gadget_debug()
{
[ $DEBUG ] && echo "$name: $1"
}
die()
{
gadget_info "$1"
exit 1
}
g_remove()
{
[ -h $1 ] && rm -f $1
[ -d $1 ] && rmdir $1
[ -e $1 ] && rm -f $1
}
## MSC
msc_ramdisk_()
{
# Debug Ramdisk for MSC without any argument
gadget_info "msc: ramdisk: $RAMDISK_PATH/disk.img"
mkdir -p $RAMDISK_PATH/sda
dd if=/dev/zero of=$RAMDISK_PATH/disk.img bs=1M count=1038
mkdosfs -F 32 $RAMDISK_PATH/disk.img
}
msc_config()
{
gadget_debug "add a msc function instance"
MSC_DIR=$GFUNC_PATH/mass_storage.usb0
mkdir -p $MSC_DIR
DEVICE=$1
[ $DEVICE ] || DEVICE=$MSC_ARG
# Create a backstore
if [ -z "$DEVICE" ]; then
echo "$name: no device specificed, select ramdisk as backstore"
msc_ramdisk_
echo "tmp files would be created in: $RAMDISK_PATH"
echo "$RAMDISK_PATH/disk.img" > $MSC_DIR/lun.0/file
elif [ -b $DEVICE ]; then
echo "$name: block device"
echo "$DEVICE" > $MSC_DIR/lun.0/file
else
echo "$name: other path, regular file"
echo "$DEVICE" > $MSC_DIR/lun.0/file
fi
echo 1 > $MSC_DIR/lun.0/removable
echo 0 > $MSC_DIR/lun.0/nofua
}
msc_link()
{
gadget_debug "add msc to usb config"
ln -s $MSC_DIR $GCONFIG/mass_storage.usb0
}
msc_unlink()
{
gadget_debug "remove msc from usb config"
g_remove $GCONFIG/mass_storage.usb0
}
msc_clean()
{
gadget_debug "clean msc"
g_remove $GFUNC_PATH/mass_storage.usb0
g_remove $RAMDISK_PATH/disk.img
g_remove $RAMDISK_PATH/sda
}
## UAS
uas_config()
{
gadget_debug "add a uas function instance"
# Load the target modules and mount the add a file function instance system
# Uncomment these if modules not built-in:
# lsmod | grep -q configfs || modprobe configfs
# lsmod | grep -q target_core_mod || modprobe target_core_mod
DEVICE=$1
[ $DEVICE ] || DEVICE=$UAS_ARG
mkdir -p $GADGET_PATH/functions/tcm.0
# Create a backstore
if [ -z "$DEVICE" ]; then
echo "$name: no device specificed, select rd_mcp as backstore"
BACKSTORE_DIR=$CORE_DIR/rd_mcp_0/ramdisk
mkdir -p $BACKSTORE_DIR
# ramdisk
echo rd_pages=200000 > $BACKSTORE_DIR/control
elif [ -b $DEVICE ]; then
echo "$name: block device, select iblock as backstore"
BACKSTORE_DIR=$CORE_DIR/iblock_0/iblock
mkdir -p $BACKSTORE_DIR
echo "udev_path=${DEVICE}" > $BACKSTORE_DIR/control
else
echo "$name: other path, select fileio as backstore"
BACKSTORE_DIR=$CORE_DIR/fileio_0/fileio
mkdir -p $BACKSTORE_DIR
DEVICE_SIZE=$(du -b $DEVICE | cut -f1)
echo "fd_dev_name=${DEVICE},fd_dev_size=${DEVICE_SIZE}" > $BACKSTORE_DIR/control
# echo 1 > $BACKSTORE_DIR/attrib/emulate_write_cache
fi
[ -n "$DEVICE" ] && umount $DEVICE
echo 1 > $BACKSTORE_DIR/enable
echo "$name: NAA of target: $NAA"
# Create an NAA target and a target portal group (TPG)
mkdir -p $USB_GDIR/$NAA/tpgt_1/
echo "$name tpgt_1 has lun_0"
# Create a LUN
mkdir $USB_GDIR/$NAA/tpgt_1/lun/lun_0
# Nexus initiator on target port 1 to $NAA
echo $NAA > $USB_GDIR/$NAA/tpgt_1/nexus
# Allow write access for non authenticated initiators
# echo 0 > $USB_GDIR/$NAA/tpgt_1/attrib/demo_mode_write_protect
ln -s $BACKSTORE_DIR $USB_GDIR/$NAA/tpgt_1/lun/lun_0/data
#ln -s $BACKSTORE_DIR $USB_GDIR/$NAA/tpgt_1/lun/lun_0/virtual_scsi_port
# echo 15 > $USB_GDIR/$NAA/tpgt_1/maxburst
# Enable the target portal group, with 1 lun
echo 1 > $USB_GDIR/$NAA/tpgt_1/enable
}
uas_link()
{
gadget_debug "add uas to usb config"
ln -s $GADGET_PATH/functions/tcm.0 $GCONFIG/tcm.0
}
uas_unlink()
{
gadget_debug "remove uas from usb config"
g_remove $GCONFIG/tcm.0
}
uas_clean()
{
gadget_debug "clean uas"
[ -d "$USB_GDIR/$NAA/tpgt_1/enable" ] && echo 0 > $USB_GDIR/$NAA/tpgt_1/enable
g_remove $USB_GDIR/$NAA/tpgt_1/lun/lun_0/data
g_remove $USB_GDIR/$NAA/tpgt_1/lun/lun_0/virtual_scsi_port
g_remove $USB_GDIR/$NAA/tpgt_1/lun/lun_0
g_remove $USB_GDIR/$NAA/tpgt_1/
g_remove $USB_GDIR/$NAA/
g_remove $USB_GDIR
BACKSTORE_DIR=$CORE_DIR/iblock_0/iblock
g_remove $BACKSTORE_DIR
BACKSTORE_DIR=$CORE_DIR/fileio_0/fileio
g_remove $BACKSTORE_DIR
BACKSTORE_DIR=$CORE_DIR/rd_mcp_0/ramdisk
g_remove $BACKSTORE_DIR
g_remove $GADGET_PATH/functions/tcm.0
}
## ADB
adb_config()
{
gadget_debug "add a adb function instance"
mkdir $GFUNC_PATH/ffs.adb
}
adb_link()
{
gadget_debug "add adb to usb config"
ln -s $GFUNC_PATH/ffs.adb/ $GCONFIG/ffs.adb
mkdir /dev/usb-ffs
mkdir /dev/usb-ffs/adb
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb/
#mkdir /dev/pts
#mount -t devpts -o defaults,mode=644,ptmxmode=666 devpts /dev/pts
adbd &
sleep 1
}
adb_unlink()
{
gadget_debug "remove adb from usb config"
killall adbd
g_remove $GCONFIG/ffs.adb
[ -e /dev/usb-ffs/adb/ ] && umount /dev/usb-ffs/adb/
#[ -e /dev/pts ] && umount /dev/pts
#g_remove /dev/pts
g_remove /dev/usb-ffs/adb
g_remove /dev/usb-ffs
}
adb_clean()
{
gadget_debug "clean adb"
g_remove $GFUNC_PATH/ffs.adb
}
## UVC
### Setup streaming/ directory.
add_uvc_fmt_resolution()
{
FORMAT=$1 # $1 format "uncompressed/y" / "mjpeg/m"
UVC_DISPLAY_W=$2 # $2 Width
UVC_DISPLAY_H=$3 # $3 Height
FRAMERATE=$4 # $4 HIGH_FRAMERATE 0/1
#https://docs.kernel.org/usb/gadget_uvc.html
UVC_MJPEG_PRE_PATH=$GFUNC_PATH/$UVC_INSTANCE/streaming/$FORMAT
UVC_FRAME_WDIR=${UVC_MJPEG_PRE_PATH}/${UVC_DISPLAY_H}p
gadget_debug "UVC_FRAME_WDIR: $UVC_FRAME_WDIR"
mkdir -p $UVC_FRAME_WDIR
echo $UVC_DISPLAY_W > $UVC_FRAME_WDIR/wWidth
echo $UVC_DISPLAY_H > $UVC_FRAME_WDIR/wHeight
DW_MAX_VD_FB_SZ=$(( $UVC_DISPLAY_W * $UVC_DISPLAY_H * 2 ))
if [ "$FORMAT"=="mjpeg/m" ]; then
if [ -e "$CONFIG_FILE" ]; then
# Attempt to parse the dwMaxVideoFrameBufferSize from ~/.uvcg_config
parsed_value=$(grep "^mjpeg $UVC_DISPLAY_W $UVC_DISPLAY_H" ~/.uvcg_config | awk '{print $4}')
# Check if the value was found; if not, keep the pre-calculated value
if [ ! -z "$parsed_value" ]; then
DW_MAX_VD_FB_SZ="$parsed_value"
fi
gadget_debug "format: $FORMAT, dw_max_video_fb_size: $DW_MAX_VD_FB_SZ"
fi
fi
echo $DW_MAX_VD_FB_SZ > $UVC_FRAME_WDIR/dwMaxVideoFrameBufferSize
# Many camera host app only shows the default framerate of a format in their list
# So we set it here.
if [ "$FRAMERATE" -eq 20 ]; then
echo 500000 > $UVC_FRAME_WDIR/dwDefaultFrameInterval
elif [ "$FRAMERATE" -eq 15 ]; then
echo 666666 > $UVC_FRAME_WDIR/dwDefaultFrameInterval
elif [ "$FRAMERATE" -eq 30 ]; then
echo 333333 > $UVC_FRAME_WDIR/dwDefaultFrameInterval
elif [ "$FRAMERATE" -eq 60 ]; then
echo 166666 > $UVC_FRAME_WDIR/dwDefaultFrameInterval
elif [ "$FRAMERATE" -eq 10 ]; then
echo 1000000 > $UVC_FRAME_WDIR/dwDefaultFrameInterval
fi
# lowest framerate in this script is 10fps
DW_MIN_BITRATE=$(( 10 * $DW_MAX_VD_FB_SZ * 8 ))
DW_MAX_BITRATE=$(( $FRAMERATE * $DW_MAX_VD_FB_SZ * 8 ))
if [ "$FORMAT"=="mjpeg/m" ]; then
# MJPEG can compress the data at least 5:1,
# let's set the ratio to 4
DW_MIN_BITRATE=$(( $DW_MIN_BITRATE / 4 ))
gadget_debug "format: $FORMAT, dw_min_br: $DW_MIN_BITRATE"
fi
echo $DW_MIN_BITRATE > $UVC_FRAME_WDIR/dwMinBitRate
echo $DW_MAX_BITRATE > $UVC_FRAME_WDIR/dwMaxBitRate
echo -e "\t$UVC_INSTANCE will support ${FORMAT} ${UVC_DISPLAY_W}x${UVC_DISPLAY_H}@${FRAMERATE}p"
cat <<EOF > $UVC_FRAME_WDIR/dwFrameInterval
166666
333333
416667
500000
666666
1000000
EOF
}
destroy_one_uvc_format_()
{
FORMAT=$1
UVC_MJPEG_PRE_PATH=$GFUNC_PATH/$UVC_INSTANCE/streaming/$FORMAT
for ppath in ${UVC_MJPEG_PRE_PATH}/*p; do
g_remove $ppath
done
}
destroy_all_uvc_format_()
{
destroy_one_uvc_format_ uncompressed/y
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/uncompressed/y
destroy_one_uvc_format_ mjpeg/m
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/mjpeg/m
}
create_uvc_link_()
{
mkdir $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h
ln -s $GFUNC_PATH/$UVC_INSTANCE/streaming/mjpeg/m/ $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/m
ln -s $GFUNC_PATH/$UVC_INSTANCE/streaming/uncompressed/y/ $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/y
ln -s $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/ $GFUNC_PATH/$UVC_INSTANCE/streaming/class/fs
ln -s $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/ $GFUNC_PATH/$UVC_INSTANCE/streaming/class/hs
ln -s $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/ $GFUNC_PATH/$UVC_INSTANCE/streaming/class/ss
mkdir $GFUNC_PATH/$UVC_INSTANCE/control/header/h
ln -s $GFUNC_PATH/$UVC_INSTANCE/control/header/h/ $GFUNC_PATH/$UVC_INSTANCE/control/class/fs/
ln -s $GFUNC_PATH/$UVC_INSTANCE/control/header/h/ $GFUNC_PATH/$UVC_INSTANCE/control/class/ss/
}
destroy_uvc_link_()
{
g_remove $GFUNC_PATH/$UVC_INSTANCE/control/class/fs/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/control/class/ss/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/control/header/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/class/ss/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/class/hs/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/class/fs/h
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/m
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h/y
g_remove $GFUNC_PATH/$UVC_INSTANCE/streaming/header/h
}
destroy_uvc_()
{
destroy_uvc_link_
destroy_all_uvc_format_
g_remove $GFUNC_PATH/$UVC_INSTANCE
}
set_uvc_maxpacket_()
{
MAX=$1 ## $1 1024/2048/3072
BURST=$2 ## $2 1-15
FUNCTION=$GFUNC_PATH/$UVC_INSTANCE
echo -e "\t$UVC_INSTANCE set streaming_maxpacket=$MAX, streaming_maxburst=$BURST"
echo $MAX > $FUNCTION/streaming_maxpacket
echo $BURST > $FUNCTION/streaming_maxburst
}
uvc_config()
{
UVC_INSTANCE=uvc.0
gadget_info "Adding a uvc function instance $UVC_INSTANCE..."
mkdir -p $GFUNC_PATH/$UVC_INSTANCE
# add_uvc_fmt_resolution <format> <width> <height> <framerate>
add_uvc_fmt_resolution uncompressed/y 320 240 30
add_uvc_fmt_resolution uncompressed/y 640 360 30
add_uvc_fmt_resolution uncompressed/y 640 480 30
add_uvc_fmt_resolution uncompressed/y 640 640 30
add_uvc_fmt_resolution uncompressed/y 1280 720 30
add_uvc_fmt_resolution uncompressed/y 1920 1080 30
add_uvc_fmt_resolution uncompressed/y 3840 2160 30
add_uvc_fmt_resolution mjpeg/m 640 360 30
add_uvc_fmt_resolution mjpeg/m 640 480 30
add_uvc_fmt_resolution mjpeg/m 1280 720 30
add_uvc_fmt_resolution mjpeg/m 1920 1080 30
add_uvc_fmt_resolution mjpeg/m 3840 2160 30
set_uvc_maxpacket_ 3072 15
create_uvc_link_
}
uvc_link()
{
gadget_debug "add uvc to usb config, unlike adb, you have to run ur own uvc-gadget app"
UVC_INSTANCE=uvc.0
ln -s $GFUNC_PATH/$UVC_INSTANCE/ $GCONFIG/$UVC_INSTANCE
}
uvc_unlink()
{
gadget_debug "remove uvc from usb config"
UVC_INSTANCE=uvc.0
g_remove $GCONFIG/$UVC_INSTANCE
}
uvc_clean()
{
gadget_debug "clean uvc"
UVC_INSTANCE=uvc.0
destroy_uvc_
}
## RNDIS
rndis_config()
{
OVERRIDE_VENDOR_FOR_WINDOWS=$1
# create function instance
# functions/<f_function allowed>.<instance name>
# f_function allowed: rndis
mkdir -p $GFUNC_PATH/rndis.0
}
rndis_link()
{
# Add Microsoft os descriptors to ensure
# Windows recognize us as an RNDIS compatible device
# thus no need to install driver manually.
# Verified on Windows 10.
echo 0xEF > $GADGET_PATH/bDeviceClass
echo 0x02 > $GADGET_PATH/bDeviceSubClass
echo 0x01 > $GADGET_PATH/bDeviceProtocol
echo 1 > $GADGET_PATH/os_desc/use
echo 0x1 > $GADGET_PATH/os_desc/b_vendor_code
echo "MSFT100" > $GADGET_PATH/os_desc/qw_sign
mkdir -p $GFUNC_PATH/rndis.0/os_desc/interface.rndis
echo RNDIS > $GFUNC_PATH/rndis.0/os_desc/interface.rndis/compatible_id
echo 5162001 > $GFUNC_PATH/rndis.0/os_desc/interface.rndis/sub_compatible_id
ln -s $GADGET_PATH/configs/c.1 $GADGET_PATH/os_desc/c.1
ln -s $GFUNC_PATH/rndis.0 $GCONFIG
HOST_ADDR=`cat $GFUNC_PATH/rndis.0/host_addr`
DEV_ADDR=`cat $GFUNC_PATH/rndis.0/dev_addr`
IFNAME=`cat $GFUNC_PATH/rndis.0/ifname`
gadget_info "rndis function enabled, mac(h): $HOST_ADDR, mac(g): $DEV_ADDR, ifname: $IFNAME."
gadget_info "execute ifconfig $IFNAME up to enable rndis iface."
}
rndis_unlink()
{
[ -e $GFUNC_PATH/rndis.0/ifname ] && ifconfig `cat $GFUNC_PATH/rndis.0/ifname` down
g_remove $GCONFIG/rndis.0
}
rndis_clean()
{
g_remove $GFUNC_PATH/rndis.0
}
## MTP
mtp_config()
{
die "MTP Not Supported yet."
}
mtp_link()
{
die "MTP Not Supported yet."
}
mtp_unlink()
{
die "MTP Not Supported yet."
}
mtp_clean()
{
die "MTP Not Supported yet."
}
## GADGET
no_udc()
{
gadget_info "Echo none to udc"
gadget_info "We are now trying to echo None to UDC......"
[ -e $GADGET_PATH/UDC ] || die "gadget not configured yet"
[ `cat $GADGET_PATH/UDC` ] && echo "" > $GADGET_PATH/UDC
gadget_info "echo none to UDC successfully done"
gadget_info "echo none to UDC done."
}
give_hint_to_which_have_udc_()
{
for config_path in "/sys/kernel/config/usb_gadget/"*; do
udc_path="$config_path/UDC"
is_here=$(cat $udc_path | grep $selected_udc | wc -l)
if [ "$is_here" -gt 0 ]; then
gadget_info "ERROR: Your udc is occupied by: $udc_path"
fi
done
}
echo_udc()
{
[ -e $GADGET_PATH/UDC ] || die "gadget not configured yet"
[ `cat $GADGET_PATH/UDC` ] && die "UDC `cat $GADGET_PATH/UDC` already been set"
if [ "$USB_UDC_IDX" ]; then
selected_udc=$(ls /sys/class/udc | awk "NR==$USB_UDC_IDX{print}")
else
selected_udc=$USB_UDC
gadget_info "Selected udc by name: $selected_udc"
gadget_info "We are now trying to echo $selected_udc to UDC......"
fi
our_udc_occupied=$(cat /sys/kernel/config/usb_gadget/*/UDC | grep $selected_udc | wc -l)
if [ "$our_udc_occupied" -gt 0 ]; then
give_hint_to_which_have_udc_
gadget_info "ERROR: configfs preserved, run $name resume after conflict resolved"
exit 127
fi
echo $selected_udc > $GADGET_PATH/UDC
gadget_info "echo $selected_udc to UDC done"
}
gconfig()
{
gadget_info "config $VENDOR_ID/$PRODUC_ID/$SERNUM_STR/$MANUAF_STR/$PRODUC_STR."
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config
[ -e $GADGET_PATH ] && die "ERROR: gadget already configured, should run stop first"
mkdir $GADGET_PATH
echo $VENDOR_ID > $GADGET_PATH/idVendor
echo $PRODUC_ID > $GADGET_PATH/idProduct
mkdir $GADGET_PATH/strings/0x409
echo $SERNUM_STR > $GADGET_PATH/strings/0x409/serialnumber
echo $MANUAF_STR > $GADGET_PATH/strings/0x409/manufacturer
echo $PRODUC_STR > $GADGET_PATH/strings/0x409/product
mkdir $GCONFIG
echo 0xc0 > $GCONFIG/bmAttributes
echo 500 > $GCONFIG/MaxPower
mkdir $GCONFIG/strings/0x409
# Windows rndis driver requires rndis to be the first interface
[ $RNDIS = okay ] && rndis_config
[ $MSC = okay ] && msc_config
[ $UAS = okay ] && uas_config
[ $ADB = okay ] && adb_config
[ $UVC = okay ] && uvc_config
}
gclean()
{
[ -e $GADGET_PATH/UDC ] || die "gadget not configured, no need to clean"
msc_clean
uas_clean
rndis_clean
adb_clean
uvc_clean
# Remove string in gadget
gadget_info "remove strings of $GADGET_PATH."
g_remove $GADGET_PATH/strings/0x409
# Remove gadget
gadget_info "remove $GADGET_PATH."
g_remove $GADGET_PATH
}
glink()
{
[ $RNDIS = okay ] && rndis_link
[ $MSC = okay ] && msc_link
[ $UAS = okay ] && uas_link
[ $ADB = okay ] && adb_link
[ $UVC = okay ] && uvc_link
}
gunlink()
{
[ -e $GADGET_PATH/UDC ] || die "gadget not configured yet"
rndis_unlink
msc_unlink
uas_unlink
adb_unlink
uvc_unlink
# Remove strings:
gadget_info "remove strings of c.1."
g_remove $GCONFIG/strings/0x409
# Remove config:
gadget_info "remove configs c.1."
g_remove $GCONFIG
}
select_one()
{
func=$1
if [[ "$func" == "#"* ]];then
gadget_debug "met hashtag, skip"
return
fi
if [[ "$func" == USB_UDC=* ]]; then
USB_UDC=$(echo $func | awk -F= '{print $2}')
gadget_info "Set USB_UDC to $USB_UDC from config file"
return
fi
case "$func" in
msc*|mass*|storage*)
MSC=okay
MSC_ARG=$(echo $func | awk -F: '{print $2}')
;;
"uvc"|"video|webcam")
UVC=okay
;;
uas*|uasp*)
UAS=okay
UAS_ARG=$(echo $func | awk -F: '{print $2}')
;;
"rndis"|"network"|"net"|"if")
RNDIS=okay
;;
"mtp")
MTP=okay
;;
"adb"|"fastboot"|"adbd")
ADB=okay
;;
*)
die "not supported function: $func"
;;
esac
gadget_info "Selected function $func"
let FUNCTION_CNT=FUNCTION_CNT+1
}
handle_select() {
local input_str=$1
local IFS=, # split via comma
OLDIFS=$IFS # split functions
IFS=,
for token in $input_str; do
[ $DEBUG ]
select_one $token
done
IFS=$OLDIFS
}
parse_config()
{
[ -e $CONFIG_FILE ] || die "$CONFIG_FILE not found, abort."
while read line
do
select_one $line
done < $CONFIG_FILE
}
gstart()
{
gconfig
glink
[ $FUNCTION_CNT -lt 1 ] && die "No function selected, will not pullup."
echo_udc $1
}
gstop()
{
no_udc
gunlink
gclean
}
gen_role_switch_list()
{
ROLE_SWITCH_LIST=""
# Find those names with dwc3 in the dir: /sys/kernel/debug/usb
for dir in /sys/kernel/debug/usb/*; do
if [[ -d "$dir" && "$dir" == *"dwc3"* ]]; then
ROLE_SWITCH_LIST="$(basename "$dir") $ROLE_SWITCH_LIST"
fi
done
# Find role-switch location in dir: /sys/class/usb_role/xxx-role-switch/ with a role file existing
for role_switch in /sys/class/usb_role/*-role-switch/; do
if [[ -d "$role_switch" && -f "${role_switch}role" ]]; then
ROLE_SWITCH_LIST="$(basename "$role_switch") $ROLE_SWITCH_LIST"
fi
done
}
print_role_switch_info()
{
gen_role_switch_list
echo -n "Available DRDs: "
echo "$ROLE_SWITCH_LIST"
}
# Function to set the role for a specific role switch
set_role() {
if [ "$#" -lt 1 ]; then
echo "Usage: $name set_role <role_switch> [host|device]"
echo -e "\t$name set_role <role_switch>=[host|device]"
return 1
fi
local input="$*"
local role_switch
local role
# Use awk to parse the input
echo "$input" | awk -F'[ =]' '{
if (NF == 2) {
role_switch = $1;
role = $2;
} else if (NF == 1) {
role_switch = $1;
role = "NONE"; # Default role
} else if (NF >= 3) {
role_switch = $1;
role = $3;
sub(/=[^=]+$/, "", role_switch); # Remove the =part from role_switch
}
print role_switch, role
}' | {
read role_switch role
if [[ "$role_switch" == *"-role-switch" ]]; then
# It's a role-switch, verify its existence
local role_switch_path="/sys/class/usb_role/$role_switch/role"
if [ ! -e "$role_switch_path" ]; then
gadget_info "Error: Role switch '$role_switch' does not exist."
return 1
fi
if [[ "$role" == "NONE" ]]; then
role=$(cat $role_switch_path)
gadget_info "Role for role switch '$role_switch' is currently '$role'."
else
echo "$role" > "$role_switch_path"
gadget_info "Role for'$role_switch' set to '$role'."
fi
else
# It's a controller type, verify its existence
local usb_controller_path="/sys/kernel/debug/usb/$role_switch/mode"
if [ ! -e "$usb_controller_path" ]; then
gadget_info "Error: controller support mode switch '$role_switch' does not exist."
return 1
fi
if [[ "$role" == "NONE" ]]; then
role=$(cat $usb_controller_path)
gadget_info "Mode for '$role_switch' is currently '$role'."
else
echo "$role" > "$usb_controller_path"
sleep 1
role_after="$(cat $usb_controller_path)"
if [[ "$role" != "$role_after" ]]; then
gadget_info "Error: controller '$role_switch' doesn't support mode switch!!!"
role="$(cat $usb_controller_path)"
gadget_info "Mode for Controller '$role_switch' is currently '$role'."
else
gadget_info "Mode for controller '$role_switch' set to '$role'."
fi
fi
fi
print_role_switch_info
}
}
print_info()
{
echo "Ky gadget-setup tool $SCRIPT_VERSION"
echo
echo "Board Model: `tr -d '\000' < /proc/device-tree/model`"
echo "Serial Number: $SERNUM_STR"
echo "General Config Info: $VENDOR_ID/$PRODUC_ID/$MANUAF_STR/$PRODUC_STR."
echo "Config File Path: $CONFIG_FILE"
echo "MSC Ramdisk Path (selected from tmpfs mounting point): $RAMDISK_PATH"
echo "UASP SCSI NAA: $NAA"
echo "UASP Target Dir: $USB_GDIR"
echo "Available UDCs: `ls -1 /sys/class/udc/ | tr '\n' ' '`"
print_role_switch_info
echo
}
## MAIN
case "$1" in
stop|clean)
gstop
;;
restart|reload)
gstop
parse_config
gstart
;;
start)
parse_config
gstart $2
;;
pause|disconnect)
no_udc
;;
resume|connect)
USBDEV_IDX=$2
echo_udc
;;
config)
vi $CONFIG_FILE
[ -e $CONFIG_FILE ] && gadget_info ".usb_config updated"
;;
help)
usage
;;
info)
print_info
;;
set_role|role_switch|role|rolesw|mode|switch|dr_mode)
shift
set_role "$@"
;;
[a-z]*)
handle_select $1
gstart $2
;;
*)
usage
;;
esac
exit $?

Binary file not shown.

View File

@ -0,0 +1,5 @@
[Service]
ExecStartPre=/bin/sh -c 'exec /bin/sleep 10'
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin orangepi %I $TERM
Type=idle

View File

@ -0,0 +1,5 @@
[Service]
ExecStartPre=/bin/sh -c 'exec /bin/sleep 10'
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin orangepi %I $TERM
Type=idle

View File

@ -0,0 +1,29 @@
#!/bin/bash
if [[ -z $1 ]]; then
user=root
else
user=$1
fi
[[ -d /lib/systemd/system/getty@.service.d/ ]] && rm /lib/systemd/system/getty@.service.d/ -rf
[[ -f /lib/systemd/system/serial-getty@.service.d/override.conf ]] && rm /lib/systemd/system/serial-getty@.service.d/override.conf -f
[[ -d /etc/systemd/system/getty@.service.d/ ]] && rm /etc/systemd/system/getty@.service.d/ -rf
[[ -f /etc/systemd/system/serial-getty@.service.d/override.conf ]] && rm /etc/systemd/system/serial-getty@.service.d/override.conf -f
if [[ $1 == "-d" ]]; then
exit
fi
mkdir -p /etc/systemd/system/getty@.service.d/
mkdir -p /etc/systemd/system/serial-getty@.service.d/
cat <<-EOF > \
/etc/systemd/system/serial-getty@.service.d/override.conf
[Service]
ExecStartPre=/bin/sh -c 'exec /bin/sleep 10'
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin ${user} %I \$TERM
Type=idle
EOF
cp /etc/systemd/system/serial-getty@.service.d/override.conf \
/etc/systemd/system/getty@.service.d/override.conf

1919
external/packages/bsp/ky/usr/local/bin/create_ap vendored Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,4 @@
#!/bin/bash
sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

Binary file not shown.

Binary file not shown.

View File

@ -1560,6 +1560,7 @@ prepare_host()
# download external Linaro compiler and missing special dependencies since they are needed for certain sources # download external Linaro compiler and missing special dependencies since they are needed for certain sources
local toolchains=( local toolchains=(
"ky-toolchain-linux-glibc-x86_64-v1.0.1.tar.xz"
"gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz" "gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz"
"gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz" "gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz"
"gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz" "gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz"
@ -1684,6 +1685,11 @@ download_and_verify()
return return
fi fi
if [[ ${filename} == *ky* ]]; then
server="http://www.iplaystore.cn/"
remotedir=""
fi
# switch to china mirror if US timeouts # switch to china mirror if US timeouts
timeout 10 curl --head --fail --silent ${server}${remotedir}/${filename} 2>&1 >/dev/null timeout 10 curl --head --fail --silent ${server}${remotedir}/${filename} 2>&1 >/dev/null
if [[ $? -ne 7 && $? -ne 22 && $? -ne 0 ]]; then if [[ $? -ne 7 && $? -ne 22 && $? -ne 0 ]]; then

View File

@ -316,7 +316,7 @@ dpkg_install_debs_chroot()
display_alert "Installing" "$(basename $deb_dir)" display_alert "Installing" "$(basename $deb_dir)"
# when building in bulk from remote, lets make sure we have up2date index # when building in bulk from remote, lets make sure we have up2date index
chroot "${SDCARD}" /bin/bash -c "dpkg -i ${names[*]} " >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1 chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive dpkg -i ${names[*]} " >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
[[ $? -ne 0 ]] && exit_with_error "Installation of $(basename $deb_dir) failed" "${BOARD} ${RELEASE} ${BUILD_DESKTOP} ${LINUXFAMILY}" [[ $? -ne 0 ]] && exit_with_error "Installation of $(basename $deb_dir) failed" "${BOARD} ${RELEASE} ${BUILD_DESKTOP} ${LINUXFAMILY}"
chroot "${SDCARD}" /bin/bash -c "apt-mark hold ${package_names[*]}" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1 chroot "${SDCARD}" /bin/bash -c "apt-mark hold ${package_names[*]}" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
fi fi

View File

@ -247,6 +247,8 @@ if [[ -z $BOARD ]]; then
options+=("orangepicm4" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT") options+=("orangepicm4" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
options+=("orangepi3b" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT") options+=("orangepi3b" "Rockchip RK3566 quad core 2-8GB RAM GBE eMMC USB3 NvMe WiFi/BT")
options+=("orangepirv" "Starfive JH7110 quad core 2-8GB RAM GBE USB3 NvMe WiFi/BT") options+=("orangepirv" "Starfive JH7110 quad core 2-8GB RAM GBE USB3 NvMe WiFi/BT")
options+=("orangepirv2" "Ky X1 octa core 2-8GB RAM GBE USB3 WiFi/BT NVMe eMMC")
#options+=("orangepir2s" "Ky X1 octa core 2-8GB RAM 2.5GBE USB3 eMMC")
#options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI") #options+=("orangepir1plus" "Rockchip RK3328 quad core 1GB RAM 2xGBE USB2 SPI")
#options+=("orangepi3plus" "Amlogic S905D3 quad core 2/4GB RAM SoC eMMC GBE USB3 SPI WiFi/BT") #options+=("orangepi3plus" "Amlogic S905D3 quad core 2/4GB RAM SoC eMMC GBE USB3 SPI WiFi/BT")
@ -475,6 +477,12 @@ if [[ ${IGNORE_UPDATES} != yes ]]; then
fi fi
if [[ ${BOARDFAMILY} == "ky" && $RELEASE =~ noble ]]; then
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/ky_packages" "branch:ky_packages"
fi
if [[ ${BOARDFAMILY} == "sun55iw3" && $RELEASE =~ bookworm|jammy ]]; then if [[ ${BOARDFAMILY} == "sun55iw3" && $RELEASE =~ bookworm|jammy ]]; then
[[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/t527_packages" "branch:t527_packages" [[ ${BUILD_OPT} == image ]] && fetch_from_repo "https://github.com/orangepi-xunlong/rk-rootfs-build.git" "${EXTER}/cache/sources/t527_packages" "branch:t527_packages"