Peter-Easton / android-debug-cable-howto

This is a simple how-to to create your own android kernel debugging cable using commercially available parts.
190 stars 19 forks source link

fastboot oem uart enable does not work for Xiaomi #10

Closed lattice0 closed 2 years ago

lattice0 commented 2 years ago

On my Poco M3:

 fastboot oem uart disable
                                                   FAILED (remote: 'unknown command')
fastboot: error: Command failed

anyone knows how it can be done on Xiaomi?

samueldr commented 2 years ago

The cable documented here is only expected to work with Pixel 2 and following phones from Google.

Other OEMs may or may not have different implementations for debugging cables. Most likely there is nothing available opening the device.

An external ressource that is generally helpful may be the serial cable schematics section of the postmarketOS wiki:

Also note that devices may or may not need commands to turn serial facilities on or off. Again, this will be device and OEM dependent.

lattice0 commented 2 years ago

Thank you. I wanted to try crazy things with the kernel and certainly I'll need debugging. Do you know if on-screen console is efficient/easy to do on any device? I just did stuff with an nvidia jetson nano and used UART which was very helpful but I'm trying to get into androids now.

I bought the breakout board anyway to see if I can get something. I'm just afraid to run some kernel and get no output.

I see there's a fastboot option to boot a specific kernel. Wouldn't this show a UART output already?

samueldr commented 2 years ago

Note that connecting the wrong debugging accessory to the wrong device may or may not be an issue. This is because it might be that you'd end up directly connected to some sensitive hardware, maybe sending more than the maximum allowable voltage.

It's generally not a good idea to do so.

As far as on-display debugging. It's extremely dependent on the kernel implementaiton. In my experience, most qualcomm vendor kernels simply can't be configured to show fbcon on the display.

fastboot boot will not provide stdout of the running system. It's simply not made for it.

Though search for console ramoops and android pstore; these are schemes used to save kernel output in a reserved area of RAM, and as long as the device powered on, it will be readable at the next boot.

lattice0 commented 2 years ago

One last question: do you think I can brick this phone by just switching kernels? I mean, bricking in a way that it cannot be fixed? I think that I'll not be tweaking anything before the kernel, so if I upload a broken kernel I can just upload another one until it works.

Are there extreme cases where I can do something really wrong such that I cannot reflash another image?

samueldr commented 2 years ago

Strictly just switching kernels? generally unlikely.

Though note that Xiaomi have been found to have some buggy ARB (anti-rollback) on recent~ish phones where bad kernel builds would trigger ARB in a way that bricked the phone. So it will be highly dependent on the specifics of your situation. The Poco M3 is not one of those I know about. But that doesn't mean it will be safe.

Do some due diligence, look through android ROM communities (e.g. xda developers) and try to get a feeling of if people generally brick easily, and how they brick.

Are there extreme cases where I can do something really wrong such that I cannot reflash another image?

Through fastboot flash it could happen in some implementations if you flash over e.g. aboot or abl or xbl or any "early boot" partitions. Though some implementations protect against bad flashes to these "firmware" partitions.

If you strictly limit yourself to fastboot boot ... and fastboot flash [boot|system|userdata] ..., it should be generally safe, as long as there is no buggy behaviour in the bootloader and ARB (anti-rollback).

DISCLAIMER: obviously this is done at your own risks... Research things beforehand!

samueldr commented 2 years ago

You might also want to search around ROM communities to see if there's unbricking methods. Some OEMs have generally accessible unbricking methods, others don't. (e.g. Google don't, if early boot steps are broken, you're toast.)

lattice0 commented 2 years ago

Apprently lots of things don't work on Xiaomi. I couldn't do fastboot boot:

fastboot boot Image
creating boot image...
creating boot image - 35883008 bytes
Sending 'boot.img' (35042 KB)                      OKAY [  0.837s]
Booting                                            FAILED (remote: 'unknown command')
fastboot: error: Command failed

just posting here in case someone finds this thread and knows a way to run fastboot boot kernel on Poco M3