diff mbox series

[OpenWrt-Devel,5/5] mesongx: new target

Message ID 20181019173707.22951-6-stijn@linux-ipv6.be
State Changes Requested
Delegated to: John Crispin
Headers show
Series mesongx: new target for AmLogic S9 SoCs | expand

Commit Message

Stijn Tintel Oct. 19, 2018, 5:37 p.m. UTC
This target supports Amlogic S9 SoCs.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
---
 target/linux/mesongx/Makefile                      |  36 ++
 target/linux/mesongx/base-files/etc/inittab        |   5 +
 .../mesongx/base-files/lib/preinit/79_move_config  |  22 +
 .../mesongx/base-files/lib/upgrade/platform.sh     |  95 +++++
 target/linux/mesongx/config-4.14                   | 455 +++++++++++++++++++++
 target/linux/mesongx/image/Makefile                |  66 +++
 target/linux/mesongx/image/boot.odroid-c2.txt      |   8 +
 7 files changed, 687 insertions(+)
 create mode 100644 target/linux/mesongx/Makefile
 create mode 100644 target/linux/mesongx/base-files/etc/inittab
 create mode 100644 target/linux/mesongx/base-files/lib/preinit/79_move_config
 create mode 100644 target/linux/mesongx/base-files/lib/upgrade/platform.sh
 create mode 100644 target/linux/mesongx/config-4.14
 create mode 100644 target/linux/mesongx/image/Makefile
 create mode 100644 target/linux/mesongx/image/boot.odroid-c2.txt

Comments

