Problem porting to Moto E 2015 4G (surnia)


  • Infrastructure

    @Nic264 Ah Cool I take a look 🙂
    One thing, I messed up the lxc cmd, it should be lxc-info -n android

    BR Florian



  • @Flohack This was already in my random commands (OP), but here it is:

    root@ubuntu-phablet:/# lxc-info -n android
    Name:           android
    State:          RUNNING
    PID:            591
    IP:             192.168.2.15
    CPU use:        3.44 seconds
    

  • Infrastructure

    @Nic264 Ok so the good thing is, the LXC container is running. What I currently do not like from dmesg is this:

    [   47.167516] initrd: mounting system.img (user mode)
    [   47.192790] init (308) used greatest stack depth: 5248 bytes left
    [   47.205913] initrd: mounting device image as ro
    ...
    [   47.267907] initrd: device is unknown
    

    Device is unknown means that somehow initrd does not detect the device correctly. This needs to be fixed. But tbh I forgot the logic there, need to take a look again.
    Also, did you already dump the udev rules? See https://developer.ubuntu.com/en/phone/devices/porting-new-device/ and also this page can be helpful to understand whats going on at the beginning: https://wiki.ubuntu.com/Touch/ContainerArchitecture - udev rules need to be placed inside the image (mount - o remount,rw /)

    That said, its normal to have exactly these issues at the beginning. Every device is different, so its hard to tell you exactly whats going on.

    You can try to enable debug (but it might break the boot since it dumps too much udev debug into the logs xD), for this add "debug" to the kernel cmdline. But read this first: https://wiki.ubports.com/wiki/When-the-Bootloader-Decides-to-Override-your-Command-Line - probably you need to patch the kernel for this.

    Did you BTW update the kernel config with the script from here: https://github.com/janimo/phablet-porting-scripts/blob/master/kernel/check-config, and also you need to patch apparmor3 inside (but this is not needed now)



  • @Flohack
    After reading the initrd code, device is determined by reading ro.product.device in the build.prop, but in my case it is set in ro.cm.device, I'll correct this and rebuild.
    I didn't dump the udev rules for now, going to do this now too.

    I updated the kernel config with that script then had to patch a couple of problems in regard of uid_t becoming kuid_t etc… I already managed to change my kernel cmdline and I don't think what my bootloader appends can cause any problem: (does it?)

    androidboot.emmc=true
    androidboot.serialno=TA36406M0E
    androidboot.baseband=msm
    androidboot.mode=charger
    androidboot.device=surnia
    androidboot.hwrev=0x8300
    androidboot.radio=0x4
    androidboot.powerup_reason=0x00000100
    androidboot.bootreason=charger
    androidboot.write_protect=0
    msm_poweroff.download_mode=0
    androidboot.fsg-id=
    androidboot.secure_hardware=1
    androidboot.cid=0x7
    androidboot.wifimacaddr=E8:91:20:79:04:53,E8:91:20:79:04:54
    mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_mot_boe_450_qhd_video_v3
    androidboot.bootloader=0x8020
    androidboot.carrier=retfr
    androidboot.hardware.sku=XT1524
    androidboot.bl_state=2
    

    Thanks for you help 🙂



  • OK so the property ro.product.device used by Ubuntu's init to determine the device was set by Android's init too late (this is an unified device tree). It is now fixed (hardcoded in my system.prop).

    [   19.324825] initrd: device is surnia_umts
    ...
    [   28.163553] init: Found radio id: 0x4 setting build properties for surnia_umts device
    

    I have dumped my udev rules and placed them in /etc/udev/rules.d/70-surnia_umts.rules. I haven't noticed any change so far (except for udev complaining about unknown users and groups).

    You were right, the debug boot option broke the boot, causing a boot loop 😕 I'll check in the console-ramoops when I have the time.

    Will I really need to patch AppArmor? I already run Linux 3.10.49…


  • Infrastructure

    @Nic264 HI,
    well basically you are on a good path. You seem to have the knowledge and the motivation to analyze the things in detail 🙂
    Basically I did not expect that the issue with the fb device goes away just by adding udev rules and setting the device id. It was just part of the procedure. Kernel config might have helped, and its not bad to have it in place already.
    The kernel cmdline seems fine, if it reacts on debug you dont need the patch. however, remember that the bootloader cmdline might get appended to yours and will overwrite settings if they appear twice.
    For AppArmor: Yes 3.10 might indeed contain already the correct apparmor version. Which was actually the original Android version for this device?

    BR



  • @Flohack Hi,
    I don't really have the required knowledge, but I'm learning 😛

    This is the mess debug gives me, this line fills my buffer:

    [ growing time ] systemd-udevd[237]: maximum number (16) of children reached
    

    Original android version was 5.0.2, upgraded to 5.1.1 then 6.0 by Motorola then 7.1 by the CM/LineageOS team.

    I updated my initrd in order to use a F2FS data partition so I don't have to reformat every time I switch back to Lineage (this is my only phone), would that be a problem?

    I'm trying to build libhybris right now (on the device since cross-compiling gives me trouble)…


  • Infrastructure

    @Nic264 Hi,

    yes debug fills up the log with udev messages, but I think this is a good sign, seems udev is really busy creating all necessary entries 😉 - you can switch it off again, it has no better use now.

    Ok so basically on what CM versions did you base your device Kernel and vendor tree?

    BR



  • @Flohack Hi, sorry for the lengthy follow-up, I've been busy with competitive exams…

    I am sorry to say that I won't be able to try and port this anymore: probably because of a power surge, my phone USB port is dead and I can't transmit anymore data to the phone…

    Thanks for the help, I'll try to contribute some other way (but after the oral part of my exams).


  • Infrastructure

    @Nic264 Hi,

    no problem. If you got any meaningful changes or improvements in the code, consider forking the repos and pushing your changes into those new repos.

    BR


Log in to reply