Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[experimental-tmp4] dts: msm8939: htc-a51dtul: Add support for HTC Desire 820 Dual SIM #316

Open
wants to merge 4 commits into
base: rebase/dts
Choose a base branch
from

Conversation

rom4nik
Copy link

@rom4nik rom4nik commented Jan 1, 2024

DSC04569 final

HBOOT on this device is pretty quirky and has two bugs that made preparing .dts quite confusing. My versions of stuff:

*** Software status: Official ***
*** UNLOCKED ***
A51_DTUL PVT SHIP S-OFF
CID-11111111
HBOOT-3.19.0.0000
RADIO-01.01.010_U10305041_08.01.51015
OS-3.17.720.3
eMMC-boot 2048MB
Apr 11 2016,21:16:51.33150

a51dtul HBOOT bugs?

1. fastboot boot lk2nd.img doesn't boot lk2nd images

It will print into logs the DTBs found inside image pushed via fastboot, but then it'll ignore it and boot from local boot partition without really saying so. Example logs:

1a. empty boot partition - erased with fastboot erase lk2nd from booted lk2nd:

In this particular scenario I'm always seeing only 3 DTBs despite 342,343,344,345 in qcom,msm-id in .dts - no clue why. In some code blocks I've added comments on the right side, you might need to scroll horizontally to see them.

fastboot_command:[download:0004d810]
CMD:download: download:0004d810
recv data addr=86800000 size=4D810
status: DATA0004d810
Prepare to download data[317456 Bytes]...
fastboot_command:[boot]
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000
[DEBUG] DTB entry[1] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        <--- 3/4 DTBs from pushed lk2nd.img
[DEBUG] DTB entry[2] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        
[DEBUG] DTB entry[3] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        
[ERR] boot image does not exist!!!                                                                              <--- empty boot partition probably?
[FATAL] Invalid dtb address                                                                                     <--- wtf - I guess it complains that boot had no DTBs because it was empty?
[ERR] Updating device tree failed
[WARN] Abort booting linux...

1b. same lk2nd flashed to boot and then fastboot booted over USB:

fastboot_command:[download:0004d810]
CMD:download: download:0004d810
recv data addr=86800000 size=4D810
status: DATA0004d810
Prepare to download data[317456 Bytes]...
fastboot_command:[boot]
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000                                                          <--- first "whoami" debug print right before listing DTBs
[DEBUG] DTB entry[1] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        <--- 3/4 DTBs from pushed lk2nd.img
[DEBUG] DTB entry[2] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[INFO] dts table: version = 2                                                                                   
[INFO] dts table: num_entries = 4
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000                                                          <--- second "whoami" debug print right before listing DTBs
[DEBUG] DTB entry[1] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        <--- 3/4 DTBs from pushed lk2nd.img
[DEBUG] DTB entry[2] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)             <--- picks one DTB and boots from local boot partition
Device CID is super CID
Device CID is super CID
Device CID is not powerkey debounce CID

1c. lk2nd flashed to boot, fastboot boot mystery-twrp-dumped-from-phone.img:

fastboot_command:[getvar:has-slot:boot]
fastboot_command:[getvar:max-download-size]
fastboot_command:[getvar:is-logical:boot]
fastboot_command:[getvar:is-logical:boot]
fastboot_command:[getvar:partition-size:boot]
fastboot_command:[download:0004d810]
CMD:download: download:0004d810
recv data addr=86800000 size=4D810
status: DATA0004d810
Prepare to download data[317456 Bytes]...
fastboot_command:[flash:boot]
radio_batt_level: NOT IMPLEMENTED!
Start Verify: 0
fastboot_command:[download:02000000]
CMD:download: download:02000000
recv data addr=86800000 size=2000000
status: DATA02000000
Prepare to download data[33554432 Bytes]...
fastboot_command:[boot]
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)       <--- DTBs from TWRP
[DEBUG] DTB entry[2] pid:342, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[3] pid:342, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[4] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[5] pid:343, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[6] pid:343, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[7] pid:343, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[8] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[9] pid:344, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[10] pid:344, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[11] pid:344, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[DEBUG] DTB entry[12] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x2E000)
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 4
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)        <--- DTBs from local lk2nd
[DEBUG] DTB entry[2] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)
...
booting linux @ 0x80008000, ramdisk @ 0x82008000 (5274945), tags/device tree @ 0x81e00000, machine type: 0
[INFO] Jump to a 32bit kernel...

