[Q] Exposing droid4 drivers to linux - Motorola Droid 4

I have a curiosity that I'm trying to justify if it's worth attempting but don't know where to start. My desired outcome is to turn my Moto Droid 4 into a full out linux machine with one catch, making phone calls.
I already know that I can root and install a flavor of linux side by side with android, but I'm hoping to replace android with linux and my own software.
I wondering if the drivers for the phone's radio and other devices(camera, led, etc) exposable which I then could write my software to use in linux.
I'm pretty sure it's not feasible as it's all most likely proprietary drivers made by motorola, but on the off chance that it wasn't I figured someone here would know.

Related

Multitouch limited to two fingers?

Hi,
as you may have realized the Streak has only 2 fingers multitouch. Sometimes it is an software limitation and can be adjusted. Does anyone know if this is the case for the Streak? Any hint?
According atmel, it supports 10 touch
http://www.atmel.com/dyn/products/product_card.asp?part_id=4620
http://www.scribd.com/doc/50575488/datasheet-for-mXT224
http://forum.xda-developers.com/showthread.php?t=878936
Okay, now we need to figure out where the limitation is and fix it. Anyone on it?
Every multi-touch tester I've tried only shows 2 fingers max. My Evo 3D shows 4 fingers with the same app.
If you want more touch points (assuming that it is in fact that controller), you'll need to modify/rewrite the touchscreen drivers to make it work with more.
The last link giveen gave is link to a patch to tell it to accept more touch points. It doesnt ADD touch points, it merely tells it to use more points that were already available, but simply not turned on.
If it's simply points not being enabled it should be a trivial rebuild, if it's not in the s7's kernel source code you'll need to merge in a driver that does support the extra points.
There should be a reason that dell didnt turn them on, as a 7" display can reasonably take advantage of at least 4 points.
To compare to the fm audio support on the s5 (which was also turned off) it was due to it being rather buggy, if the code to take use more points is in fact in the kernel, it might not be particularly useful.
Did anyone figured out how to enable more touch points?
If anyone wants to give it a try, this is our TS driver
https://github.com/DJSteve/streak7-...s/input/touchscreen/atmel_mXT224_touch_luna.c
https://github.com/DJSteve/streak7-kernel/blob/master/arch/arm/mach-tegra/board-ventana.c
Well, I'm going to have a go at this, bearing in mind I'm going to be teaching myself as I go along, if I can figure out where to modify the files, I may need someone's help getting it into a kernel. Really I'll be happy if I can figure out how to get even one more touch point active.
TesseractSpace said:
Well, I'm going to have a go at this, bearing in mind I'm going to be teaching myself as I go along, if I can figure out where to modify the files, I may need someone's help getting it into a kernel. Really I'll be happy if I can figure out how to get even one more touch point active.
Click to expand...
Click to collapse
I've actually done a bit of work into this.
First you need to build a linux box, personally I use a virtual machine, using Ubuntu 11.10 x64.
Then you need to get our source, listed above in the ICS branch or the HC branch.
Now our board-ventana.c already states 10 finger touch. That was built-in.
Now the driver is for a Atmel mXT224 touchscreen controller, which is a TS common in lots of devices. Now I am currently working with a couple people in Dell tracking down some information in regard to the DS7. I was informed the reason why the TS controller driver is not a standard format like all other mxT224 drivers is because the screen itself is different. I am still waiting to hear back in regard to this.
I've been denied loads of information due to legality issues.
Anyways........
the driver is a custom one and needs to be re-written to accept more touch.
how would one Install this? im running Giveen and Dj_Steve's HC on a US 4g model
ThattOneKiddMichael said:
how would one Install this? im running Giveen and Dj_Steve's HC on a US 4g model
Click to expand...
Click to collapse
HC build is purely Steve, I didn't do anything with that build.
Second, you can't install this. Its a driver source code that needs to be modified and then built.

Unlock Windows Phone 8

