Commit Graph
130 Commits
Author SHA1 Message Date
Chris Renshaw 7ccf4d62ce AK3: fix signing derp
Thanks @Zackptg5

Closes #40
2019-06-12 16:52:29 -03:00
osm0sis 6d25afd03a AK3: allow ChromeOS auto-detect, clean up signing, fixes
- since magiskboot has built-in detection for the ChromeOS image pre-header signature, allow it to be auto-detected and if futility and signing files are present re-sign automatically (thanks @Zackptg5 for the nudge)
- simplify signing and error catching
- fix typo breaking ramdisk_recovery partition detection
- hide expected stderr for formats where some files may not exist (cmdline for ELF, etc.)
2019-06-10 23:12:00 -03:00
osm0sis e4497f231e AK3: clean up "OG AK" mode stderr on images with no kernel/ramdisk present 2019-06-07 23:28:18 -03:00
osm0sis bf38d208c8 AK3: be clear when unpack_ramdisk fails because there is no ramdisk
- previously this was failing a bit too spectacularly for my liking since $comp would erroneously get set to "fopen: ramdisk.cpio failed with 2: No such file or directory"
- on devices where there is no ramdisk.cpio unless rooted with Magisk this will indicate better to developers working on the device that they should be using "OG AK" mode to avoid trying to unpack a ramdisk which may or may not exist
2019-06-07 21:35:10 -03:00
osm0sis 76d59d67e6 AK3: also make mtd partition detection variables local 2019-06-06 16:04:43 -03:00
osm0sis ad665cc95f AK3: cleanups and fixes to config/setup functions
- simplify rdtmp and $ramdisk creation and keep only in `unpack_ramdisk`
- fix `reset_ak` and `setup_ak` behavior if run before $block is set
- only save boot.img and boot-new.img in *-files subdirectories on multi-partition setups since otherwise the tmpfs (in recovery) and ext4 .img (when booted) size usage gets quickly out of hand
- fix slot_select=inactive when used with block=auto or block=boot partition detection
2019-06-06 15:42:40 -03:00
osm0sis 725e3a0006 tools: update magisk tools to v19.3(19300) stable 2019-06-05 20:33:59 -03:00
osm0sis 192ccc94d3 AK3: support MTK /dev/bootimg and /dev/recovery partition matching
(note these probably require nanddump and nandwrite to access correctly)
2019-06-04 23:45:47 -03:00
osm0sis 97de781a55 AK3: resolve non-zero return code introduced by cat <img> /dev/zero > <block>
- the expected "cat: write error: No space left on device" gives a non-zero return code so always return true
- devices that flash dtbo abort since the return code would get passed back to the Backend and silently fail as the final command in anykernel.sh (via `write_boot`), so catch seperately with a proper error message for other image write methods
2019-06-02 19:15:47 -03:00
osm0sis 24032c0732 AK3: allow workaround for dtbo devices with cat /dev/zero issues
- some device recoveries (e.g. TWRP for wahoo) seem to have issues with the new `cat <image> /dev/zero > <block>` method of flashing, so allow setting customdd="bs=1048576" shell variable in anykernel.sh to work around this by reverting back to dd wipe+flash for dtbo as it does with boot
2019-06-02 15:44:49 -03:00
Chris Renshaw c8d087bbad AK3: fix elftool repack cmdline handling 2019-06-01 01:30:56 -03:00
osm0sis cba94d3103 tools: rename ak2-core.sh to ak3-core.sh 2019-05-31 23:59:39 -03:00
osm0sis 6986821230 Welcome to AK3: AnyKernel2 + Magisk = AnyKernel3!
- abstract out execution directory as $home to fascilitate testing individual scripts (defaults to /tmp/anykernel)
- general script clean ups for uniformity, readability, speed and simplicity
- simplify consecutive `ui_print` commands where possible

