diff mbox series

[v6,1/3] mvebu: add support for iEi Puzzle-M901/Puzzle-M902

Message ID 20210803033537.23390-1-ianchang@ieiworld.com
State Changes Requested
Headers show
Series [v6,1/3] mvebu: add support for iEi Puzzle-M901/Puzzle-M902 | expand

Commit Message

eveans2002@gmail.com Aug. 3, 2021, 3:35 a.m. UTC
From: Ian Chang <ianchang@ieiworld.com>

 Hardware specification
 ----------------------
 * CN9130 SoC, Quad-core ARMv8 Cortex-72 @ 2200 MHz
 * 4 GB DDR
 * 4 GB eMMC
 * mmcblk0
 - mmcblk0p164M  kernel_1
 - mmcblk0p264M  kernel_2
 - mmcblk0p3   512M  rootfs_1
 - mmcblk0p4   512M  rootfs_2
 - mmcblk0p5   512M  Reserved
 - mmcblk0p6    64M  Reserved
 - mmcblk0p7   1.8G  rootfs_data

 * 4 MB (SPI Flash)
 * 6 x 2.5 Gigabit  ports (Puzzle-M901)
 - External PHY with 6 ports (AQR112R)
 * 6 x 2.5 Gigabit ports (Puzzle-M902)
 - External PHY with 6 ports (AQR112R)
   3 x 10 Gigabit ports (Puzzle-M902)
 - External PHY with 3 ports (AQR113R)
 * 4 x Front panel LED
 * 1 x USB 3.0
 * Reset button on Rear panel
 * UART (115200 8N1,header on PCB)

 Flash instructions:
	The original firmware is based on OpenWrt.
	Flash firmware using LuCI and CLI

Signed-off-by: Ian Chang <ianchang@ieiworld.com>
---
 .../base-files/etc/board.d/02_network         |  6 ++++
 .../cortexa72/base-files/lib/upgrade/emmc.sh  | 36 +++++++++++++++++++
 .../base-files/lib/upgrade/platform.sh        |  8 +++++
 target/linux/mvebu/image/cortexa72.mk         | 18 ++++++++++
 4 files changed, 68 insertions(+)
 create mode 100644 target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh

Comments

Adrian Schmutzler Aug. 22, 2021, 1:39 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org]
> On Behalf Of eveans2002@gmail.com
> Sent: Dienstag, 3. August 2021 05:36
> To: openwrt-devel@lists.openwrt.org
> Cc: Ian Chang
> Subject: [PATCH v6 1/3] mvebu: add support for iEi Puzzle-M901/Puzzle-
> M902
> 
> From: Ian Chang <ianchang@ieiworld.com>
> 
>  Hardware specification
>  ----------------------
>  * CN9130 SoC, Quad-core ARMv8 Cortex-72 @ 2200 MHz
>  * 4 GB DDR
>  * 4 GB eMMC
>  * mmcblk0
>  - mmcblk0p164M  kernel_1
>  - mmcblk0p264M  kernel_2
>  - mmcblk0p3   512M  rootfs_1
>  - mmcblk0p4   512M  rootfs_2
>  - mmcblk0p5   512M  Reserved
>  - mmcblk0p6    64M  Reserved
>  - mmcblk0p7   1.8G  rootfs_data
> 
>  * 4 MB (SPI Flash)
>  * 6 x 2.5 Gigabit  ports (Puzzle-M901)
>  - External PHY with 6 ports (AQR112R)
>  * 6 x 2.5 Gigabit ports (Puzzle-M902)
>  - External PHY with 6 ports (AQR112R)
>    3 x 10 Gigabit ports (Puzzle-M902)
>  - External PHY with 3 ports (AQR113R)
>  * 4 x Front panel LED
>  * 1 x USB 3.0
>  * Reset button on Rear panel
>  * UART (115200 8N1,header on PCB)
> 
>  Flash instructions:
> 	The original firmware is based on OpenWrt.
> 	Flash firmware using LuCI and CLI
> 
> Signed-off-by: Ian Chang <ianchang@ieiworld.com>

This commit should provide full support. Please include the DTS files here, since adding them later will result in a broken state after this commit.

The fact that 2/3 is not really meaningful is also evidenced by the lack of a proper commit message.

Best

Adrian