Tomasz Maciej Nowak Nov. 7, 2018, 5:58 p.m. UTC | #1
Hi Stijn, comments inline (disclaimer: I don't own such device).

W dniu 19.10.2018 o 19:37, Stijn Tintel pisze:
> This target supports Amlogic S9 SoCs.
> 
> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
> ---
>  target/linux/mesongx/Makefile                      |  36 ++
>  target/linux/mesongx/base-files/etc/inittab        |   5 +
>  .../mesongx/base-files/lib/preinit/79_move_config  |  22 +
>  .../mesongx/base-files/lib/upgrade/platform.sh     |  95 +++++
>  target/linux/mesongx/config-4.14                   | 455 +++++++++++++++++++++
>  target/linux/mesongx/image/Makefile                |  66 +++
>  target/linux/mesongx/image/boot.odroid-c2.txt      |   8 +
>  7 files changed, 687 insertions(+)
>  create mode 100644 target/linux/mesongx/Makefile
>  create mode 100644 target/linux/mesongx/base-files/etc/inittab
>  create mode 100644 target/linux/mesongx/base-files/lib/preinit/79_move_config
>  create mode 100644 target/linux/mesongx/base-files/lib/upgrade/platform.sh
>  create mode 100644 target/linux/mesongx/config-4.14
>  create mode 100644 target/linux/mesongx/image/Makefile
>  create mode 100644 target/linux/mesongx/image/boot.odroid-c2.txt
> 
> diff --git a/target/linux/mesongx/Makefile b/target/linux/mesongx/Makefile
> new file mode 100644
> index 0000000000..507f5d2526
> --- /dev/null
> +++ b/target/linux/mesongx/Makefile
> @@ -0,0 +1,36 @@
> +#
> +# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +
> +include $(TOPDIR)/rules.mk
> +
> +ARCH:=aarch64
> +BOARD:=mesongx
> +BOARDNAME:=Amlogic S9 family
> +CPU_TYPE:=cortex-a53
> +DEVICE_TYPE:=other
> +FEATURES:=audio boot-part ext4 fpu squashfs usbgadget
> +MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
> +
> +KERNEL_PATCHVER:=4.14
> +
> +define Target/Description
> +	Build firmware image for Amlogic S9 SoC devices.
> +endef
> +
> +include $(INCLUDE_DIR)/target.mk
> +
> +DEFAULT_PACKAGES += \
> +	e2fsprogs \
> +	kmod-sound-core \
> +	kmod-usb-hid \
> +	mkf2fs \
> +	partx-utils \
> +	v4l-utils

These v4l-utils shouldn't be part of default packages they are in packages repo.

> +
> +KERNELNAME:=Image dtbs
> +
> +$(eval $(call BuildTarget))
> diff --git a/target/linux/mesongx/base-files/etc/inittab b/target/linux/mesongx/base-files/etc/inittab
> new file mode 100644
> index 0000000000..a5100a7050
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/etc/inittab
> @@ -0,0 +1,5 @@
> +::sysinit:/etc/init.d/rcS S boot
> +::shutdown:/etc/init.d/rcS K shutdown
> +::askconsole:/usr/libexec/login.sh
> +tty1::askfirst:/usr/libexec/login.sh
> +ttyAML0::askfirst:/usr/libexec/login.sh
> diff --git a/target/linux/mesongx/base-files/lib/preinit/79_move_config b/target/linux/mesongx/base-files/lib/preinit/79_move_config
> new file mode 100644
> index 0000000000..6ac1b3be69
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/lib/preinit/79_move_config
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +# Copyright (C) 2012-2015 OpenWrt.org
> +
> +move_config() {
> +	local partdev
> +
> +	. /lib/upgrade/common.sh
> +
> +	if export_bootdevice && export_partdevice partdev 1; then
> +		mkdir -p /boot
> +		if mount -t ext4 -o ro,noatime "/dev/$partdev" /boot; then
> +			if [ -f /boot/sysupgrade.tgz ]; then
> +				mount /boot -o remount,rw,noatime
> +				mv -f /boot/sysupgrade.tgz /
> +				mount /boot -o remount,ro,noatime
> +			fi
> +		fi
> +	fi
> +}
> +
> +boot_hook_add preinit_mount_root move_config
> +
> diff --git a/target/linux/mesongx/base-files/lib/upgrade/platform.sh b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
> new file mode 100644
> index 0000000000..3bfefc6b92
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
> @@ -0,0 +1,95 @@
> +platform_check_image() {
> +	local diskdev partdev diff
> +	[ "$#" -gt 1 ] && return 1
> +
> +	case "$(get_magic_word "$1")" in
> +		24c8) ;;
> +		*)
> +			echo "Invalid image type"
> +			return 1
> +		;;
> +	esac
> +
> +	export_bootdevice && export_partdevice diskdev 0 || {
> +		echo "Unable to determine upgrade device"
> +		return 1
> +	}
> +
> +	get_partitions "/dev/$diskdev" bootdisk
> +
> +	#extract the boot sector from the image
> +	get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
> +
> +	get_partitions /tmp/image.bs image
> +
> +	#compare tables
> +	diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
> +
> +	rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
> +
> +	if [ -n "$diff" ]; then
> +		echo "Partition layout has changed. Full image will be written."
> +		ask_bool 0 "Abort" && exit 1
> +		return 0
> +	fi
> +}
> +
> +platform_copy_config() {
> +	local partdev
> +
> +	if export_partdevice partdev 1; then
> +		mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
> +		cp -af "$CONF_TAR" /mnt/
> +		umount /mnt
> +	fi
> +}
> +
> +platform_do_upgrade() {
> +	local diskdev partdev diff
> +
> +	export_bootdevice && export_partdevice diskdev 0 || {
> +		echo "Unable to determine upgrade device"
> +		return 1
> +	}
> +
> +	sync
> +
> +	if [ "$SAVE_PARTITIONS" = "1" ]; then
> +		get_partitions "/dev/$diskdev" bootdisk
> +
> +		#extract the boot sector from the image
> +		get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
> +
> +		get_partitions /tmp/image.bs image
> +
> +		#compare tables
> +		diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
> +	else
> +		diff=1
> +	fi
> +
> +	if [ -n "$diff" ]; then
> +		get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
> +
> +		# Separate removal and addtion is necessary; otherwise, partition 1
> +		# will be missing if it overlaps with the old partition 2
> +		partx -d - "/dev/$diskdev"
> +		partx -a - "/dev/$diskdev"
> +
> +		return 0
> +	fi
> +
> +	#iterate over each partition from the image and write it to the boot disk
> +	while read part start size; do
> +		if export_partdevice partdev $part; then
> +			echo "Writing image to /dev/$partdev..."
> +			get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> +		else
> +			echo "Unable to find partition $part device, skipped."
> +		fi
> +	done < /tmp/partmap.image
> +
> +	#copy partition uuid
> +	echo "Writing new UUID to /dev/$diskdev..."
> +	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
> +}
> diff --git a/target/linux/mesongx/config-4.14 b/target/linux/mesongx/config-4.14
> new file mode 100644
> index 0000000000..aa2ba17d4a
> --- /dev/null
> +++ b/target/linux/mesongx/config-4.14
> @@ -0,0 +1,455 @@
> +CONFIG_64BIT=y
> +# CONFIG_AIO is not set
> +CONFIG_ARCH_CLOCKSOURCE_DATA=y
> +CONFIG_ARCH_DMA_ADDR_T_64BIT=y
> +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
> +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
> +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
> +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
> +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
> +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y
> +CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y
> +CONFIG_ARCH_HAS_KCOV=y
> +CONFIG_ARCH_HAS_PMEM_API=y
> +CONFIG_ARCH_HAS_SET_MEMORY=y
> +CONFIG_ARCH_HAS_SG_CHAIN=y
> +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
> +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
> +CONFIG_ARCH_HAS_TICK_BROADCAST=y
> +CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE=y
> +CONFIG_ARCH_MESON=y
> +CONFIG_ARCH_MMAP_RND_BITS=18
> +CONFIG_ARCH_MMAP_RND_BITS_MAX=33
> +CONFIG_ARCH_MMAP_RND_BITS_MIN=18
> +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11
> +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set
> +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set
> +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
> +CONFIG_ARCH_PROC_KCORE_TEXT=y
> +CONFIG_ARCH_SELECT_MEMORY_MODEL=y
> +CONFIG_ARCH_SPARSEMEM_DEFAULT=y
> +CONFIG_ARCH_SPARSEMEM_ENABLE=y
> +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
> +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
> +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
> +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
> +CONFIG_ARCH_SUPPORTS_UPROBES=y
> +CONFIG_ARCH_SUSPEND_POSSIBLE=y
> +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
> +CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
> +CONFIG_ARCH_WANT_FRAME_POINTERS=y
> +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
> +CONFIG_ARM64=y
> +# CONFIG_ARM64_16K_PAGES is not set
> +CONFIG_ARM64_4K_PAGES=y
> +# CONFIG_ARM64_64K_PAGES is not set
> +CONFIG_ARM64_CONT_SHIFT=4
> +# CONFIG_ARM64_CRYPTO is not set
> +CONFIG_ARM64_ERRATUM_819472=y
> +CONFIG_ARM64_ERRATUM_824069=y
> +CONFIG_ARM64_ERRATUM_826319=y
> +CONFIG_ARM64_ERRATUM_827319=y
> +CONFIG_ARM64_ERRATUM_843419=y
> +CONFIG_ARM64_ERRATUM_858921=y
> +CONFIG_ARM64_HW_AFDBM=y
> +# CONFIG_ARM64_LSE_ATOMICS is not set
> +CONFIG_ARM64_MODULE_CMODEL_LARGE=y
> +CONFIG_ARM64_PAGE_SHIFT=12
> +CONFIG_ARM64_PAN=y
> +CONFIG_ARM64_PMEM=y
> +# CONFIG_ARM64_PTDUMP_CORE is not set
> +# CONFIG_ARM64_PTDUMP_DEBUGFS is not set
> +# CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET is not set
> +CONFIG_ARM64_SSBD=y
> +# CONFIG_ARM64_SW_TTBR0_PAN is not set
> +CONFIG_ARM64_UAO=y
> +CONFIG_ARM64_VA_BITS=48
> +# CONFIG_ARM64_VA_BITS_39 is not set
> +CONFIG_ARM64_VA_BITS_48=y
> +CONFIG_ARM64_VHE=y
> +CONFIG_ARM_AMBA=y
> +CONFIG_ARM_ARCH_TIMER=y
> +CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
> +CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND=y
> +CONFIG_ARM_GIC=y
> +CONFIG_ARM_GIC_V3=y
> +CONFIG_ARM_PSCI_FW=y
> +CONFIG_ARM_SCPI_POWER_DOMAIN=y
> +CONFIG_ARM_SCPI_PROTOCOL=y
> +# CONFIG_ARM_SP805_WATCHDOG is not set
> +CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
> +# CONFIG_BCM_FLEXRM_MBOX is not set
> +CONFIG_BLK_DEBUG_FS=y
> +# CONFIG_BLK_DEV_INITRD is not set
> +CONFIG_BLK_DEV_LOOP=y
> +CONFIG_BOUNCE=y
> +CONFIG_CC_STACKPROTECTOR=y
> +# CONFIG_CC_STACKPROTECTOR_NONE is not set
> +CONFIG_CC_STACKPROTECTOR_STRONG=y
> +CONFIG_CEC_CORE=y
> +CONFIG_CEC_NOTIFIER=y
> +CONFIG_CEC_PLATFORM_DRIVERS=y
> +CONFIG_CLKDEV_LOOKUP=y
> +CONFIG_CLONE_BACKWARDS=y
> +CONFIG_CMA=y
> +CONFIG_CMA_ALIGNMENT=8
> +CONFIG_CMA_AREAS=7
> +# CONFIG_CMA_DEBUG is not set
> +# CONFIG_CMA_DEBUGFS is not set
> +CONFIG_CMA_SIZE_MBYTES=16
> +# CONFIG_CMA_SIZE_SEL_MAX is not set
> +CONFIG_CMA_SIZE_SEL_MBYTES=y
> +# CONFIG_CMA_SIZE_SEL_MIN is not set
> +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
> +CONFIG_COMMON_CLK=y
> +CONFIG_COMMON_CLK_AMLOGIC=y
> +CONFIG_COMMON_CLK_GXBB=y
> +# CONFIG_COMMON_CLK_SCPI is not set
> +CONFIG_COMMON_CLK_XGENE=y
> +CONFIG_COMPACTION=y
> +# CONFIG_COMPAT is not set
> +CONFIG_CONSOLE_TRANSLATIONS=y
> +CONFIG_COREDUMP=y
> +# CONFIG_CPU_BIG_ENDIAN is not set
> +CONFIG_CPU_RMAP=y
> +CONFIG_CRC16=y
> +CONFIG_CRC7=y
> +CONFIG_CRC_ITU_T=y
> +CONFIG_CRYPTO_AEAD=y
> +CONFIG_CRYPTO_AEAD2=y
> +CONFIG_CRYPTO_CRC32=y
> +CONFIG_CRYPTO_CRC32C=y
> +CONFIG_CRYPTO_HASH=y
> +CONFIG_CRYPTO_HASH2=y
> +CONFIG_CRYPTO_MANAGER=y
> +CONFIG_CRYPTO_MANAGER2=y
> +CONFIG_CRYPTO_NULL2=y
> +CONFIG_CRYPTO_RNG2=y
> +CONFIG_CRYPTO_WORKQUEUE=y
> +CONFIG_DCACHE_WORD_ACCESS=y
> +CONFIG_DEBUG_INFO=y
> +CONFIG_DMA_CMA=y
> +CONFIG_DMA_SHARED_BUFFER=y
> +CONFIG_DRM=y
> +CONFIG_DRM_ARM=y
> +CONFIG_DRM_BRIDGE=y
> +CONFIG_DRM_DW_HDMI=y
> +CONFIG_DRM_GEM_CMA_HELPER=y
> +CONFIG_DRM_KMS_CMA_HELPER=y
> +CONFIG_DRM_KMS_FB_HELPER=y
> +CONFIG_DRM_KMS_HELPER=y
> +CONFIG_DRM_MALI_DISPLAY=y
> +CONFIG_DRM_MESON=y
> +CONFIG_DRM_MESON_DW_HDMI=y
> +CONFIG_DRM_PANEL=y
> +CONFIG_DRM_PANEL_BRIDGE=y
> +CONFIG_DTC=y
> +CONFIG_DUMMY_CONSOLE=y
> +CONFIG_DWMAC_DWC_QOS_ETH=y
> +# CONFIG_DWMAC_GENERIC is not set
> +CONFIG_DWMAC_MESON=y
> +CONFIG_EDAC_SUPPORT=y
> +CONFIG_ELF_CORE=y
> +CONFIG_EXT4_FS=y
> +CONFIG_EXT4_FS_SECURITY=y
> +CONFIG_EXTCON=y
> +# CONFIG_F2FS_CHECK_FS is not set
> +CONFIG_F2FS_FS=y
> +CONFIG_F2FS_FS_POSIX_ACL=y
> +# CONFIG_F2FS_FS_SECURITY is not set
> +CONFIG_F2FS_FS_XATTR=y
> +CONFIG_F2FS_STAT_FS=y
> +CONFIG_FB=y
> +CONFIG_FB_CFB_COPYAREA=y
> +CONFIG_FB_CFB_FILLRECT=y
> +CONFIG_FB_CFB_IMAGEBLIT=y
> +CONFIG_FB_CMDLINE=y
> +CONFIG_FB_DEFERRED_IO=y
> +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set
> +CONFIG_FB_SYS_COPYAREA=y
> +CONFIG_FB_SYS_FILLRECT=y
> +CONFIG_FB_SYS_FOPS=y
> +CONFIG_FB_SYS_IMAGEBLIT=y
> +CONFIG_FIXED_PHY=y
> +CONFIG_FIX_EARLYCON_MEM=y
> +# CONFIG_FONTS is not set
> +CONFIG_FONT_8x16=y
> +CONFIG_FONT_8x8=y
> +CONFIG_FONT_SUPPORT=y
> +CONFIG_FRAMEBUFFER_CONSOLE=y
> +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
> +# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
> +CONFIG_FRAME_POINTER=y
> +CONFIG_FSL_ERRATUM_A008585=y
> +CONFIG_FS_MBCACHE=y
> +CONFIG_FS_POSIX_ACL=y
> +CONFIG_GENERIC_ALLOCATOR=y
> +CONFIG_GENERIC_ARCH_TOPOLOGY=y
> +CONFIG_GENERIC_BUG=y
> +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
> +CONFIG_GENERIC_CLOCKEVENTS=y
> +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
> +CONFIG_GENERIC_CPU_AUTOPROBE=y
> +CONFIG_GENERIC_CSUM=y
> +CONFIG_GENERIC_EARLY_IOREMAP=y
> +CONFIG_GENERIC_IDLE_POLL_SETUP=y
> +CONFIG_GENERIC_IO=y
> +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y
> +CONFIG_GENERIC_IRQ_SHOW=y
> +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
> +CONFIG_GENERIC_PCI_IOMAP=y
> +CONFIG_GENERIC_PHY=y
> +CONFIG_GENERIC_PINCONF=y
> +CONFIG_GENERIC_PINCTRL_GROUPS=y
> +CONFIG_GENERIC_PINMUX_FUNCTIONS=y
> +CONFIG_GENERIC_SCHED_CLOCK=y
> +CONFIG_GENERIC_SMP_IDLE_THREAD=y
> +CONFIG_GENERIC_STRNCPY_FROM_USER=y
> +CONFIG_GENERIC_STRNLEN_USER=y
> +CONFIG_GENERIC_TIME_VSYSCALL=y
> +CONFIG_GLOB=y
> +CONFIG_GPIOLIB=y
> +CONFIG_GPIO_SYSFS=y
> +# CONFIG_GRO_CELLS is not set
> +CONFIG_HANDLE_DOMAIN_IRQ=y
> +CONFIG_HARDEN_BRANCH_PREDICTOR=y
> +CONFIG_HARDIRQS_SW_RESEND=y
> +CONFIG_HAS_DMA=y
> +CONFIG_HAS_IOMEM=y
> +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
> +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
> +CONFIG_HAVE_ARCH_AUDITSYSCALL=y
> +CONFIG_HAVE_ARCH_BITREVERSE=y
> +CONFIG_HAVE_ARCH_HUGE_VMAP=y
> +CONFIG_HAVE_ARCH_JUMP_LABEL=y
> +CONFIG_HAVE_ARCH_KASAN=y
> +CONFIG_HAVE_ARCH_KGDB=y
> +CONFIG_HAVE_ARCH_PFN_VALID=y
> +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
> +CONFIG_HAVE_ARCH_TRACEHOOK=y
> +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
> +CONFIG_HAVE_ARCH_VMAP_STACK=y
> +CONFIG_HAVE_ARM_SMCCC=y
> +# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
> +CONFIG_HAVE_CC_STACKPROTECTOR=y
> +CONFIG_HAVE_CLK=y
> +CONFIG_HAVE_CLK_PREPARE=y
> +CONFIG_HAVE_CMPXCHG_DOUBLE=y
> +CONFIG_HAVE_CMPXCHG_LOCAL=y
> +CONFIG_HAVE_CONTEXT_TRACKING=y
> +CONFIG_HAVE_C_RECORDMCOUNT=y
> +CONFIG_HAVE_DEBUG_BUGVERBOSE=y
> +CONFIG_HAVE_DEBUG_KMEMLEAK=y
> +CONFIG_HAVE_DMA_API_DEBUG=y
> +CONFIG_HAVE_DMA_CONTIGUOUS=y
> +CONFIG_HAVE_DYNAMIC_FTRACE=y
> +CONFIG_HAVE_EBPF_JIT=y
> +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
> +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
> +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
> +CONFIG_HAVE_FUNCTION_TRACER=y
> +CONFIG_HAVE_GENERIC_DMA_COHERENT=y
> +CONFIG_HAVE_GENERIC_GUP=y
> +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
> +CONFIG_HAVE_MEMBLOCK=y
> +CONFIG_HAVE_MEMORY_PRESENT=y
> +CONFIG_HAVE_NET_DSA=y
> +CONFIG_HAVE_PATA_PLATFORM=y
> +CONFIG_HAVE_PERF_EVENTS=y
> +CONFIG_HAVE_PERF_REGS=y
> +CONFIG_HAVE_PERF_USER_STACK_DUMP=y
> +CONFIG_HAVE_RCU_TABLE_FREE=y
> +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
> +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
> +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
> +CONFIG_HDMI=y
> +CONFIG_HISILICON_ERRATUM_161010101=y
> +CONFIG_HOLES_IN_ZONE=y
> +# CONFIG_HUGETLBFS is not set
> +CONFIG_HWMON=y
> +CONFIG_HW_CONSOLE=y
> +CONFIG_HW_RANDOM=y
> +CONFIG_HW_RANDOM_MESON=y
> +CONFIG_I2C=y
> +CONFIG_I2C_ALGOBIT=y
> +CONFIG_I2C_BOARDINFO=y
> +CONFIG_I2C_MESON=y
> +CONFIG_IIO=y
> +# CONFIG_IIO_BUFFER is not set
> +# CONFIG_IIO_TRIGGER is not set
> +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
> +CONFIG_INPUT=y
> +CONFIG_IOMMU_HELPER=y
> +CONFIG_IOSCHED_BFQ=y
> +CONFIG_IPV6=y
> +CONFIG_IPV6_MROUTE=y
> +CONFIG_IPV6_MULTIPLE_TABLES=y
> +# CONFIG_IPV6_PIMSM_V2 is not set
> +CONFIG_IPV6_SUBTREES=y
> +CONFIG_IRQCHIP=y
> +CONFIG_IRQ_DOMAIN=y
> +CONFIG_IRQ_DOMAIN_HIERARCHY=y
> +CONFIG_IRQ_FORCED_THREADING=y
> +CONFIG_IRQ_WORK=y
> +CONFIG_IR_MESON=y
> +# CONFIG_IR_SERIAL is not set
> +# CONFIG_IR_SIR is not set
> +CONFIG_JBD2=y
> +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set
> +CONFIG_LEDS_GPIO=y
> +CONFIG_LIBFDT=y
> +CONFIG_LOCK_SPIN_ON_OWNER=y
> +CONFIG_MAGIC_SYSRQ=y
> +CONFIG_MAILBOX=y
> +# CONFIG_MAILBOX_TEST is not set
> +CONFIG_MDIO_BUS=y
> +CONFIG_MDIO_DEVICE=y
> +CONFIG_MEDIA_CEC_RC=y
> +CONFIG_MEDIA_CEC_SUPPORT=y
> +CONFIG_MEDIA_SUPPORT=y

