diff --git a/Makefile b/Makefile index dd6e1aa94c..239d56fc2a 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ image: noobs: ./scripts/image noobs +amlpkg: + ./scripts/image amlpkg + clean: rm -rf $(BUILD_DIRS)/* $(BUILD_DIRS)/.stamps diff --git a/packages/sysutils/busybox/scripts/init b/packages/sysutils/busybox/scripts/init index 11cfa45283..1b2a9b4e27 100755 --- a/packages/sysutils/busybox/scripts/init +++ b/packages/sysutils/busybox/scripts/init @@ -291,6 +291,10 @@ mount_common "$NFS_EXPORT" "$2" "$3,nolock,soft,timeo=3,retrans=2,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs" } + mount_ubifs() { + mount_common "$1" "$2" "$3" "ubifs" + } + mount_part() { # Mount a local or network filesystem # $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type] @@ -298,6 +302,11 @@ MOUNT_TARGET="${1#*=}" case $1 in + /dev/ubi*) + MOUNT_CMD="mount_ubifs" + MOUNT_TARGET="$1" + RUN_FSCK="no" + ;; LABEL=*|UUID=*|/*) MOUNT_CMD="mount_common" MOUNT_TARGET="$1" diff --git a/projects/WeTek_Play/install/files/bootloader.img b/projects/WeTek_Play/install/files/bootloader.img new file mode 100644 index 0000000000..52b60a2294 Binary files /dev/null and b/projects/WeTek_Play/install/files/bootloader.img differ diff --git a/projects/WeTek_Play/install/files/logo.img b/projects/WeTek_Play/install/files/logo.img new file mode 100644 index 0000000000..4e068cf348 Binary files /dev/null and b/projects/WeTek_Play/install/files/logo.img differ diff --git a/projects/WeTek_Play/install/files/recovery.img b/projects/WeTek_Play/install/files/recovery.img new file mode 100644 index 0000000000..973b267a2a Binary files /dev/null and b/projects/WeTek_Play/install/files/recovery.img differ diff --git a/projects/WeTek_Play/install/update-binary b/projects/WeTek_Play/install/update-binary new file mode 100644 index 0000000000..9a69da8d14 Binary files /dev/null and b/projects/WeTek_Play/install/update-binary differ diff --git a/projects/WeTek_Play/install/updater-script b/projects/WeTek_Play/install/updater-script new file mode 100644 index 0000000000..97e9e9166f --- /dev/null +++ b/projects/WeTek_Play/install/updater-script @@ -0,0 +1,32 @@ +show_progress(0.500000, 3); +set_bootloader_env("upgrade_step", "3"); + +ui_print("Wiping Userdata"); +format("ext4", "EMMC", "/dev/block/data", "0", "/data"); + +show_progress(0.020000, 0); + +ui_print("Wiping System"); +format("ubifs", "UBI", "system", "0", "/system"); +mount("ubifs", "UBI", "system", "/system"); +ui_print("Writing system files"); +package_extract_file("KERNEL", "/system/KERNEL"); +package_extract_dir("system", "/system"); +unmount("/system"); + +show_progress(0.300000, 60); + +ui_print("Writing recovery"); +write_raw_image(package_extract_file("recovery.img"), "recovery"); + +show_progress(0.018000, 0); + +ui_print("Writing bootloader"); +write_raw_image(package_extract_file("bootloader.img"), "bootloader"); + +ui_print("Writing logo"); +write_raw_image(package_extract_file("logo.img"), "logo"); + +set_bootloader_env("upgrade_step", "1"); +show_progress(0.100000, 0); +ui_print("OpenELEC Installed Successfully"); diff --git a/projects/WeTek_Play/linux/linux.arm.conf b/projects/WeTek_Play/linux/linux.arm.conf index 79599bde11..1a3405d639 100644 --- a/projects/WeTek_Play/linux/linux.arm.conf +++ b/projects/WeTek_Play/linux/linux.arm.conf @@ -479,9 +479,9 @@ CONFIG_ZBOOT_ROM_TEXT=0 CONFIG_ZBOOT_ROM_BSS=0 CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y -# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set +CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y # CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set -CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_APPEND=y +# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_APPEND is not set CONFIG_CMDLINE="" # CONFIG_XIP_KERNEL is not set # CONFIG_KEXEC is not set @@ -1031,7 +1031,7 @@ CONFIG_MMC_AML=y # # CONFIG_AML_NEXT_GEN_NAND is not set CONFIG_AML_NFTL_NEW=y -# CONFIG_AML_NAND_KEY is not set +CONFIG_AML_NAND_KEY=y # # Meson NAND Device Support @@ -1039,6 +1039,7 @@ CONFIG_AML_NFTL_NEW=y CONFIG_AM_NAND=y CONFIG_AM_NAND_RBPIN=y CONFIG_AML_NAND_ENV=y +CONFIG_NAND_KEY_BLOCK_NUM=8 # CONFIG_AML_NFTL is not set # CONFIG_AML_NEXT_NAND is not set diff --git a/projects/WeTek_Play/patches/linux/030-add_bootargs_to_device_tree.patch b/projects/WeTek_Play/patches/linux/030-add_bootargs_to_device_tree.patch deleted file mode 100644 index 05641a48b0..0000000000 --- a/projects/WeTek_Play/patches/linux/030-add_bootargs_to_device_tree.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/arch/arm/boot/dts/amlogic/wetek_play.dtd b/arch/arm/boot/dts/amlogic/wetek_play.dtd -index 3fc5e4e..3d3601f 100755 ---- a/arch/arm/boot/dts/amlogic/wetek_play.dtd -+++ b/arch/arm/boot/dts/amlogic/wetek_play.dtd -@@ -20,6 +20,9 @@ void root_func(){ - interrupt-parent = <&gic>; - #address-cells = <1>; - #size-cells = <1>; -+ chosen { -+ bootargs = "root=/dev/ram0 rdinit=/init boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 BOOT_IMAGE=kernel.img console=tty0 consoleblank=0 scaling_governor=hotplug scaling_min_freq=200000 scaling_max_freq=1512000 systemd.show_status=auto"; -+ }; - - /// *************************************************************************************** - /// - CPU diff --git a/projects/WeTek_Play/patches/linux/201-update_nand_partition_layout.patch b/projects/WeTek_Play/patches/linux/201-update_nand_partition_layout.patch new file mode 100644 index 0000000000..2ec822e443 --- /dev/null +++ b/projects/WeTek_Play/patches/linux/201-update_nand_partition_layout.patch @@ -0,0 +1,46 @@ +diff --git a/arch/arm/boot/dts/amlogic/wetek_play.dtd b/arch/arm/boot/dts/amlogic/wetek_play.dtd +index ce4f2e8..10433be 100755 +--- a/arch/arm/boot/dts/amlogic/wetek_play.dtd ++++ b/arch/arm/boot/dts/amlogic/wetek_play.dtd +@@ -790,7 +790,7 @@ void root_func(){ + t_rea = <20>; + t_rhoh = <15>; + chip_num = <2>; +- part_num = <9>; ++ part_num = <6>; + partition = <&nand_partitions>; + rb_detect = <1>; + }; +@@ -800,28 +800,16 @@ void root_func(){ + offset=<0x0 0x4800000>; + size=<0x0 0x800000>; + }; +- aml_logo{ +- offset=<0x0 0x5800000>; +- size=<0x0 0x800000>; +- }; + recovery{ +- offset=<0x0 0x6800000>; +- size=<0x0 0x800000>; +- }; +- boot{ +- offset=<0x0 0x8800000>; ++ offset=<0x0 0x5800000>; + size=<0x0 0x800000>; + }; + system{ +- offset=<0x0 0xa800000>; +- size=<0x0 0x40000000>; ++ offset=<0x0 0x7000000>; ++ size=<0x0 0x10000000>; + }; + cache{ +- offset=<0x0 0x4a800000>; +- size=<0x0 0x20000000>; +- }; +- backup{ +- offset=<0x0 0x6a800000>; ++ offset=<0x0 0x17000000>; + size=<0x0 0x10000000>; + }; + userdata{ diff --git a/projects/WeTek_Play/patches/linux/202-disable_ethernet_mac_update_from_nand.patch b/projects/WeTek_Play/patches/linux/202-disable_ethernet_mac_update_from_nand.patch new file mode 100644 index 0000000000..07ce5aac14 --- /dev/null +++ b/projects/WeTek_Play/patches/linux/202-disable_ethernet_mac_update_from_nand.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/amlogic/ethernet/am_net8218.c b/drivers/amlogic/ethernet/am_net8218.c +index aec2980..697984f 100755 +--- a/drivers/amlogic/ethernet/am_net8218.c ++++ b/drivers/amlogic/ethernet/am_net8218.c +@@ -890,7 +890,7 @@ static int mac_pmt_enable(unsigned int enable) + * @return + */ + /* --------------------------------------------------------------------------*/ +-//#undef CONFIG_AML_NAND_KEY ++#undef CONFIG_AML_NAND_KEY + #ifdef CONFIG_AML_NAND_KEY + extern int get_aml_key_kernel(const char* key_name, unsigned char* data, int ascii_flag); + extern int extenal_api_key_set_version(char *devvesion); diff --git a/scripts/image b/scripts/image index 3497a16ee2..cd5a907b21 100755 --- a/scripts/image +++ b/scripts/image @@ -236,7 +236,7 @@ fi # set permissions chmod 0644 $TARGET_IMG/$IMAGE_NAME.system - if [ "$1" = "release" -o "$1" = "mkimage" ]; then + if [ "$1" = "release" -o "$1" = "mkimage" -o "$1" = "amlpkg" ]; then RELEASE_DIR="target/$IMAGE_NAME" @@ -322,6 +322,57 @@ fi $SCRIPTS/mkimage fi + # create WeTek Play (Amlogic) ZIP update and auto-install packages if requested + if [ "$1" = "amlpkg" ]; then + echo "Creating Amlogic ZIP update package" + + INSTALL_SRC_DIR="$PROJECT_DIR/$PROJECT/install" + AML_PKG_DIR="$RELEASE_DIR/ampl-pkg" + + # create package directory + mkdir -p "$AML_PKG_DIR" + + # copy system and kernel images + mkdir -p "$AML_PKG_DIR/system" + cp $TARGET_IMG/$IMAGE_NAME.system $AML_PKG_DIR/system/SYSTEM + cp $TARGET_IMG/$IMAGE_NAME.kernel $AML_PKG_DIR/KERNEL + + # copy update-binary and updater-script + META_INF_DIR="$AML_PKG_DIR/META-INF/com/google/android" + mkdir -p "$META_INF_DIR" + cp $INSTALL_SRC_DIR/update-binary $META_INF_DIR + cp $INSTALL_SRC_DIR/updater-script $META_INF_DIR + + # copy other files if any + if [ -d "$INSTALL_SRC_DIR/files" ]; then + cp -PR $INSTALL_SRC_DIR/files/* $AML_PKG_DIR + fi + + # create the update package + pushd "$AML_PKG_DIR" > /dev/null + zip -rq update.zip * + + # sign the update package + echo "Signing the update package" + mkdir -p sign + SIGNAPK_DIR="$ROOT/tools/signapk" + java -Xmx1024m -jar $SIGNAPK_DIR/signapk.jar -w $SIGNAPK_DIR/testkey.x509.pem $SIGNAPK_DIR/testkey.pk8 update.zip sign/$IMAGE_NAME-update.zip + + # create the auto-install package + if [ -f "$INSTALL_SRC_DIR/files/recovery.img" ]; then + echo "Creating Amlogic ZIP auto-install package" + pushd sign > /dev/null + echo --update_package=/sdcard/$IMAGE_NAME-update.zip > factory_update_param.aml + cp $INSTALL_SRC_DIR/files/recovery.img . + zip -q $TARGET_IMG/$IMAGE_NAME.zip * + popd > /dev/null + fi + + # copy update package to target directory + cp sign/$IMAGE_NAME-update.zip $TARGET_IMG + popd > /dev/null + fi + # cleanup release dir rm -rf $RELEASE_DIR diff --git a/tools/signapk/signapk.jar b/tools/signapk/signapk.jar new file mode 100755 index 0000000000..b050dd4dc5 Binary files /dev/null and b/tools/signapk/signapk.jar differ diff --git a/tools/signapk/testkey.pk8 b/tools/signapk/testkey.pk8 new file mode 100644 index 0000000000..586c1bd5cf Binary files /dev/null and b/tools/signapk/testkey.pk8 differ diff --git a/tools/signapk/testkey.x509.pem b/tools/signapk/testkey.x509.pem new file mode 100644 index 0000000000..e242d83e2b --- /dev/null +++ b/tools/signapk/testkey.x509.pem @@ -0,0 +1,27 @@ +-----BEGIN CERTIFICATE----- +MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD +VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g +VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE +AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe +Fw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET +MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G +A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p +ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI +hvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuD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