> ---
>  .../base-files/etc/board.d/02_network         |  6 ++++
>  .../cortexa72/base-files/lib/upgrade/emmc.sh  | 36 +++++++++++++++++++
>  .../base-files/lib/upgrade/platform.sh        |  8 +++++
>  target/linux/mvebu/image/cortexa72.mk         | 18 ++++++++++
>  4 files changed, 68 insertions(+)
>  create mode 100644 target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/emmc.sh
> 
> diff --git a/target/linux/mvebu/cortexa72/base-
> files/etc/board.d/02_network b/target/linux/mvebu/cortexa72/base-
> files/etc/board.d/02_network
> index 9ab3c8174d..e0a4bc3015 100755
> --- a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
> +++ b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
> @@ -11,6 +11,12 @@ board_config_update
>  board=$(board_name)
> 
>  case "$board" in
> +iei,puzzle-m901)
> +	ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
> +	;;
> +iei,puzzle-m902)
> +	ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5 eth10
> eth11 eth12" "eth0"
> +	;;
>  marvell,armada8040-mcbin-doubleshot|\
>  marvell,armada8040-mcbin-singleshot)
>  	ucidef_set_interfaces_lan_wan "eth0 eth1 eth3" "eth2"
> diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> new file mode 100644
> index 0000000000..5e5c356ed6
> --- /dev/null
> +++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
> @@ -0,0 +1,36 @@
> +platform_do_upgrade_emmc() {
> +	local board=$(board_name)
> +	local diskdev partdev
> +
> +	export_bootdevice && export_partdevice diskdev 0 || {
> +		v "Unable to determine upgrade device"
> +		return 1
> +	}
> +	sync
> +	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
> +		get_partitions "/dev/$diskdev" bootdisk
> +		v "Extract boot sector from the image"
> +		get_image_dd "$1" of=/tmp/image.bs count=1 bs=512b
> +		get_partitions /tmp/image.bs image
> +	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
> +			if [ "$partdev" = "mmcblk0p2" ]; then
> +				v "Writing image mmcblk0p3 for
> /dev/$partdev  $start $size"
> +				get_image_dd "$1" of="/dev/mmcblk0p3"
> ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> +			elif [ "$partdev" = "mmcblk0p1" ]; then
> +				v "Writing image mmcblk0p1 for
> /dev/$partdev $start $size"
> +				get_image_dd "$1" of="/dev/$partdev"
> ibs="512" obs=1M skip="$start" count="$size" conv=fsync
> +			fi
> +		else
> +			v "Unable to find partition $part device, skipped."
> +		fi
> +	done < /tmp/partmap.image
> +
> +	v "Writing new UUID to /dev/$diskdev..."
> +	get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4
> seek=440
> +conv=fsync
> +
> +	sleep 1
> +}
> diff --git a/target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa72/base-
> files/lib/upgrade/platform.sh
> index 04ea634097..9a89768d14 100755
> --- a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
> @@ -9,6 +9,8 @@ REQUIRE_IMAGE_METADATA=1
> 
>  platform_check_image() {
>  	case "$(board_name)" in
> +	iei,puzzle-m901|\
> +	iei,puzzle-m902|\
>  	marvell,armada8040-mcbin-doubleshot|\
>  	marvell,armada8040-mcbin-singleshot)
>  		platform_check_image_sdcard "$1"
> @@ -21,6 +23,10 @@ platform_check_image() {
> 
>  platform_do_upgrade() {
>  	case "$(board_name)" in
> +	iei,puzzle-m901|\
> +	iei,puzzle-m902)
> +		platform_do_upgrade_emmc "$1"
> +		;;
>  	marvell,armada8040-mcbin-doubleshot|\
>  	marvell,armada8040-mcbin-singleshot)
>  		platform_do_upgrade_sdcard "$1"
> @@ -32,6 +38,8 @@ platform_do_upgrade() {  }
>  platform_copy_config() {
>  	case "$(board_name)" in
> +	iei,puzzle-m901|\
> +	iei,puzzle-m902|\
>  	marvell,armada8040-mcbin-doubleshot|\
>  	marvell,armada8040-mcbin-singleshot)
>  		platform_copy_config_sdcard
> diff --git a/target/linux/mvebu/image/cortexa72.mk
> b/target/linux/mvebu/image/cortexa72.mk
> index 1440c07a0b..29727f8b9d 100644
> --- a/target/linux/mvebu/image/cortexa72.mk
> +++ b/target/linux/mvebu/image/cortexa72.mk
> @@ -43,3 +43,21 @@ define Device/marvell_macchiatobin-singleshot
>    SUPPORTED_DEVICES := marvell,armada8040-mcbin-singleshot
>  endef
>  TARGET_DEVICES += marvell_macchiatobin-singleshot
> +
> +define Device/iei_puzzle-m901
> +  $(call Device/Default-arm64)
> +  DEVICE_VENDOR := iEi
> +  DEVICE_MODEL := Puzzle-M901
> +  SOC := cn9131
> +  IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip |
> +append-metadata endef TARGET_DEVICES += iei_puzzle-m901
> +
> +define Device/iei_puzzle-m902
> +  $(call Device/Default-arm64)
> +  DEVICE_VENDOR := iEi
> +  DEVICE_MODEL := Puzzle-M902
> +  SOC := cn9132
> +  IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip |
> +append-metadata endef TARGET_DEVICES += iei_puzzle-m902
> --
> 2.17.1
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
index 9ab3c8174d..e0a4bc3015 100755
--- a/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
+++ b/target/linux/mvebu/cortexa72/base-files/etc/board.d/02_network
@@ -11,6 +11,12 @@  board_config_update
 board=$(board_name)
 
 case "$board" in
