Port to Oneplus 2



  • Hi,

    Im currently trying to port to the Oneplus 2, but am gettign a few build errors. I synced the ubp-5.1 sources (from your wiki), and im using the device tree from your github, even though i already tried others with same problems. Same for the kernel.

    My changes so far:

    • setting the libc_common_conlyflags (bionic/libc/Android.mk) to -std=gnu11 instead of gnu99 (fixed a few build errors because nullptr was unknown)

    • used latest toolchain from cm (had a few kernel errors that got fixed by that)

    • frameworks/av/media/libmediaplayerservice/Android.mk i removed the LOCAL_32_BIT_ONLY := true (had some build errors because it wanted the 64 bit version too for some reason, but couldnt find it)
    • same in frameworks/av/services/medialog/Android.mk
    • I added
    #define AUDIO_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE "music_offload_flac_min_blk_size"
    #define AUDIO_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE "music_offload_flac_max_blk_size"
    #define AUDIO_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE "music_offload_flac_min_frame_size"
    #define AUDIO_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE "music_offload_flac_max_frame_size" 
    

    to frameworks/av/media/libstagefright/Utils.cpp because it wasnt defined.

    • changed in a few file
    #define BQ_LOGV(x, ...) ALOGV("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
    to
    #define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) 
    

    (and similar)

    • disabled the stack protector in the kernel... had some compile errors there too

    for now im just trying to get it built...

    My error now is

    /home/markus/ubports/out/target/product/oneplus2/obj/SHARED_LIBRARIES/libdsyscalls_intermediates/bionic/dl_iterate_phdr_static.o: In function `dl_iterate_phdr':
    /home/markus/ubports/bionic/libc/bionic/dl_iterate_phdr_static.cpp:41: undefined reference to `__executable_start'
    /home/markus/ubports/bionic/libc/bionic/dl_iterate_phdr_static.cpp:41: undefined reference to `__executable_start'
    collect2: error: ld returned 1 exit status
    build/core/shared_library_internal.mk:68: recipe for target '/home/markus/ubports/out/target/product/oneplus2/obj/SHARED_LIBRARIES/libdsyscalls_intermediates/LINKED/libdsyscalls.so' failed
    make: *** [/home/markus/ubports/out/target/product/oneplus2/obj/SHARED_LIBRARIES/libdsyscalls_intermediates/LINKED/libdsyscalls.so] Error 1
    make: *** Waiting for unfinished jobs....
    

    Im stuck there for a while now :/
    I hope someone can help me, or maybe im using the wrong sources? Are there better ones?


  • Community

    Hey there,

    Could you please post the local manifest that you're using so we know where you're getting your sources from?



  • I have this atm:

    <?xml version="1.0" encoding="UTF-8"?>
    <manifest> 
    
    	<remote name="cm"
    	  fetch="http://github.com/CyanogenMod"
    	  revision="refs/heads/cm-12.1" />
    
    	<remote name="ubp2"
    	  fetch="http://github.com/ubports"
    	  revision="refs/heads/ubp-5.1" />
    
    	<remote name="grarak"
    	fetch="http://github.com/Grarak"
    	revision="refs/heads/cm-12.1" />
    
    	<project path="device/qcom/common" name="android_device_qcom_common" remote="cm" revision="cm-12.1" />
    	<project path="device/qcom/sepolicy" name="android_device_qcom_sepolicy" remote="cm" revision="cm-12.1" />
    
    	<!--<project path="device/oneplus/oneplus2" name="android_device_oneplus_oneplus2" remote="cm" revision="cm-12.1" />
    	<project path="kernel/oneplus/msm8994" name="android_kernel_oneplus_msm8994" remote="cm" revision="cm-12.1" />-->
    
    	<project path="device/oneplus/oneplus2" name="android_device_oneplus_oneplus2" remote="ubp2" revision="ubp-5.1" />
    	<project path="kernel/oneplus/msm8994" name="android_kernel_oneplus_msm8994-1" remote="ubp2" revision="ubp-5.1" />
    
    	<project path="device/oppo/common" name="android_device_oppo_common" remote="cm" revision="cm-12.1" />
    	<project path="vendor/oneplus" name="proprietary_vendor_oneplus" remote="grarak" revision="cm-12.1" />
    </manifest>
    

    i know its kinda bit of a mess, but i was trying out a few things, will most likely clean it up as soon as it actually builts

    EDIT: Im (trying to) building on Ubuntu 16.04 if that makes any difference



  • @Infrastructure @Community

    So... i switched to the 6.0.0_r1 base, and it compiled (after a few missing kernel headers lol) :D
    Even though it says "broken" in your wiki, atleast it compiled, i guess?

    currently downloading the vivid-preinstalled-touch-armhf.tar.gz

    As we finally managed to get MultiROM working on the Oneplus 2... Is there a way now to install this as a secondary ROM for testing?
    Or just primary and i should restore my primary rom as secondary?


  • Community

    @SGCMarkus Please don't ping whole teams unless your post specifically needs them.

    I'd recommend that you avoid MultiROM. The project doesn't support MultiROM and there's really nothing we can do if it doesn't work.



  • Sorry about the tag.

    The injection into the boot.img seems to work atleast (the only thing that does appearantly).
    I have a system.img now, a vivid-preinstalled-touch-armhf.tar.gz, the rootstock-touch-install script appearantly works without any error (everything done), but phone instantly reboots after the boot logo (the image before the boot animation) .. :/ (or as soon as the multirom injection tries to boot)

    Also noticed that /system is completly empty (if mounted), should that be the case?
    sorry for all the questions but i can't find anything about that :/


  • Community

    @SGCMarkus

    /system can be empty. Can you check to see if the /data/system-image/ directory is created on your phone?



  • nope, no directory "system-image" in /data, in /data i have "media", "misc", "system" folders, and a system.img and ubuntu.img (which seems to be a link to the system.img what i saw in the script) file.

    The content of those seems to be valid though.
    output of ls /system: (mounted the system.img there)

    android     data        firmware    media       proc        srv         userdata
    
    bin         dev         home        mnt         root        sys         usr
    
    boot        etc         lib         opt         run         system      var
    
    cache       factory     lost+found  persist     sbin        tmp         vendor
    

    I used this rootstock script (from your wiki), maybe somethings missing in there?


  • Community

    @SGCMarkus

    That means that the rootfs is never starting. It's possible that the kernel is panicking. Take a look at the cmdline you're passing to the kernel, ensure that there's no "console=" directive or anything similar. The cmdline is specified in device/oneplus/oneplus2/BoardConfig.mk



  • The complete command line (maybe something missing which i overread?)
    BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5

    Also noticed that the recovery.img that was created doesnt boot either :/ so i guess a bit more is going wrong (i tried to boot it with fastboot boot recovery.img and it loaded a bit, rebooted and booted my normal installed recovery)


  • Community

    @SGCMarkus Interesting.
    Finding why the recovery won't boot would be the number 1 priority... Try to remove as much of the cmdline as possible. Just leave, say, "androidboot.hardware=qcom boot_cpus=0-5".



  • @UniSuperBox
    I suppose i used a wrong kernel then? I think i have currently the CM13 kernel source, which is CAF as far as i know.

    Will try what you said, and some other kernels tomorrow, hopefully that will work

    Edit: appearantly "TARGET_USES_UNCOMPRESSED_KERNEL" was set to true... and the new firmware needs a compressed kernel... so i guess thats the main reason it failed, building now again, this time compressed and with an AOSP kernel



  • So... I feel stupid now... forgot completly about the kernel patches that are described in the the official porting guide ...

    With the script thats provided there, i set the variables needed, but now i get an error while its compiling the kernel :/

      CC      kernel/irq/resend.o
    In file included from /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/inet_hashtables.h:32:0,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/tcp.h:37,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/security/selinux/hooks.c:55:
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/route.h: In function 'ip_route_output_ports':
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/route.h:146:55: error: type mismatch in conditional expression
           daddr, saddr, dport, sport, sk ? sock_i_uid(sk) : 0);
                                                           ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/route.h: In function 'ip_route_connect_init':
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/route.h:256:2: error: incompatible type for argument 12 of 'flowi4_init_output'
      flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
      ^
    In file included from /home/markus/ubport_6/kernel/oneplus/msm8994/include/linux/netfilter.h:275:0,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/include/uapi/linux/netfilter_ipv4.h:8,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/include/linux/netfilter_ipv4.h:7,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/security/selinux/hooks.c:49:
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/net/flow.h:87:20: note: expected 'uid_t' but argument is of type 'kuid_t'
     static inline void flowi4_init_output(struct flowi4 *fl4, int oif,
                        ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:308: recipe for target 'security/selinux/hooks.o' failed
    make[4]: *** [security/selinux/hooks.o] Error 1
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:455: recipe for target 'security/selinux' failed
    make[3]: *** [security/selinux] Error 2
    /home/markus/ubport_6/kernel/oneplus/msm8994/Makefile:843: recipe for target 'security' failed
      CC      crypto/twofish_common.o
    make[2]: *** [security] Error 2
    make[2]: *** Waiting for unfinished jobs....
    
    /home/markus/ubport_6/kernel/oneplus/msm8994/kernel/cgroup.c: In function 'subsys_cgroup_allow_attach':
    /home/markus/ubport_6/kernel/oneplus/msm8994/kernel/cgroup.c:2138:37: error: invalid operands to binary != (have 'kuid_t' and 'kuid_t')
       if (current != task && cred->euid != tcred->uid &&
                                         ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/kernel/cgroup.c:2139:18: error: invalid operands to binary != (have 'kuid_t' and 'kuid_t')
           cred->euid != tcred->suid)
                      ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:308: recipe for target 'kernel/cgroup.o' failed
    make[3]: *** [kernel/cgroup.o] Error 1
    make[3]: *** Waiting for unfinished jobs....
    
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c: In function 'exfat_allow_set_time':
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1145:22: error: invalid operands to binary != (have 'kuid_t' and 'kuid_t')
      if (current_fsuid() != inode->i_uid) {
                          ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c: In function 'exfat_setattr':
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1218:18: error: invalid operands to binary != (have 'kuid_t' and 'uid_t')
        (attr->ia_uid != sbi->options.fs_uid)) ||
                      ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1220:18: error: invalid operands to binary != (have 'kgid_t' and 'gid_t')
        (attr->ia_gid != sbi->options.fs_gid)) ||
                      ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c: In function 'exfat_fill_inode':
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1677:15: error: incompatible types when assigning to type 'kuid_t' from type 'uid_t'
      inode->i_uid = sbi->options.fs_uid;
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1678:15: error: incompatible types when assigning to type 'kgid_t' from type 'gid_t'
      inode->i_gid = sbi->options.fs_gid;
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c: In function 'parse_options':
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:2047:15: error: incompatible types when assigning to type 'uid_t' from type 'kuid_t'
      opts->fs_uid = current_uid();
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:2048:15: error: incompatible types when assigning to type 'gid_t' from type 'kgid_t'
      opts->fs_gid = current_gid();
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c: In function 'exfat_read_root':
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:2182:15: error: incompatible types when assigning to type 'kuid_t' from type 'uid_t'
      inode->i_uid = sbi->options.fs_uid;
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:2183:15: error: incompatible types when assigning to type 'kgid_t' from type 'gid_t'
      inode->i_gid = sbi->options.fs_gid;
                   ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:308: recipe for target 'fs/exfat/exfat_super.o' failed
    make[4]: *** [fs/exfat/exfat_super.o] Error 1
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:455: recipe for target 'fs/exfat' failed
    make[3]: *** [fs/exfat] Error 2
    make[3]: *** Waiting for unfinished jobs....
    

    and should CONFIG_DEFAULT_SECURITY be "apparmor" or "selinux" ? the script didnt set it to "apparmor" on first run

    Or is even something else making problems now suddenly :/

    EDIT: a few more errors that appeared at the same time which i didnt see


  • Community

    @SGCMarkus

    It should be apparmor. These config changes will probably cause more build errors, so don't be alarmed.

    Since the device uses a 3.10 kernel, you're going to need the commits from other 3.10 kernels, like I used on my tree for the Nexus 5X: https://github.com/usb-bullhead-ubuntu-touch/kernel_msm/commits/android-msm-bullhead-3.10-marshmallow-dr1.6-ut



  • @UniSuperBox

    What is this bull**** now lol

    (!gid_eq(attr->ia_gid, sbi->options.fs_gid))
    results in ->
    /home/markus/ubport_6/kernel/oneplus/msm8994/fs/exfat/exfat_super.c:1220:6: error: incompatible type for argument 2 of 'gid_eq'
    (!gid_eq(attr->ia_gid, sbi->options.fs_gid ))) ||
    note: expected 'kgid_t' but argument is of type 'gid_t'

    and if i have

    (!gid_eq(make_kgid(NULL, attr->ia_gid), make_kgid(NULL, sbi->options.fs_gid)))
    it results in ->
    error: incompatible type for argument 2 of 'make_kgid'
    note: expected 'gid_t' but argument is of type 'kgid_t'

    so if i trust the second one, and its already kgid_t, why does it say its not in the first one...? and it has no .val value, so it has to be of type gid_t (what the first one says) so why doesnt the second one not work... what the fuck is going on there O.o


  • Community

    @SGCMarkus

    You'll need to take a look at the commit log that I sent in my last post. These are known bugs in the 3.10 kernel that you will need to fix.



  • @UniSuperBox applied all that already, and some more that produced similar errors afterwards, atm trying to apply that to everything else that produces errors that have todo with uid_t/kuid_t (gid) ... but that from my last post confuses me, because it says its the other, even though it isnt and should work with the first O.o


  • Community

    @SGCMarkus

    What file is that in? It looks like something with the filesystem, did you disable CONFIG_EXT4_FS_POSIX_ACL in the defconfig? You'll need to comment out or remove the line, not set it to No.



  • @UniSuperBox

    that error is in fs/exfat/exfat_super.c line ~1217 (may be a bit different from versio nto version what i found) in function "exfat_setattr".

    Another one:

    /home/markus/ubport_6/kernel/oneplus/msm8994/drivers/platform/msm/pft.c: In function 'pft_is_current_process_registered':
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/linux/cred.h:332:24: error: incompatible types when initializing type 'u32' using type 'kuid_t'
     #define current_uid()  (current_cred_xxx(uid))
                            ^
    /home/markus/ubport_6/kernel/oneplus/msm8994/drivers/platform/msm/pft.c:369:12: note: in expansion of macro 'current_uid'
      u32 uid = current_uid();
                ^
    In file included from /home/markus/ubport_6/kernel/oneplus/msm8994/include/linux/kernel.h:14:0,
                     from /home/markus/ubport_6/kernel/oneplus/msm8994/drivers/platform/msm/pft.c:48:
    /home/markus/ubport_6/kernel/oneplus/msm8994/drivers/platform/msm/pft.c: In function 'pft_inode_create':
    /home/markus/ubport_6/kernel/oneplus/msm8994/include/linux/dynamic_debug.h:64:16: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'kuid_t' [-Wformat=]
    error, forbidden warning: dynamic_debug.h:64
      CC      drivers/rtc/rtc-lib.o
    /home/markus/ubport_6/kernel/oneplus/msm8994/scripts/Makefile.build:308: recipe for target 'drivers/platform/msm/pft.o' failed
    make[5]: *** [drivers/platform/msm/pft.o] Error 1
    make[5]: *** Waiting for unfinished jobs....
    

    Currently rebuilding without any CONFIG_EXT4_FS_POSIX_ACL in the defconfig, will update this post with the result.


  • Community

    @SGCMarkus One more thing, it doesn't look like I have any exfat enabled in my kernel. You might consider disabling it for yours, too.


Log in to reply
 

Looks like your connection to UBports Forum was lost, please wait while we try to reconnect.