On Mon, Jul 11, 2022 at 08:55:45AM +0200, Denis 'GNUtoo' Carikli wrote:
> On Sun, 10 Jul 2022 21:27:14 -0400
> "A. F. Cano via Replicant" <replicant@osuosl.org> wrote:
> > Not strictly a replicant question, but I can't think of a better place
> > to ask.  If people here can't help probably no one can.  I would love
> > it if this phone could run replicant.  Has it been tried?
> The first step would be to find information on that device.
> 
> The entry about the Galaxy S6 in the Replicant wiki doesn't tell if it
> has shared memory or not, or if the battery is replaceable[1].

The battery appears not to be replaceable.  The front and back appear
to be pieces of glass glued to the metal frame all around and probably
requires a special tool to pull apart.

> In addition I looked very rapidly on Wikipedia and I didn't find
> information if the SM-G920T had any differences with the SM-G920F that
> is or was supported by LineageOS.

adb shell shows at the prompt: "zerofltetmo", so it appears that this is
identical to the SM-920F.  It was supported by LineageOS.  After looking
it up, the supported version is 14.1.  However, way down the page (of
Lineage OS build for zerofltexx, it says:

  Now ensure your Samsung Galaxy S6 is connected to your computer via
  the USB cable, with ADB and root enabled, and that you are in the
  ~/android/lineage/device/samsung/zerofltexx folder. Then run the
  extract-files.sh script:

So it looks like the phone needs to be rooted in order to extract the
proprietary blobs.  Catch 22.  That's what I'm trying to do without
success so far.

> > What are the possibly incompatible devices/firmware?
> We have some requirements for officially supported devices, like having
> an isolated modem or having replaceable battery.

It's unlikely I'll be able to find this out without the phone being
rooted.

> Though we also accept patches for devices that don't met the
> requirements but it will be up to the people who send these patches to
> make the releases for that device, and to handle the bug reports.
> We'd also have to find a good name for the fork. Replicant can help for
> all the rest.

It's looking like I'll have to first figure out how to root the stock
firmware, unless I'm misunderstanding something about the process of
installing LineageOS and root access can be gained after installing/
flashing some components.

> > The upgrade to the official latest software was completed after a few
> > protocol errors and hard resets.  The official software consists of 2
> > files:
> > 
> > recovery.img and boot.img.  These were installed with:
> > 
> > heimdall flash --RECOVERY recovery.img --no-reboot
> > heimdall flash --BOOT boot.img
> > 
> > The phone reports "official" after installing these.
> Usually there are more files than just boot and recovery images, like
> a system.img. 

These are the only files in the web site I referenced before.

> The boot.img file typically contains the boot kernel (+ sometimes an
> initramfs), and the recovery.img usually contains the recovery
> initramfs (+ sometimes a recovery kernel as well).

So, if the stock boot.img is actually sabotaging the installation of the
custom recovery, which in turns prevents the commands in cache.img from
running and installing su and whatever else needs to be done to root the
system, I'd have to find a way to replace that too as the first step.

> > This command appears to have succeeded, but when I tried the next one:
> > 
> > heimdall flash --CACHE cache.img
> > 
> > it failed.  
> Replicant 6.0 supports several devices, and they either have a Samsung
> Exynos or a TI OMAP CPU/system on a chip.
> 
> On the ones with the Samsung Exynos, heimdall is not very reliable with
> large files: I can reliably make heimdall fail with a very large file
> (for instance a system.img) and by increasing the IO and CPU load on
> the computer that runs heimdall (for instance by compiling Replicant
> at the same time or doing some heavy file copy).

I seem to not be hitting errors any more.  Adding --resume to the flash
cache command makes it complete without errors after the flashing of
recovery, but it doesn't say explicitly that it flashed the cache.
Since I've done that repeatedly, unless some part of the boot process
wipes it out, it should all still be there, including the commands it
did run once to install su.  I haven't been able to see those messages
on boot since that first time, no matter how fast I turn off DL mode
after flashing recovery.

> The issue seems to be in the bootloader, so the workaround we use is to
> keep the boot.img and recovery.img files small and then use the recovery
> to make the install.
> 
> > The first time I tried this it succeeded and then rebooted
> > immediately. During reboot a lot of messages came up: patching ...,
> > installing super su, etc... and then something about installing
> > standard recovery.  Weird.  I can still not run adb root (not allowed
> > in production environment, but if I do adb shell and from there type
> > su it does work.  I get the # prompt.

Sadly, I haven't been able to get to that state again.

> > This was then.  When I tried doing this again after a factory reset
> > (the only way to get rid of a continously running media app that was
> > making the phone very hot and drained the battery in an hour [1]),
> > flashing the cache doesn't do any of the above, I only see a red
> > message briefly that says "RECOVERY IS NOT STANDARD ENFORCING" and
> > then the phone boots normally.  Of course if I do "su" from adb
> > shell, it claims "su not found".  So now I can't get back to even the
> > result achieved the first time.
> Note that on Samsung phones more recent than the ones actually supported
> by Replicant, when it boots, the stock boot.img restores the stock
> recovery.img if it was modified.

This is probably what is happening.  But how to bypass this?  The files
I found (official and custom recovery + cache) don't have that.

> Also I don't know how root works in your case, but:
> - For Replicant 6.0, the cache partition can contains commands to be
>   executed in the recovery in /cache/recovery/command

That seems to be what happened that one time.  Unfortunately, /cache is
not readable in an unrooted phone.

> - As I understand some solutions to add root depend on either boot.img
>   (like magisk that adds su inside the initramfs) or recovery.img (to
>   add the su binary to the rootfs).
> 
> > What am I missing?
> 
> > Is the order these files are flashed critical?
> Yes and no. If you don't reboot between flashes, the order doesn't
> matter. If you reboot between flashes the order matters a lot.

After many tries, I have only been able to get into recovery mode,
supposedly entered by pressing the keys VOL UP/HOME/POWER, once.  I'm
not sure why it worked that one time.  Normally it's impossible to boot
into that mode on power up, or after exiting DL mode.  But even from
there, how do I flash recovery and/or cache so that boot.img doesn't
reverse it the next time it boots?

> ...
> Why do you need the stock distribution? Is there some community
> distribution for the SM-G920F that could make it easier for you to
> do tests on that device (like finding the system on a chip it use to
> understand how easily it might be to port Replicant to it)?

I will try LineageOS, as far as I can go, but the bit about the phone
having to be rooted beforehand is not too encouraging.

> Apart from very specific tests (like getting debug logs from the modem
> operating system, or trying to find how to reconstruct an EFS from
> scratch) the stock OS is not required.
> 
> ...
> The LineageOS installation instructions typically tell people to
> install a recovery with heimdall flash [...] --no-reboot and then to
> not reboot and power off the phone instead, and then boot directly on
> the recovery by holding the correct button sequence.

I have tried to do this repeatedly and can't get into recovery mode.
The one time I did, there were no options to flash or run anything in
cache.

> If for some reasons it boots to the boot.img instead of the recovery,
> the original recovery is restored, so users need to try again to flash
> the recovery and to boot from it.

I wonder if it's possible to flash a boot.img that doesn't do that.

> The advantage of that procedure is that users can make the decision to
> overwrite the existing system when they are in the recovery.
> 
> To do that the installation instructions make the users install the
> recovery only to the recovery partition.
> 
> Replicant has different tradeoffs: the decision to override the
> existing system is done earlier (when users use heimdall). That makes
> the installation instructions much easier to follow.
> 
> To do that it installs the recovery to both the boot and recovery
> partitions. This way it boots in the Replicant recovery in all the
> cases.
> 
> As for how your rooting procedure work in details I've no idea.
> 
> I would also be interested in knowing more about it because I've to add
> root support in Replicant 11 where root is currently only available
> through adb and not through the local terminal, and magisk requires an
> initramfs which we don't have anymore on Replicant 11.
> 
> And since the BOOT and RECOVERY partitions are only 8MiB, adding an
> initramfs would be complicated. And I'm not sure that re-partitioning
> would work on the Galaxy SIII (GT-I9300).

Mmm...  I'll keep trying and report back if I make any progress.
Thanks a lot for taking the time to reply.
> Denis.

Augustine
_______________________________________________
Replicant mailing list
Replicant@osuosl.org
https://lists.osuosl.org/mailman/listinfo/replicant

Reply via email to