[TOOLS][ZIPS][SCRIPTS] osm0sis' Odds and Ends [Multiple Devices/Platforms]

_that

Recognized Developer / Recognized Contributor
Oct 2, 2012
4,817
4,205
243
For some reason, I'm unable to use the "Enter" key when in the TWRP Terminal.
The "Enter" key in TWRP's terminal sends ASCII code 10 which is understood correctly by the shell's line editor and by busybox vi. I don't remember why I explicitly translated CR to LF (must be a leftover from an early hack), but removing that code makes nano happy.

Fix: https://gerrit.omnirom.org/#/c/17941/
 
Last edited:

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Hey @osm0sis!

I wanted to stop by and say thanks for the nano binary/zip - I find it very useful for being able to modify files directly in the TWRP Terminal. However, since attempting to do this, I've come across an issue. For some reason, I'm unable to use the "Enter" key when in the TWRP Terminal. For example, if I want to edit /data/.supersu and open it with nano, I can navigate with the arrow keys, backspace, and type new data. However, if I want to save those changes, I'm unable to do so, because I can't press the Enter key. It appears to produce a double vibration when trying to press it, and the key never registers. Do you think this is something that can be fixed?
Ah! Thanks for noticing that and bringing it up. I had discovered that awhile back but forgot to mention it! :silly:

The "Enter" key in TWRP's terminal sends ASCII code 10 which is understood correctly by the shell's line editor and by busybox vi. I don't remember why I explicitly translated CR to LF (must be a leftover from an early hack), but removing that code makes nano happy.

Fix: https://gerrit.omnirom.org/#/c/17941/
Perfect! Thanks! I was hoping it was something easily fixed on TWRP's end since I noticed everything worked fine within AROMA Filemanager's Console. :)
 
  • Like
Reactions: Captain_Throwback

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Update ALL of the things! Mostly they all contain the same fixes: make sure /su gets mounted rw correctly if it was mounted ro for some reason, and some new versions of some functions to further extend support to recoveries that (foolishly :mad:) don't have awk anymore like CM Recovery.

There is also a new Kernel MultiROM Injector script zip intended for use in @Chainfire's excellent FlashFire app to automate re-injecting the current boot image ramdisk with MultiROM's trampoline bootmenu; this avoids having to do this as an extra step in MR-TWRP following an OTA, ROM Delta or SuperSU update through FlashFire. :cowboy:

Other than that, nano got a new binary compile and some recovery wrapper fixes, and Kernel init.d Injector also got updated to potentially work with Android N+; honestly su.d is a better choice nowadays, but there may still be a use-case for a self-contained binary-free init.d solution.

I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!

UPDATE-adb.Installer.v1.0.26-signed.zip;
UPDATE-Busybox.Installer.v1.24.2-ALL-signed.zip:

- unmount /su first before attempting to mount to ensure it gets mounted rw.

UPDATE-Flashlt.Installer.v2.3-signed.zip:
- unmount /su first before attempting to mount to ensure it gets mounted rw.
- update to latest versions of set_perm and set_perm_recursive from my Complete Shell Zip Documentation to support recoveries currently without awk (CM Recovery).

UPDATE-sdcard.Fix.Permissions-signed.zip:
- update to latest versions of set_perm and set_perm_recursive from my Complete Shell Zip Documentation to support recoveries currently without awk (CM Recovery).

UPDATE-SUmount-signed.zip:
- mount /data and /cache to fix su.img detection on recoveries that have these unmounted at first (CM Recovery).

UPDATE-nano.Terminal.Editor.v2.5.3-signed.zip:
- unmount /su first before attempting to mount to ensure it gets mounted rw.
- update recovery nano wrapper to mount /data and /cache for recoveries that have these unmounted at first (CM Recovery).
- update recovery nano wrapper to mount /su rw since we could be editing something in /su/su.d and wouldn't want to limit that.
- switch to building nano with libncurses 5.9 prebuilt library, resolving some "variable-size enums" warnings from the build which could improve compatibility across devices.
- instead of reverting the breaking change for Android execution that I reported from 2.5.3, cherry-pick the resulting fixes from the Git master branch HEAD.

UPDATE-Kernel.MultiROM.Injector-signed.zip:
- determines /sdcard multirom directory then runs the injection command, just like MR-TWRP and the MultiROM installation zip do, but a little more clever since it detects the boot partition on-the-fly (should work for all EMMC devices).

UPDATE-Kernel_init.d_Injector-AK2-signed.zip:
- update to latest AnyKernel2 base, resolving missing command issues on stock recoveries.
- add seclabel to the service for potential Android N support.


I've also force-pushed another couple fixes into gappsintegrator v8.5, added my nano building tricks to the Knowledge Base post, and divided the zips section of the OP into "Flashable Script Zips" and "Flashable Installer Zips" to make it a little easier to navigate/digest. Enjoy! :D
 
Last edited:

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Hi @osm0sis

I can't get your gapps integrator to run, both in SManager and Term Emulator it errors in line 6: syntax error: ')' unexpected, which I believe is-
freespace() {

I uncommented everything to easily find where it was messing up at-
https://db.tt/6maEqqyb

Why is it erroring?
Works fine here from Terminal Emulator, but you should really be running it as a su.d script, either from /system/su.d or /su/su.d; Make sure you download and extract it from the repo.zip link if you're having trouble with line-endings (ie. you shouldn't be copy-pasting it from GitHub):
http://forum.xda-developers.com/showpost.php?p=66854770&postcount=697
 
Last edited:

fhem

Senior Member
Nov 4, 2013
880
1,573
93
Pittsburgh, PA
@osmosis I really appreciate all your great work. I use and have played with many of your works. As an old retired guy I have really learned a lot looking at all your scripts/works, etc and trying to understand what you are doing. It is one of my hobbies LOL.

OK -- Now my question!! I know SuperR is using your BB zip in his kitchen so......... would it be ok if I try to use your bb.zip with my aosp builds. I currently use cm bionic bb but I would like to try yours. Of course I will give credit.

Thanks in advance.
 
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
I really appreciate all your great work. I use and have played with many of your works. As an old retired guy I have really learned a lot looking at all your scripts/works, etc and trying to understand what you are doing. It is one of my hobbies LOL.

OK -- Now my question!! I know SuperR is using your BB zip in his kitchen so......... would it be ok if I try to use your bb.zip with my aosp builds. I currently use cm bionic bb but I would like to try yours. Of course I will give credit.

Thanks in advance.
Yup! No problem at all. Thanks for the kind words and support! I'll look forward to checking out your ROM. :)
 
  • Like
Reactions: jesssiii and fhem

fhem

Senior Member
Nov 4, 2013
880
1,573
93
Pittsburgh, PA
Yup! No problem at all. Thanks for the kind words and support! I'll look forward to checking out your ROM. :)
Working great on the three devices ( N6, N6P, & N9 ) for which I build and use.

https://github.com/fwhem/platform_vendor_noobbuilds/commit/0df4fbce3ed82a01438c83917c9772a48340f96f
https://github.com/fwhem/platform_build/commit/ae1703c267c1ed11c6260995ab413fce05c3ccb0

Thank you sir. I gotta buy you a cuppa!!

EDIT: @osm0sis here's that cuppa -> Confirmation number: 4686293632501151M

Thanks again.
 
Last edited:

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Working great on the three devices ( N6, N6P, & N9 ) for which I build and use.

https://github.com/fwhem/platform_vendor_noobbuilds/commit/0df4fbce3ed82a01438c83917c9772a48340f96f
https://github.com/fwhem/platform_build/commit/ae1703c267c1ed11c6260995ab413fce05c3ccb0

Thank you sir. I gotta buy you a cuppa!!

EDIT: @osm0sis here's that cuppa -> Confirmation number: 4686293632501151M

Thanks again.
Thank you!

Donations are few and far between so I truly appreciate that! :)

It helps me explain to my girlfriend why I spend so much time messing around with my phone in my free time (;)), and helps keep me motivated to put the time in to trying out new ideas. :cowboy:

And, actually, speaking of which.. :D

UPDATE-Adreno.Systemless.Installer-signed.zip:
http://forum.xda-developers.com/showpost.php?p=67117557&postcount=173

For use with Qualcomm's updated GPU drivers packages for N5, N6 and N7 '13.
 
Last edited:

fhem

Senior Member
Nov 4, 2013
880
1,573
93
Pittsburgh, PA
Thank you!

Donations are few and far between so I truly appreciate that! :)

It helps me explain to my girlfriend why I spend so much time messing around with my phone in my free time (;)), and helps keep me motivated to put the time in to trying out new ideas. :cowboy:

And, actually, speaking of which.. :D

UPDATE-Adreno.Systemless.Installer-signed.zip:
http://forum.xda-developers.com/showpost.php?p=67117557&postcount=173

For use with Qualcomm's updated GPU drivers packages for N5, N6 and N7 '13.
You are very welcome --- I believe donating to devs who are active and supportive of the community. It is good for us all.
BTW: Let's go Pens!!!!!!! and thanks for sending us Sid the Kid
 
  • Like
Reactions: osm0sis

dingermtb

Senior Member
Sep 5, 2010
1,650
1,588
0
Richeyville
You are very welcome --- I believe donating to devs who are active and supportive of the community. It is good for us all.
BTW: Let's go Pens!!!!!!! and thanks for sending us Sid the Kid
I just had to chime in, being from "The Burgh"... yes, Let's go Pens

Sent from Outside the 9 using my Zombiefied Exodus OnyX
 
  • Like
