From 81e8382601560032dc2b53fcec47e2e21693a986 Mon Sep 17 00:00:00 2001 From: jomadeto Date: Sun, 15 Dec 2024 10:34:33 +0100 Subject: [PATCH] Add new TVBox aml-c400-plus: Magicsee C400 Plus --- config/boards/aml-c400-plus.tvb | 51 +++++ .../_packages/bsp-cli/boot/armbianEnv.txt | 5 + .../_packages/bsp-cli/boot/emmc_autoscript | Bin 0 -> 3505 bytes .../_packages/bsp-cli/boot/s905_autoscript | Bin 0 -> 3506 bytes .../_packages/bsp-cli/root/fstab.template | 7 + .../_packages/bsp-cli/root/install-aml.sh | 198 ++++++++++++++++++ .../families/include/meson64_common.inc | 2 +- config/sources/families/meson-gxl.conf | 4 + 8 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 config/boards/aml-c400-plus.tvb create mode 100644 config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/armbianEnv.txt create mode 100644 config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/emmc_autoscript create mode 100644 config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/s905_autoscript create mode 100644 config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/fstab.template create mode 100755 config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/install-aml.sh diff --git a/config/boards/aml-c400-plus.tvb b/config/boards/aml-c400-plus.tvb new file mode 100644 index 000000000000..22d3026c348b --- /dev/null +++ b/config/boards/aml-c400-plus.tvb @@ -0,0 +1,51 @@ +# Amlogic S912 octa core 3Gb RAM SoC eMMC +BOARD_NAME="Magicsee C400 Plus" +BOARDFAMILY="meson-gxl" +BOARD_MAINTAINER="jomadeto" +BOOTSIZE="512" +BOOTFS_TYPE="fat" +KERNEL_TARGET="current,edge" +MODULES_BLACKLIST="simpledrm" # SimpleDRM conflicts with Panfrost +KERNEL_TEST_TARGET="current" +SERIALCON="ttyAML0" +FULL_DESKTOP="yes" +ASOUND_STATE="asound.state.mesongx" +BOOT_FDT_FILE="amlogic/meson-gxm-c400-plus.dtb" +BOOT_LOGO="desktop" +SRC_EXTLINUX="no" +SRC_CMDLINE='rootflags=data=writeback console=ttyAML0,115200n8 console=tty0' + +function post_family_config__uboot_aml-c400-plus() { + # This board type relies on the vendor installed u-boot on emmc to boot + display_alert "$BOARD" "Configuring ($BOARD) non-u-boot" "info" + unset BOOTSOURCE + declare -g BOOTCONFIG='none' +} + +function post_family_tweaks_bsp__config_aml-c400-plus_bsp() { + : "${destination:?destination is not set}" + + # Important: this board has board-specific bsp-cli files in config/optional/boards/aml-c400-plus/_packages/bsp-cli + # that path is hashed by the bsp-cli hashing function automatically + display_alert "${BOARD}" "Adjusting perms of bsp-cli files for ${BOARD} in /root" "info" + run_host_command_logged chmod -v 744 "${destination}"/root/install-aml.sh + run_host_command_logged chmod -v 644 "${destination}"/root/fstab.template + + display_alert "${BOARD}" "Removing armbian-install" "info" + run_host_command_logged rm -v "${destination}"/usr/bin/armbian-install + + display_alert "${BOARD}" "Adding bsp-cli preinst logic" "info" + # Inline function! So this function is automatically hashed when this hook is hashed. + function aml-c400-plus-bsp-cli-preinst() { + #update of the board bsp-cli package fails because the filesystem type is + #fat and dpkg tries to create a hard link for the existing files as backup + #so rm the files instead in a preinst step + [ -f /boot/armbianEnv.txt ] && rm /boot/armbianEnv.txt + [ -f /boot/aml_autoscript ] && rm /boot/aml_autoscript + [ -f /boot/emmc_autoscript ] && rm /boot/emmc_autoscript + return 0 # short-circuits above, avoid errors + } + preinst_functions+=('aml-c400-plus-bsp-cli-preinst') + if false; then aml-c400-plus-bsp-cli-preinst; fi # so shellcheck stops complaining the function is unused. sorry + +} diff --git a/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/armbianEnv.txt b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/armbianEnv.txt new file mode 100644 index 000000000000..4b1c9a02e98b --- /dev/null +++ b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/armbianEnv.txt @@ -0,0 +1,5 @@ +extraargs=earlycon rootflags=data=writeback rw no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 +bootlogo=false +verbosity=7 +console=both +fdtfile=amlogic/meson-gxm-c400-plus.dtb diff --git a/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/emmc_autoscript b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/emmc_autoscript new file mode 100644 index 0000000000000000000000000000000000000000..70f082db53adb6c31f2d0778f9deb4d13f7f57dc GIT binary patch literal 3505 zcmcInQE%He5Y8T2zykU@Y;OlO=r*8s>^5oF6ngL)4-1eiLu>45fJTdyO++FUigMzn z`k8y%kJwMxQ50p#aq0}{@(_vS-RbVTyYJ}l9)0`!pMM?yJ^$mYZ}#?{TV?{qS6^BVj`9UeWO83$eD(`$TF!kqmU6rQl^>8D+6OI4n`NOE09XcV~(=1 zR4`5xIp+~9nV`5V`jzBt1(Yq*IPyHrat;3eEw1${W2FxP_&z*)WOZ@G)Y) zEiQ_5t2FMz$n$D->lC3>fj_(%j)p%D@y~b1mrMzkgyuZ75--eoOCqMaeSElaO!X{G zSz3uyU)U7jf@?*?L=x(}7`@yu5~VbxGPKwrlpOYNJD!!ev0=z;t$iz-faQ{@gseiQ z6awzYB*~eNxuz^8MWSIzl7i(feuZB{guy=>|1>!Z-d|iy!^!#iy9OY%Hj_EmEAU6n zW+X)}6U@m>>P53_+{bLo=A(5A%s1lPCXwCf!$yJ12%`*Trg_Rg63x*p_)_>yFqG$H zmauSHyar#Z0weKw3{}ze86x1y#=e@8z_(1XnBSD$T7C<9!Gza~2|7vWeY)#J&s(js`!N4nHsP+@ZNFWWSQM(9y42M5(!s!hlrJDl zR;euXV!-D@D%Q6F_iND{bI{T%eUD+)d%gP&2DYwE33U}WQr0R!>#*&oE+|DlTX1?+ zaCM1Uv#Wt!2FN*##mD#<4v*~P(4y{I&;VldZ5k!mzpZ<+1oLuDkek;XR3F=RG8NkP z-XT9rh`0=fxLh#Bgbp()li0He^6UQAKlk#q5gWOa(#f2NZ0c{7A}3>Irpx97 z&gqSg>sHjJyS1BJ4H}PkB(B|k4U=s(=G_y!8OYY-4>%@uizBYNUI1R56E4^>BGya+ zydFQH3KeWR253K>( KNQtMg literal 0 HcmV?d00001 diff --git a/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/s905_autoscript b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/boot/s905_autoscript new file mode 100644 index 0000000000000000000000000000000000000000..fcb1261773b21f6eedf461f9fb5584fd0fffe6e2 GIT binary patch literal 3506 zcmcInQE%He5Y9^nSU_I~>}5EpLAL>wW4B4SCGdl{WLSW79hP9gumS=lQZ^TfR4K}d z>*{&GV1H&mZrD*2Wyx{s4CwL@iR9hs<9Bx-=`S9A_Um7t|MvIn_kZ5(?LAg|&ELtJ zKgpv{KiRwdc60=!)Ut>b&$V0bJRkpI22Z>vaQYg4dVK|Fr{`C2_2c;^{BVA8=9!hB zQ$`8~jB*VJk(By?s4U_{oQcIy-)hhj3Z|hb^IR&;DC9(ujA^EdI>6MLgYg9m1u{u_ z!qGO73Z_{qXFP@l6BLJKP+LYzplp#PvFB-4Xz=$}IM&OYRX$9>_u=VN^I;|y#?UN) zUlx(yH5X;J)f(qv_24AZZx8m^x>Z%DCQsC;wzM7iAw_LG=-&Xx%J^?*v!W$$6K@xhO@48^_jpPkX zVe-uM1Oyr*^_>!)vVy;3m6z}}TrBd2He0s1wHy=WTU@T(8xx{t$V4-kXuTYx9Y%9| z-wakT#Yy_WSkqS*qi5ss5tjOgqt@Ad7`{$SxC^_B+f|8Wq0XsGO;ayD4h%`f9P)IT z$x_dUd?ut~f!%P>m=>6Wj#uS-49ngd+#hga>)Mo1-*F>lodUFgZA0}*L1~(E`nKfi z8nb3cLpz+H=rEQX<6|^BvX4W{y6Zthh|RZYl*#_8Y03)B%MC$sUUyKlY}?6HXcxU> zK1zwWo{VrfXNn0O=2E7U=dS>}Gi3{wVwAS8D<};DRCe=i^C(MBD@b`nG#R3b$7~{` zh~EP4EGV>8WX9a~_E$LB%-J0qP+daI7`t8(v&VK2Nup>y<9CZ=n<7}=Q5E{6uW8#~ zx%Ud8(37T-yd5&IMQs~ZDbH&~-xc7FemCyt8M3#_ zxg+ezUgL>J%|WgCMqg0y(Fp1zrGF5ZX;teFygWL3@zOKrusaouD{z59o0+0I0V=%# z3d;^g`Wn~4MC=)V&_qOx?rV)vu%4-*4{;~b_56Uvb38GoId(V~GqAituH=GKyhWT| zIq+-H;fDhI-e6EuV9|7jroSZ28qK;w9fGubsaY7D{mfCn5tr+{}x2(DbZ0tyBG(hAqVw1yZX JBjV1y_b<-})&c+k literal 0 HcmV?d00001 diff --git a/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/fstab.template b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/fstab.template new file mode 100644 index 000000000000..c17caddce91f --- /dev/null +++ b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/fstab.template @@ -0,0 +1,7 @@ +#/var/swap none swap sw 0 0 +#/dev/root / auto noatime,errors=remount-ro 0 1 +#proc /proc proc defaults 0 0 + +/dev/root / ext4 defaults,noatime,errors=remount-ro 0 1 +tmpfs /tmp tmpfs defaults,nosuid 0 0 +LABEL=BOOT_EMMC /boot vfat defaults 0 2 diff --git a/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/install-aml.sh b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/install-aml.sh new file mode 100755 index 000000000000..ae231a086d29 --- /dev/null +++ b/config/optional/boards/aml-c400-plus/_packages/bsp-cli/root/install-aml.sh @@ -0,0 +1,198 @@ +#!/bin/sh + +echo "Start script create MBR and filesystem" + +hasdrives=$(lsblk | grep -oE '(mmcblk[0-9])' | sort | uniq) +if [ "$hasdrives" = "" ] +then + echo "UNABLE TO FIND ANY EMMC OR SD DRIVES ON THIS SYSTEM!!! " + exit 1 +fi +avail=$(lsblk | grep -oE '(mmcblk[0-9]|sda[0-9])' | sort | uniq) +if [ "$avail" = "" ] +then + echo "UNABLE TO FIND ANY DRIVES ON THIS SYSTEM!!!" + exit 1 +fi + +#unmount /var/log.hdd so logic below can find the root partition +umount /var/log.hdd + +runfrom=$(lsblk | grep /$ | grep -oE '(mmcblk[0-9]|sda[0-9])') +if [ "$runfrom" = "" ] +then + echo " UNABLE TO FIND ROOT OF THE RUNNING SYSTEM!!! " + exit 1 +fi +emmc=$(echo $avail | sed "s/$runfrom//" | sed "s/sd[a-z][0-9]//g" | sed "s/ //g") +if [ "$emmc" = "" ] +then + echo " UNABLE TO FIND YOUR EMMC DRIVE OR YOU ALREADY RUN FROM EMMC!!!" + exit 1 +fi +if [ "$runfrom" = "$avail" ] +then + echo " YOU ARE RUNNING ALREADY FROM EMMC!!! " + exit 1 +fi +if [ $runfrom = $emmc ] +then + echo " YOU ARE RUNNING ALREADY FROM EMMC!!! " + exit 1 +fi +if [ "$(echo $emmc | grep mmcblk)" = "" ] +then + echo " YOU DO NOT APPEAR TO HAVE AN EMMC DRIVE!!! " + exit 1 +fi + +DEV_EMMC="/dev/$emmc" + +echo $DEV_EMMC + +echo "Start backup u-boot default" + +dd if="${DEV_EMMC}" of=/root/u-boot-default-aml.img bs=1M count=4 + +echo "Start create MBR and partittion" + +parted -s "${DEV_EMMC}" mklabel msdos +parted -s "${DEV_EMMC}" mkpart primary fat32 512M 1024M +parted -s "${DEV_EMMC}" mkpart primary ext4 1025M 100% + +echo "Start restore u-boot" + +dd if=/root/u-boot-default-aml.img of="${DEV_EMMC}" conv=fsync bs=1 count=442 +dd if=/root/u-boot-default-aml.img of="${DEV_EMMC}" conv=fsync bs=512 skip=1 seek=1 + +sync + +echo "Done" + +echo "Start copy system for eMMC." + +mkdir -p /ddbr +chmod 777 /ddbr + +PART_BOOT="${DEV_EMMC}p1" +PART_ROOT="${DEV_EMMC}p2" +DIR_INSTALL="/ddbr/install" + +if [ -d $DIR_INSTALL ] ; then + rm -rf $DIR_INSTALL +fi +mkdir -p $DIR_INSTALL + +if grep -q $PART_BOOT /proc/mounts ; then + echo "Unmounting BOOT partiton." + umount -f $PART_BOOT +fi +echo -n "Formatting BOOT partition..." +mkfs.vfat -n "BOOT_EMMC" $PART_BOOT +echo "done." + +mount -o rw $PART_BOOT $DIR_INSTALL + +echo -n "Copying BOOT..." +cp -r /boot/* $DIR_INSTALL && sync +echo "done." + +echo -n "Edit init config..." +sed -e "s/\(rootdev=UUID\)\([[:graph:]]\)*/rootdev=LABEL=ROOT_EMMC/gi" \ + -i "$DIR_INSTALL/armbianEnv.txt" +echo "done." + +rm $DIR_INSTALL/s9* +rm $DIR_INSTALL/aml* + +if [ -f /boot/u-boot.ext ] ; then + mv -f $DIR_INSTALL/u-boot.ext $DIR_INSTALL/u-boot.emmc + + sed -e "s/u-boot.ext/u-boot.emmc/g" \ + -i "$DIR_INSTALL/boot.ini" + echo "done." + + sync +fi + +umount $DIR_INSTALL + +if grep -q $PART_ROOT /proc/mounts ; then + echo "Unmounting ROOT partiton." + umount -f $PART_ROOT +fi + +echo "Formatting ROOT partition..." +mke2fs -F -q -t ext4 -L ROOT_EMMC -m 0 $PART_ROOT +e2fsck -n $PART_ROOT +echo "done." + +echo "Copying ROOTFS." + +mount -o rw $PART_ROOT $DIR_INSTALL + +cd / +echo "Copy BIN" +tar -cf - bin | (cd $DIR_INSTALL; tar -xpf -) +#echo "Copy BOOT" +#mkdir -p $DIR_INSTALL/boot +#tar -cf - boot | (cd $DIR_INSTALL; tar -xpf -) +echo "Create DEV" +mkdir -p $DIR_INSTALL/dev +#tar -cf - dev | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy ETC" +tar -cf - etc | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy HOME" +tar -cf - home | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy LIB" +tar -cf - lib | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy LIB64" +tar -cf - lib64 | (cd $DIR_INSTALL; tar -xpf -) +echo "Create MEDIA" +mkdir -p $DIR_INSTALL/media +#tar -cf - media | (cd $DIR_INSTALL; tar -xpf -) +echo "Create MNT" +mkdir -p $DIR_INSTALL/mnt +#tar -cf - mnt | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy OPT" +tar -cf - opt | (cd $DIR_INSTALL; tar -xpf -) +echo "Create PROC" +mkdir -p $DIR_INSTALL/proc +echo "Copy ROOT" +tar -cf - root | (cd $DIR_INSTALL; tar -xpf -) +echo "Create RUN" +mkdir -p $DIR_INSTALL/run +echo "Copy SBIN" +tar -cf - sbin | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy SELINUX" +tar -cf - selinux | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy SRV" +tar -cf - srv | (cd $DIR_INSTALL; tar -xpf -) +echo "Create SYS" +mkdir -p $DIR_INSTALL/sys +echo "Create TMP" +mkdir -p $DIR_INSTALL/tmp +echo "Copy USR" +tar -cf - usr | (cd $DIR_INSTALL; tar -xpf -) +echo "Copy VAR" +tar -cf - var | (cd $DIR_INSTALL; tar -xpf -) +sync + +echo "Copy fstab" + +rm $DIR_INSTALL/etc/fstab +cp -a /root/fstab.template $DIR_INSTALL/etc/fstab + +rm $DIR_INSTALL/root/install*.sh +rm $DIR_INSTALL/root/fstab.template +rm $DIR_INSTALL/usr/bin/ddbr + + +cd / +sync + +umount $DIR_INSTALL + +echo "*******************************************" +echo "Complete copy OS to eMMC " +echo "*******************************************" diff --git a/config/sources/families/include/meson64_common.inc b/config/sources/families/include/meson64_common.inc index c2ad22311e53..e0e591ef3096 100644 --- a/config/sources/families/include/meson64_common.inc +++ b/config/sources/families/include/meson64_common.inc @@ -268,7 +268,7 @@ family_tweaks_bsp() { mkdir -p "$destination"/etc/X11/xorg.conf.d case "${BOARD}" in - "odroidc2" | "nanopik2-s905" | "lepotato" | "lafrite" | "khadas-vim1" | "khadas-vim2" | "aml-s9xx-box") + "odroidc2" | "nanopik2-s905" | "lepotato" | "lafrite" | "khadas-vim1" | "khadas-vim2" | "aml-c400-plus" | "aml-s9xx-box") cat <<- EOF > "$destination"/etc/X11/xorg.conf.d/02-driver.conf Section "OutputClass" Identifier "Amlogic" diff --git a/config/sources/families/meson-gxl.conf b/config/sources/families/meson-gxl.conf index b5ce02467e97..18711440ad75 100644 --- a/config/sources/families/meson-gxl.conf +++ b/config/sources/families/meson-gxl.conf @@ -38,6 +38,10 @@ uboot_custom_postprocess() { uboot_gxl_postprocess $SRC/cache/sources/odroidc2-blobs/ gxl fi + if [[ $BOARD == aml-c400-plus ]]; then + uboot_gxl_postprocess $SRC/cache/sources/odroidc2-blobs/ gxl + fi + if [[ $BOARD == aml-s9xx-box ]]; then uboot_gxl_postprocess $SRC/cache/sources/odroidc2-blobs/ gxl fi