The media config options trigger unresolved symbols when all kmods are built. On the side note, maybe creating packages for them would be a better idea?

> +CONFIG_MEMORY_ISOLATION=y
> +CONFIG_MESON_EFUSE=y
> +CONFIG_MESON_GXBB_WATCHDOG=y
> +# CONFIG_MESON_GXL_PHY is not set
> +CONFIG_MESON_GX_PM_DOMAINS=y
> +CONFIG_MESON_GX_SOCINFO=y
> +CONFIG_MESON_MX_SOCINFO=y
> +CONFIG_MESON_SARADC=y
> +CONFIG_MESON_SM=y
> +CONFIG_MESON_WATCHDOG=y
> +CONFIG_MFD_SYSCON=y
> +CONFIG_MIGRATION=y
> +CONFIG_MMC=y
> +CONFIG_MMC_ARMMMCI=y
> +CONFIG_MMC_BLOCK=y
> +CONFIG_MMC_MESON_GX=y
> +CONFIG_MMC_SPI=y
> +CONFIG_MODULES_USE_ELF_RELA=y
> +CONFIG_MQ_IOSCHED_DEADLINE=y
> +CONFIG_MQ_IOSCHED_KYBER=y
> +CONFIG_MUTEX_SPIN_ON_OWNER=y
> +CONFIG_NEED_DMA_MAP_STATE=y
> +CONFIG_NEED_SG_DMA_LENGTH=y
> +CONFIG_NET_CLS_ACT=y
> +CONFIG_NET_EMATCH=y
> +CONFIG_NET_FLOW_LIMIT=y
> +CONFIG_NET_PTP_CLASSIFY=y
> +CONFIG_NLS=y
> +CONFIG_NO_BOOTMEM=y
> +CONFIG_NO_HZ_COMMON=y
> +CONFIG_NO_HZ_IDLE=y
> +CONFIG_NO_IOPORT_MAP=y
> +CONFIG_NR_CPUS=8
> +# CONFIG_NUMA is not set
> +CONFIG_NVMEM=y
> +CONFIG_OF=y
> +CONFIG_OF_ADDRESS=y
> +CONFIG_OF_EARLY_FLATTREE=y
> +CONFIG_OF_FLATTREE=y
> +CONFIG_OF_GPIO=y
> +CONFIG_OF_IRQ=y
> +CONFIG_OF_MDIO=y
> +CONFIG_OF_NET=y
> +CONFIG_OF_RESERVED_MEM=y
> +CONFIG_PADATA=y
> +CONFIG_PARTITION_PERCPU=y
> +# CONFIG_PCI_DOMAINS is not set
> +# CONFIG_PCI_DOMAINS_GENERIC is not set
> +# CONFIG_PCI_SYSCALL is not set
> +CONFIG_PGTABLE_LEVELS=4
> +CONFIG_PHYLIB=y
> +CONFIG_PHYS_ADDR_T_64BIT=y
> +CONFIG_PHY_MESON8B_USB2=y
> +CONFIG_PHY_MESON_GXL_USB2=y
> +CONFIG_PINCTRL=y
> +CONFIG_PINCTRL_MESON=y
> +CONFIG_PLATFORM_MHU=y
> +CONFIG_PM=y
> +CONFIG_PM_CLK=y
> +# CONFIG_PM_DEBUG is not set
> +CONFIG_PM_GENERIC_DOMAINS=y
> +CONFIG_PM_GENERIC_DOMAINS_OF=y
> +CONFIG_POSIX_MQUEUE=y
> +CONFIG_POSIX_MQUEUE_SYSCTL=y
> +CONFIG_POWER_RESET=y
> +CONFIG_POWER_SUPPLY=y
> +CONFIG_PPS=y
> +CONFIG_PRINTK_TIME=y
> +CONFIG_PTP_1588_CLOCK=y
> +CONFIG_PWM=y
> +CONFIG_PWM_MESON=y
> +CONFIG_PWM_SYSFS=y
> +# CONFIG_RANDOMIZE_BASE is not set
> +CONFIG_RATIONAL=y
> +CONFIG_RCU_NEED_SEGCBLIST=y
> +CONFIG_RCU_STALL_COMMON=y
> +CONFIG_RC_CORE=y
> +CONFIG_RC_DEVICES=y
> +CONFIG_REALTEK_PHY=y
> +CONFIG_REGMAP=y
> +CONFIG_REGMAP_I2C=y
> +CONFIG_REGMAP_MMIO=y
> +CONFIG_REGULATOR=y
> +CONFIG_REGULATOR_DEBUG=y
> +CONFIG_REGULATOR_FIXED_VOLTAGE=y
> +CONFIG_REGULATOR_GPIO=y
> +CONFIG_RESET_CONTROLLER=y
> +CONFIG_RESET_MESON=y
> +CONFIG_RFS_ACCEL=y
> +CONFIG_RPS=y
> +CONFIG_RWSEM_SPIN_ON_OWNER=y
> +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
> +# CONFIG_SCHED_INFO is not set
> +# CONFIG_SCSI_DMA is not set
> +CONFIG_SDIO_UART=y
> +CONFIG_SENSORS_ARM_SCPI=y
> +CONFIG_SERIAL_8250_FSL=y
> +# CONFIG_SERIAL_AMBA_PL011 is not set
> +CONFIG_SERIAL_MESON=y
> +CONFIG_SERIAL_MESON_CONSOLE=y
> +CONFIG_SMP=y
> +CONFIG_SOC_BUS=y
> +CONFIG_SPARSEMEM=y
> +CONFIG_SPARSEMEM_EXTREME=y
> +CONFIG_SPARSEMEM_MANUAL=y
> +CONFIG_SPARSEMEM_VMEMMAP=y
> +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
> +CONFIG_SPARSE_IRQ=y
> +CONFIG_SPI=y
> +CONFIG_SPI_MASTER=y
> +CONFIG_SPI_MESON_SPICC=y
> +CONFIG_SPI_MESON_SPIFC=y
> +CONFIG_SRCU=y
> +CONFIG_STMMAC_ETH=y
> +CONFIG_STMMAC_PLATFORM=y
> +CONFIG_SWIOTLB=y
> +CONFIG_SWPHY=y
> +CONFIG_SYNC_FILE=y
> +CONFIG_SYSCTL_EXCEPTION_TRACE=y
> +CONFIG_SYS_SUPPORTS_HUGETLBFS=y
> +CONFIG_THREAD_INFO_IN_TASK=y
> +CONFIG_TICK_CPU_ACCOUNTING=y
> +CONFIG_TIMER_OF=y
> +CONFIG_TIMER_PROBE=y
> +CONFIG_TREE_RCU=y
> +CONFIG_TREE_SRCU=y
> +CONFIG_UNMAP_KERNEL_AT_EL0=y
> +CONFIG_USB=y
> +CONFIG_USB_COMMON=y
> +CONFIG_USB_DWC2=y
> +CONFIG_USB_DWC2_DUAL_ROLE=y
> +# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set
> +# CONFIG_USB_EHCI_HCD is not set
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_OTG=y
> +CONFIG_USB_OTG_FSM=y
> +CONFIG_USB_PHY=y
> +CONFIG_USB_SUPPORT=y
> +CONFIG_VIDEOMODE_HELPERS=y
> +CONFIG_VIDEO_MESON_AO_CEC=y
> +CONFIG_VMAP_STACK=y
> +CONFIG_VT=y
> +CONFIG_VT_CONSOLE=y
> +CONFIG_VT_HW_CONSOLE_BINDING=y
> +CONFIG_WATCHDOG_CORE=y
> +CONFIG_XPS=y
> diff --git a/target/linux/mesongx/image/Makefile b/target/linux/mesongx/image/Makefile
> new file mode 100644
> index 0000000000..d2fba8ca03
> --- /dev/null
> +++ b/target/linux/mesongx/image/Makefile
> @@ -0,0 +1,66 @@
> +#
> +# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +include $(TOPDIR)/rules.mk
> +include $(INCLUDE_DIR)/image.mk
> +
> +define Build/bootloader-odroid-c2
> +	fip_create \
> +		--bl30  $(STAGING_DIR_IMAGE)/odroidc2/bl30.bin \
> +		--bl301 $(STAGING_DIR_IMAGE)/odroidc2/bl301.bin \
> +		--bl31  $(STAGING_DIR_IMAGE)/odroidc2/bl31.bin \
> +		--bl33  $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin \
> +		$(BIN_DIR)/u-boot-odroid-c2/fip.bin
> +
> +	cat $(STAGING_DIR_IMAGE)/odroidc2/bl2.package $(BIN_DIR)/u-boot-odroid-c2/fip.bin > $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin
> +
> +	amlbootsig $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed
> +
> +	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed of=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb bs=512 skip=96
> +	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=1 count=440
> +	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=512 skip=1 seek=1
> +	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb of=$@ conv=fsync,notrunc bs=512 seek=97
> +endef

There are a bunch of files left in $(BIN_DIR), they can cause confusion for average user, are they necessary?

> +
> +define Build/sdcard-img
> +	$(INSTALL_DIR) $(KDIR)/boot.ext4
> +	$(CP) $(KDIR)/boot.$1.scr $(KDIR)/boot.ext4/boot.scr
> +	$(CP) $(KDIR_KERNEL_IMAGE) $(KDIR)/boot.ext4/uImage
> +	$(foreach dts,$(DEVICE_DTS),$(CP) $(DTS_DIR)/$(dts).dtb $(KDIR)/boot.ext4/)
> +	PADDING="$(CONFIG_TARGET_IMAGES_PAD)" \
> +	PATH="$(TARGET_PATH)" \
> +	$(SCRIPT_DIR)/gen_image_generic.sh $@ \
> +		$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/boot.ext4 \
> +		$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
> +		4096
> +endef

You need to clean temporary files in $(KDIR)/boot.ext4, otherwise on every iteration of this define it'll error out saying that the files already exist.

> +
> +define Build/uImage-meson
> +	$(call Build/uImage,none)
> +	mkimage -A arm64 -T script -C none -n "boot.scr uImage" -d boot.$1.txt $(KDIR)/boot.$1.scr
> +endef
> +
> +### Devices ###
> +define Device/Default
> +  CONSOLE := ttyAML0,115200
> +  FILESYSTEMS := ext4 squashfs
> +  IMAGES := sdcard.img
> +  IMAGE/sdcard.img := sdcard-img $$(DEVICE_NAME) | bootloader-$$(DEVICE_NAME)
> +  KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
> +  KERNEL_LOADADDR := 0x01080000
> +  KERNEL_NAME := Image
> +  PROFILES = Default $$(DEVICE_NAME)
> +endef
> +
> +define Device/odroid-c2
> +  DEVICE_DTS := amlogic/meson-gxbb-odroidc2
> +  DEVICE_PACKAGES += odroid-firmware-c2 u-boot-odroid-c2
> +  DEVICE_TITLE := ODROID C2
> +  KERNEL := kernel-bin | uImage-meson $$(DEVICE_NAME)
> +endef
> +TARGET_DEVICES += odroid-c2
> +
> +$(eval $(call BuildImage))
> diff --git a/target/linux/mesongx/image/boot.odroid-c2.txt b/target/linux/mesongx/image/boot.odroid-c2.txt
> new file mode 100644
> index 0000000000..371e6ec42c
> --- /dev/null
> +++ b/target/linux/mesongx/image/boot.odroid-c2.txt
> @@ -0,0 +1,8 @@
> +setenv bootargs "root=PARTUUID=5452574f-02 rootwait ro rootfstype=ext4,squashfs console=ttyAML0,115200"
> +setenv loadaddr "0x01080000"
> +setenv dtb_loadaddr "0x01000000"
> +
> +ext2load mmc 0:1 ${loadaddr} uImage
> +ext2load mmc 0:1 ${dtb_loadaddr} meson-gxbb-odroidc2.dtb
> +
> +bootm ${loadaddr} - ${dtb_loadaddr}
> 