And then it hangs, after some time (watchdog?) resets into ramdump mode and boots back to lk2nd. Weird, at least it disproves my early suspicion that fastboot boot is completely broken.

2. DTB reuse bug with lk2nd-appended-dtb images

DSC04563 dtb reuse

I have no idea if this is supposed to be a feature or a bug, but it made figuring out a minimal .dts here extremely confusing, especially since for a long time I assumed that this phone needs appended DTBs like htc-m8qlul.

Basically, you can take a current prebuilt lk2nd-msm8916-appended-dtb.img (in spite of device being QCDT) from latest GH release, flash it to boot partition, and then kinda sorta boot despite no HBOOT-approved DTBs in image, by either:

  • cold booting to recovery with valid DTB and rebooting via GUI or adb reboot (I have some TWRP found on XDA a while ago)
  • shutting down phone, plugging in charger, waiting for cold boot charging screen to appear then holding power button until device reboots

Right now it seems to not occur on lk2nd-msm8916.img builds.
Also I don't remember exact steps and can't reproduce it right now, but while going through a loop of: edit .dts -> rebuild -> fastboot flash lk2nd build-lk2nd-msm8916/lk2nd.img -> fastboot reboot, a few times I might have been able to warm boot into a DTB that later wouldn't cold boot. I'm not sure if that was a case of HBOOT reusing DTB from last successful lk2nd DTB selection, or maybe I misremember things. That was weird.

Since then I've added a $DATE variable to model var in my .dts.template and ran this oneliner for reliable reflashing:

DATE=$(date +%T) envsubst < dts/msm8916/msm8939-htc-a51dtul.dts.tpl > dts/msm8916/msm8939-htc-a51dtul.dts && \          # add timestamp to model
make -j8 TOOLCHAIN_PREFIX=arm-none-eabi- lk2nd-msm8916 && \
fastboot erase lk2nd && fastboot reboot && \                                                                            # erase boot partition to force reboot into HBOOT
fastboot flash boot build-lk2nd-msm8916/lk2nd.img && fastboot reboot                                                    # flash lk2nd and reboot again

I also had modfied makefile to include LK2ND_VERSION := $(LK2ND_VERSION)-dirty-/\)-$(shell date +%T), just to be sure I have both latest build of my lk2nd and DTB, built at the same moment. I'm not mentioning this bug in .dts since you probably won't run into it unless you don't know what you're doing and really want to make lk2nd-appended-dtb.img work somehow.

With that I was finally quite confident that my changes in .dts are actually applied and can be used to assess the kinda blackbox (to me) HBOOT + lk2nd behavior further.

a51dtul HBOOT, lk2nd and journey to minimal viable .dts

As a general note, IIRC, on this device there's surprisingly very little needed to cold boot lk2nd:

  1. only first "number" in qcom,msm-id has to be 344, changing any other value in qcom,* vars will result in just a warning from HBOOT
  2. you can build with all .dts in rules.mk, unlike htc-m8qlul with the same SoC
  3. flash lk2nd.img (QCDT) to boot partition instead of lk2nd-appended-dtb.img, unlike htc-m8qlul
  4. lk2nd will complain about weird DTB but will boot.

So just to give some ideas for others and myself next time I look at this, here's a kinda step-by-step journal of how I arrived at current .dts (it was actually much more chaotic due to HBOOT bugs mentioned above, but IMO it's still worth noting how HBOOT responded to various changes).

lk2nd,keys

That was borrowed from https://github.com/msm8916-mainline/lk2nd/blob/541dd6768ab7bc03208be3fb2e031303c4a30d34/dts/msm8916/msm8939-htc-m8qlul.dts, without it the power button and volup were doing scroll and voldown was doing nothing.

IDs from kernel source

So just for reference, here's where I initally got the magic board numbers from. I've taken the kernel source from htcdev.com untouched and reuploaded to GH just for convenience of online searches and linking in this PR.

htc,project-id, htc,hw-id, qcom,board-id:

https://github.com/rom4nik/kernel_release-a51ul-3.10.28-g1e0287c/blob/b3d118eff02b0a30c930bbf2a3e09e05ee5ac266/arch/arm64/boot/dts/qcom/msm8939-a51dtul.dts#L18-L22

