From dd3d5cda923d404fd650200d5f041a5f496c2bc3 Mon Sep 17 00:00:00 2001 From: misaka4e21 Date: Thu, 30 May 2019 22:59:02 +0800 Subject: [PATCH] motorola-titan: fix boot.img flashing and booting (!399) 1. Set deviceinfo_flash_offset_base to 0x00000000. 2. Enable deviceinfo_bootimg_qcdt, and make dt.img for it. Directly use zImage instead of zImage-dtb for smaller boot.img size. 3. Reduce kernel size by disable xz, lzma and bz2 compressing. 4. Update kernel to the last version in LineageOS repository. Please note that it is ONLY TESTED on XT1079 "thea", aka Moto G 2014 LTE. However, "thea" and "titan" are nearly identical, sharing same kernel and defconfig on LineageOS, etc. [ci:skip-build]: already built successfully in CI --- device/device-motorola-titan/APKBUILD | 6 ++--- device/device-motorola-titan/deviceinfo | 4 ++- device/linux-motorola-titan/APKBUILD | 25 ++++++++++++------- .../config-motorola-titan.armhf | 19 ++++++++------ 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/device/device-motorola-titan/APKBUILD b/device/device-motorola-titan/APKBUILD index 978a6c59e..685196c42 100644 --- a/device/device-motorola-titan/APKBUILD +++ b/device/device-motorola-titan/APKBUILD @@ -1,6 +1,6 @@ pkgname=device-motorola-titan pkgver=1 -pkgrel=29 +pkgrel=30 pkgdesc="Motorola Moto G 2014" url="https://postmarketos.org" arch="armhf" @@ -37,7 +37,7 @@ nonfree_firmware() { mkdir "$subpkgdir" } -sha512sums="2c7595391e38bf89c62c8fa92e959e4466ce6466e88525fda03090f5cbf752d80300ccbf84ff82a788a518c4bad0f248dcd4bc8f41c3929604c5a74b68329ee9 deviceinfo -8406968cd554393ea1e350967c80810d059de2b1d33ea1302e265780c1f0110d64cf15a68c2f374981a88906d0317315e0a71995c85fd5eaf93bb47ed427529c 90-android-touch-dev.rules +sha512sums="8406968cd554393ea1e350967c80810d059de2b1d33ea1302e265780c1f0110d64cf15a68c2f374981a88906d0317315e0a71995c85fd5eaf93bb47ed427529c 90-android-touch-dev.rules +d3af55f4c8dd617685ba9bbeeac7dd24d09f0abe6acb4bbf79c8281e947e40cad88829381189a0518825f1583bc3c6ac59665ea7dfdcccd2b5343adb8041c7bc deviceinfo d04013c17caf77a87ebea167dbe48f7efa9c9d3123c5743d359f3ea8ccc6b268fa021535a4bf8291eb4a352f0c92f6eb527da0db340421f53bc1cc439a453306 profile.sh 86a0c08720225e4532f797ad69307dfff66867e4a35de1aacceefc48f19721caf93f9a17a268e58f1f5a7e947f157d6984676837c2b5b835b0caf6ee9821bb5a weston.ini" diff --git a/device/device-motorola-titan/deviceinfo b/device/device-motorola-titan/deviceinfo index d3c48aebb..35d3af092 100644 --- a/device/device-motorola-titan/deviceinfo +++ b/device/device-motorola-titan/deviceinfo @@ -10,7 +10,7 @@ deviceinfo_keyboard="false" deviceinfo_nonfree="????" deviceinfo_dtb="" deviceinfo_modules_initfs="" -deviceinfo_external_storage="false" +deviceinfo_external_storage="true" deviceinfo_flash_method="fastboot" deviceinfo_arch="armhf" @@ -19,6 +19,7 @@ deviceinfo_screen_width="720" deviceinfo_screen_height="1280" # Fastboot related +deviceinfo_flash_offset_base="0x00000000" deviceinfo_flash_offset_kernel="0x00008000" deviceinfo_flash_offset_ramdisk="0x01000000" deviceinfo_flash_offset_second="0x00f00000" @@ -26,4 +27,5 @@ deviceinfo_flash_offset_tags="0x00000100" deviceinfo_flash_pagesize="2048" deviceinfo_kernel_cmdline="androidboot.bootdevice=msm_sdcc.1 androidboot.hardware=qcom vmalloc=400M utags.blkdev=/dev/block/platform/msm_sdcc.1/by-name/utags buildvariant=userdebug" deviceinfo_generate_bootimg="true" +deviceinfo_bootimg_qcdt="true" deviceinfo_flash_sparse="true" diff --git a/device/linux-motorola-titan/APKBUILD b/device/linux-motorola-titan/APKBUILD index 17633048c..8402a5111 100644 --- a/device/linux-motorola-titan/APKBUILD +++ b/device/linux-motorola-titan/APKBUILD @@ -16,7 +16,7 @@ _vendor=motorola _flavor=motorola-titan -_hash="09cff47d6b79b73ecc3461e227abf09faaa9e754" +_commit="22bc4ed7f4149f95c84634e6c1baccbbd16c5cc5" _config="config-${_flavor}.armhf" pkgname=linux-${_flavor} @@ -25,16 +25,16 @@ case $pkgver in *.*.*) _kernver=${pkgver%.*};; *.*) _kernver=$pkgver;; esac -pkgrel=10 +pkgrel=11 arch="armhf" pkgdesc="Motorola Moto G 2014 kernel from LineageOS" url="https://github.com/LineageOS/android_kernel_motorola_msm8226" depends="" -makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev xz gcc6" +makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev xz gcc6 dtbtool" options="!strip !check !tracedeps" install= source=" - $pkgname-$_hash.tar.gz::https://github.com/LineageOS/android_kernel_motorola_msm8226/archive/${_hash}.tar.gz + $pkgname-$_commit.tar.gz::https://github.com/LineageOS/android_kernel_motorola_msm8226/archive/${_commit}.tar.gz $_config compiler-gcc6.h 00_fix_return_address.patch @@ -57,7 +57,7 @@ if [ "${CC:0:5}" != "gcc6-" ]; then CROSS_COMPILE="gcc6-$CROSS_COMPILE" fi -ksrcdir="$srcdir/android_kernel_motorola_msm8226-${_hash}" +ksrcdir="$srcdir/android_kernel_motorola_msm8226-${_commit}" prepare() { local _patch_failed= @@ -96,19 +96,26 @@ build() { unset LDFLAGS make ARCH="$_carch" CC="${CC:-gcc}" \ - KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" + KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" + + # Generate master DTB (deviceinfo_bootimg_qcdt) + dtbTool -s 2048 -p "scripts/dtc/" -o "arch/arm/boot/dt.img" "arch/arm/boot/" } package() { - install -Dm644 "$srcdir/build/arch/arm/boot/zImage-dtb" \ + install -Dm644 "$srcdir/build/arch/arm/boot/zImage" \ "$pkgdir/boot/vmlinuz-$_flavor" install -D "$srcdir/build/include/config/kernel.release" \ "$pkgdir/usr/share/kernel/$_flavor/kernel.release" + + # Master DTB (deviceinfo_bootimg_qcdt) + install -Dm644 "$srcdir/build/arch/arm/boot/dt.img" \ + "$pkgdir/boot/dt.img" } -sha512sums="7e0fb6b0b5c4de67bfdcbc9a32e47ffd3cba3094165d76926585edf25d4a3254e0bfc10c9611cf8d20232b055ab7e07e9818e7cdc3bccd0d3414a1cb7419eb37 linux-motorola-titan-09cff47d6b79b73ecc3461e227abf09faaa9e754.tar.gz -cf95f22cf689b9bd7d89d1496c5e9beb56934b25453c42181aa0e8af0a6b874f61d44917769054988772480e52950eec3896ab51a4688b33b1546f8432d73f16 config-motorola-titan.armhf +sha512sums="5e55db19f198fadf0f914c2726c034eeaf9a1f4ad5823a7e8a4e9be2664eb0279c91fb2f1c6a9292be2ac523e367551475ff40569676775a03a709ae50a3d0ec linux-motorola-titan-22bc4ed7f4149f95c84634e6c1baccbbd16c5cc5.tar.gz +6c5ed99876f44746262d93f158c91377cb4b003f0abcd4226510bec10c7f571479dd3c7165602fd58ca54113cbab512899c819b0022c8d1dda94be3cba8f45ea config-motorola-titan.armhf d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc compiler-gcc6.h ea1d3b5a234fa565e3c1a792de48f4fc4e6023d281d303c8e319c7ef28edc5739ab0e4dea0139a41f0a5c7d03e27921ccaa214fd0ac5c72245a094ce60128864 00_fix_return_address.patch a8c955bf718f155011e980f3d0948be98e1fee5649f418299a4851780543019daf7afa406aa7b0829375645107e4e6fbf241026b0cabe2b2ac895a47df83d2d8 02_mdss_fb_refresh_rate.patch diff --git a/device/linux-motorola-titan/config-motorola-titan.armhf b/device/linux-motorola-titan/config-motorola-titan.armhf index b96570eaf..1fa005386 100644 --- a/device/linux-motorola-titan/config-motorola-titan.armhf +++ b/device/linux-motorola-titan/config-motorola-titan.armhf @@ -125,12 +125,12 @@ CONFIG_RELAY=y CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" CONFIG_RD_GZIP=y -CONFIG_RD_BZIP2=y -CONFIG_RD_LZMA=y +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set -CONFIG_RD_LZO=y +# CONFIG_RD_LZO is not set # CONFIG_RD_LZ4 is not set -# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_SYSCTL=y CONFIG_ANON_INODES=y CONFIG_PANIC_TIMEOUT=5 @@ -182,6 +182,11 @@ CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y CONFIG_HAVE_CLK=y CONFIG_HAVE_DMA_API_DEBUG=y CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_CC_STACKPROTECTOR=y +CONFIG_CC_STACKPROTECTOR=y +# CONFIG_CC_STACKPROTECTOR_NONE is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_ARCH_MMAP_RND_BITS=y CONFIG_ARCH_MMAP_RND_BITS_MIN=8 CONFIG_ARCH_MMAP_RND_BITS_MAX=16 @@ -673,7 +678,6 @@ CONFIG_FORCE_MAX_ZONEORDER=11 CONFIG_ALIGNMENT_TRAP=y # CONFIG_UACCESS_WITH_MEMCPY is not set # CONFIG_SECCOMP is not set -# CONFIG_CC_STACKPROTECTOR is not set # CONFIG_DEPRECATED_PARAM_STRUCT is not set # CONFIG_ARM_FLUSH_CONSOLE_ON_RESTART is not set CONFIG_CP_ACCESS=y @@ -2529,6 +2533,7 @@ CONFIG_FB_MSM=y # CONFIG_FB_MSM_TRIPLE_BUFFER is not set # CONFIG_FB_MSM_MDP_HW is not set CONFIG_FB_MSM_MDSS_COMMON=y +# CONFIG_MDP_DEBUG_FS is not set # CONFIG_FB_MSM_MDP22 is not set # CONFIG_FB_MSM_MDP30 is not set # CONFIG_FB_MSM_MDP31 is not set @@ -3527,6 +3532,7 @@ CONFIG_KEYS=y # CONFIG_KEYS_DEBUG_PROC_KEYS is not set # CONFIG_SECURITY_DMESG_RESTRICT is not set # CONFIG_ANDROID_CAP_SYSLOG_GROUP is not set +CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y CONFIG_SECURITY=y # CONFIG_SECURITYFS is not set CONFIG_SECURITY_NETWORK=y @@ -3690,9 +3696,6 @@ CONFIG_LZ4_DECOMPRESS=y # CONFIG_XZ_DEC is not set # CONFIG_XZ_DEC_BCJ is not set CONFIG_DECOMPRESS_GZIP=y -CONFIG_DECOMPRESS_BZIP2=y -CONFIG_DECOMPRESS_LZMA=y -CONFIG_DECOMPRESS_LZO=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_REED_SOLOMON=y CONFIG_REED_SOLOMON_ENC8=y