Skip to content

Commit

Permalink
Support Orange Pi Zero2 / Zero3
Browse files Browse the repository at this point in the history
  • Loading branch information
liu1313277 committed Dec 6, 2023
1 parent 05b3bb0 commit bcb0ba7
Show file tree
Hide file tree
Showing 14 changed files with 18,134 additions and 0 deletions.
7,487 changes: 7,487 additions & 0 deletions configs/orangepi-zero2-h616_defconfig

Large diffs are not rendered by default.

7,487 changes: 7,487 additions & 0 deletions configs/orangepi-zero3-h618_defconfig

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions package/boot/uboot-sunxi-h618/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright (C) 2013-2016 OpenWrt.org
# Copyright (C) 2017 Yousong Zhou
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/orangepi-xunlong/u-boot-orangepi
PKG_SOURCE_DATE:=2017-09
PKG_SOURCE_VERSION:=6fe17fac388aad17490cf386578b7532975e567f
PKG_MIRROR_HASH:=4345d99b0772eba496f24ede9e973d34b72b8239309a75f28acca4fd428bd59e

include $(INCLUDE_DIR)/u-boot.mk
include $(INCLUDE_DIR)/package.mk

define U-Boot/Default
BUILD_TARGET:=sunxi
UBOOT_IMAGE:=u-boot-sunxi-with-spl.bin
UENV:=default
HIDDEN:=1
endef

define U-Boot/orangepi_zero3
BUILD_SUBTARGET:=cortexa53
NAME:=Xunlong Orange Pi Zero3
BUILD_DEVICES:=xunlong_orangepi-zero3
DEPENDS:=+PACKAGE_u-boot-orangepi_zero3:trusted-firmware-a-sunxi-h616
UENV:=h616
ATF:=h616
endef

UBOOT_TARGETS := \
orangepi_zero3

UBOOT_CONFIGURE_VARS += USE_PRIVATE_LIBGCC=yes

UBOOT_MAKE_FLAGS += \
BL31=$(STAGING_DIR_IMAGE)/bl31_sunxi-$(ATF).bin SCP=/dev/null

