diff --git a/config/boards/aml-s9xx-box.tvb b/config/boards/aml-s9xx-box.tvb new file mode 100644 index 000000000..7bcb02e1d --- /dev/null +++ b/config/boards/aml-s9xx-box.tvb @@ -0,0 +1,11 @@ +# Amlogic S9xx based TVBox +BOARD_NAME="aml-s9xx-box" +BOARDFAMILY="meson-gxl" +BOOTCONFIG="libretech-cc_defconfig" +BOOTSIZE="512" +BOOTFS_TYPE="fat" +KERNEL_TARGET="current,edge" +SERIALCON="ttyAML0" +FULL_DESKTOP="yes" +ASOUND_STATE="asound.state.mesongx" +BOOT_LOGO="desktop" diff --git a/config/sources/families/include/meson64_common.inc b/config/sources/families/include/meson64_common.inc index 5f83aeaf3..770055bb0 100644 --- a/config/sources/families/include/meson64_common.inc +++ b/config/sources/families/include/meson64_common.inc @@ -251,7 +251,7 @@ family_tweaks_bsp() { mkdir -p "$destination"/etc/X11/xorg.conf.d case "${BOARD}" in - "odroidc2" | "nanopik2-s905" | "lepotato" | "lafrite" | "khadas-vim1" | "khadas-vim2") + "odroidc2" | "nanopik2-s905" | "lepotato" | "lafrite" | "khadas-vim1" | "khadas-vim2" | "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 8f42459ea..9295b54ed 100644 --- a/config/sources/families/meson-gxl.conf +++ b/config/sources/families/meson-gxl.conf @@ -21,7 +21,12 @@ if [[ $BOARD = khadas-vim2 ]]; then fi family_tweaks() { - : + if [[ $BOARD = aml-s9xx-box ]]; then + cp -r $SRC/packages/bsp/aml-s9xx-box/boot $SDCARD + install -m 755 $SRC/packages/bsp/aml-s9xx-box/root/install-aml.sh $SDCARD/root + install -m 755 $SRC/packages/bsp/aml-s9xx-box/root/install-aml-s905-emmc.sh $SDCARD/root + install -m 644 $SRC/packages/bsp/aml-s9xx-box/root/fstab.template $SDCARD/root + fi } uboot_custom_postprocess() { @@ -29,6 +34,10 @@ uboot_custom_postprocess() { 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 + if [[ $BOARD == khadas-vim1 ]]; then uboot_gxl_postprocess $SRC/cache/sources/odroidc2-blobs/ vim1 fi diff --git a/packages/bsp/aml-s9xx-box/boot/aml_autoscript b/packages/bsp/aml-s9xx-box/boot/aml_autoscript new file mode 100644 index 000000000..b35562361 Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/aml_autoscript differ diff --git a/packages/bsp/aml-s9xx-box/boot/emmc_autoscript b/packages/bsp/aml-s9xx-box/boot/emmc_autoscript new file mode 100644 index 000000000..3a1fc3f85 Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/emmc_autoscript differ diff --git a/packages/bsp/aml-s9xx-box/boot/extlinux/extlinux.conf b/packages/bsp/aml-s9xx-box/boot/extlinux/extlinux.conf new file mode 100644 index 000000000..72ad3a929 --- /dev/null +++ b/packages/bsp/aml-s9xx-box/boot/extlinux/extlinux.conf @@ -0,0 +1,11 @@ +LABEL Armbian +LINUX /Image +INITRD /uInitrd + +#FDT /dtb/amlogic/meson-gxbb-p200.dtb +#FDT /dtb/amlogic/meson-gxl-s905x-p212.dtb +FDT /dtb/amlogic/meson-gxl-s905w-tx3-mini.dtb +#FDT /dtb/amlogic/meson-gxm-q200.dtb +#FDT /dtb/amlogic/meson-g12a-x96-max.dtb +#FDT /dtb/amlogic/meson-g12b-odroid-n2.dtb + diff --git a/packages/bsp/aml-s9xx-box/boot/s905_autoscript b/packages/bsp/aml-s9xx-box/boot/s905_autoscript new file mode 100644 index 000000000..2ebb29f56 Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/s905_autoscript differ diff --git a/packages/bsp/aml-s9xx-box/boot/u-boot-readme.txt b/packages/bsp/aml-s9xx-box/boot/u-boot-readme.txt new file mode 100644 index 000000000..0ab5cf0a4 --- /dev/null +++ b/packages/bsp/aml-s9xx-box/boot/u-boot-readme.txt @@ -0,0 +1,10 @@ +The u-boot binary files included in this directory are the ones originally built +by balbes150 as part of his former TV Box builds. + +These should be recreated from scratch and either built automatically as part +of the Armbian build process, or at least there should be instructions provided +here as to how to rebuild them from source. + +I don't like releasing binary blobs of unknown origin, but as these are what +people have been using for Amlogic TV Boxes for a couple of years this is +the status quo until something better is completed. diff --git a/packages/bsp/aml-s9xx-box/boot/u-boot-s905 b/packages/bsp/aml-s9xx-box/boot/u-boot-s905 new file mode 100644 index 000000000..ec231f194 Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/u-boot-s905 differ diff --git a/packages/bsp/aml-s9xx-box/boot/u-boot-s905x-s912 b/packages/bsp/aml-s9xx-box/boot/u-boot-s905x-s912 new file mode 100644 index 000000000..d34edf3c2 Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/u-boot-s905x-s912 differ diff --git a/packages/bsp/aml-s9xx-box/boot/u-boot-s905x2-s922 b/packages/bsp/aml-s9xx-box/boot/u-boot-s905x2-s922 new file mode 100644 index 000000000..0aa25cb0a Binary files /dev/null and b/packages/bsp/aml-s9xx-box/boot/u-boot-s905x2-s922 differ diff --git a/packages/bsp/aml-s9xx-box/root/fstab.template b/packages/bsp/aml-s9xx-box/root/fstab.template new file mode 100644 index 000000000..c17caddce --- /dev/null +++ b/packages/bsp/aml-s9xx-box/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/packages/bsp/aml-s9xx-box/root/install-aml-s905-emmc.sh b/packages/bsp/aml-s9xx-box/root/install-aml-s905-emmc.sh new file mode 100755 index 000000000..79bd86683 --- /dev/null +++ b/packages/bsp/aml-s9xx-box/root/install-aml-s905-emmc.sh @@ -0,0 +1,183 @@ +#!/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-s905.img bs=1M count=4 + +if [ -f /root/u-boot/u-boot-s905/u-boot.img ] ; then + echo "Start install u-boot to eMMC" + dd if=/root/u-boot/u-boot-s905/u-boot.img of="${DEV_EMMC}" +fi + +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 "Cppying BOOT..." +cp -r /boot/* $DIR_INSTALL && sync +echo "done." + +echo -n "Edit init config..." +sed -e "s/\(root=UUID\)\([[:graph:]]\)*/root=LABEL=ROOT_EMMC/gi" \ + -i "$DIR_INSTALL/extlinux/extlinux.conf" +echo "done." + +#rm $DIR_INSTALL/s9* +rm $DIR_INSTALL/aml* +rm $DIR_INSTALL/boot.ini +#mv -f $DIR_INSTALL/s905_emmc_autoscript $DIR_INSTALL/s905_autoscript + +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/packages/bsp/aml-s9xx-box/root/install-aml.sh b/packages/bsp/aml-s9xx-box/root/install-aml.sh new file mode 100755 index 000000000..8e9859a8e --- /dev/null +++ b/packages/bsp/aml-s9xx-box/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 1000M 1512M +parted -s "${DEV_EMMC}" mkpart primary ext4 1513M 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 "Cppying BOOT..." +cp -r /boot/* $DIR_INSTALL && sync +echo "done." + +echo -n "Edit init config..." +sed -e "s/\(root=UUID\)\([[:graph:]]\)*/root=LABEL=ROOT_EMMC/gi" \ + -i "$DIR_INSTALL/extlinux/extlinux.conf" +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 "*******************************************"