Does someone unlock Windows Phone 8 OS ?
Will someone do it ?
Thanks for info.
Yeah, when they have bootlevel 0 access, maybe it could be done
As I have heard, and understood, the chips are hard-encoded, for every device, so the JB cannot be achieved Will it ever be? Who knows, this is quite a challenge, but I am no optimist.
Hard coded?? Wow those SOBs. They really need to rethink as to why they are not selling as many phones as they would love to.
LOL. 99% of earth's population does not know or care about the "hard coded" chip (it is not hard coded, it is analogical thus it cant be reprogrammed)
Scumbag Microsoft
Just a question on this. So, boot level stuff is not posable because of encryption. So as of now, Custom roms are out, not possable, YET.
With this being known, what most of us would be happy with is a suto Interop unlock. This would allow max unsigned apps and maybe some minor system level apps (think Advanced Config type apps) maybe bosted with a root tools type of app (almost a custom rom but, not). This stuff will all run on the OS, not the boot level. Shouldn't this be possable once someone finds a hole someplace ?
So, full unlock with custom roms will not be possable but, at least we can have a step there to have some fun with out phones till someone actually figures it out (slim chance if it's encrypted)
mcosmin222 said:
LOL. 99% of earth's population does not know or care about the "hard coded" chip (it is not hard coded, it is analogical thus it cant be reprogrammed)
Click to expand...
Click to collapse
And I agree, becides hobbiests and hackers (and XDA readers ), no one really cares about a unlock, that is about 98% of of the Windows Phone users. That does not mean we (the 2-3%) dont want it...
MSFT clearly does not care about hackers like us. Otherwise they would give us more APIs to program with.
They care about the bad type of hackers.
In WP7 we only had Full Unlock on devices that had a Custom ROM flashed onto it. This does not mean that it is not possible to exploit other loopholes but the NT Kernel is kind of a harder nut to crack than the old CE Kernel powering WP7. Basically you would need a vulnerability in a system App to get your code running. Then that code would have to escape from it's jail and acquire a higher permission level. Then I guess the first step would be to write something to the registry that would allow:
a) to sideload apps (basically what the developer unlock does)
b) to elevate permissions on those sideloaded apps (similar to what the Root Tools were able to do)
We only had two ways ever to get any Unlocks without flashing a CustomROM on WP7. The first was the original ChevronWP7 and the second was Window Break which only worked on certain Samsung devices and was quickly patched. Aside from that everything concentrated on the CustomROM route or on how an Unlock achieved previously could be conserved through system updates (Nodo to Mango).
So it might be quite some time before we even see something like the Interop Unlocks. Even most Android devices were routed by flashing a modified kernel.
It's been a while, has there been ANY progress on a Unlock even if interop or something for Windows Phone 8 ? I have a dev unlock and it limits me to 3 apps but, what I miss the most is apps like Advanced config giving me unlimited options for colors...
I do not believe so.

Mounting (MTP) on Linux?

Hey All--
I can't get my moto x to show up as a drive (mounted) on linux.
My nexus 4 was just plug and play on this.
Anyone have a suggestion?
(mint 16, if it matters)
I am not sure what it was called, but when I searched the Ubuntu market, I found one right away...maybe something like qMTP? Seemed to work well.
Sent from my XT1053
jhedfors said:
I am not sure what it was called, but when I searched the Ubuntu market, I found one right away...maybe something like qMTP? Seemed to work well.
Sent from my XT1053
Click to expand...
Click to collapse
so no way to get it to automatically show up?
When I put it into PTP mode, it works perfe3ctly....but no go on MTP
bongostl said:
so no way to get it to automatically show up?
When I put it into PTP mode, it works perfe3ctly....but no go on MTP
Click to expand...
Click to collapse
It seemed that there was a way, but it involved way to many steps than I was willing to take. The MTP app was a lot simpler.
Someone else might have a suggestion though...
Sent from my XT1053
Did anyone figure this out? Thanks
ddswanson said:
Did anyone figure this out? Thanks
Click to expand...
Click to collapse
I was having trouble with this yesterday (got my phone in yesterday)
It seems as though the device needs to manually be added... its recognized as mtp device but won't mount for some reason....
i plan to play with this this weekend to see if i can get it to work.
in reality the poster that mentioned it would be easier to use the app but thats no fun!
I will report back if i get it to work.
I've had a problem with mtp on my Arch linux system before. Had to add each device manually. But when I plugged in my X it worked without adding anything. Maybe it's getting fixed in the newer kernels?
Anyway, best guide:
https://wiki.archlinux.org/index.php/Mtp
I use gomtpfs, and have got it working on friends machines too.
Now, it just takes a click and it connects.
It is bizarre that both are linux systems
Hope that helps. Good luck.
Thanks. I installed the android sdk and can flash moto x from linux. Also, I get Motorola PCS as a device with lsusb. Not sure if that helps anyone.
talkingduck said:
I've had a problem with mtp on my Arch linux system before. Had to add each device manually. But when I plugged in my X it worked without adding anything. Maybe it's getting fixed in the newer kernels?
Anyway, best guide:
https://wiki.archlinux.org/index.php/Mtp
I use gomtpfs, and have got it working on friends machines too.
Now, it just takes a click and it connects.
It is bizarre that both are linux systems
Hope that helps. Good luck.
Click to expand...
Click to collapse
Running Ubuntu 13.10 right now on an XPS 12, and I was amazed when the same thing happened to me. I freshly installed Ubuntu, and it just connected out of the box. I recommend seeing if there are any software updates for Mint, that might fix it.
Thanks, unfortunetly it is still not working in Linux Mint 13 LTS even with the latest kernel from the precise repo.
I had lots of trouble until I upgraded to Ubuntu 13.10. Now it works great.
Sent from my Nexus 7 using Tapatalk
So mtp and Moto X for what it is worth if someone might be interested would not work out of the box in Linux Mint 13 or 16 or Kubuntu 13.10 or Debian Wheezy, but it did work on Debian Jessie.