Reactions: fhem

mikeoswego

Senior Member
May 4, 2014
903
773
0
Northern Indiana
gappsintegrator: v8.5 - add limits for until loops, add fallback log location, fixes:
Finally had a chance to check this out on the Motorola stock based 5.1 (SDK 22) rom that I maintain for the XT1096 Verizon version of the MotoX.

You've got a workaround already in place for /sdcard not being writable by root. It never becomes writeable, shell can write to it but not root. There is a symlink for /sdcard to /storage/emulated/legacy which works as shell but as root, the path changes to /storage/emulated/0 I can create a symlink from 0 to legacy but that doesn't stick after a reboot. This is not your fault, of course, but I thought I would report it. I've modified the script to just write the log to /data/local and check for access there instead of /sdcard.

The other problem with this rom is that the chmod included in their version of toybox doesn't work with multiple filenames or wildcards, so the line
Code:
chmod 644 $sysapk/$sysname.apk $sysapk/lib/*/*;
fails. Changing that line to
Code:
busybox chmod 644 $sysapk/$sysname.apk $sysapk/lib/*/*;
fixes the problem. (I install BusyBox in the ROM, Moto doesn't include it.) I imagine this problem might be widespread so hopefully the info helps future troubleshooting.

Thanks for your work!
 
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Did some - work trying to crack the bootloader lockstates for the N5X this week, and while it isn't looking too good due to what is likely a secure auth token, it did present me with the opportunity to be satisfied that Factory Reset Protection (FRP) is being implemented consistently enough to make support for it generalized for all devices detected with it.

This should be pretty future-proof since it gets the FRP persist partition from getprop and then (since Google's spec says it's the last byte) calculates the offset on-the-fly. This means I shouldn't need to update the zip to support any new FRP devices unless there's an actual unlock method to be added. :good:

Flashlt also gained a way to circumvent my fancy dump trimming method in case raw dumps are needed for some reason. ;)

I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!

UPDATE-Nexus.BootUnlocker-signed.zip:
- refactor so that FRP is now automatically detected and toggled for any device that doesn't match for a classic unlock.
- simplify, cut down on duplication, pulling model name from getprop and combining all devices with the same offsets.

UPDATE-Flashlt.Installer.v2.4-signed.zip:
- add --notrim argument to "dumpit" functionality.


Edit: Re-uploaded Nexus BootUnlocker with a couple more cleanups (shouldn't affect anything functionally) since it likely won't need to be updated again for a while.
 
Last edited:

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Thanks my dude for the high degree of awesome ideas that you turn into code that can be executed on our devices. I really really appreciate everything that you do for the xda community. Thanks again and have a couple beers on me 7V6057044H099262K
Thanks so much for the support and the extremely kind words! :D
 
Last edited:
  • Like
Reactions: skulldreamz

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
Looked into Sony ELF kernel images a bit today, here's the bulk of what I worked out:

Code:
$ readelf -lS kernel-mtkc4.elf
There are 1 section headers, starting at offset 0x9a0c8a:

Section Header:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0] <no-name>         LOUSER+53494e   00000000 99fc8a 001000 00      0   0  0
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Elf file type is EXEC (Executable file)
Entry point 0x40080000
There are 2 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000074 0x40080000 0x40080000 0x65a7d5 0x65a7d5     0
  LOAD           0x65a849 0x44000000 0x44000000 0x345441 0x345441     0

Raw Header:
e_ident
7F 45 4C 46 EI_MAG (ELF)
01 EI_CLASS (32-bit)
01 EI_DATA (Little Endian)
01 EI_VERSION
61 EI_OSABI (?61=kernel.elf)
00 EI_ABIVERSION
00 00 00 00 00 00 00 EI_PAD

02 00 e_type (executable)
28 00 e_machine (ARM)

01 00 00 00 e_version
00 00 08 40 e_entry
34 00 00 00 e_phoff
8A 0C 9A 00 e_shoff (s_header)
00 00 00 00 e_flags
34 00 e_ehsize
20 00 e_phentsize
02 00 e_phnum
28 00 e_shentsize
01 00 e_shnum
00 00 e_shstrndx

p_header
01 00 00 00 | 74 00 00 00 p_type|p_offset
00 00 08 40 | 00 00 08 40 p_vaddr|p_paddr (kernel_offset)
D5 A7 65 00 | D5 A7 65 00 p_filesz|p_memsz
00 00 00 00 | 00 00 00 00 p_flags|p_align

01 00 00 00 | 49 A8 65 00 p_type|p_offset
00 00 00 44 | 00 00 00 44 p_vaddr|p_paddr (ramdisk_offset)
41 54 34 00 | 41 54 34 00 p_filesz|p_memsz
00 00 00 00 | 00 00 00 00 p_flags|p_align