Regards, Tomasz.
Hauke Mehrtens Nov. 24, 2018, 2:01 p.m. UTC | #2
On 10/19/18 7:37 PM, Stijn Tintel wrote:
> This target supports Amlogic S9 SoCs.
> 
> Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
> ---
>  target/linux/mesongx/Makefile                      |  36 ++
>  target/linux/mesongx/base-files/etc/inittab        |   5 +
>  .../mesongx/base-files/lib/preinit/79_move_config  |  22 +
>  .../mesongx/base-files/lib/upgrade/platform.sh     |  95 +++++
>  target/linux/mesongx/config-4.14                   | 455 +++++++++++++++++++++
>  target/linux/mesongx/image/Makefile                |  66 +++
>  target/linux/mesongx/image/boot.odroid-c2.txt      |   8 +
>  7 files changed, 687 insertions(+)
>  create mode 100644 target/linux/mesongx/Makefile
>  create mode 100644 target/linux/mesongx/base-files/etc/inittab
>  create mode 100644 target/linux/mesongx/base-files/lib/preinit/79_move_config
>  create mode 100644 target/linux/mesongx/base-files/lib/upgrade/platform.sh
>  create mode 100644 target/linux/mesongx/config-4.14
>  create mode 100644 target/linux/mesongx/image/Makefile
>  create mode 100644 target/linux/mesongx/image/boot.odroid-c2.txt
> 
> diff --git a/target/linux/mesongx/Makefile b/target/linux/mesongx/Makefile
> new file mode 100644
> index 0000000000..507f5d2526
> --- /dev/null
> +++ b/target/linux/mesongx/Makefile
> @@ -0,0 +1,36 @@
> +#
> +# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +
> +include $(TOPDIR)/rules.mk
> +
> +ARCH:=aarch64
> +BOARD:=mesongx
> +BOARDNAME:=Amlogic S9 family
> +CPU_TYPE:=cortex-a53
> +DEVICE_TYPE:=other
> +FEATURES:=audio boot-part ext4 fpu squashfs usbgadget
> +MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
> +
> +KERNEL_PATCHVER:=4.14
> +
> +define Target/Description
> +	Build firmware image for Amlogic S9 SoC devices.
> +endef
> +
> +include $(INCLUDE_DIR)/target.mk
> +
> +DEFAULT_PACKAGES += \
> +	e2fsprogs \
> +	kmod-sound-core \
> +	kmod-usb-hid \
> +	mkf2fs \
> +	partx-utils \
> +	v4l-utils
> +
> +KERNELNAME:=Image dtbs
> +
> +$(eval $(call BuildTarget))
> diff --git a/target/linux/mesongx/base-files/etc/inittab b/target/linux/mesongx/base-files/etc/inittab
> new file mode 100644
> index 0000000000..a5100a7050
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/etc/inittab
> @@ -0,0 +1,5 @@
> +::sysinit:/etc/init.d/rcS S boot
> +::shutdown:/etc/init.d/rcS K shutdown
> +::askconsole:/usr/libexec/login.sh
> +tty1::askfirst:/usr/libexec/login.sh
> +ttyAML0::askfirst:/usr/libexec/login.sh
> diff --git a/target/linux/mesongx/base-files/lib/preinit/79_move_config b/target/linux/mesongx/base-files/lib/preinit/79_move_config
> new file mode 100644
> index 0000000000..6ac1b3be69
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/lib/preinit/79_move_config
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +# Copyright (C) 2012-2015 OpenWrt.org
> +
> +move_config() {
> +	local partdev
> +
> +	. /lib/upgrade/common.sh
> +
> +	if export_bootdevice && export_partdevice partdev 1; then
> +		mkdir -p /boot
> +		if mount -t ext4 -o ro,noatime "/dev/$partdev" /boot; then
> +			if [ -f /boot/sysupgrade.tgz ]; then
> +				mount /boot -o remount,rw,noatime
> +				mv -f /boot/sysupgrade.tgz /
> +				mount /boot -o remount,ro,noatime
> +			fi
> +		fi
> +	fi
> +}
> +
> +boot_hook_add preinit_mount_root move_config
> +
> diff --git a/target/linux/mesongx/base-files/lib/upgrade/platform.sh b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
> new file mode 100644
> index 0000000000..3bfefc6b92
> --- /dev/null
> +++ b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
> @@ -0,0 +1,95 @@
> +platform_check_image() {
> +	local diskdev partdev diff
> +	[ "$#" -gt 1 ] && return 1
> +
> +	case "$(get_magic_word "$1")" in
> +		24c8) ;;
> +		*)
> +			echo "Invalid image type"
> +			return 1
> +		;;
> +	esac
> +
> +	export_bootdevice && export_partdevice diskdev 0 || {
> +		echo "Unable to determine upgrade device"
> +		return 1
> +	}
> +
> +	get_partitions "/dev/$diskdev" bootdisk
> +
> +	#extract the boot sector from the image
> +	get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
> +
> +	get_partitions /tmp/image.bs image
> +
> +	#compare tables
> +	diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
> +
> +	rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
> +
> +	if [ -n "$diff" ]; then
> +		echo "Partition layout has changed. Full image will be written."
> +		ask_bool 0 "Abort" && exit 1
> +		return 0
> +	fi
> +}
> +
> +platform_copy_config() {
> +	local partdev
> +
> +	if export_partdevice partdev 1; then
> +		mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
> +		cp -af "$CONF_TAR" /mnt/
> +		umount /mnt
> +	fi
> +}
> +
> +platform_do_upgrade() {
> +	local diskdev partdev diff
> +
> +	export_bootdevice && export_partdevice diskdev 0 || {
> +		echo "Unable to determine upgrade device"
> +		return 1
> +	}
> +
> +	sync
> +
> +	if [ "$SAVE_PARTITIONS" = "1" ]; then
> +		get_partitions "/dev/$diskdev" bootdisk
> +
> +		#extract the boot sector from the image
> +		get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
> +
> +		get_partitions /tmp/image.bs image
> +
> +		#compare tables
> +		diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
> +	else
> +		diff=1
> +	fi
> +
> +	if [ -n "$diff" ]; then
> +		get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
> +
> +		# Separate removal and addtion is necessary; otherwise, partition 1
> +		# will be missing if it overlaps with the old partition 2
> +		partx -d - "/dev/$diskdev"
> +		partx -a - "/dev/$diskdev"
> +
> +		return 0
> +	fi
> +
> +	#iterate over each partition from the image and write it to the boot disk
> +	while read part start size; do
> +		if export_partdevice partdev $part; then
> +			echo "Writing image to /dev/$partdev..."
> +			get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> +		else
> +			echo "Unable to find partition $part device, skipped."
> +		fi
> +	done < /tmp/partmap.image
> +
> +	#copy partition uuid
> +	echo "Writing new UUID to /dev/$diskdev..."
> +	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
> +}
> diff --git a/target/linux/mesongx/config-4.14 b/target/linux/mesongx/config-4.14
> new file mode 100644
> index 0000000000..aa2ba17d4a
> --- /dev/null
> +++ b/target/linux/mesongx/config-4.14
> @@ -0,0 +1,455 @@
> +CONFIG_64BIT=y
> +# CONFIG_AIO is not set
> +CONFIG_ARCH_CLOCKSOURCE_DATA=y
> +CONFIG_ARCH_DMA_ADDR_T_64BIT=y
> +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
> +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
> +CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
> +CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
> +CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
> +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y
> +CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y
> +CONFIG_ARCH_HAS_KCOV=y
> +CONFIG_ARCH_HAS_PMEM_API=y
> +CONFIG_ARCH_HAS_SET_MEMORY=y
> +CONFIG_ARCH_HAS_SG_CHAIN=y
> +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
> +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
> +CONFIG_ARCH_HAS_TICK_BROADCAST=y
> +CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE=y
> +CONFIG_ARCH_MESON=y
> +CONFIG_ARCH_MMAP_RND_BITS=18
> +CONFIG_ARCH_MMAP_RND_BITS_MAX=33
> +CONFIG_ARCH_MMAP_RND_BITS_MIN=18
> +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11
> +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set
> +# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set
> +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
> +CONFIG_ARCH_PROC_KCORE_TEXT=y
> +CONFIG_ARCH_SELECT_MEMORY_MODEL=y
> +CONFIG_ARCH_SPARSEMEM_DEFAULT=y
> +CONFIG_ARCH_SPARSEMEM_ENABLE=y
> +CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
> +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
> +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
> +CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
> +CONFIG_ARCH_SUPPORTS_UPROBES=y
> +CONFIG_ARCH_SUSPEND_POSSIBLE=y
> +CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
> +CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
> +CONFIG_ARCH_WANT_FRAME_POINTERS=y
> +CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
> +CONFIG_ARM64=y
> +# CONFIG_ARM64_16K_PAGES is not set
> +CONFIG_ARM64_4K_PAGES=y
> +# CONFIG_ARM64_64K_PAGES is not set
> +CONFIG_ARM64_CONT_SHIFT=4
> +# CONFIG_ARM64_CRYPTO is not set
> +CONFIG_ARM64_ERRATUM_819472=y
> +CONFIG_ARM64_ERRATUM_824069=y
> +CONFIG_ARM64_ERRATUM_826319=y
> +CONFIG_ARM64_ERRATUM_827319=y
> +CONFIG_ARM64_ERRATUM_843419=y
> +CONFIG_ARM64_ERRATUM_858921=y
> +CONFIG_ARM64_HW_AFDBM=y
> +# CONFIG_ARM64_LSE_ATOMICS is not set
> +CONFIG_ARM64_MODULE_CMODEL_LARGE=y
> +CONFIG_ARM64_PAGE_SHIFT=12
> +CONFIG_ARM64_PAN=y
> +CONFIG_ARM64_PMEM=y
> +# CONFIG_ARM64_PTDUMP_CORE is not set
> +# CONFIG_ARM64_PTDUMP_DEBUGFS is not set
> +# CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET is not set
> +CONFIG_ARM64_SSBD=y
> +# CONFIG_ARM64_SW_TTBR0_PAN is not set
> +CONFIG_ARM64_UAO=y
> +CONFIG_ARM64_VA_BITS=48
> +# CONFIG_ARM64_VA_BITS_39 is not set
> +CONFIG_ARM64_VA_BITS_48=y
> +CONFIG_ARM64_VHE=y
> +CONFIG_ARM_AMBA=y
> +CONFIG_ARM_ARCH_TIMER=y
> +CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
> +CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND=y
> +CONFIG_ARM_GIC=y
> +CONFIG_ARM_GIC_V3=y
> +CONFIG_ARM_PSCI_FW=y
> +CONFIG_ARM_SCPI_POWER_DOMAIN=y
> +CONFIG_ARM_SCPI_PROTOCOL=y
> +# CONFIG_ARM_SP805_WATCHDOG is not set
> +CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
> +# CONFIG_BCM_FLEXRM_MBOX is not set
> +CONFIG_BLK_DEBUG_FS=y
> +# CONFIG_BLK_DEV_INITRD is not set
> +CONFIG_BLK_DEV_LOOP=y
> +CONFIG_BOUNCE=y
> +CONFIG_CC_STACKPROTECTOR=y
> +# CONFIG_CC_STACKPROTECTOR_NONE is not set
> +CONFIG_CC_STACKPROTECTOR_STRONG=y

By default OpenWrt uses CONFIG_CC_STACKPROTECTOR_NONE, but I do not know
if this is a good default.