+iei,puzzle-m901)
+	ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
+	;;
+iei,puzzle-m902)
+	ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5 eth10 eth11 eth12" "eth0"
+	;;
 marvell,armada8040-mcbin-doubleshot|\
 marvell,armada8040-mcbin-singleshot)
 	ucidef_set_interfaces_lan_wan "eth0 eth1 eth3" "eth2"
diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
new file mode 100644
index 0000000000..5e5c356ed6
--- /dev/null
+++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc.sh
@@ -0,0 +1,36 @@ 
+platform_do_upgrade_emmc() {
+	local board=$(board_name)
+	local diskdev partdev
+
+	export_bootdevice && export_partdevice diskdev 0 || {
+		v "Unable to determine upgrade device"
+		return 1
+	}
+	sync
+	if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
+		get_partitions "/dev/$diskdev" bootdisk
+		v "Extract boot sector from the image"
+		get_image_dd "$1" of=/tmp/image.bs count=1 bs=512b
+		get_partitions /tmp/image.bs image
+	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
+			if [ "$partdev" = "mmcblk0p2" ]; then
+				v "Writing image mmcblk0p3 for /dev/$partdev  $start $size"
+				get_image_dd "$1" of="/dev/mmcblk0p3" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
+			elif [ "$partdev" = "mmcblk0p1" ]; then
+				v "Writing image mmcblk0p1 for /dev/$partdev $start $size"
+				get_image_dd "$1" of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
+			fi
+		else
+			v "Unable to find partition $part device, skipped."
+		fi
+	done < /tmp/partmap.image
+
+	v "Writing new UUID to /dev/$diskdev..."
+	get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
+
+	sleep 1
+}
diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
index 04ea634097..9a89768d14 100755
--- a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/platform.sh
@@ -9,6 +9,8 @@  REQUIRE_IMAGE_METADATA=1
 
 platform_check_image() {
 	case "$(board_name)" in
+	iei,puzzle-m901|\
+	iei,puzzle-m902|\
 	marvell,armada8040-mcbin-doubleshot|\
 	marvell,armada8040-mcbin-singleshot)
 		platform_check_image_sdcard "$1"
@@ -21,6 +23,10 @@  platform_check_image() {
 
 platform_do_upgrade() {
 	case "$(board_name)" in
+	iei,puzzle-m901|\
+	iei,puzzle-m902)
+		platform_do_upgrade_emmc "$1"
+		;;
 	marvell,armada8040-mcbin-doubleshot|\
 	marvell,armada8040-mcbin-singleshot)
 		platform_do_upgrade_sdcard "$1"
@@ -32,6 +38,8 @@  platform_do_upgrade() {
 }
 platform_copy_config() {
 	case "$(board_name)" in
+	iei,puzzle-m901|\
+	iei,puzzle-m902|\
 	marvell,armada8040-mcbin-doubleshot|\
 	marvell,armada8040-mcbin-singleshot)
 		platform_copy_config_sdcard
diff --git a/target/linux/mvebu/image/cortexa72.mk b/target/linux/mvebu/image/cortexa72.mk
index 1440c07a0b..29727f8b9d 100644
--- a/target/linux/mvebu/image/cortexa72.mk
+++ b/target/linux/mvebu/image/cortexa72.mk
@@ -43,3 +43,21 @@  define Device/marvell_macchiatobin-singleshot
   SUPPORTED_DEVICES := marvell,armada8040-mcbin-singleshot
 endef
 TARGET_DEVICES += marvell_macchiatobin-singleshot
+
+define Device/iei_puzzle-m901
+  $(call Device/Default-arm64)
+  DEVICE_VENDOR := iEi
+  DEVICE_MODEL := Puzzle-M901
+  SOC := cn9131
+  IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
+endef
+TARGET_DEVICES += iei_puzzle-m901
+
+define Device/iei_puzzle-m902
+  $(call Device/Default-arm64)
+  DEVICE_VENDOR := iEi
+  DEVICE_MODEL := Puzzle-M902
+  SOC := cn9132
+  IMAGE/sdcard.img.gz := boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
+endef
+TARGET_DEVICES += iei_puzzle-m902