define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
$(CP) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-u-boot-with-spl.bin
mkimage -C none -A arm -T script -d uEnv-$(UENV).txt \
$(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-boot.scr
endef

define Package/u-boot/install/default
endef

$(eval $(call BuildPackage/U-Boot))
8 changes: 8 additions & 0 deletions package/boot/uboot-sunxi-h618/uEnv-default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
setenv fdt_high ffffffff
setenv mmc_rootpart 2
part uuid mmc ${mmc_bootdev}:${mmc_rootpart} uuid
setenv loadkernel fatload mmc \$mmc_bootdev \$kernel_addr_r uImage
setenv loaddtb fatload mmc \$mmc_bootdev \$fdt_addr_r dtb
setenv bootargs console=ttyS0,115200 earlyprintk root=PARTUUID=${uuid} rootwait
setenv uenvcmd run loadkernel \&\& run loaddtb \&\& bootm \$kernel_addr_r - \$fdt_addr_r
run uenvcmd
7 changes: 7 additions & 0 deletions package/boot/uboot-sunxi-h618/uEnv-h616.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setenv mmc_rootpart 2
part uuid mmc ${mmc_bootdev}:${mmc_rootpart} uuid
setenv loadkernel fatload mmc \$mmc_bootdev \$kernel_addr_r uImage
setenv loaddtb fatload mmc \$mmc_bootdev \$fdt_addr_r dtb
setenv bootargs console=ttyS0,115200 earlyprintk root=PARTUUID=${uuid} rootwait
setenv uenvcmd run loadkernel \&\& run loaddtb \&\& booti \$kernel_addr_r - \$fdt_addr_r
run uenvcmd
9 changes: 9 additions & 0 deletions target/linux/sunxi/base-files/etc/init.d/resize-rootfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh /etc/rc.common

START=22
start() {
rm -rf /etc/rc.d/S22resize-rootfs
#service resize-rootfs disable
/usr/bin/resize-rootfs.sh
}

1 change: 1 addition & 0 deletions target/linux/sunxi/base-files/etc/rc.d/S22resize-rootfs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../init.d/resize-rootfs
56 changes: 56 additions & 0 deletions target/linux/sunxi/base-files/usr/bin/resize-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

FDISK=$(which fdisk) || { echo "E: You must have fdisk" && exit 1; }
LOSETUP=$(which losetup) || { echo "E: You must have losetup" && exit 1; }
roottype=$(findmnt -n -o SOURCE / -o FSTYPE)
case ${roottype} in
overlay)
FSCKEXT4=$(which fsck.ext4) || { echo "E: You must have fsck.ext4" && exit 1; }
RESIZE2FS=$(which resize2fs) || { echo "E: You must have resize2fs" && exit 1; }
rootsource=$(findmnt -n -o SOURCE /rom) # i.e. /dev/mmcblk0p2
rootdevice=${rootsource%p*} # i.e. /dev/mmcblk0
partitions=${rootsource##*p}

# Resizing partitions
lastsector=$(${FDISK} -l ${rootdevice} |grep "Disk ${rootdevice}" |awk '{print $7}')
lastsector=$(( $lastsector - 1 ))
startfrom=$(${FDISK} -l ${rootdevice} |grep ${rootsource} |awk '{print $2}')
partend=$(${FDISK} -l ${rootdevice} |grep ${rootsource} |awk '{print $3}')
[[ $lastsector -eq $partend ]] && exit 0
(echo d; echo $partitions; echo n; echo p; echo ; echo $startfrom; echo $lastsector ; echo w;) | fdisk $rootdevice
# Start resizing filesystem
LOOP="$(losetup -n -O NAME | sort | sed -n -e "1p")"
ROOT="$(losetup -n -O BACK-FILE ${LOOP} | sed -e "s|^|/dev|")"
OFFS="$(losetup -n -O OFFSET ${LOOP})"
LOOP="$(losetup -f)"
${LOSETUP} -o ${OFFS} ${LOOP} ${ROOT}
${FSCKEXT4} -y ${LOOP}
${RESIZE2FS} ${LOOP}
reboot
;;
ext4)
FSCKEXT4=$(which fsck.ext4) || { echo "E: You must have fsck.ext4" && exit 1; }
RESIZE2FS=$(which resize2fs) || { echo "E: You must have resize2fs" && exit 1; }
rootsource=$(findmnt -n -o SOURCE / | sed 's~\[.*\]~~') # i.e. /dev/mmcblk0p2
rootdevice=${rootsource%p*} # i.e. /dev/mmcblk0
partitions=${rootsource##*p}

# Resizing partitions
lastsector=$(${FDISK} -l ${rootdevice} |grep "Disk ${rootdevice}" |awk '{print $7}')
lastsector=$(( $lastsector - 1 ))
startfrom=$(${FDISK} -l ${rootdevice} |grep ${rootsource} |awk '{print $2}')
partend=$(${FDISK} -l ${rootdevice} |grep ${rootsource} |awk '{print $3}')
[[ $lastsector -eq $partend ]] && exit 0
(echo d; echo $partitions; echo n; echo p; echo ; echo $startfrom; echo $lastsector ; echo w;) | fdisk $rootdevice

# Start resizing filesystem
LOOP="$(losetup -f)"
${LOSETUP} ${LOOP} ${rootsource}
${FSCKEXT4} -y ${LOOP}
${RESIZE2FS} ${LOOP}
reboot
;;
esac

exit 0

1 change: 1 addition & 0 deletions target/linux/sunxi/config-6.1
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,4 @@ CONFIG_XZ_DEC_ARM=y
CONFIG_XZ_DEC_BCJ=y
CONFIG_ZBOOT_ROM_BSS=0
CONFIG_ZBOOT_ROM_TEXT=0
CONFIG_MOTORCOMM_PHY=y
12 changes: 12 additions & 0 deletions target/linux/sunxi/image/cortexa53.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ define Device/sun50i-h616
$(Device/sun50i)
endef

define Device/sun50i-h618
SOC := sun50i-h618
$(Device/sun50i)
endef

define Device/friendlyarm_nanopi-neo-plus2
DEVICE_VENDOR := FriendlyARM
DEVICE_MODEL := NanoPi NEO Plus2
Expand Down Expand Up @@ -113,6 +118,13 @@ define Device/xunlong_orangepi-pc2
endef
TARGET_DEVICES += xunlong_orangepi-pc2

define Device/xunlong_orangepi-zero3
DEVICE_VENDOR := Xunlong
DEVICE_MODEL := Orange Pi Zero 3
$(Device/sun50i-h618)
endef
TARGET_DEVICES += xunlong_orangepi-zero3

define Device/xunlong_orangepi-zero2
DEVICE_VENDOR := Xunlong
DEVICE_MODEL := Orange Pi Zero 2
Expand Down
Loading

0 comments on commit bcb0ba7

Please sign in to comment.