> +CONFIG_CEC_CORE=y
> +CONFIG_CEC_NOTIFIER=y
> +CONFIG_CEC_PLATFORM_DRIVERS=y
> +CONFIG_CLKDEV_LOOKUP=y
> +CONFIG_CLONE_BACKWARDS=y
> +CONFIG_CMA=y
> +CONFIG_CMA_ALIGNMENT=8
> +CONFIG_CMA_AREAS=7
> +# CONFIG_CMA_DEBUG is not set
> +# CONFIG_CMA_DEBUGFS is not set
> +CONFIG_CMA_SIZE_MBYTES=16
> +# CONFIG_CMA_SIZE_SEL_MAX is not set
> +CONFIG_CMA_SIZE_SEL_MBYTES=y
> +# CONFIG_CMA_SIZE_SEL_MIN is not set
> +# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
> +CONFIG_COMMON_CLK=y
> +CONFIG_COMMON_CLK_AMLOGIC=y
> +CONFIG_COMMON_CLK_GXBB=y
> +# CONFIG_COMMON_CLK_SCPI is not set
> +CONFIG_COMMON_CLK_XGENE=y

CONFIG_COMMON_CLK_XGENE is probably not needed

> +CONFIG_COMPACTION=y
> +# CONFIG_COMPAT is not set
> +CONFIG_CONSOLE_TRANSLATIONS=y
> +CONFIG_COREDUMP=y
> +# CONFIG_CPU_BIG_ENDIAN is not set
> +CONFIG_CPU_RMAP=y
> +CONFIG_CRC16=y
> +CONFIG_CRC7=y
> +CONFIG_CRC_ITU_T=y
> +CONFIG_CRYPTO_AEAD=y
> +CONFIG_CRYPTO_AEAD2=y
> +CONFIG_CRYPTO_CRC32=y
> +CONFIG_CRYPTO_CRC32C=y
> +CONFIG_CRYPTO_HASH=y
> +CONFIG_CRYPTO_HASH2=y
> +CONFIG_CRYPTO_MANAGER=y
> +CONFIG_CRYPTO_MANAGER2=y
> +CONFIG_CRYPTO_NULL2=y
> +CONFIG_CRYPTO_RNG2=y
> +CONFIG_CRYPTO_WORKQUEUE=y

Are all these crypto algorithms needed by default?

> +CONFIG_DCACHE_WORD_ACCESS=y
> +CONFIG_DEBUG_INFO=y
> +CONFIG_DMA_CMA=y
> +CONFIG_DMA_SHARED_BUFFER=y
> +CONFIG_DRM=y
> +CONFIG_DRM_ARM=y
> +CONFIG_DRM_BRIDGE=y
> +CONFIG_DRM_DW_HDMI=y
> +CONFIG_DRM_GEM_CMA_HELPER=y
> +CONFIG_DRM_KMS_CMA_HELPER=y
> +CONFIG_DRM_KMS_FB_HELPER=y
> +CONFIG_DRM_KMS_HELPER=y
> +CONFIG_DRM_MALI_DISPLAY=y
> +CONFIG_DRM_MESON=y
> +CONFIG_DRM_MESON_DW_HDMI=y
> +CONFIG_DRM_PANEL=y
> +CONFIG_DRM_PANEL_BRIDGE=y
> +CONFIG_DTC=y
> +CONFIG_DUMMY_CONSOLE=y
> +CONFIG_DWMAC_DWC_QOS_ETH=y
> +# CONFIG_DWMAC_GENERIC is not set
> +CONFIG_DWMAC_MESON=y
> +CONFIG_EDAC_SUPPORT=y
> +CONFIG_ELF_CORE=y
> +CONFIG_EXT4_FS=y
> +CONFIG_EXT4_FS_SECURITY=y
> +CONFIG_EXTCON=y
> +# CONFIG_F2FS_CHECK_FS is not set
> +CONFIG_F2FS_FS=y
> +CONFIG_F2FS_FS_POSIX_ACL=y
> +# CONFIG_F2FS_FS_SECURITY is not set
> +CONFIG_F2FS_FS_XATTR=y
> +CONFIG_F2FS_STAT_FS=y
> +CONFIG_FB=y
> +CONFIG_FB_CFB_COPYAREA=y
> +CONFIG_FB_CFB_FILLRECT=y
> +CONFIG_FB_CFB_IMAGEBLIT=y
> +CONFIG_FB_CMDLINE=y
> +CONFIG_FB_DEFERRED_IO=y
> +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set
> +CONFIG_FB_SYS_COPYAREA=y
> +CONFIG_FB_SYS_FILLRECT=y
> +CONFIG_FB_SYS_FOPS=y
> +CONFIG_FB_SYS_IMAGEBLIT=y
> +CONFIG_FIXED_PHY=y
> +CONFIG_FIX_EARLYCON_MEM=y
> +# CONFIG_FONTS is not set
> +CONFIG_FONT_8x16=y
> +CONFIG_FONT_8x8=y
> +CONFIG_FONT_SUPPORT=y
> +CONFIG_FRAMEBUFFER_CONSOLE=y
> +CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
> +# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
> +CONFIG_FRAME_POINTER=y
> +CONFIG_FSL_ERRATUM_A008585=y
> +CONFIG_FS_MBCACHE=y
> +CONFIG_FS_POSIX_ACL=y
> +CONFIG_GENERIC_ALLOCATOR=y
> +CONFIG_GENERIC_ARCH_TOPOLOGY=y
> +CONFIG_GENERIC_BUG=y
> +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
> +CONFIG_GENERIC_CLOCKEVENTS=y
> +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
> +CONFIG_GENERIC_CPU_AUTOPROBE=y
> +CONFIG_GENERIC_CSUM=y
> +CONFIG_GENERIC_EARLY_IOREMAP=y
> +CONFIG_GENERIC_IDLE_POLL_SETUP=y
> +CONFIG_GENERIC_IO=y
> +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y
> +CONFIG_GENERIC_IRQ_SHOW=y
> +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
> +CONFIG_GENERIC_PCI_IOMAP=y
> +CONFIG_GENERIC_PHY=y
> +CONFIG_GENERIC_PINCONF=y
> +CONFIG_GENERIC_PINCTRL_GROUPS=y
> +CONFIG_GENERIC_PINMUX_FUNCTIONS=y
> +CONFIG_GENERIC_SCHED_CLOCK=y
> +CONFIG_GENERIC_SMP_IDLE_THREAD=y
> +CONFIG_GENERIC_STRNCPY_FROM_USER=y
> +CONFIG_GENERIC_STRNLEN_USER=y
> +CONFIG_GENERIC_TIME_VSYSCALL=y
> +CONFIG_GLOB=y
> +CONFIG_GPIOLIB=y
> +CONFIG_GPIO_SYSFS=y
> +# CONFIG_GRO_CELLS is not set
> +CONFIG_HANDLE_DOMAIN_IRQ=y
> +CONFIG_HARDEN_BRANCH_PREDICTOR=y
> +CONFIG_HARDIRQS_SW_RESEND=y
> +CONFIG_HAS_DMA=y
> +CONFIG_HAS_IOMEM=y
> +# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
> +CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
> +CONFIG_HAVE_ARCH_AUDITSYSCALL=y
> +CONFIG_HAVE_ARCH_BITREVERSE=y
> +CONFIG_HAVE_ARCH_HUGE_VMAP=y
> +CONFIG_HAVE_ARCH_JUMP_LABEL=y
> +CONFIG_HAVE_ARCH_KASAN=y
> +CONFIG_HAVE_ARCH_KGDB=y
> +CONFIG_HAVE_ARCH_PFN_VALID=y
> +CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
> +CONFIG_HAVE_ARCH_TRACEHOOK=y
> +CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
> +CONFIG_HAVE_ARCH_VMAP_STACK=y
> +CONFIG_HAVE_ARM_SMCCC=y
> +# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
> +CONFIG_HAVE_CC_STACKPROTECTOR=y
> +CONFIG_HAVE_CLK=y
> +CONFIG_HAVE_CLK_PREPARE=y
> +CONFIG_HAVE_CMPXCHG_DOUBLE=y
> +CONFIG_HAVE_CMPXCHG_LOCAL=y
> +CONFIG_HAVE_CONTEXT_TRACKING=y
> +CONFIG_HAVE_C_RECORDMCOUNT=y
> +CONFIG_HAVE_DEBUG_BUGVERBOSE=y
> +CONFIG_HAVE_DEBUG_KMEMLEAK=y
> +CONFIG_HAVE_DMA_API_DEBUG=y
> +CONFIG_HAVE_DMA_CONTIGUOUS=y
> +CONFIG_HAVE_DYNAMIC_FTRACE=y
> +CONFIG_HAVE_EBPF_JIT=y
> +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
> +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
> +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
> +CONFIG_HAVE_FUNCTION_TRACER=y
> +CONFIG_HAVE_GENERIC_DMA_COHERENT=y
> +CONFIG_HAVE_GENERIC_GUP=y
> +CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
> +CONFIG_HAVE_MEMBLOCK=y
> +CONFIG_HAVE_MEMORY_PRESENT=y
> +CONFIG_HAVE_NET_DSA=y
> +CONFIG_HAVE_PATA_PLATFORM=y
> +CONFIG_HAVE_PERF_EVENTS=y
> +CONFIG_HAVE_PERF_REGS=y
> +CONFIG_HAVE_PERF_USER_STACK_DUMP=y
> +CONFIG_HAVE_RCU_TABLE_FREE=y
> +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
> +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
> +CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
> +CONFIG_HDMI=y
> +CONFIG_HISILICON_ERRATUM_161010101=y
> +CONFIG_HOLES_IN_ZONE=y
> +# CONFIG_HUGETLBFS is not set
> +CONFIG_HWMON=y
> +CONFIG_HW_CONSOLE=y
> +CONFIG_HW_RANDOM=y
> +CONFIG_HW_RANDOM_MESON=y
> +CONFIG_I2C=y
> +CONFIG_I2C_ALGOBIT=y
> +CONFIG_I2C_BOARDINFO=y
> +CONFIG_I2C_MESON=y
> +CONFIG_IIO=y
> +# CONFIG_IIO_BUFFER is not set
> +# CONFIG_IIO_TRIGGER is not set
> +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
> +CONFIG_INPUT=y
> +CONFIG_IOMMU_HELPER=y
> +CONFIG_IOSCHED_BFQ=y
> +CONFIG_IPV6=y

IPv6 should be provided by a module like for other OpenWrt tragets.