qcom,msm-id:

https://github.com/rom4nik/kernel_release-a51ul-3.10.28-g1e0287c/blob/b3d118eff02b0a30c930bbf2a3e09e05ee5ac266/arch/arm64/boot/dts/qcom/msm8939.dtsi#L27

And I also saw 239 in msm8939-mtp.dts in lk2nd repo. idk, maybe in HTC kernel it was overriden somewhere else in .dts files.

htc,project-id, htc,hw-id

Since a51dtul HBOOT is happy to boot DTBs without that, I've removed those as well. I assumed they'd be necessary on my phone since m8qlul had them.

However, I feel it's important to note that on HTC phones qcom,msm-id must be set to whatever the HTC kernel source had as htc,project-id, otherwise HBOOT will not be interested in those DTBs. I didn't know that, and combined with fastboot boot bug described above for a long while I thought that the second time DTBs were listed, it was HBOOT telling me what it it wants?

Source for this:

qcom,msm-id

1. So if you take the easy route and use qcom,msm-id = <239 0> and qcom,board-id = <1 0>, HBOOT will refuse to boot the flashed image:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 1
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:239, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)
[ERR] Getting device tree address failed
[FATAL] Invalid dtb address
[ERR] Updating device tree failed
[WARN] Abort booting linux..

Again, don't let yourself get lured into fastboot booting unless you reflash the image every time anyway and realize that you're actually just using this command as a "continue local boot". I've wasted many days by this.

2. You could just use <344 0>, obtained by the "least changes" route from <239 0>. HBOOT will boot that, but will complain:

(with qcom,board-id still set to <1 0>)

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 1
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:344, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)
[WARN] Board pid, pcbid, soc version doesn't match device tree!                                             <--- just a warning
[WARN] Board pid:344, pcbid:0x80, soc version:0x10000 
[WARN] DTB   pid:344, pcbid:0x1, soc version:0x0 
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)         <--- nice

lk2nd also will complain a bit, showing DTB - <344 0x1 0 0x0> in yellow color on LCD under serial number, and in logs:

[350] ### Ohai, this is lk2nd (or lk1st?) ###
[350] Board: platform: 239, foundry: 0x0, platform_version: 0x10000, platform_hw: 0x1, platform_subtype: 0x0, target: 0x10001, baseband: 0x0, platform_hlos_subtype: 0x0
[360] pmic_info[0]: type: 0x1000b, version: 0x20000, target: 0x2000b
...
[460] Device model: HTC Desire 820 Dual SIM 01:51:31
[460] Found an appended flattened device tree (HTC Desire 820 Dual SIM 01:51:31 - 344 1 0 0x0)
[470] Device tree exact match the board: <344 1 0 0x0> == <239 1 0 0x10000>
[480] Weird DTB selected by bootloader. Need to override. Sad.

Where did that 0x10000 come from here?

3. Setting qcom,msm-id = <342 0>, <343 0>, <344 0>, <345 0>;, since that's almost the numbers that HTC source had:

HBOOT logs with above + qcom,board-id = <1 0>:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 4
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)        <--- 4/4 DTBs now? huh
[DEBUG] DTB entry[2] pid:343, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)
[DEBUG] DTB entry[4] pid:345, pcbid:0x1, hw_subtype:0x0, soc version:0x0 (offset:0x800, size:0x800)
[WARN] Board pid, pcbid, soc version doesn't match device tree!
[WARN] Board pid:344, pcbid:0x80, soc version:0x10000 
[WARN] DTB   pid:344, pcbid:0x1, soc version:0x0 
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)

lk2nd doesn't show yellow DTB line on LCD, no complaints in logs:

[350] ### Ohai, this is lk2nd (or lk1st?) ###
[350] Board: platform: 239, foundry: 0x0, platform_version: 0x10000, platform_hw: 0x1, platform_subtype: 0x0, target: 0x10001, baseband: 0x0, platform_hlos_subtype: 0x0
[360] pmic_info[0]: type: 0x1000b, version: 0x20000, target: 0x2000b
...
[460] Device model: HTC Desire 820 Dual SIM 01:49:26

Still, there's a mismatch of soc version:0x10000 vs 0x0 in DTBs, so let's try to fix that.

