WIP: Added new device: Sony Xperia J
Unfortunately, this merge request was not imported correctly from GitHub:
Something went wrong while fetching comments. Please try again.
WilliamO7 or anyone else: if you have updated the code for another review, please open up a new merge request. Sorry for the trouble.
Created by: WilliamO7
So this is the second device I've ported, and boy was this one difficult!
- Two new packages were added, unpackelf and mkelf to deal with the non-standard boot images the phone uses (don't ask me why, blame Sony.)
- Therefore, pmb and the mkinitfs programs were modified to accomodate this.
- Info will go up into the wiki soon(tm) - need to do other stuff first.
Device status: Convinced the phone does not boot at all. I cannot get a usb shell and the screen stays turned off.
EDIT: It does boot using the original kernel in the boot.img here with the generated initramfs (no screen still however).
Merge request reports
Activity
1 pkgname=unpackelf 2 pkgver="21" 3 pkgrel=1 4 pkgdesc="A single tool to unpack Sony ELF kernel format image variants" 5 url="https://github.com/osm0sis/unpackelf/" 6 arch="all" 7 license="APACHE2" 8 depends="" 9 _commit="2735dd0b35d2e40a03008eb609b465acb83190db" 10 source=" 11 $pkgname-$_commit.tar.gz::https://github.com/osm0sis/unpackelf/archive/${_commit}.tar.gz Created by: ollieparanoid
Hey @osm0sis! We haven't packaged your
mkbootimg
yet (#441 (closed), needs testing for regression with all devices etc) - however, we would like to package yourunpackelf
here. Could you tag a version (e.g.1.0
), so we could package it nicely? Thanks for making such useful tools!By * postmarketOS Bot on 2018-01-04T19:58:48
Edited by Ghost User
45 62 else: 46 raise RuntimeError("File is not an Android bootimg. (" + file_output + ")") 63 raise RuntimeError( 64 "File is not an Android bootimg. (" + file_output + ")") 47 65 48 # Extract all the files 49 pmb.chroot.user(args, ["unpackbootimg", "-i", "boot.img"], working_dir=temp_path) 66 # Extract all the files using the correct tool. 67 if bootimg_is_sonyelf is True: 68 pmb.chroot.user( 69 args, ["unpackelf", "-i", "boot.img"], working_dir=temp_path) 70 else: 71 pmb.chroot.user(args, ["unpackbootimg", "-i", 72 "boot.img"], working_dir=temp_path) 50 73 51 74 output = {} Created by: ollieparanoid
Sorry, but this isn't very readable. How about we replace everything from
output = {}
untilreturn output
with the following few lines:# Necessary fields fields = ["base", "kernel_offset", "ramdisk_offset", "pagesize", "cmdline"] if not bootimg_is_sonyelf: fields += ["second_offset", "tags_offset"] # Parse fields from extracted files ret = {"generate_bootimg": "true", "sonyelf": bootimg_is_sonyelf} for field in fields: ret[field] = bootimg_parse_field(bootimg_path, field) return ret
The now missing
bootimg_parse_fields
function can be added abovedef bootimg()
:def bootimg_parse_field(bootimg_path, field): """ Get the content for one deviceinfo variable out of the extracted boot.img. :param bootimg_path: absolute path to the boot.img file, with the extracted files in the same folder :param field: deviceinfo field we're interested in, without the "deviceinfo_flash" prefix. """ # Hex numbers if field in ["base", "kernel_offset", "ramdisk_offset", "second_offset", "tags_offset"]: with open(bootimg_path + "-" + field, "r") as handle: return "0x%08x" % int(handle.read().replace('\n', ''), 16) # Strings if field in ["pagesize", "cmdline"]: with open(bootimg_path + "-" + field, "r") as handle: return handle.read().replace('\n', '') # qcdt: Check for a non-empty "boot.img-dt" file if field == "qcdt": if os.path.isfile(bootimg_path + "-dt") and os.path.getsize(bootimg_path + "-dt") > 0: return "true" return "false" raise RuntimeError("bootimg_parse_field: Don't know how to parse '" + field + "'!")
By * postmarketOS Bot on 2018-01-04T19:58:48
Edited by Ghost User
1 pkgname=unpackelf 2 pkgver="21" 3 pkgrel=1 4 pkgdesc="A single tool to unpack Sony ELF kernel format image variants" 5 url="https://github.com/osm0sis/unpackelf/" 6 arch="all" 7 license="APACHE2" 8 depends="" 9 _commit="2735dd0b35d2e40a03008eb609b465acb83190db" 10 source=" 11 $pkgname-$_commit.tar.gz::https://github.com/osm0sis/unpackelf/archive/${_commit}.tar.gz @ollieparanoid tagged at 2017.12.13, should be ready to go for you now. Cheers!
By osm0sis on 2018-01-06T14:28:02
1 pkgname=unpackelf 2 pkgver="21" 3 pkgrel=1 4 pkgdesc="A single tool to unpack Sony ELF kernel format image variants" 5 url="https://github.com/osm0sis/unpackelf/" 6 arch="all" 7 license="APACHE2" 8 depends="" 9 _commit="2735dd0b35d2e40a03008eb609b465acb83190db" 10 source=" 11 $pkgname-$_commit.tar.gz::https://github.com/osm0sis/unpackelf/archive/${_commit}.tar.gz Created by: mirh
Man, I don't want to be disrespectful, and all, but I think like you canned the tree to base. This is the latest one from "the team", and here's more plot. You (all) should frequent a bit more XDA forums (totally absurd how this doesn't even seem to be a thing)
Anyway I guess this is even of a bigger feat, if you got it to boot? Gg.
By * postmarketOS Bot on 2018-01-07T01:27:36
Created by: ollieparanoid
Thanks for the input @mirh. You're saying you would recommend the TamsuiCM11 kernel and linked to the most important commits of it, right? Why do you recommend it?
PS: If this becomes a longer discussion, I'd recommend that we put it into a new issue in the tracker, so we don't clutter up this PR.
By * postmarketOS Bot on 2018-01-07T02:03:31
Created by: mirh
Because it would be quite newer than the other. I mean, it isn't freexperia official one*, and I'm not sure how much of that work was half-assed rather than quality one, but (for as much as I don't own the device) certainly that would be my first rom choice. And I just linked the branch they say to use with J in the readme.
*whose latest branch is this btw
By * postmarketOS Bot on 2018-01-07T12:45:39
Edited by Ghost User@WilliamO7 @ollieparanoid I think that almost everything have been addressed, only few things are left:
- proper versioning of
unpackelf
with tagged release - version of
mkelf
? - resolve merge conflict
- perform some manual test again
- add test case with boot.img here
By Daniele Debernardi on 2018-01-24T10:04:27
- proper versioning of
Created by: PureTryOut
I believe @WilliamO7 has been offline from Github for a while. Should we fix the remaining issues ourselves?
Also, @ollieparanoid, you notified the wrong William07
By * postmarketOS Bot on 2018-03-01T14:42:33
Created by: WilliamO7
I'm still here, but uni work, and the fact that my laptop works on a btrfs filesystem (and I didn't bring the phone up here either) means i've been out of action for a while.
You're free to tie up the odds and ends though - I probably won't be back to this for another two weeks at least.
(Not to mention my tree is probably severely out of date now)
By * postmarketOS Bot on 2018-03-01T15:45:28
Edited by Ghost UserCreated by: ollieparanoid
I think this makes more sense, when there's someone with the device to actually test it. So maybe we can try this in a few weeks if you're still interested and have access to your device again, I'd be happy to finish this up together
We won't run out of work until then, no worriesBy * postmarketOS Bot on 2018-03-01T20:34:49
mentioned in merge request pmaports!1192 (closed)
By DarkNeutrino on 2020-04-26T18:56:17