> +CONFIG_IPV6_MROUTE=y
> +CONFIG_IPV6_MULTIPLE_TABLES=y
> +# CONFIG_IPV6_PIMSM_V2 is not set
> +CONFIG_IPV6_SUBTREES=y
> +CONFIG_IRQCHIP=y
> +CONFIG_IRQ_DOMAIN=y
> +CONFIG_IRQ_DOMAIN_HIERARCHY=y
> +CONFIG_IRQ_FORCED_THREADING=y
> +CONFIG_IRQ_WORK=y
> +CONFIG_IR_MESON=y
> +# CONFIG_IR_SERIAL is not set
> +# CONFIG_IR_SIR is not set
> +CONFIG_JBD2=y
> +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set
> +CONFIG_LEDS_GPIO=y
> +CONFIG_LIBFDT=y
> +CONFIG_LOCK_SPIN_ON_OWNER=y
> +CONFIG_MAGIC_SYSRQ=y
> +CONFIG_MAILBOX=y
> +# CONFIG_MAILBOX_TEST is not set
> +CONFIG_MDIO_BUS=y
> +CONFIG_MDIO_DEVICE=y
> +CONFIG_MEDIA_CEC_RC=y
> +CONFIG_MEDIA_CEC_SUPPORT=y
> +CONFIG_MEDIA_SUPPORT=y
> +CONFIG_MEMORY_ISOLATION=y
> +CONFIG_MESON_EFUSE=y
> +CONFIG_MESON_GXBB_WATCHDOG=y
> +# CONFIG_MESON_GXL_PHY is not set
> +CONFIG_MESON_GX_PM_DOMAINS=y
> +CONFIG_MESON_GX_SOCINFO=y
> +CONFIG_MESON_MX_SOCINFO=y
> +CONFIG_MESON_SARADC=y
> +CONFIG_MESON_SM=y
> +CONFIG_MESON_WATCHDOG=y
> +CONFIG_MFD_SYSCON=y
> +CONFIG_MIGRATION=y
> +CONFIG_MMC=y
> +CONFIG_MMC_ARMMMCI=y
> +CONFIG_MMC_BLOCK=y
> +CONFIG_MMC_MESON_GX=y
> +CONFIG_MMC_SPI=y
> +CONFIG_MODULES_USE_ELF_RELA=y
> +CONFIG_MQ_IOSCHED_DEADLINE=y
> +CONFIG_MQ_IOSCHED_KYBER=y
> +CONFIG_MUTEX_SPIN_ON_OWNER=y
> +CONFIG_NEED_DMA_MAP_STATE=y
> +CONFIG_NEED_SG_DMA_LENGTH=y
> +CONFIG_NET_CLS_ACT=y
> +CONFIG_NET_EMATCH=y
> +CONFIG_NET_FLOW_LIMIT=y
> +CONFIG_NET_PTP_CLASSIFY=y
> +CONFIG_NLS=y
> +CONFIG_NO_BOOTMEM=y
> +CONFIG_NO_HZ_COMMON=y
> +CONFIG_NO_HZ_IDLE=y
> +CONFIG_NO_IOPORT_MAP=y
> +CONFIG_NR_CPUS=8
> +# CONFIG_NUMA is not set
> +CONFIG_NVMEM=y
> +CONFIG_OF=y
> +CONFIG_OF_ADDRESS=y
> +CONFIG_OF_EARLY_FLATTREE=y
> +CONFIG_OF_FLATTREE=y
> +CONFIG_OF_GPIO=y
> +CONFIG_OF_IRQ=y
> +CONFIG_OF_MDIO=y
> +CONFIG_OF_NET=y
> +CONFIG_OF_RESERVED_MEM=y
> +CONFIG_PADATA=y
> +CONFIG_PARTITION_PERCPU=y
> +# CONFIG_PCI_DOMAINS is not set
> +# CONFIG_PCI_DOMAINS_GENERIC is not set
> +# CONFIG_PCI_SYSCALL is not set
> +CONFIG_PGTABLE_LEVELS=4
> +CONFIG_PHYLIB=y
> +CONFIG_PHYS_ADDR_T_64BIT=y
> +CONFIG_PHY_MESON8B_USB2=y
> +CONFIG_PHY_MESON_GXL_USB2=y
> +CONFIG_PINCTRL=y
> +CONFIG_PINCTRL_MESON=y
> +CONFIG_PLATFORM_MHU=y
> +CONFIG_PM=y
> +CONFIG_PM_CLK=y
> +# CONFIG_PM_DEBUG is not set
> +CONFIG_PM_GENERIC_DOMAINS=y
> +CONFIG_PM_GENERIC_DOMAINS_OF=y
> +CONFIG_POSIX_MQUEUE=y
> +CONFIG_POSIX_MQUEUE_SYSCTL=y
> +CONFIG_POWER_RESET=y
> +CONFIG_POWER_SUPPLY=y
> +CONFIG_PPS=y
> +CONFIG_PRINTK_TIME=y
> +CONFIG_PTP_1588_CLOCK=y
> +CONFIG_PWM=y
> +CONFIG_PWM_MESON=y
> +CONFIG_PWM_SYSFS=y
> +# CONFIG_RANDOMIZE_BASE is not set
> +CONFIG_RATIONAL=y
> +CONFIG_RCU_NEED_SEGCBLIST=y
> +CONFIG_RCU_STALL_COMMON=y
> +CONFIG_RC_CORE=y
> +CONFIG_RC_DEVICES=y
> +CONFIG_REALTEK_PHY=y
> +CONFIG_REGMAP=y
> +CONFIG_REGMAP_I2C=y
> +CONFIG_REGMAP_MMIO=y
> +CONFIG_REGULATOR=y
> +CONFIG_REGULATOR_DEBUG=y
> +CONFIG_REGULATOR_FIXED_VOLTAGE=y
> +CONFIG_REGULATOR_GPIO=y
> +CONFIG_RESET_CONTROLLER=y
> +CONFIG_RESET_MESON=y
> +CONFIG_RFS_ACCEL=y
> +CONFIG_RPS=y
> +CONFIG_RWSEM_SPIN_ON_OWNER=y
> +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
> +# CONFIG_SCHED_INFO is not set
> +# CONFIG_SCSI_DMA is not set
> +CONFIG_SDIO_UART=y
> +CONFIG_SENSORS_ARM_SCPI=y
> +CONFIG_SERIAL_8250_FSL=y
> +# CONFIG_SERIAL_AMBA_PL011 is not set
> +CONFIG_SERIAL_MESON=y
> +CONFIG_SERIAL_MESON_CONSOLE=y
> +CONFIG_SMP=y
> +CONFIG_SOC_BUS=y
> +CONFIG_SPARSEMEM=y
> +CONFIG_SPARSEMEM_EXTREME=y
> +CONFIG_SPARSEMEM_MANUAL=y
> +CONFIG_SPARSEMEM_VMEMMAP=y
> +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
> +CONFIG_SPARSE_IRQ=y
> +CONFIG_SPI=y
> +CONFIG_SPI_MASTER=y
> +CONFIG_SPI_MESON_SPICC=y
> +CONFIG_SPI_MESON_SPIFC=y
> +CONFIG_SRCU=y
> +CONFIG_STMMAC_ETH=y
> +CONFIG_STMMAC_PLATFORM=y
> +CONFIG_SWIOTLB=y
> +CONFIG_SWPHY=y
> +CONFIG_SYNC_FILE=y
> +CONFIG_SYSCTL_EXCEPTION_TRACE=y
> +CONFIG_SYS_SUPPORTS_HUGETLBFS=y
> +CONFIG_THREAD_INFO_IN_TASK=y
> +CONFIG_TICK_CPU_ACCOUNTING=y
> +CONFIG_TIMER_OF=y
> +CONFIG_TIMER_PROBE=y
> +CONFIG_TREE_RCU=y
> +CONFIG_TREE_SRCU=y
> +CONFIG_UNMAP_KERNEL_AT_EL0=y
> +CONFIG_USB=y
> +CONFIG_USB_COMMON=y
> +CONFIG_USB_DWC2=y
> +CONFIG_USB_DWC2_DUAL_ROLE=y
> +# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set
> +# CONFIG_USB_EHCI_HCD is not set
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_OTG=y
> +CONFIG_USB_OTG_FSM=y
> +CONFIG_USB_PHY=y
> +CONFIG_USB_SUPPORT=y
> +CONFIG_VIDEOMODE_HELPERS=y
> +CONFIG_VIDEO_MESON_AO_CEC=y
> +CONFIG_VMAP_STACK=y
> +CONFIG_VT=y
> +CONFIG_VT_CONSOLE=y
> +CONFIG_VT_HW_CONSOLE_BINDING=y

Is the VT faremwork needed?

> +CONFIG_WATCHDOG_CORE=y
> +CONFIG_XPS=y
> diff --git a/target/linux/mesongx/image/Makefile b/target/linux/mesongx/image/Makefile
> new file mode 100644
> index 0000000000..d2fba8ca03
> --- /dev/null
> +++ b/target/linux/mesongx/image/Makefile
> @@ -0,0 +1,66 @@
> +#
> +# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +include $(TOPDIR)/rules.mk
> +include $(INCLUDE_DIR)/image.mk
> +
> +define Build/bootloader-odroid-c2
> +	fip_create \
> +		--bl30  $(STAGING_DIR_IMAGE)/odroidc2/bl30.bin \
> +		--bl301 $(STAGING_DIR_IMAGE)/odroidc2/bl301.bin \
> +		--bl31  $(STAGING_DIR_IMAGE)/odroidc2/bl31.bin \
> +		--bl33  $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin \
> +		$(BIN_DIR)/u-boot-odroid-c2/fip.bin
> +
> +	cat $(STAGING_DIR_IMAGE)/odroidc2/bl2.package $(BIN_DIR)/u-boot-odroid-c2/fip.bin > $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin
> +
> +	amlbootsig $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed
> +
> +	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed of=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb bs=512 skip=96
> +	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=1 count=440
> +	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=512 skip=1 seek=1
> +	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb of=$@ conv=fsync,notrunc bs=512 seek=97
> +endef
> +
> +define Build/sdcard-img
> +	$(INSTALL_DIR) $(KDIR)/boot.ext4
> +	$(CP) $(KDIR)/boot.$1.scr $(KDIR)/boot.ext4/boot.scr
> +	$(CP) $(KDIR_KERNEL_IMAGE) $(KDIR)/boot.ext4/uImage
> +	$(foreach dts,$(DEVICE_DTS),$(CP) $(DTS_DIR)/$(dts).dtb $(KDIR)/boot.ext4/)
> +	PADDING="$(CONFIG_TARGET_IMAGES_PAD)" \
> +	PATH="$(TARGET_PATH)" \
> +	$(SCRIPT_DIR)/gen_image_generic.sh $@ \
> +		$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/boot.ext4 \
> +		$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
> +		4096
> +endef
> +
> +define Build/uImage-meson
> +	$(call Build/uImage,none)
> +	mkimage -A arm64 -T script -C none -n "boot.scr uImage" -d boot.$1.txt $(KDIR)/boot.$1.scr
> +endef
> +
> +### Devices ###
> +define Device/Default
> +  CONSOLE := ttyAML0,115200
> +  FILESYSTEMS := ext4 squashfs
> +  IMAGES := sdcard.img
> +  IMAGE/sdcard.img := sdcard-img $$(DEVICE_NAME) | bootloader-$$(DEVICE_NAME)
> +  KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
> +  KERNEL_LOADADDR := 0x01080000
> +  KERNEL_NAME := Image
> +  PROFILES = Default $$(DEVICE_NAME)
> +endef
> +
> +define Device/odroid-c2
> +  DEVICE_DTS := amlogic/meson-gxbb-odroidc2
> +  DEVICE_PACKAGES += odroid-firmware-c2 u-boot-odroid-c2
> +  DEVICE_TITLE := ODROID C2
> +  KERNEL := kernel-bin | uImage-meson $$(DEVICE_NAME)
> +endef
> +TARGET_DEVICES += odroid-c2
> +
> +$(eval $(call BuildImage))
> diff --git a/target/linux/mesongx/image/boot.odroid-c2.txt b/target/linux/mesongx/image/boot.odroid-c2.txt
> new file mode 100644
> index 0000000000..371e6ec42c
> --- /dev/null
> +++ b/target/linux/mesongx/image/boot.odroid-c2.txt
> @@ -0,0 +1,8 @@
> +setenv bootargs "root=PARTUUID=5452574f-02 rootwait ro rootfstype=ext4,squashfs console=ttyAML0,115200"
> +setenv loadaddr "0x01080000"
> +setenv dtb_loadaddr "0x01000000"
> +
> +ext2load mmc 0:1 ${loadaddr} uImage
> +ext2load mmc 0:1 ${dtb_loadaddr} meson-gxbb-odroidc2.dtb
> +
> +bootm ${loadaddr} - ${dtb_loadaddr}
>
diff mbox series

Patch

diff --git a/target/linux/mesongx/Makefile b/target/linux/mesongx/Makefile
new file mode 100644
index 0000000000..507f5d2526
--- /dev/null
+++ b/target/linux/mesongx/Makefile
@@ -0,0 +1,36 @@ 
+#
+# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+ARCH:=aarch64
+BOARD:=mesongx
+BOARDNAME:=Amlogic S9 family
+CPU_TYPE:=cortex-a53
+DEVICE_TYPE:=other
+FEATURES:=audio boot-part ext4 fpu squashfs usbgadget
+MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
+
+KERNEL_PATCHVER:=4.14
+
+define Target/Description
+	Build firmware image for Amlogic S9 SoC devices.
+endef
+
+include $(INCLUDE_DIR)/target.mk
+
+DEFAULT_PACKAGES += \
+	e2fsprogs \
+	kmod-sound-core \
+	kmod-usb-hid \
+	mkf2fs \
+	partx-utils \
+	v4l-utils
+
+KERNELNAME:=Image dtbs
+
+$(eval $(call BuildTarget))
diff --git a/target/linux/mesongx/base-files/etc/inittab b/target/linux/mesongx/base-files/etc/inittab
new file mode 100644
index 0000000000..a5100a7050
--- /dev/null
+++ b/target/linux/mesongx/base-files/etc/inittab
@@ -0,0 +1,5 @@ 
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+::askconsole:/usr/libexec/login.sh
+tty1::askfirst:/usr/libexec/login.sh
+ttyAML0::askfirst:/usr/libexec/login.sh
diff --git a/target/linux/mesongx/base-files/lib/preinit/79_move_config b/target/linux/mesongx/base-files/lib/preinit/79_move_config
new file mode 100644
index 0000000000..6ac1b3be69
--- /dev/null
+++ b/target/linux/mesongx/base-files/lib/preinit/79_move_config
@@ -0,0 +1,22 @@ 
+#!/bin/sh
+# Copyright (C) 2012-2015 OpenWrt.org
+
+move_config() {
+	local partdev
+
+	. /lib/upgrade/common.sh
+
+	if export_bootdevice && export_partdevice partdev 1; then
+		mkdir -p /boot
+		if mount -t ext4 -o ro,noatime "/dev/$partdev" /boot; then
+			if [ -f /boot/sysupgrade.tgz ]; then
+				mount /boot -o remount,rw,noatime
+				mv -f /boot/sysupgrade.tgz /
+				mount /boot -o remount,ro,noatime
+			fi
+		fi
+	fi
+}
+
+boot_hook_add preinit_mount_root move_config
+
diff --git a/target/linux/mesongx/base-files/lib/upgrade/platform.sh b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
new file mode 100644
index 0000000000..3bfefc6b92
--- /dev/null
+++ b/target/linux/mesongx/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,95 @@ 
+platform_check_image() {
+	local diskdev partdev diff
+	[ "$#" -gt 1 ] && return 1
+
+	case "$(get_magic_word "$1")" in
+		24c8) ;;
+		*)
+			echo "Invalid image type"
+			return 1
+		;;
+	esac
+
+	export_bootdevice && export_partdevice diskdev 0 || {
+		echo "Unable to determine upgrade device"
+		return 1
+	}
+
+	get_partitions "/dev/$diskdev" bootdisk
+
+	#extract the boot sector from the image
+	get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
+
+	get_partitions /tmp/image.bs image
+
+	#compare tables
+	diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
+
+	rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
+
+	if [ -n "$diff" ]; then
+		echo "Partition layout has changed. Full image will be written."
+		ask_bool 0 "Abort" && exit 1
+		return 0
+	fi
+}
+
+platform_copy_config() {
+	local partdev
+
+	if export_partdevice partdev 1; then
+		mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
+		cp -af "$CONF_TAR" /mnt/
+		umount /mnt
+	fi
+}
+
+platform_do_upgrade() {
+	local diskdev partdev diff
+
+	export_bootdevice && export_partdevice diskdev 0 || {
+		echo "Unable to determine upgrade device"
+		return 1
+	}
+
+	sync
+
+	if [ "$SAVE_PARTITIONS" = "1" ]; then
+		get_partitions "/dev/$diskdev" bootdisk
+
+		#extract the boot sector from the image
+		get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
+
+		get_partitions /tmp/image.bs image
+
+		#compare tables
+		diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
+	else
+		diff=1
+	fi
+
+	if [ -n "$diff" ]; then
+		get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
+
+		# Separate removal and addtion is necessary; otherwise, partition 1
+		# will be missing if it overlaps with the old partition 2
+		partx -d - "/dev/$diskdev"
+		partx -a - "/dev/$diskdev"
+
+		return 0
+	fi
+
+	#iterate over each partition from the image and write it to the boot disk
+	while read part start size; do
+		if export_partdevice partdev $part; then
+			echo "Writing image to /dev/$partdev..."
+			get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
+		else
+			echo "Unable to find partition $part device, skipped."
+		fi
+	done < /tmp/partmap.image
+
+	#copy partition uuid
+	echo "Writing new UUID to /dev/$diskdev..."
+	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
+}
diff --git a/target/linux/mesongx/config-4.14 b/target/linux/mesongx/config-4.14
new file mode 100644
index 0000000000..aa2ba17d4a
--- /dev/null
+++ b/target/linux/mesongx/config-4.14
@@ -0,0 +1,455 @@ 
+CONFIG_64BIT=y
+# CONFIG_AIO is not set
+CONFIG_ARCH_CLOCKSOURCE_DATA=y
+CONFIG_ARCH_DMA_ADDR_T_64BIT=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+CONFIG_ARCH_HAS_GIGANTIC_PAGE=y
+CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y
+CONFIG_ARCH_HAS_KCOV=y
+CONFIG_ARCH_HAS_PMEM_API=y
+CONFIG_ARCH_HAS_SET_MEMORY=y
+CONFIG_ARCH_HAS_SG_CHAIN=y
+CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
+CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
+CONFIG_ARCH_HAS_TICK_BROADCAST=y
+CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE=y
+CONFIG_ARCH_MESON=y
+CONFIG_ARCH_MMAP_RND_BITS=18
+CONFIG_ARCH_MMAP_RND_BITS_MAX=33
+CONFIG_ARCH_MMAP_RND_BITS_MIN=18
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11
+# CONFIG_ARCH_OPTIONAL_KERNEL_RWX is not set
+# CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT is not set
+CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
+CONFIG_ARCH_PROC_KCORE_TEXT=y
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
+CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
+CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
+CONFIG_ARCH_WANT_FRAME_POINTERS=y
+CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
+CONFIG_ARM64=y
+# CONFIG_ARM64_16K_PAGES is not set
+CONFIG_ARM64_4K_PAGES=y
+# CONFIG_ARM64_64K_PAGES is not set
+CONFIG_ARM64_CONT_SHIFT=4
+# CONFIG_ARM64_CRYPTO is not set
+CONFIG_ARM64_ERRATUM_819472=y
+CONFIG_ARM64_ERRATUM_824069=y
+CONFIG_ARM64_ERRATUM_826319=y
+CONFIG_ARM64_ERRATUM_827319=y
+CONFIG_ARM64_ERRATUM_843419=y
+CONFIG_ARM64_ERRATUM_858921=y
+CONFIG_ARM64_HW_AFDBM=y
+# CONFIG_ARM64_LSE_ATOMICS is not set
+CONFIG_ARM64_MODULE_CMODEL_LARGE=y
+CONFIG_ARM64_PAGE_SHIFT=12
+CONFIG_ARM64_PAN=y
+CONFIG_ARM64_PMEM=y
+# CONFIG_ARM64_PTDUMP_CORE is not set
+# CONFIG_ARM64_PTDUMP_DEBUGFS is not set
+# CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET is not set
+CONFIG_ARM64_SSBD=y
+# CONFIG_ARM64_SW_TTBR0_PAN is not set
+CONFIG_ARM64_UAO=y
+CONFIG_ARM64_VA_BITS=48
+# CONFIG_ARM64_VA_BITS_39 is not set
+CONFIG_ARM64_VA_BITS_48=y
+CONFIG_ARM64_VHE=y
+CONFIG_ARM_AMBA=y
+CONFIG_ARM_ARCH_TIMER=y
+CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
+CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND=y
+CONFIG_ARM_GIC=y
+CONFIG_ARM_GIC_V3=y
+CONFIG_ARM_PSCI_FW=y
+CONFIG_ARM_SCPI_POWER_DOMAIN=y
+CONFIG_ARM_SCPI_PROTOCOL=y
+# CONFIG_ARM_SP805_WATCHDOG is not set
+CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
+# CONFIG_BCM_FLEXRM_MBOX is not set
+CONFIG_BLK_DEBUG_FS=y
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BOUNCE=y
+CONFIG_CC_STACKPROTECTOR=y
+# CONFIG_CC_STACKPROTECTOR_NONE is not set
+CONFIG_CC_STACKPROTECTOR_STRONG=y
+CONFIG_CEC_CORE=y
+CONFIG_CEC_NOTIFIER=y
+CONFIG_CEC_PLATFORM_DRIVERS=y
+CONFIG_CLKDEV_LOOKUP=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_CMA=y
+CONFIG_CMA_ALIGNMENT=8
+CONFIG_CMA_AREAS=7
+# CONFIG_CMA_DEBUG is not set
+# CONFIG_CMA_DEBUGFS is not set
+CONFIG_CMA_SIZE_MBYTES=16
+# CONFIG_CMA_SIZE_SEL_MAX is not set
+CONFIG_CMA_SIZE_SEL_MBYTES=y
+# CONFIG_CMA_SIZE_SEL_MIN is not set
+# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
+CONFIG_COMMON_CLK=y
+CONFIG_COMMON_CLK_AMLOGIC=y
+CONFIG_COMMON_CLK_GXBB=y
+# CONFIG_COMMON_CLK_SCPI is not set
+CONFIG_COMMON_CLK_XGENE=y
+CONFIG_COMPACTION=y
+# CONFIG_COMPAT is not set
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_COREDUMP=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_CPU_RMAP=y
+CONFIG_CRC16=y
+CONFIG_CRC7=y
+CONFIG_CRC_ITU_T=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_CRC32=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+CONFIG_CRYPTO_NULL2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_DCACHE_WORD_ACCESS=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DMA_CMA=y
+CONFIG_DMA_SHARED_BUFFER=y
+CONFIG_DRM=y
+CONFIG_DRM_ARM=y
+CONFIG_DRM_BRIDGE=y
+CONFIG_DRM_DW_HDMI=y
+CONFIG_DRM_GEM_CMA_HELPER=y
+CONFIG_DRM_KMS_CMA_HELPER=y
+CONFIG_DRM_KMS_FB_HELPER=y
+CONFIG_DRM_KMS_HELPER=y
+CONFIG_DRM_MALI_DISPLAY=y
+CONFIG_DRM_MESON=y
+CONFIG_DRM_MESON_DW_HDMI=y
+CONFIG_DRM_PANEL=y
+CONFIG_DRM_PANEL_BRIDGE=y
+CONFIG_DTC=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_DWMAC_DWC_QOS_ETH=y
+# CONFIG_DWMAC_GENERIC is not set
+CONFIG_DWMAC_MESON=y
+CONFIG_EDAC_SUPPORT=y
+CONFIG_ELF_CORE=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_EXTCON=y
+# CONFIG_F2FS_CHECK_FS is not set
+CONFIG_F2FS_FS=y
+CONFIG_F2FS_FS_POSIX_ACL=y
+# CONFIG_F2FS_FS_SECURITY is not set
+CONFIG_F2FS_FS_XATTR=y
+CONFIG_F2FS_STAT_FS=y
+CONFIG_FB=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+CONFIG_FB_CMDLINE=y
+CONFIG_FB_DEFERRED_IO=y
+# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set
+CONFIG_FB_SYS_COPYAREA=y
+CONFIG_FB_SYS_FILLRECT=y
+CONFIG_FB_SYS_FOPS=y
+CONFIG_FB_SYS_IMAGEBLIT=y
+CONFIG_FIXED_PHY=y
+CONFIG_FIX_EARLYCON_MEM=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x16=y
+CONFIG_FONT_8x8=y
+CONFIG_FONT_SUPPORT=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+CONFIG_FRAME_POINTER=y
+CONFIG_FSL_ERRATUM_A008585=y
+CONFIG_FS_MBCACHE=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_GENERIC_ARCH_TOPOLOGY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_GENERIC_CPU_AUTOPROBE=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_EARLY_IOREMAP=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_GENERIC_IO=y
+CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_PHY=y
+CONFIG_GENERIC_PINCONF=y
+CONFIG_GENERIC_PINCTRL_GROUPS=y
+CONFIG_GENERIC_PINMUX_FUNCTIONS=y
+CONFIG_GENERIC_SCHED_CLOCK=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GLOB=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+# CONFIG_GRO_CELLS is not set
+CONFIG_HANDLE_DOMAIN_IRQ=y
+CONFIG_HARDEN_BRANCH_PREDICTOR=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_HAS_DMA=y
+CONFIG_HAS_IOMEM=y
+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
+CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_HAVE_ARCH_BITREVERSE=y
+CONFIG_HAVE_ARCH_HUGE_VMAP=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_KASAN=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_ARCH_PFN_VALID=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
+CONFIG_HAVE_ARCH_VMAP_STACK=y
+CONFIG_HAVE_ARM_SMCCC=y
+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
+CONFIG_HAVE_CC_STACKPROTECTOR=y
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_HAVE_CMPXCHG_DOUBLE=y
+CONFIG_HAVE_CMPXCHG_LOCAL=y
+CONFIG_HAVE_CONTEXT_TRACKING=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_DEBUG_BUGVERBOSE=y
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_EBPF_JIT=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_HAVE_GENERIC_GUP=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+CONFIG_HAVE_NET_DSA=y
+CONFIG_HAVE_PATA_PLATFORM=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_HAVE_PERF_REGS=y
+CONFIG_HAVE_PERF_USER_STACK_DUMP=y
+CONFIG_HAVE_RCU_TABLE_FREE=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HDMI=y
+CONFIG_HISILICON_ERRATUM_161010101=y
+CONFIG_HOLES_IN_ZONE=y
+# CONFIG_HUGETLBFS is not set
+CONFIG_HWMON=y
+CONFIG_HW_CONSOLE=y
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_MESON=y
+CONFIG_I2C=y
+CONFIG_I2C_ALGOBIT=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_MESON=y
+CONFIG_IIO=y
+# CONFIG_IIO_BUFFER is not set
+# CONFIG_IIO_TRIGGER is not set
+CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
+CONFIG_INPUT=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_IOSCHED_BFQ=y
+CONFIG_IPV6=y
+CONFIG_IPV6_MROUTE=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
+# CONFIG_IPV6_PIMSM_V2 is not set
+CONFIG_IPV6_SUBTREES=y
+CONFIG_IRQCHIP=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_DOMAIN_HIERARCHY=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_IRQ_WORK=y
+CONFIG_IR_MESON=y
+# CONFIG_IR_SERIAL is not set
+# CONFIG_IR_SIR is not set
+CONFIG_JBD2=y
+# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set
+CONFIG_LEDS_GPIO=y
+CONFIG_LIBFDT=y
+CONFIG_LOCK_SPIN_ON_OWNER=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MAILBOX=y
+# CONFIG_MAILBOX_TEST is not set
+CONFIG_MDIO_BUS=y
+CONFIG_MDIO_DEVICE=y
+CONFIG_MEDIA_CEC_RC=y
+CONFIG_MEDIA_CEC_SUPPORT=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEMORY_ISOLATION=y
+CONFIG_MESON_EFUSE=y
+CONFIG_MESON_GXBB_WATCHDOG=y
+# CONFIG_MESON_GXL_PHY is not set
+CONFIG_MESON_GX_PM_DOMAINS=y
+CONFIG_MESON_GX_SOCINFO=y
+CONFIG_MESON_MX_SOCINFO=y
+CONFIG_MESON_SARADC=y
+CONFIG_MESON_SM=y
+CONFIG_MESON_WATCHDOG=y
+CONFIG_MFD_SYSCON=y
+CONFIG_MIGRATION=y
+CONFIG_MMC=y
+CONFIG_MMC_ARMMMCI=y
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_MMC_SPI=y
+CONFIG_MODULES_USE_ELF_RELA=y
+CONFIG_MQ_IOSCHED_DEADLINE=y
+CONFIG_MQ_IOSCHED_KYBER=y
+CONFIG_MUTEX_SPIN_ON_OWNER=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_NEED_SG_DMA_LENGTH=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_EMATCH=y
+CONFIG_NET_FLOW_LIMIT=y
+CONFIG_NET_PTP_CLASSIFY=y
+CONFIG_NLS=y
+CONFIG_NO_BOOTMEM=y
+CONFIG_NO_HZ_COMMON=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NO_IOPORT_MAP=y
+CONFIG_NR_CPUS=8
+# CONFIG_NUMA is not set
+CONFIG_NVMEM=y
+CONFIG_OF=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_MDIO=y
+CONFIG_OF_NET=y
+CONFIG_OF_RESERVED_MEM=y
+CONFIG_PADATA=y
+CONFIG_PARTITION_PERCPU=y
+# CONFIG_PCI_DOMAINS is not set
+# CONFIG_PCI_DOMAINS_GENERIC is not set
+# CONFIG_PCI_SYSCALL is not set
+CONFIG_PGTABLE_LEVELS=4
+CONFIG_PHYLIB=y
+CONFIG_PHYS_ADDR_T_64BIT=y
+CONFIG_PHY_MESON8B_USB2=y
+CONFIG_PHY_MESON_GXL_USB2=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON=y
+CONFIG_PLATFORM_MHU=y
+CONFIG_PM=y
+CONFIG_PM_CLK=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_GENERIC_DOMAINS=y
+CONFIG_PM_GENERIC_DOMAINS_OF=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_SUPPLY=y
+CONFIG_PPS=y
+CONFIG_PRINTK_TIME=y
+CONFIG_PTP_1588_CLOCK=y
+CONFIG_PWM=y
+CONFIG_PWM_MESON=y
+CONFIG_PWM_SYSFS=y
+# CONFIG_RANDOMIZE_BASE is not set
+CONFIG_RATIONAL=y
+CONFIG_RCU_NEED_SEGCBLIST=y
+CONFIG_RCU_STALL_COMMON=y
+CONFIG_RC_CORE=y
+CONFIG_RC_DEVICES=y
+CONFIG_REALTEK_PHY=y
+CONFIG_REGMAP=y
+CONFIG_REGMAP_I2C=y
+CONFIG_REGMAP_MMIO=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_DEBUG=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_GPIO=y
+CONFIG_RESET_CONTROLLER=y
+CONFIG_RESET_MESON=y
+CONFIG_RFS_ACCEL=y
+CONFIG_RPS=y
+CONFIG_RWSEM_SPIN_ON_OWNER=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+# CONFIG_SCHED_INFO is not set
+# CONFIG_SCSI_DMA is not set
+CONFIG_SDIO_UART=y
+CONFIG_SENSORS_ARM_SCPI=y
+CONFIG_SERIAL_8250_FSL=y
+# CONFIG_SERIAL_AMBA_PL011 is not set
+CONFIG_SERIAL_MESON=y
+CONFIG_SERIAL_MESON_CONSOLE=y
+CONFIG_SMP=y
+CONFIG_SOC_BUS=y
+CONFIG_SPARSEMEM=y
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSE_IRQ=y
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_MESON_SPICC=y
+CONFIG_SPI_MESON_SPIFC=y
+CONFIG_SRCU=y
+CONFIG_STMMAC_ETH=y
+CONFIG_STMMAC_PLATFORM=y
+CONFIG_SWIOTLB=y
+CONFIG_SWPHY=y
+CONFIG_SYNC_FILE=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYS_SUPPORTS_HUGETLBFS=y
+CONFIG_THREAD_INFO_IN_TASK=y
+CONFIG_TICK_CPU_ACCOUNTING=y
+CONFIG_TIMER_OF=y
+CONFIG_TIMER_PROBE=y
+CONFIG_TREE_RCU=y
+CONFIG_TREE_SRCU=y
+CONFIG_UNMAP_KERNEL_AT_EL0=y
+CONFIG_USB=y
+CONFIG_USB_COMMON=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_DWC2_DUAL_ROLE=y
+# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set
+# CONFIG_USB_EHCI_HCD is not set
+CONFIG_USB_GADGET=y
+CONFIG_USB_OTG=y
+CONFIG_USB_OTG_FSM=y
+CONFIG_USB_PHY=y
+CONFIG_USB_SUPPORT=y
+CONFIG_VIDEOMODE_HELPERS=y
+CONFIG_VIDEO_MESON_AO_CEC=y
+CONFIG_VMAP_STACK=y
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_WATCHDOG_CORE=y
+CONFIG_XPS=y
diff --git a/target/linux/mesongx/image/Makefile b/target/linux/mesongx/image/Makefile
new file mode 100644
index 0000000000..d2fba8ca03
--- /dev/null
+++ b/target/linux/mesongx/image/Makefile
@@ -0,0 +1,66 @@ 
+#
+# Copyright (C) 2017-2018 Stijn Tintel <stijn@linux-ipv6.be>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/image.mk
+
+define Build/bootloader-odroid-c2
+	fip_create \
+		--bl30  $(STAGING_DIR_IMAGE)/odroidc2/bl30.bin \
+		--bl301 $(STAGING_DIR_IMAGE)/odroidc2/bl301.bin \
+		--bl31  $(STAGING_DIR_IMAGE)/odroidc2/bl31.bin \
+		--bl33  $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin \
+		$(BIN_DIR)/u-boot-odroid-c2/fip.bin
+
+	cat $(STAGING_DIR_IMAGE)/odroidc2/bl2.package $(BIN_DIR)/u-boot-odroid-c2/fip.bin > $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin
+
+	amlbootsig $(BIN_DIR)/u-boot-odroid-c2/boot_new.bin $(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed
+
+	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.bin.signed of=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb bs=512 skip=96
+	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=1 count=440
+	dd if=$(STAGING_DIR_IMAGE)/odroidc2/bl1.bin.hardkernel of=$@ conv=fsync,notrunc bs=512 skip=1 seek=1
+	dd if=$(BIN_DIR)/u-boot-odroid-c2/u-boot.gxbb of=$@ conv=fsync,notrunc bs=512 seek=97
+endef
+
+define Build/sdcard-img
+	$(INSTALL_DIR) $(KDIR)/boot.ext4
+	$(CP) $(KDIR)/boot.$1.scr $(KDIR)/boot.ext4/boot.scr
+	$(CP) $(KDIR_KERNEL_IMAGE) $(KDIR)/boot.ext4/uImage
+	$(foreach dts,$(DEVICE_DTS),$(CP) $(DTS_DIR)/$(dts).dtb $(KDIR)/boot.ext4/)
+	PADDING="$(CONFIG_TARGET_IMAGES_PAD)" \
+	PATH="$(TARGET_PATH)" \
+	$(SCRIPT_DIR)/gen_image_generic.sh $@ \
+		$(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/boot.ext4 \
+		$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
+		4096
+endef
+
+define Build/uImage-meson
+	$(call Build/uImage,none)
+	mkimage -A arm64 -T script -C none -n "boot.scr uImage" -d boot.$1.txt $(KDIR)/boot.$1.scr
+endef
+
+### Devices ###
+define Device/Default
+  CONSOLE := ttyAML0,115200
+  FILESYSTEMS := ext4 squashfs
+  IMAGES := sdcard.img
+  IMAGE/sdcard.img := sdcard-img $$(DEVICE_NAME) | bootloader-$$(DEVICE_NAME)
+  KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
+  KERNEL_LOADADDR := 0x01080000
+  KERNEL_NAME := Image
+  PROFILES = Default $$(DEVICE_NAME)
+endef
+
+define Device/odroid-c2
+  DEVICE_DTS := amlogic/meson-gxbb-odroidc2
+  DEVICE_PACKAGES += odroid-firmware-c2 u-boot-odroid-c2
+  DEVICE_TITLE := ODROID C2
+  KERNEL := kernel-bin | uImage-meson $$(DEVICE_NAME)
+endef
+TARGET_DEVICES += odroid-c2
+
+$(eval $(call BuildImage))
diff --git a/target/linux/mesongx/image/boot.odroid-c2.txt b/target/linux/mesongx/image/boot.odroid-c2.txt
new file mode 100644
index 0000000000..371e6ec42c
--- /dev/null
+++ b/target/linux/mesongx/image/boot.odroid-c2.txt
@@ -0,0 +1,8 @@ 
+setenv bootargs "root=PARTUUID=5452574f-02 rootwait ro rootfstype=ext4,squashfs console=ttyAML0,115200"
+setenv loadaddr "0x01080000"
+setenv dtb_loadaddr "0x01000000"
+
+ext2load mmc 0:1 ${loadaddr} uImage
+ext2load mmc 0:1 ${dtb_loadaddr} meson-gxbb-odroidc2.dtb
+
+bootm ${loadaddr} - ${dtb_loadaddr}