4. qcom,msm-id = <342 0x10000>, <343 0x10000>, <344 0x10000>, <345 0x10000>

HBOOT:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 4
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[2] pid:343, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[4] pid:345, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[WARN] Board pid, pcbid, soc version doesn't match device tree!
[WARN] Board pid:344, pcbid:0x80, soc version:0x10000 
[WARN] DTB   pid:344, pcbid:0x1, soc version:0x10000 
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)

No complaints from lk2nd. So HBOOT still complains about pcbid:0x80 vs 0x1, but by now I could guess that it's first number in qcom,board-id.

To sum up, I'm not sure what these htc,project-ids were, maybe some regional variants? I saw that m8qlul has just one project-id, but even though my device is just a Board pid:344 according to HBOOT, I guess it wouldn't hurt to give it DTBs for all 4 IDs, to make HBOOT and lk2nd happier.

qcom,board-id

So this was just a journey to get fewer complaints in HBOOT logs. We're keeping qcom,msm-id = <342 0x10000>, <343 0x10000>, <344 0x10000>, <345 0x10000>.

1. qcom,board-id = <0x80 0>

HBOOT:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 4
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[2] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)

No complaints from HBOOT and lk2nd, nice!

2. But maybe let's try qcom,board-id = <0x0 0>, <0x1 0>, <0x2 0>, <0x80 0>, since HTC kernel had more IDs (htc,hw-id = <0 0>,<1 0>,<2 0>,<128 0>).

HBOOT:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 16
[DEBUG] Board pid:344, pcbid:0x80, soc version:0x10000 
[DEBUG] DTB entry[1] pid:342, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[2] pid:342, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[3] pid:342, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[4] pid:342, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[5] pid:343, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[6] pid:343, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[7] pid:343, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[8] pid:343, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[9] pid:344, pcbid:0x0, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[10] pid:344, pcbid:0x1, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[11] pid:344, pcbid:0x2, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[DEBUG] DTB entry[12] pid:344, pcbid:0x80, hw_subtype:0x0, soc version:0x10000 (offset:0x800, size:0x800)
[INFO] Loading matched device tree into memory... (addr:0x81e00000, dt_offset=0x800, dt_size=0x800)

Still no complaints from HBOOT and lk2nd. I've left just <0x80 0> in submitted .dts for now to avoid bloating prebuilt images with DTBs for devices that I don't even know if exist.

What next?

I haven't had time to try booting mainline kernel yet, I'm just happy I could realize the HBOOT bugs/glitches wasn't me incorrectly noting down what works and what doesn't. So far I can say that the mystery TWRP built for stock bootloader doesn't boot via lk2nd - it complains about lack of appended DTB, of all things. Oh well.

So, it'd be great if you could let me know if the code's okay and hopefully if there's any fault in my reasoning above.

Unrelated: moserial was too slow to catch some of HBOOT/lk2nd logs, sometimes it would glitch out and omit some lk2nd logs if there was a lot of HBOOT logs, e.g. during listing of DTBs in lk2nd.img built with full rules.mk. Even just using stty -F /dev/ttyACM0 115200 and cat /dev/ttyACM0 gave me full(er?) logs.

@TravMurav
Copy link
Member

This is a huge and amazing writeup! Sorry, didn't read it all yet, but a thing I caught:

In this particular scenario I'm always seeing only 3 DTBs despite 342,343,344,345 in qcom,msm-id in .dts - no clue why.

Seems like it always stops on the valid entry, probably exits the loop when it matches?

Copy link
Member

@TravMurav TravMurav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes themselves look good to me.

Is there any chance you can add your device to -next (use i.e. rebase/dts branch) in a way similar to this:

06fc76c

and check that it still works properly? We want to eventually switch to the new branch, even though there is still a bit of work to do before we can, but I want to make sure the changes for two branches are in-sync so we don't miss stuff.

If you don't have the time, I will add it myself there later, but then it won't be tested...

@rom4nik rom4nik changed the base branch from master to rebase/dts January 1, 2024 12:58
@rom4nik
Copy link
Author

rom4nik commented Jan 1, 2024

Seems like it always stops on the valid entry, probably exits the loop when it matches?

Yeah, that would make sense - when it doesn't see pcbid:0x80 it lists all DTBs and only after all of them it reluctantly picks one.

Is there any chance you can add your device to -next (use i.e. rebase/dts branch)

