From patchwork Thu Nov 28 17:06:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 1202230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=c0d3.blue Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lXilxWEE"; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=c0d3.blue header.i=@c0d3.blue header.b="S2s8IzvN"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47P3wg1bqjz9sP6 for ; Fri, 29 Nov 2019 04:07:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wkIq0dDbMYvRz0tFePG5StS4Idq0kKZ7To5waVq8bc0=; b=lXilxWEECHsQuR /uL7hjNLA4CS2s65s4iGyS/Av+qRTCACTv0KPMaubSNY2hN4YOjjWKvRCSRRQa30kTPEAjlET434C gXeyF/6W6OYXp3yYcSSSiucrFw9ZGnKK0TQyoZuKTi9dc/LpySMw7nFKkfTQm9JwUrNyqeI9pInf9 Hc14GPpZWKQmJLHV36OgJFCXQ4ABuW75DAl7jUx8Z0kuoZL0c6TMaLJF7fMClFS7PnRQNt5JH57Bb G8glmpBs+SDtVlNbrJavlk8r/WcDvN2ZtSPU5MJufmnYdyjZChk3PBl8Ji1w6rW6uIbDnV5tjSzef mxJRH2B0d+XgzI36l6Ng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iaNGD-0006kh-GW; Thu, 28 Nov 2019 17:07:21 +0000 Received: from mail.aperture-lab.de ([138.201.29.205]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iaNG9-0006jW-61 for openwrt-devel@lists.openwrt.org; Thu, 28 Nov 2019 17:07:20 +0000 From: =?utf-8?q?Linus_L=C3=BCssing?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1574960823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p6BSMQpXrcJrJ1znS2YPPbTXPo0UUBsJPF4bYWnN+S8=; b=S2s8IzvNaF3kR4yRhzaXZRYrjHmscpHJwYMkbRUnmG9dmRGeMG3sCZLJepyU5DhFoqhFlU PGcJV68U+ZRjWGLJU76vI6OPteGEfeoMfRBSySX8stxSBj3NGUZ53qkdfofOautnqGTkog HqCKESWqtHvqjIndEvmUtahoqkrsCrskY/Wiktk/V5Sv7W3vy2OASQpnUSpiRZE3qypaRG ApSpmLPjpNJ/y0iDvpfMMDCENiQedmQNe2NVTX/GrESwjpp1uiCGkdA9og21pdGiUN2hWj tCNYyKPNPURbZN4jJtzLBfTOwaUUY6juzY9xt/x97G9iXySDgIXKzQipwupQSw== To: openwrt-devel@lists.openwrt.org Date: Thu, 28 Nov 2019 18:06:35 +0100 Message-Id: <20191128170635.4397-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1574960823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p6BSMQpXrcJrJ1znS2YPPbTXPo0UUBsJPF4bYWnN+S8=; b=D1MO6E9a6AH+n7uo7aJ10x/AV0sYd1qbWwpUw1j08iU7lIZHIBXh69ry/sC53FuFKMJck+ If/wUxtxZp21+Yet96ERo/k14F7glCYp719sMoPKN4qjf1hp+2+VLrDLS/uc3vjl+Rbfvu /CNHRadFqxRnbQQcJLmMvheXT9u+Fr5k6gn9oVn7d95JEFiDi0/DbDjPyL2KMxRuE4jnF2 y0iyqXgoi21toWTvZSOFfLTVz5UVH3pOWina17dfJtmxKgxciI97/fbzop5MXxZDQi47ca 6g0ZCfBA6h0rqpJ/EZKP7LJ430+eri3dficP0mfy2sjihGX3lVz7osZCZOyq8g== ARC-Seal: i=1; s=2018; d=c0d3.blue; t=1574960823; a=rsa-sha256; cv=none; b=MmC17HaFCuzCTBDYyWFR/655Fe7yEb71rEhrcjQZsGhcH81M2QfULmgRb+lypQ4fRwRCxi RvHlYGSgPYRqWyfgxOpkXAQ5Ccmfj00NxBpvsoo0sPOUhJ6fd7710n3oJubsme7Lu5taGh qDdtFRrwoRGcDyIwNWiEQrqSFQPQcKOMSJXP8nrlybrTNG1/bnhDvrSmJnaQhY/A3bNe/6 2Y7CayYbAJACRbFWLYCWMYPOB+JE/gu+o7hqJGL5zFM1i8p7qC+RhJXYgXa6oRmvnW8Cid 9lydORWeUOU4ruPbCkWM4+9DRHL51iubS6wwg+q0etl83rvPQw/qrk01T81ZkA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue Authentication-Results: ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191128_090717_532335_746AA778 X-CRM114-Status: GOOD ( 14.67 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [138.201.29.205 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid Subject: [OpenWrt-Devel] [PATCH] imx6: Adding Ka-Ro electronics TX6U-8033 Module on MB7 baseboard support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Linus_L=C3=BCssing?= , Simon Wunderlich Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Linus Lüssing This adds support for the Ka-Ro MB7 board with a TX6U-8033 module. Specification, according to Linux DTS commit: TX6U-8033: Processor Freescale i.MX 6 Dual Lite, 800MHz RAM 1GiB DDR3 SDRAM ROM 4GiB eMMC Power supply Single 3.1V to 5.5V Size 31mm SO-DIMM Temp. Range industrial grade (-40°C/-25°C to 105°C Tj) The u-boot shipped by the vendor by default expects the following partition layout: MBR/MSDOS, disk-id '0cc66cc0' { 0cc66cc0-01 => ext2, /vmlinuz 0cc66cc0-02 => ext4, rootfs } TX6DL U-Boot > env print append_bootargs=rootfstype=ext4 [...] bootcmd_mmc=setenv autostart no;run bootargs_mmc;ext2load mmc 0 ${kerneladdr} vmlinuz [...] rootpart_uuid=0cc66cc0-02 [...] This is also one of the reasons, why only ext4 rootfs support was added and tested so far. No squashfs support yet. Other than that, nothing fancy needs to be added or preserved on the eMMC. Cc: Simon Wunderlich Signed-off-by: Linus Lüssing --- target/linux/imx6/Makefile | 2 +- .../imx6/base-files/etc/board.d/02_network | 3 +- target/linux/imx6/base-files/lib/imx6.sh | 4 + .../base-files/lib/preinit/79_move_config | 9 ++ .../imx6/base-files/lib/upgrade/platform.sh | 108 +++++++++++++++++- target/linux/imx6/image/Makefile | 34 ++++++ .../linux/imx6/image/gen_karo_sdcard_img.sh | 26 +++++ .../imx6/patches-4.14/100-bootargs.patch | 13 +++ tools/Makefile | 1 + 9 files changed, 197 insertions(+), 3 deletions(-) create mode 100755 target/linux/imx6/image/gen_karo_sdcard_img.sh diff --git a/target/linux/imx6/Makefile b/target/linux/imx6/Makefile index ac4300f7eb..8083a54e16 100644 --- a/target/linux/imx6/Makefile +++ b/target/linux/imx6/Makefile @@ -20,6 +20,6 @@ include $(INCLUDE_DIR)/target.mk KERNELNAME:=zImage dtbs -DEFAULT_PACKAGES += uboot-envtools mkf2fs e2fsprogs blkid +DEFAULT_PACKAGES += uboot-envtools mkf2fs e2fsprogs blkid partx-utils $(eval $(call BuildTarget)) diff --git a/target/linux/imx6/base-files/etc/board.d/02_network b/target/linux/imx6/base-files/etc/board.d/02_network index 6ec667346d..9f93d5b17e 100755 --- a/target/linux/imx6/base-files/etc/board.d/02_network +++ b/target/linux/imx6/base-files/etc/board.d/02_network @@ -21,7 +21,8 @@ cubox-i |\ *gw552x) ucidef_set_interfaces_lan_wan 'eth0' 'eth1' ;; -*wandboard) +*wandboard |\ +*tx6u-8033) ucidef_set_interface_wan 'eth0' ;; 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" + ;; + *) 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*) + 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*) + 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*) + tx6u_8033_do_upgrade "$1" + ;; esac } @@ -67,6 +170,9 @@ platform_copy_config() { apalis*) apalis_copy_config ;; + *tx6u-8033*) + tx6u_8033_copy_config + ;; esac } diff --git a/target/linux/imx6/image/Makefile b/target/linux/imx6/image/Makefile index d1e9e9034e..34fb4a2690 100644 --- a/target/linux/imx6/image/Makefile +++ b/target/linux/imx6/image/Makefile @@ -113,6 +113,24 @@ define Build/apalis-emmc $(Build/imx6-combined-image-clean) endef +define Build/karo-boot-img + $(RM) -rf $@.bootdir + mkdir $@.bootdir + + $(CP) $(IMAGE_KERNEL) $@.bootdir/$(KERNEL_IMG) + + genext2fs --block-size $(BLOCKSIZE:%k=%Ki) --size-in-blocks $$((1024 * 1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE) / ($(subst k,* 1024,$(BLOCKSIZE))))) --root $@.bootdir $@.boot + + # convert it to revision 1 - needed for u-boot ext2load + $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot + $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null +endef + +define Build/karo-sdcard-img + ./gen_karo_sdcard_img.sh $@ $@.boot $(IMAGE_ROOTFS) $(CONFIG_TARGET_KERNEL_PARTSIZE) $(CONFIG_TARGET_ROOTFS_PARTSIZE) +endef + + ################################################# # Devices ################################################# @@ -232,4 +250,20 @@ define Device/apalis endef TARGET_DEVICES += apalis +define Device/tx6u-8033 + DEVICE_TITLE := Ka-Ro electronics TX6U-8033 Module on MB7 baseboard + DEVICE_DTS := imx6dl-tx6u-8033 + FILESYSTEMS := ext4 + BLOCKSIZE := 4k + KERNEL_SUFFIX := -zImage + KERNEL_NAME := zImage + KERNEL := kernel-bin + KERNEL_IMG := vmlinuz + IMAGES := factory.img.gz sysupgrade.img.gz + IMAGE_SIZE := 3776m + IMAGE/sysupgrade.img.gz := karo-boot-img | karo-sdcard-img | check-size $$$$(IMAGE_SIZE) | gzip | append-metadata + IMAGE/factory.img.gz := karo-boot-img | karo-sdcard-img | check-size $$$$(IMAGE_SIZE) | gzip +endef +TARGET_DEVICES += tx6u-8033 + $(eval $(call BuildImage)) diff --git a/target/linux/imx6/image/gen_karo_sdcard_img.sh b/target/linux/imx6/image/gen_karo_sdcard_img.sh new file mode 100755 index 0000000000..362ce5838b --- /dev/null +++ b/target/linux/imx6/image/gen_karo_sdcard_img.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -x +[ $# -eq 5 ] || { + echo "SYNTAX: $0 " + exit 1 +} + +OUTPUT="$1" +BOOTFS="$2" +ROOTFS="$3" +BOOTFSSIZE="$4" +ROOTFSSIZE="$5" + +head=4 +sect=63 + +set `ptgen -o $OUTPUT -h $head -s $sect -l 4096 -t 83 -S 0x0cc66cc0 -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M` + +BOOTOFFSET="$(($1 / 512))" +BOOTSIZE="$(($2 / 512))" +ROOTFSOFFSET="$(($3 / 512))" +ROOTFSSIZE="$(($4 / 512))" + +dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc +dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc diff --git a/target/linux/imx6/patches-4.14/100-bootargs.patch b/target/linux/imx6/patches-4.14/100-bootargs.patch index 0954391203..6c025e15db 100644 --- a/target/linux/imx6/patches-4.14/100-bootargs.patch +++ b/target/linux/imx6/patches-4.14/100-bootargs.patch @@ -1,3 +1,16 @@ +--- a/arch/arm/boot/dts/imx6dl-tx6u-8033.dts ++++ b/arch/arm/boot/dts/imx6dl-tx6u-8033.dts +@@ -51,6 +51,10 @@ + display = &display; + }; + ++ chosen { ++ bootargs = "console=ttymxc0,115200"; ++ }; ++ + backlight: backlight { + compatible = "pwm-backlight"; + pwms = <&pwm2 0 500000 PWM_POLARITY_INVERTED>; --- a/arch/arm/boot/dts/imx6dl-wandboard.dts +++ b/arch/arm/boot/dts/imx6dl-wandboard.dts @@ -19,4 +19,8 @@ diff --git a/tools/Makefile b/tools/Makefile index 2f57d25525..034e54c5d9 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -39,6 +39,7 @@ tools-$(BUILD_ISL) += isl tools-$(CONFIG_USE_SPARSE) += sparse tools-$(CONFIG_TARGET_apm821xx)$(CONFIG_TARGET_gemini) += genext2fs tools-$(CONFIG_TARGET_tegra) += cbootimage cbootimage-configs +tools-$(CONFIG_TARGET_imx6) += genext2fs # builddir dependencies $(curdir)/bison/compile := $(curdir)/flex/compile