[Q] Root on a mac

So...
Can you root the ATT Note 3 on a mac yet NOT using VMware or parallels????
If so...some help?
Thanks
Not as far as I know - I think it's kingo or rdlv, both of which are Windows native.
It's not unusual for things like this to only be released for Windows, so I'd recommend you not hold your breath waiting for that - between the fact that there are many ways to run Windows on a Mac (vm, dual boot, etc), the fact that almost everyone has access to some form of Windows pc, the smaller market share of Mac computers, and the tendency of Mac users to go with matching apple smartphones, there's not a huge demand for this. It's possible you'll never see a Mac rooting tool fir the note 3, so you should look into rooting phone with one the pc tools.

[kernel][RnD][rom] Running Arch Linux Arm with mainline linux on Jemlte

Hi, everyone.
Some time ago I've been working on getting mainline linux to work on our device.
I was mostly interested in running desktop GNU/Linux, not Android, not in chroot.
I used it in Uni for occasional coding, in order not to carry laptop with me.
I'm not sure if I'll continue to actively develop and maintain it, so I decided to share my work with whoever might be interested in it.
However if there would be community interest, I might continue to improve support.
Or maybe someone would like to help me with this undertaking.
The code is not based on amazon kernel, and don't use legacy board files, but is Device Tree based.
Most of the basic hardware works, however, some don't, and would be nice if someone smarter or more stubborn than me helps to troubleshoot it.
What works:
It boots)
Serial console - needs device disassembly, convenient for debugging
eMMC
Display panel with backlight - 18bit mode, without dithering.
HDMI display (hotplug, modeswitching)
USB device - works as usb cdc, handy for SSH access and configuration.
Charging - uses driver from stock kernel
Battery monitoring - doesn't strictly match android measurements, but works.
WiFi - uses brcmfmac driver, needs firmware, haven't tested it outside of regular client mode, not shure if either hotspot or p2p works.
Bluetooth - needs firmware uploaded from userspace, however may be rewriten with serdev interface.
Touchscreen - uses driver from stock kernel.
Vvolume gpio keys
Power button - connected to power management chip
Vivante gc320 - gives a nice speedup for X11 and Xv scaling.
Hall sensor (protective cover (lid) sensor)
Case thermal sensor
Audio codec - headphones, speakers, microphones not tested
LTE modem - can be used for data and SMS but not calling (unless you figure out how to ). Not sure about positioning (if it is available on this modem)
What doesn't work:
Sound - codec works, but I failed to make it properly communicate with omap, am I missing something obvious? works now: mclk pinmux was misconfigured
Camera - not really interested in it anyway.
RPROC - see notes below
[*] DSP - seems to be not used on stock andoid at all;
[*] IPU - required for camera and video encoding/decoding acceleration
[*] IVA-HD - part of VPU.​
GNSS - provided by the same chip as Bluetooth, but communicates via some obscure protocol from userspace.
PoverVR gpu.
What could be brought up with small effort (supposedly):
Various sensors:
IMU: accelerometer, gyroscope, compass.
Hall sensor - protective cover lid
ambient light sensor
various thermal sensors.
LTE (might actually have GPS in it, or call functionality, who knows...)
Bugs:
Bluetooth needs to be enabled in android prior to (hot) reboot to linux, I'm obviously missing some port configuraion.
USB host technically works, but is disabled since it needs some work. (And it makes high pitched noise while 5v booster is on though)
Suspend/resume mighth not work Should work :silly: (proper power management needs newer u-boot).
Charging sometimes get's limited to 500mA -- smb347 driver needs some debugging.
CPU Idle is disabled, not really shure what's wrong with it.
Frequency scaling is not perfect (since omap4470 is not really supported in mainline kernel).
HDMI DDC - EDID reading corrupted, looks like some issues with ddc pullup/esd protection chip, sometimes it might even work. If someone with osciloscope is interested in debugging, you are welcome. And one more thing: after you reboot back to android hdmi wouldn't work here for some time, untill it gets back to normal. Resolved.
Remoteproc functionality (DSP, IPU) for omap chips is not really present in mainline. It IS in TI kernel, I was able to build firmware for ducati, and run it.
But was unable to make it properly communicate with userspace.
Someone experienced with it might help.
What is unlikely to EVER work:
SGX544sc has no userspace drivers, so unless you have some contacts at TI who would bother to compile it, this gpu won't work.
Camera requires some code running on IPU, which, AFAIK, was never opensourced.
Boot process:
The kernel is booted directly via second bootloader.
For now without initramfs, so it needs a separate partition on eMMC for rootfs.
With initramfs, on the other hand, one may put rootfs on the regular `data` partition, either as file or in directory.
Works nicely along with regular Android: with a small tweak to bootloader you can boot either via volume key combination.
The bootloader is configured to boot from `dkernel` partition if both volume buttons are pressed.
Dkernel partition initially contains kernel for factory device check and is not used in regular device operation. Still, you may wish to back it up if you feel like you may need it at some point.
You may choose whichever linux distribution you like, I'm using archlinuxarm for now.
I'll provide a more detailed manual, and flashable binaries, alongside with rootfs later,
But for now, if you know what you are doing, here are some sources:
kernel (current working branch is `integration-4.18`, use omap4jem_defconfig)
u-boot (will upload source code later, for binary build see attachment)
Basic outline of required steps are:
replace secondary bootloader in your main boot partition
rebuild dkernel, with zImage build from sources and flash it.
shrink your 'data' partition
add new partition on your eMMC for your rootfs and format it to ext4 or f2fs
unpack your rootfs onto it
mount and chroot into it to make basic configuration
boot.
A video demo:
https://www.youtube.com/watch?v=mpjwL4VRS-E
Have a nice day!
ipipipipip said:
...
Click to expand...
Click to collapse
Sorry for jumping on the bandwagon a little late here. Seems like a promising project. If you managed to get mainline 4.18 to at least boot (which sounds hard in and of itself), how would it work out if it booted nicely on Android? that wouldn't be too bad of a prospect. Complicated, yes, but maybe remotely possible. I'd be willing to test drive it on my non-lte jem - after I give this project a spin, of course.
A quick update:
Bluetooth now neither require to be powered on prior reboot (there was a clock that I forgot to enable that prevented bcm module from starting), nor a user-space firmware upload.
It now uses serdev bus and kernel-space driver to upload firmware, that removes the hassle of adding system daemon that will properly initiate bluetooth with the correct tty.
There is no proper way for now to check what version of jem/jemlte device you are using so you have to rebuild the kernel with the correct firmware in "firmware/brcm/BCM2076B1_26MHZ.hcd". The default firmware is for lte version, so if you use non-LTE version please replace the file "firmware/brcm/BCM2076B1_26MHZ.hcd" with the 20MHZ one from the same directory (just remove the 26MHZ one, and change 20MHZ to 26MHZ in file name).
WiFi no longer causes issues on resume, and device suspends and resumes properly (more or less), I haven't measured battery drain)
Bad news:
I've bricked my device and not sure if I still can revive it, looks like eMMC is almost dead. Or another case of crappy samsung moviNand firmware.
It is detected over USB as OMAP4470 device and it looks like cpu does not detect emmc.
After about 5 minutes (some kind of watchdog??) it manages to boot u-boot aka fastboot. Any other action that tries to modify content on emmc causes the flash controller lockup and communication with it is no longer possible.
Soldering wires directly to pcb pads doesn't help much, the card is not detected by card-reader.
The main idea for now is to use vendor command 62, as mentioned in one of #Hashcode's posts to wipe all the content of the chip. The problem is that I have wiped linux partition and can't boot into any kind of working linux system on the device. (Recovery tries to mount some partitions rw and thus makes flash chip inaccessible). Guess it's time to make an NFS rootfs and boot the device over USB network.... Or maybe someone knows how to prevent TWRP from accessing partitions on device?
In the worst case scenario I'll have to replace emmc chip (if it's not glued too hard in place), curious if some 128GB will work
Or maybe someone has a spare PCB, or a broken device that they no longer need and may donate?
monster1612 said:
Sorry for jumping on the bandwagon a little late here. Seems like a promising project. If you managed to get mainline 4.18 to at least boot (which sounds hard in and of itself), how would it work out if it booted nicely on Android? that wouldn't be too bad of a prospect. Complicated, yes, but maybe remotely possible. I'd be willing to test drive it on my non-lte jem - after I give this project a spin, of course.
Click to expand...
Click to collapse
There will be no GPU or video decoding acceleration, which might be a problem with modern apps, if you wish, go on and try, might be interesting to have a look, I don't have much experience in building android ROM's.
Sup, have some news on the progress of the project
An eMMC on my tablet died completely, thus I had to replace it with another one. My initial intent was to place some 64gig SanDisk emmc 5.1 from ebay, but I was not sure if it'll work with omap4 and that I won't fry it in the process of replacement. So I've bought some similar scrapped 16gig variant from a local reseller for a couple of pennies. After recovering partition layout and bootloaders the tablet came back to life, thus it's pretty safe to put whatever eMMC chip you have on your hands in your tablet) (it's time to order a larger capacity flash now, 16 gig is rather scarce for both android, arch and some content). The trusty old stock kernel, on the other hand, needed a tiny patch to let kernel understand a flash from the future. The driver checks for known emmc protocol version and unloads flash driver if the revision is too high.
Now feeling more confident in unbrickability of my tablet, I've gone an extra mile of porting mainline U-Boot bootloader to the tablet.
The port is pretty minimal, just support for serial port, usb/fastboot, and framebuffer console. Since pinmuxing and HW initialization is done via stock bl, nothing much to do. But it adds ability to freely manipulate boot sources, kernels, ramdisks, supports dtbs and overlays, environment save/restore, and external boot scrips on a FAT boot partition ). For some reason bootloader font is corrupted and hard to read, bit it should be easy to fix.
The good parts:
kernel version is bumped up to the latest 5.0.0
enabled mpu6050 IMU sensor
enabled tmp103 temperature sensor, supposedly case temperature...
enabled hall sensor that is triggered by a case lid magnet, It's mapped as a SW_LID key
some cleanups for display panel code
resolved HDMI edid issue: two part problem of wrong DDC pin mux sequence and wrong HDMI vdda supply regulator match string
Regressions:
Somewhere in the process it lost the ability to resume from suspend, have to find what caused that.
New bootloader does not handle IDME tags, therefore for the stock os I had to hardcode serial and MAC addresses in stock kernel idme driver. But since there is plenty of place to put different bootloaders on our tablets you may use one for stock rom, and another for development.
A second part of the update is coming soon...
Hi there,
This is very exciting work - how is the tablet doing a year on? I'm wondering how much of your work is applicable to the 7 inch equivalent, seeing as the board is common, just with a few minor hardware differences.
Thanks,
Jack
Jack_Kekzoz said:
Hi there,
This is very exciting work - how is the tablet doing a year on? I'm wondering how much of your work is applicable to the 7 inch equivalent, seeing as the board is common, just with a few minor hardware differences.
Thanks,
Jack
Click to expand...
Click to collapse
Hi Jack, since last update I got some additional pieces working. Specifically: sound (and that was a brain-teaser for a long time) and LTE modem are working now. UEFI boot with u-boot implementation is functional.
Indeed 7-inch tablet may be brought-up with quite a low effort: lcd panel is slightly different, but there is a driver for it already in kernel, touch screen is also different. Apart from that rest of the stuff should work quite the same, that is usb, uart, wifi, bt, audio, backlight, keys, emmc, hdmi, with minor DeviceTree adjustments.
Same for u-boot: for basic functionality only a few pin-assignment changes are needed.
Hi,
For a relative arch Linux beginner, what resources would you point one to to be able to implement this on an OG kindle fire HD 8.9?
I'm decently comfortable on the command line, but once it starts getting deep in the kernel, I am a little more cautious..
Many thanks,
Jeff
Joonatnoon said:
Hi,
For a relative arch Linux beginner, what resources would you point one to to be able to implement this on an OG kindle fire HD 8.9?
I'm decently comfortable on the command line, but once it starts getting deep in the kernel, I am a little more cautious..
Many thanks,
Jeff
Click to expand...
Click to collapse
It depends on what you want to achieve. This kernel will happily work on any kindle fire 8.9 2012. LTE version just has an additional board with a modem on it, (and needs another Bluetooth firmware).
At some point, I created a bit more user-friendly image of Manjaro with LXQt suitable for dual-boot, but without hardware acceleration, it was too sluggish for any real use.
If you want to have some fun and do something useful at the same time, I'd suggest adding support for this device in postmarket os project.
The starting point is here https://wiki.postmarketos.org/wiki/Porting_to_a_new_device
If you encounter any difficulties, feel free to ask
ipipipipip said:
Hi Jack, since last update I got some additional pieces working. Specifically: sound (and that was a brain-teaser for a long time) and LTE modem are working now. UEFI boot with u-boot implementation is functional.
Indeed 7-inch tablet may be brought-up with quite a low effort: lcd panel is slightly different, but there is a driver for it already in kernel, touch screen is also different. Apart from that rest of the stuff should work quite the same, that is usb, uart, wifi, bt, audio, backlight, keys, emmc, hdmi, with minor DeviceTree adjustments.
Same for u-boot: for basic functionality only a few pin-assignment changes are needed.
Click to expand...
Click to collapse
Thanks for all this. I hope to port the 7 inch version (soho) to postmarketOS (am surprised you didn't want to get jem running it so you can have a nice touch interface).
Have you seen the attempts to get mainline drivers that interface with PowerVR SGX 5xx graphics firmware? Seems like one day there might be 3D working...
https://github.com/openpvrsgx-devgroup/linux_openpvrsgx
One more question - have all the changes you described been pulled upstream, so I can just fork from mainline, or are some important ones still not yet in, so I should fork your repo?
Thanks again for all your efforts - I am very excited as to how this will benefit soho development.
Jack_Kekzoz said:
Thanks for all this. I hope to port the 7 inch version (soho) to postmarketOS (am surprised you didn't want to get jem running it so you can have a nice touch interface).
Click to expand...
Click to collapse
I did get it run postmarket, but it was somewhat clumsy and not properly integrated into a build tree. Also, it seemed a bit clumsy to update-rebuild-flash-reboot firmware image after a change contrary to rebuilding some users-pace parts just on the device.
Have you seen the attempts to get mainline drivers that interface with PowerVR SGX 5xx graphics firmware? Seems like one day there might be 3D working...
https://github.com/openpvrsgx-devgroup/linux_openpvrsgx
Click to expand...
Click to collapse
If only there was a non-android userspace driver for sgx544sc that is in 4470, inb4: ti still uses sgx544 in their new chips, but it is different.
Would be nice to have 3d, but I'm afraid that without major testing and bug fixing (on source code driver level, which is closed) It will be buggy as hell.
One more question - have all the changes you described been pulled upstream, so I can just fork from mainline, or are some important ones still not yet in, so I should fork your repo?
Click to expand...
Click to collapse
Nope :angel: . Clone my repo.
Hello again,
I've been trying to get a downstream kernel postmarketOS running on soho, and had noted the bootloader refused to load my kernel (just went to fastboot) unless I hexedited some zeroes (and some other data) at the beginning of my boot image (a technique required for the one custom rom available for it), after which it bootlooped. I see jem too requires some boot image manipulation to get cm11 on it (https://github.com/LineageOS/android_device_amazon_jem/blob/cm-11.0/boot.mk) - how did you get your kernel booting? I don't know much about the boot process, but I imagine there is some sort of signature verification Amazon cooked in that the hex data added at the beginning confuses.
Can I pm you?
Thanks,
Jack
Hi, yes boot image is signed and verified, but at least on Jem there is a vulnerability in stock u-boot that allows to bypass the signature check and execute arbitrary code.
Not sure how it is done on soho, but, at a first glance, the exploit looks kinda the same (even addresses are the same).
https://github.com/TeamWin/android_device_amazon_soho/blob/cm-12.0/exploit.mk
On jem there is an image size check missing when loading boot image into ram. The boot.img header contains image size to be loaded, and thus if you load a large enough chunk you will overwrite current stack frame (and what's important - return address), thus after data is loaded bootloader will jump to user-specified address. The trick is to load your executable code (second bootloader in my case) into ram (put it somewhere at a known place in boot partition) and use that address to overwrite the stack.
One problem was that main boot partition is too small (8MiB) to contain a patch to overwrite the stack, thus initially it was placed somewhere at the beginning of system partition (with hopes and prayers that it will not corrupt ext4). But then I resized those partitions to 16MiB which is enough to fit everything.
If you don't want to bother with modifying bootloader, just retrofit those boot image creation makefiles.
Thanks - so how did you modify your boot image when you were tinkering with pmOS? Did you just replace the stock u-boot so no exploit was necessary? I thought x-loader would refuse to load any u-boot not signed with Amazon's keys? Sorry, you stated you put your second bootloader at an address in the boot partition. I'm just curious as to how exactly one does that when building pmOS.
Thanks,
Jack
Who knows, there is actually no sane way to create simply flashable boot.img without resizing boot partition first, that I highly suggest you to do. Make a backup of all partitions and gpt table, practice a bit on a spare sdcard, boot twrp, remove boot partition, and what's after it, then recreate those with sizes as need (and don't forget to restore partition names, that's important). Also would be handy to increase system partition size on the way, by sacrificing userdata size.
But, if you have working third party ROM, and don't expect to fiddle with bootloader, chances are you may get away with just dd-ing a few values and 2nd loader over boot.img postmarket builds (there is a package stage in linux-xxx target in postmarket's APKBUILD where you can put this code), and hope that magic value (stack smashing value) will not be overwritten while installing firmware
Thanks for this info. I've managed, through your help and others, to get a boot pmOS (on a downstream kernel). I'm in the process of merging my work, and the question is being asked of the boot hack, which I am hoping to get merged into postmarketos-mkinitfs package (not in an APKBUILD for soho) - are there any other devices that use a similar hack? If the answer is yes, I think it makes sense to include them in the same portion of code for future pmOS jem attempts - I know you didn't want to merge all your code, and that's ok, but could I make a request for one part of it? Please may I ask what exact shell commands you needed to run to amend jem's boot.img so that tricking the signature check takes place? For what it is worth, for soho I adapted the boot hack in the rom makefile to the below:
SOHO_HEADER_DATA='\x50\x03\x00\x00\x00\x25\xe4\x00'
SOHO_HEADER_SIZE=848
SOHO_HEADER_OFFSET=52
tempfile=$(mktemp)
dd if=/dev/zero of="${tempfile}" bs=$SOHO_HEADER_SIZE count=1
printf "%b" $SOHO_HEADER_DATA | dd of="${tempfile}" bs=$SOHO_HEADER_OFFSET seek=1 conv=notrunc
cat "${outfile/initramfs-/boot.img-}" >> "${tempfile}"
mv "${tempfile}" "${outfile/initramfs-/boot.img-}"
(I didn't need to resize my boot partition as I believe the hidden bootloader is stored in the recovery partition.) Anyway, thanks for all the help. I'm going to work a bit more on polishing my downstream port before turning my attention upstream, and copying most of your dts and relevant commits
Nice , as for other devices: fire hd 2012 7" (IIRC it is called tate) is likely using the same hack, and that's it, it was an amazons bug so no other devices affected. You may assume that the commands for jem are exactly the same.
BTW, may I have a look at a merge request for postmarketos-mkinitfs, when you create it? I dug a bit, trying to find a nice clean method of wrapping boot.img after mkinitfs creates it, but didn't found any. The closest thing that exists are a few device-specific "sign" steps, which are almost exactly what we need, except that, I don't want to add more ugly device-specific checks in build scripts. Some generic field that names the tool for signing and a separate package that does that device-specific signature would've been the best IMO.
I guess It's time to rebase jem to a latest kernel, with a cleanup, coz a few things are broken now and need additional rework.
The Kindle Fire 2 (otter2) also appears to require a similar exploit. Merge request is here: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/1995
Rebasing jem sounds exciting!
I don't know if you've read the MR comments, but lead dev Ollie has just said what you said re device specific code. Time to rewrite then...

Categories

Resources