Sure, sorry. Unfortunately it seems that this phone also doesn't like too many DTBs, like htc-m8qlul:

[INFO] bootimage cmdline = 'lk2nd'
[INFO] dts table: version = 2
[INFO] dts table: num_entries = 86
[ERR] The device tree entry table should be LESS THAN a page (2048)
[FATAL] Invalid dtb address
[ERR] Updating device tree failed
[WARN] Abort booting linux...

Meanwhile fastboot boot of the same image throws an error and hangs without watchdog reset:

fastboot_command:[download:0005b010]
CMD:download: download:0005b010
recv data addr=86800000 size=5B010
status: DATA0005b010
Prepare to download data[372752 Bytes]...
fastboot_command:[boot]
[ERR] common/fastboot_cmd.c: In function 'arrange_dtb'
[ERR] common/fastboot_cmd.c:1258: assert

Removing other .dts from rules.mk helps, so I've added a warning in .dts but left it in rules.mk since you've done the same for m8qlul (to check for regressions in CI builds, I guess?).

Also I've checked that it can boot https://github.com/msm8916-mainline/linux, at least with a UART only .dts there. As for menu options:

  • reboot works
  • recovery and bootloader behave like normal reboot
  • EDL works (Qualcomm, Inc. Gobi Wireless Modem (QDL mode) in lsusb)
  • shutdown works

Flashing pmOS rootfs sparse image to system or userdata partition makes lk2nd log [174340] fastboot: flash:system or :userdata, UI still works and can be navigated using buttons, but then after approx. 30s phone reboots - sometimes normally, sometimes with a ramdump in HBOOT log. Not sure what's happening here, but fwiw HBOOT accepts the same image for system partition in 13 "parts", refuses it for userdata, and lk2nd receives and writes the image in one part.

@TravMurav TravMurav changed the title dts: msm8939: htc-a51dtul: Add support for HTC Desire 820 Dual SIM [experimental-tmp4] dts: msm8939: htc-a51dtul: Add support for HTC Desire 820 Dual SIM Jan 2, 2024
@TravMurav
Copy link
Member

after approx. 30s phone reboots

I guess this happens even in the old lk2nd? Maybe we need to stop some watchdog then...

I marked this PR like others that target "-next" (sorry, our naming for this historically is quite weird as we initially weren't sure if things will work and then it stuck). We will go through them when the branch is switched to the main one and maybe ask to re-test or (very unlikely) suggest changes if we change the dts model again, then merge it.

Feel free to submit a second PR with the changes you had before, targeting master and I will merge it if you want to make use of that too. (note that two branches have slightly different feature sets)

@rom4nik
Copy link
Author

rom4nik commented Jan 13, 2024

I guess this happens even in the old lk2nd? Maybe we need to stop some watchdog then...

It does, but would watchdog be possible reason for these reboots, if during flashing the UI of lk2nd is not frozen and I can use buttons? (=> I assume that the watchdog is also continuously taken care of)

Another thing is that after booting to msm8916-mainline and debug-shell I could get a kernel panic (something about Asynchronous SError Interrupt, I don't have a log saved) just by running dd if=/dev/zero of=/dev/mmcblk0p44 bs=1M count=100. p44 is system partition iirc, lower counts would pass but I don't remember if count=100 was the first value that would repeatedly cause a panic.

@TravMurav
Copy link
Member

lk2nd runs UI and fastboot in separate threads so they won't generally hang each other. But as I understood you, the device dies after ~30s regardless of what you do in lk2nd?

Asynchronous SError Interrupt

Can you run something like stress-ng to excercise /all/ the ram you have? Maybe you're missing some reserved memory?

@rom4nik
Copy link
Author

rom4nik commented Apr 19, 2024

Rebased on rebase/dts branch @ 5b7d72a.

But as I understood you, the device dies after ~30s regardless of what you do in lk2nd?

No, sorry. If I'm not doing anything, phone stays alive. When I'm flashing pmOS rootfs via pmbootstrap flasher flash_rootfs to system partition or to userdata, lk2nd stops responding to button presses after ~ 27s (timer started at Writing 'userdata'), then a second later phone reboots. For a moment it lands in ramdump mode, and out of a lot of logs there Fatal Error: NON_SECURE_WDT stands out.

I'll check stress-ng next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants