[OpenWrt-Devel] [PATCH] imx6: Adding Ka-Ro electronics TX6U-8033 Module on MB7 baseboard support

Adrian Schmutzler mail at adrianschmutzler.de
Thu Nov 28 12:30:10 EST 2019


Hi,

[...]

> -*wandboard)
> +*wandboard |\
> +*tx6u-8033)
>  	ucidef_set_interface_wan 'eth0'
>  	;;

Please do not use wildcard characters for the board name. This makes it really ugly to change anything later, as you cannot grep for a particular device.
Despite, I do not see any reason for introducing a wildcard for supporting a single device.

>  esac
> diff --git a/target/linux/imx6/base-files/lib/imx6.sh b/target/linux/imx6/base-
> files/lib/imx6.sh
> index 68caaff15f..c4b87d1c21 100755
> --- a/target/linux/imx6/base-files/lib/imx6.sh
> +++ b/target/linux/imx6/base-files/lib/imx6.sh
> @@ -99,6 +99,10 @@ imx6_board_detect() {
>  		name="wandboard"
>  		;;
> 
> +	"Ka-Ro electronics TX6U-8033 Module on MB7 baseboard")
> +		name="tx6u-8033"
> +		;;
> +

I'm not familiar with this target, but I wonder why we do not use the compatible here, but still define board names of our own (deviating from the compatible).
However, I admit that this currently is prevented by the default case below and this might be a little bit off-topic for the subject of this PR.
Nevertheless, it would be an improvement.

>  	*)
>  		name="generic"
>  		;;
> diff --git a/target/linux/imx6/base-files/lib/preinit/79_move_config
> b/target/linux/imx6/base-files/lib/preinit/79_move_config
> index bdf397c4fc..00e3570d1d 100644
> --- a/target/linux/imx6/base-files/lib/preinit/79_move_config
> +++ b/target/linux/imx6/base-files/lib/preinit/79_move_config
> @@ -15,6 +15,15 @@ move_config() {
>  			umount /boot
>  		fi
>  		;;
> +	*tx6u-8033*)

Please don't use wildcards.

> +		local bootpart=/dev/mmcblk2p1
> +
> +		if [ -b $bootpart ]; then
> +			mkdir -p /boot
> +			mount -t ext2 -o rw,noatime $bootpart /boot
> +			[ -f /boot/sysupgrade.tgz ] && mv -f
> /boot/sysupgrade.tgz /
> +		fi
> +		;;
>  	esac
>  }
> 
> diff --git a/target/linux/imx6/base-files/lib/upgrade/platform.sh
> b/target/linux/imx6/base-files/lib/upgrade/platform.sh
> index a090cc080b..d6eef0c3eb 100755
> --- a/target/linux/imx6/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/imx6/base-files/lib/upgrade/platform.sh
> @@ -1,5 +1,5 @@
>  #
> -# Copyright (C) 2010-2015 OpenWrt.org
> +# Copyright (C) 2010-2019 OpenWrt.org
>  #
> 
>  . /lib/imx6.sh
> @@ -30,6 +30,102 @@ apalis_do_upgrade() {
>  	umount /boot
>  }
> 
> +# (mostly) copied from brcm2708 platform.sh (which was copied from x86?)
> +tx6u_8033_check_image() {
> +	local diskdev partdev diff
> +
> +	[ "$#" -gt 1 ] && return 1
> +
> +	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
> +
> +	return 0;
> +}
> +
> +# (mostly) copied from brcm2708 platform.sh (which was copied from x86?)
> +tx6u_8033_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=2M 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
> +}
> +
> +# (mostly) copied from brcm2708 platform.sh (which was copied from x86?)
> +tx6u_8033_copy_config() {
> +	local partdev
> +
> +	if export_partdevice partdev 1; then
> +		mkdir -p /boot
> +		[ -f /boot/vmlinuz.img ] || mount -t ext4 -o rw,noatime
> "/dev/$partdev" /boot
> +		cp -af "$UPGRADE_BACKUP" "/boot/$BACKUP_FILE"
> +		sync
> +		unmount /boot
> +	fi
> +}
> +
>  platform_check_image() {
>  	local board=$(board_name)
> 
> @@ -41,6 +137,10 @@ platform_check_image() {
>  		nand_do_platform_check $board $1
>  		return $?;
>  		;;
> +	*tx6u-8033*)

Please don't use wildcards.

> +		tx6u_8033_check_image "$1"
> +		return $?;
> +		;;
>  	esac
> 
>  	echo "Sysupgrade is not yet supported on $board."
> @@ -57,6 +157,9 @@ platform_do_upgrade() {
>  	*gw5*)
>  		nand_do_upgrade "$1"
>  		;;
> +	*tx6u-8033*)

Please don't use wildcards.

> +		tx6u_8033_do_upgrade "$1"
> +		;;
>  	esac
>  }
> 
> @@ -67,6 +170,9 @@ platform_copy_config() {
>  	apalis*)
>  		apalis_copy_config
>  		;;
> +	*tx6u-8033*)

Please don't use wildcards.

Best

Adrian 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20191128/ba7823c5/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list