Backend only fixes:
- use busybox umount and mount whenever possible to avoid linker warnings in stderr during system-as-root setup
- use `busybox --install -s` for bin/* setup
- consolidate setup to abort earlier if there are issues
- add backwards compatible symlinks for those who might not have updated their anykernel.sh with ak3-core.sh (to be renamed in subsequent commit)

Tools only fixes:
- add magiskboot to replace separate support for AOSP and PXA-AOSP formats, with MTK headers, BLOB, DHTB, SEAndroid and Nook signing
- add magiskpolicy to allow for easy sepolicy patching
- remove xz and lz4 since magiskboot supports these

AK3 Core only fixes:
- use full `ui_print` function implementation like the backend
- add `abort` function to simplify exit on errors
- fix $patch directory being excluded from `reset_ak`
- update $ramdisk_compression handling for magiskboot
- magiskboot also resolves long-standing request for built-in Bump support (#18)
- update Sony ELF and related support for initial repack as AOSP by using mkbootimg as plug-and-play optional add-in binary
- update Sony ELF MTK header support using mkmtkhdr only when ELF is initially unpacked by unpackelf
- add support for MTK RECOVERY ramdisk header type with Sony ELF
- simplify U-Boot dumpimage/mkimage and Sony ELF unpackelf/mkbootimg split_img file handling
- update patch_cmdline to handle both magiskboot as header prop file, and unpackelf or mboot as cmdline.txt
- use `cp -fp` for `backup_file` and `restore_file` to hopefully better preserve attributes if used outside of the ramdisk
- refactor setup into `setup_ak` to simplify `reset_ak` trigger to find slot and block again
- add fallback to busybox for compression formats (i.e. lzop) which magiskboot cannot handle

IMPORTANT NOTES:
1) forcing repack with uncompressed cpio ramdisk is not currently supported by magiskboot
2) forcing repack with lzop ramdisk when previously another format is not currently supported by magiskboot
2019-05-31 23:49:19 -03:00
osm0sis 1bd118035f AK2: underp opposite slot case 2019-05-10 02:35:10 -03:00
osm0sis 1a143d7306 AK2: add support for multi-slot zips
- extend `reset_ak` with `reset_ak keep` which will keep files to be available to patch the other slot
- add optional slot_select=inactive shell variable to force inactive slot during slot detection
2019-05-09 16:13:47 -03:00
osm0sis c3e298ecc6 AK2: add U-Boot RAMDisk uImage support 2019-05-01 11:04:13 -03:00
osm0sis a38790caed AK2: add $OS$ header Android image format support
- add built-in support for mboot for Intel OSIP devices (see: https://github.com/osm0sis/mboot)
2019-04-18 21:56:30 -03:00
osm0sis d3792a4856 AK2: fix dump failures for unpackelf and dumpimage (with ramdisk) 2019-04-18 21:53:23 -03:00
osm0sis 525a1bd826 AK2: add AOSP boot_img_hdr_v2 support (READ NOTES)
- AOSP has added --dtb, so to avoid conflicts *unpackbootimg and unpackelf have had what was previously dumped as *-dtb renamed to *-dt
- the same corresponds to any replacement version of these included in the zip root, i.e. they are now dt or dt.img for the old style from before hdr_v1, and dtb or dtb.img for the new style for hdr_v2

Note: You MUST update to the newer mkbootimg and unpackbootimg for this commit if you are using architectures other than the included ARM builds!

See AIK-mobile v3.5 for updated unpackelf, and mkbootimg/unpackbootimg binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
2019-04-18 10:29:05 -03:00
osm0sis e11482bdec AK2: fix unpack for latest U-Boot tools (v2019.04) update
- v2019.04 changed the order and arguments for the U-Boot dumpimage tool

See AIK-mobile v3.5 for updated dumpimage/mkimage binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
2019-04-18 09:43:01 -03:00
osm0sis 62392072b2 tools: update to latest builds, including busybox (1.30.1), lz4 (1.9.0)
Compiled from my own updated forks:
https://github.com/osm0sis/mkbootimg
https://github.com/osm0sis/android-busybox-ndk

ARM binaries; see AIK-mobile v3.5 for other architectures and optional binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
2019-04-18 09:35:40 -03:00
osm0sis ac441a6eaa AK2: fix customdd detection logic 2019-04-06 21:46:23 -03:00
osm0sis a40fe9c65b AK2: add backwards compat for crazy devices hacking their mmcblk0
see comments here: https://github.com/osm0sis/AnyKernel2/pull/38#issuecomment-479577751

This will allow the current way people were adding arguments to dd via block= but also allow them to control this directly by adding customdd= to anykernel.sh.
2019-04-05 21:24:52 -03:00
Park Ju Hyung 3998baa529 AK2: optimize write operations
- dd uses bs=512 by default, which is far from optimal for sequential reads.
   Use bs=1048576(1M) for initial dump.
   This improves read performance by a measurable amount.

 - Zero-fill only the remaining blocks.
   There's no need to zero-fill all blocks,
   not to mention the additional/unnecessary wear and tear
   to the flash storage.

   Linux pipe uses bs=4096 by default. By using cat for this,
   we additionally gain much better write performance.

   On the OnePlus 6T, final write operation took 7.1 seconds in total with
   2 consecutive dd commands. With cat, it now takes 0.08 seconds.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
2019-04-03 14:07:15 -03:00
osm0sis 3ea64d006a AK2: workaround for U-Boot dumpimage failing on untrimmed uImage dumps
https://lists.denx.de/pipermail/u-boot/2019-January/355670.html
2019-03-21 17:13:56 -03:00
osm0sis c109065a3d AK2: fix ramdisk repack and mtk signing when uncompressed cpio 2019-02-08 23:19:21 -04:00
osm0sis 82e7c0345b AK2: add support for uncompressed cpio ramdisks
ramdisk_compression=cpio or =none to force
2019-02-07 13:00:42 -04:00
osm0sis a31d03f2ce Backend: introduce Android version check
- checks the supported.versions prop in anykernel.sh and matches against it to prevent users flashing incorrect kernels for ROM versions
- supported.versions can be a list, e.g. "7.1.2, 8.0, 8.1" or a range, e.g. "8.1 - 9" of versions in the correct formatting for that Android version in ro.build.version.release in /system/build.prop
2018-12-16 18:31:53 -04:00
osm0sis d9acb3384d AK2: allow replace_string to optionally global scope replace 2018-12-16 14:03:47 -04:00
osm0sis 1d58385b26 AK2+Backend: fix file_getprop truncating if prop value contained =
See comments: https://github.com/osm0sis/AnyKernel2/pull/35#issuecomment-447648900
2018-12-16 13:53:33 -04:00
osm0sis e1ae4412f5 AK2: add AOSP boot_img_hdr_v1 support 2018-10-28 19:30:59 -03:00
osm0sis 301ed77319 tools: update to latest builds, including busybox (1.29.3), lz4 (1.8.3)
Compiled from my own updated forks:
https://github.com/osm0sis/mkbootimg
https://github.com/osm0sis/android-busybox-ndk

ARM binaries; see AIK-mobile v3.4 for other architectures and optional binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
2018-10-28 19:28:03 -03:00
osm0sis 9d7f85807f AK2: fix stupid copy pasta error
thanks eng.stk for catching it
2018-10-01 13:18:43 -03:00
osm0sis 3ab879b71a AK2: add Android Pie /dev/block/by-name location to partition search list 2018-09-30 14:44:00 -03:00
osm0sis 361712b5e2 tools: update to latest builds, including busybox (1.29.2)
Compiled from my own updated forks:
https://github.com/osm0sis/mkbootimg
https://github.com/osm0sis/android-busybox-ndk

ARM binaries; see my Busybox Installer for busybox in other architectures:
https://github.com/Magisk-Modules-Repo/Busybox-Installer
2018-09-08 15:50:34 -03:00
Nathan Chancellor 5ce0e9f2d4 AK2: Move flash_dtbo into write_boot
split_boot is for fine grained control over what exactly gets flashed
at what point. It makes more sense for flash_dtbo to live in write_boot,
which does everything all at once.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-08-03 00:03:46 -03:00
Nathan Chancellor d067d39b83 AK2: Expose dtbo flashing
Some zips may want to flash just the dtbo so add a function that can be
called in anykernel.sh to make that happen.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-08-03 00:03:46 -03:00
osm0sis 30cca512d9 tools: bring back busybox 1.29.1 built with the broken gzip rolled back
https://bugs.busybox.net/show_bug.cgi?id=11171
2018-07-24 13:19:55 -03:00
osm0sis 8aa7b787e1 tools: revert to busybox 1.28.4 until an issue with 1.29.1 gzip can be resolved
- gzip in busybox 1.29.1 doesn't seem to use compression anymore, with -1 and -9 both coming
out to the same size, generally dramatically larger than previously resulting in
boot-new.img exceeding the partition size on some devices so then failing the check.

e.g. 28mb ramdisk.cpio -> 11.2mb ramdisk.cpio.gz in 1.28.4, is now 20mb in 1.29.1

thanks nathanchance for reporting
2018-07-23 23:03:44 -03:00
osm0sis a53e3f765c tools: update to latest builds, including busybox (1.29.1), lz4 (1.8.2) and xz (5.2.4)
Compiled from my own updated forks:
https://github.com/osm0sis/mkbootimg
https://github.com/osm0sis/android-busybox-ndk

ARM binaries; see AIK-mobile v3.3 for other architectures and optional binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
2018-07-23 10:39:04 -03:00
osm0sis 0b8b09f29e AK2: fix repacked ramdisk check now that compext is local to repack_ramdisk
Thanks eng.stk for reporting and testing the fix
2018-07-16 23:16:26 -03:00
osm0sis 955f3ce488 AK2: add patch_ueventd
- introduce function to modify or add entries to ueventd.rc using its spaced columns format, matched using the device node
2018-07-16 14:00:23 -03:00
osm0sis 1811b87a19 AK2: fix slot detection broken by block auto detection 2018-07-16 13:54:49 -03:00
osm0sis 915cdaff1b AK2: fix replace_section and remove_section functions
- was broken with search strings containing paths (a limitation with busybox sed)
- now matches blank lines and lines containing only white space for next-empty-line matching
- include end-of-file as the final possible end-point for next-empty-line matching
2018-07-14 16:48:45 -03:00
osm0sis 56373a6a1c AK2: use local variables for ramdisk editing functions 2018-07-13 02:08:44 -03:00
osm0sis 5fbae260c0 Revert "Support more locations for dtbo img (#24)"
This reverts commit bafe4bd586.

A certain level of functioning recovery is expected by AnyKernel2 (versus this patch's source, the Magisk installer, which is extremely pessimistic).
2018-07-13 01:29:33 -03:00
osm0sis 75986e14d1 AK2: add auto detection of named block (e.g. boot, recovery) partitions (#19, #26)
- search using a list of known ramdisk/kernel or recovery by-name partition names
- block=auto is equivalent to block=boot
- for use with broad, device non-specific AK2-based mod zips
2018-07-13 01:20:04 -03:00
osm0sis 2a34450ba9 AK2+Backend: move system_root setup and tear down to backend
- abstract out unmounting and expand to support undoing system_root
- also preserve and restore LD_PRELOAD
2018-07-03 20:49:31 -03:00
Chris Renshaw f2ee53b843 AK2: fix AVBv1 auto signing
- BootSignature.jar uses stderr to print VALID on image verification, so the grep was always failing
2018-05-22 01:08:01 -03:00
Zackptg5 bafe4bd586 Support more locations for dtbo img (#24)
* Support more locations for dtbo img (from Magisk's util_functions.sh)
2018-05-03 06:15:06 -03:00