s_header
00 00 00 00 name
4E 49 53 80 type
00 00 00 00 flags
00 00 00 00 address
8A FC 99 00 offset (cmdline_offset)
00 10 00 00 size (pagesize)

00 00 00 00 00 00 00 00 padding
00 00 00 00 00 00 00 00 padding




$ readelf -lS kernel-xtz4.elf
There are 1 section headers, starting at offset 0x1de3eb4:

Section Header:
  [Nr] Name              Type             Address           Offset       Size              EntSize          Flags  Link  Info  Align
  [ 0] <no-name>         LOUSER+53494e    0000000000000000  01de2eb4     0000000000001000  0000000000000000           0     0     0
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Elf file type is EXEC (Executable file)
Entry point 0x80000
There are 3 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr           FileSiz            MemSiz              Flags  Align
  LOAD           0x00000000000000e8 0x0000000000080000 0x0000000000080000 0x000000000175ee78 0x000000000175ee78         0
  LOAD           0x000000000175ef60 0x0000000002000000 0x0000000002000000 0x0000000000587419 0x0000000000587419         0
  LOAD           0x0000000001ce6379 0x0000000001e00000 0x0000000001e00000 0x00000000000fcb3b 0x00000000000fcb3b         0

Raw Header:
e_ident
7F 45 4C 46 EI_MAG (ELF)
02 EI_CLASS (64-bit)
01 EI_DATA (Little Endian)
01 EI_VERSION
61 EI_OSABI (?61=kernel.elf)
00 EI_ABIVERSION
00 00 00 00 00 00 00 EI_PAD

02 00 e_type (executable)
28 00 e_machine (ARM)

01 00 00 00 e_version

00 00 08 00 00 00 00 00 e_entry
40 00 00 00 00 00 00 00 e_phoff
B4 3E DE 01 00 00 00 00 e_shoff (s_header)

00 00 00 00 e_flags

40 00 e_ehsize
38 00 e_phentsize
03 00 e_phnum
40 00 e_shentsize
01 00 e_shnum
00 00 e_shstrndx

p_header
01 00 00 00 00 00 00 00 | E8 00 00 00 00 00 00 00 p_type|p_offset
00 00 08 00 00 00 00 00 | 00 00 08 00 00 00 00 00 p_vaddr|p_paddr (kernel_offset)
78 EE 75 01 00 00 00 00 | 78 EE 75 01 00 00 00 00 p_filesz|p_memsz

00 00 00 00 | 00 00 00 00 p_flags|p_align

01 00 00 00 00 00 00 00 | 60 EF 75 01 00 00 00 00 p_type|p_offset
00 00 00 02 00 00 00 00 | 00 00 00 02 00 00 00 00 p_vaddr|p_paddr (ramdisk_offset)
19 74 58 00 00 00 00 00 | 19 74 58 00 00 00 00 00 p_filesz|p_memsz

00 00 00 00 | 00 00 00 00 p_flags|p_align

01 00 00 00 00 00 00 00 | 79 63 CE 01 00 00 00 00 p_type|p_offset
00 00 E0 01 00 00 00 00 | 00 00 E0 01 00 00 00 00 p_vaddr|p_paddr (tags_offset)
3B CB 0F 00 00 00 00 00 | 3B CB 0F 00 00 00 00 00 p_filesz|p_memsz (dt_size)

00 00 00 00 | 00 00 00 00 p_flags|p_align

s_header
00 00 00 00 name
4E 49 53 80 type

00 00 00 00 00 00 00 00 flags
00 00 00 00 00 00 00 00 address
B4 2E DE 01 00 00 00 00 offset (cmdline_offset)
00 10 00 00 00 00 00 00 size (pagesize)

00 00 00 00 00 00 00 00 padding
00 00 00 00 00 00 00 00 padding
00 00 00 00 00 00 00 00 padding
And some analysis over in @SuperR.'s thread: http://forum.xda-developers.com/showpost.php?p=67369021&postcount=3424

Still looking pretty tricky for me to properly support this format in Android Image Kitchen, (even though @SuperR.'s worked out a pretty nifty way to convert a number of them to boot.img,) since there are just too many variations going all the way back to Gingerbread. :eek:

Edit: I stand corrected on that being pagesize (which was confusing), and have found RPM was the old name for dtb, so then again.. ;)
 
Last edited:

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,347
32,235
263
Halifax
New nano release with the fix for the Android hang bug I reported, now included officially! Build instructions updated accordingly. :)

UPDATE-nano.Terminal.Editor.v2.6.0-signed.zip:
- update to latest nano official source.
- fix to hack around new detected "-git" versioning.

I also submitted a script to Open GApps today to fix the GApps issue with Google Dialer causing reboots when it's not set as default (edit: final commit now live), and made a Pull Request to make the official BootUnlocker app show some love to the rest of the OnePlus line. ;) :cowboy:
 
Last edited: