mobile-nixos icon indicating copy to clipboard operation
mobile-nixos copied to clipboard

Oneplus 6T / oneplus-fajita

Open ds2k5 opened this issue 2 years ago • 12 comments

@samueldr

Hello, how to help you to add the Oneplus 6T / oneplus-fajita to your Devices (SOC: sdm845) ? Main Camera: IMX519 / Front: IMX376K

https://github.com/NixOS/mobile-nixos/tree/master/devices

What can I do ? ( I am not a developer - sorry )

ds2k5 avatar Sep 26 '22 11:09 ds2k5

Hi!

This is already part of #511, and previously #420.

As of right now, testing on device would be required. Though we can't support any more than the mainline efforts do, and I believe the cameras aren't supported yet.

So at this point, what you can do is:

  • Be confident about how to recover your device from bad situations
  • Know that you may lose all personal data on your device
  • Build and test from the #511 PR.
  • Report back with detailed information.

samueldr avatar Sep 26 '22 19:09 samueldr

@samueldr samueldr

Hi, thanks for you help!

got a GUI - but how to get a shell to see IP of USB-Interface to login by SSH do get dmesg etc. ?

posh build fail - see end of this post

nixos_oneplus_6t

got your files downloaded and build the system and boot.img

The Images you can Download here: https://www.swisstransfer.com/d/118f1413-f4f7-4c1e-8ba7-daedc6a1f474 but the link expire at 10/27/2022

here is what I did:

git clone https://github.com/NixOS/mobile-nixos.git
cd mobile-nixos/
git fetch origin pull/420/head:testisteintest
git checkout testisteintest
git fetch origin pull/511/head:test2
git checkout test2

[user1@nixos:~/mobile-nixos/devices]$ ls -la oneplus-fajita/
total 20
drwxr-xr-x  4 user1 users 4096 Sep 27 07:37 .
drwxr-xr-x 26 user1 users 4096 Sep 27 07:37 ..
-rw-r--r--  1 user1 users 1537 Sep 27 07:37 default.nix
drwxr-xr-x  2 user1 users 4096 Sep 27 07:37 firmware
drwxr-xr-x  2 user1 users 4096 Sep 27 07:37 kernel

but the crossShell.nix is not OK will not work....

https://nixos.wiki/wiki/Cross_Compiling

[with import <nixpkgs> {
  crossSystem = {
    config = "aarch64-unknown-linux-gnu";
  };
};

mkShell {
  buildInputs = [ zlib ]; # your dependencies here
}](url)

$ export NIX_PATH=~
$ nix-shell crossShell.nix 
$ nix-build examples/hello --argstr device oneplus-fajita -A outputs.default


nix-env -iA nixos.simg2img
img2simg system.img ~/fajita-system.img
file ~/fajita-system.img
/home/user1/fajita-system.img: Android sparse image, version: 1.0, Total of 505887 4096-byte output blocks in 10607 input chunks

$ fastboot -S 100M flash userdata fajita-system.img  
< waiting for any device >
Sending sparse 'userdata' 1/18 (95876 KB)          OKAY [  2.192s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 2/18 (101972 KB)         OKAY [  2.819s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 3/18 (97183 KB)          OKAY [  4.509s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 4/18 (102386 KB)         OKAY [  5.229s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 5/18 (102290 KB)         OKAY [  4.239s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 6/18 (102357 KB)         OKAY [  4.329s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 7/18 (99196 KB)          OKAY [  4.109s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 8/18 (97986 KB)          OKAY [  4.029s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 9/18 (95991 KB)          OKAY [  3.339s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 10/18 (102397 KB)        OKAY [  4.009s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 11/18 (100903 KB)        OKAY [  2.999s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 12/18 (99632 KB)         OKAY [  3.699s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 13/18 (90396 KB)         OKAY [  3.719s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 14/18 (102396 KB)        OKAY [  2.939s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 15/18 (95148 KB)         OKAY [  2.729s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 16/18 (102399 KB)        OKAY [  3.179s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 17/18 (102396 KB)        OKAY [  4.149s]
Writing 'userdata'                                 OKAY [  0.001s]
Sending sparse 'userdata' 18/18 (24996 KB)         OKAY [  1.699s]
Writing 'userdata'                                 OKAY [  0.001s]
Finished. Total time: 63.995s

$ ls -la /nix/store/xzbwb8ka3nn2g8xq6wv2rlcxnpf9ihny-android-fastboot-images-oneplus-fajita
total 1756760
dr-xr-xr-x    2 root root         4096 Jan  1  1970 .
drwxrwxr-t 2063 root nixbld     925696 Sep 27 09:13 ..
-r--r--r--    1 root root     22568960 Jan  1  1970 boot.img
-r-xr-xr-x    1 root root          319 Jan  1  1970 flash-critical.sh
-r--r--r--    1 root root   2072113152 Jan  1  1970 system.img

[nix-shell:~/mobile-nixos]$ nix-shell -p nix-info --run "nix-info -m"
these 6 paths will be fetched (4.85 MiB download, 31.40 MiB unpacked):
  /nix/store/0ldkj6mklr9r8fml6927akjdl3zih46m-gcc-wrapper-11.3.0
  /nix/store/4v4292agvyrh60qp2184f5lhn53gi6bs-expand-response-params
  /nix/store/75dsac7cwhrdz0ca7lpql2lampi7g78k-binutils-2.38
  /nix/store/i17qfxfgcfqryn2ylywa0a5kpcvpz5g2-binutils-wrapper-2.38
  /nix/store/ji6jsdwj6p65q5asgbqhnvzvxfa7nzfv-nix-info
  /nix/store/n4rm9iyf5prbgxzjhv8gsxmxcxprga9x-stdenv-linux
copying path '/nix/store/ji6jsdwj6p65q5asgbqhnvzvxfa7nzfv-nix-info' from 'https://cache.nixos.org'...
copying path '/nix/store/4v4292agvyrh60qp2184f5lhn53gi6bs-expand-response-params' from 'https://cache.nixos.org'...
copying path '/nix/store/75dsac7cwhrdz0ca7lpql2lampi7g78k-binutils-2.38' from 'https://cache.nixos.org'...
copying path '/nix/store/i17qfxfgcfqryn2ylywa0a5kpcvpz5g2-binutils-wrapper-2.38' from 'https://cache.nixos.org'...
copying path '/nix/store/0ldkj6mklr9r8fml6927akjdl3zih46m-gcc-wrapper-11.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/n4rm9iyf5prbgxzjhv8gsxmxcxprga9x-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.68, NixOS, 22.05 (Quokka), 22.05.3242.72783a2d0db`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `"nixos-22.05"`
 - nixpkgs: `/home/user1/nixpkgs`

$ fastboot flash boot boot.img 
< waiting for any device >

$ file boot.img 
boot.img: Android bootimg, kernel (0x8000), ramdisk (0x1000000), page size: 4096, cmdline (console=tty0 loglevel=4)


$ fastboot flash --slot=a boot boot.img 
< waiting for any device >
Sending 'boot_a' (22040 KB)                        OKAY [  0.507s]
Writing 'boot_a'                                   OKAY [  0.088s]

Tryed to build phosh but this fail:

nix-build examples/phosh --argstr device oneplus-fajita -A outputs.default

checking for pthread_mutexattr_setpshared... yes
checking for working PROCESS_SHARED locks... configure: error: in `/build/apr-1.7.0':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
error: builder for '/nix/store/9ayc9l2ip0c7qw4w1g321zl8kx9xdd5w-apr-aarch64-unknown-linux-gnu-1.7.0.drv' failed with exit code 1;
       last 10 log lines:
       > checking for LOCK_EX in sys/file.h... yes
       > checking for F_SETLK in fcntl.h... yes
       > checking for SEM_UNDO in sys/sem.h... yes
       > checking for POLLIN in poll.h sys/poll.h... yes
       > checking for PTHREAD_PROCESS_SHARED in pthread.h... yes
       > checking for pthread_mutex_timedlock... yes
       > checking for pthread_mutexattr_setpshared... yes
       > checking for working PROCESS_SHARED locks... configure: error: in `/build/apr-1.7.0':
       > configure: error: cannot run test program while cross compiling
       > See `config.log' for more details
       For full logs, run 'nix log /nix/store/9ayc9l2ip0c7qw4w1g321zl8kx9xdd5w-apr-aarch64-unknown-linux-gnu-1.7.0.drv'.
error: 1 dependencies of derivation '/nix/store/6qh312vfmj4fnxp7j5ljrqb5kx4khpvq-apache-httpd-aarch64-unknown-linux-gnu-2.4.54.drv' failed to build
building '/nix/store/km7hbhb9ymz97irkl18qbax1ydga6w3a-asound.conf.drv'...
error: 1 dependencies of derivation '/nix/store/5r37gfcyl4hxmp1q6qwqki0r0hdc28ln-gnome-user-share-aarch64-unknown-linux-gnu-3.34.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/igv4sjphc4f7lwh6fpxnvx114ryhrg4z-gnome-control-center-aarch64-unknown-linux-gnu-42.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rcjds728gh5pw4ri0snz12pg5fl81i27-system-generators.drv' failed to build
error (ignored): error: cannot unlink '/tmp/nix-build-SDL2-2.0.22.drv-0/SDL2-2.0.22/build/.libs': Directory not empty
error: 1 dependencies of derivation '/nix/store/jc94yrf4gf4w3hph4nn5xhivi4k26qkj-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5csc8rgks8kkayd1x5dpy4mc83pjjnbz-nixos-system-nixos-22.11pre-git.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2b9zxdi32w4wsdlagr5780r04fznycim-closure-info.drv' failed to build
building '/nix/store/rdwb8gibvq9bwwv2jbrs2hh3i55ra1xs-extra-utils-oneplus-fajita-extra-utils-aarch64-unknown-linux-gnu.drv'...
building '/nix/store/zzkajkrnpz6ycw9bz6k0bhlxc3q7f2n6-oneplus-fajita-boot-config.drv'...
error: 1 dependencies of derivation '/nix/store/al9bfzn15x5jyqgsav98asba38ganscj-partition-NIXOS_SYSTEM.drv' failed to build
error: 1 dependencies of derivation '/nix/store/060cfxji22rnfqsd9sz3qk1sf59dcxms-android-fastboot-images-oneplus-fajita.drv' failed to build


how to add kernel 5.19.x beacuse sound works only with 5.19.x (see Mobian)

https://gitlab.com/sdm845-mainline

  • tfa98xx.cnt from https://github.com/J0SH1X/tfa98xx/blob/mainline/tfa98xx.cnt?raw=true to /usr/lib/firmware
  • ucm2 folder from https://gitlab.com/donreddy/alsa-ucm-conf/-/tree/master/ to /usr/share/alsa

ds2k5 avatar Sep 27 '22 04:09 ds2k5

For the Camera issue:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

thanks to Kieran Bingham for the hint

ds2k5 avatar Sep 27 '22 08:09 ds2k5

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/mobile-nixos-progress-thread/342/67

nixos-discourse avatar Sep 29 '22 15:09 nixos-discourse

Hello,

did this build:


nix-shell crossShell.nix
nix-build --argstr device oneplus-fajita -A outputs.default
img2simg /nix/store/9d7x5dnzwpdm7360vjnarzzha32iy1fl-partition-NIXOS_SYSTEM/NIXOS_SYSTEM.img ~/mobile-nixos_oneplus-fajita.img

cp /nix/store/gx1mylryl4bs21hlhzg6vzp8ck2j0c4z-mobile-nixos_oneplus-fajita_boot.img ~/mobile-nixos_oneplus-fajita_boot.img

fastboot flash --slot=a boot mobile-nixos_oneplus-fajita_boot.img 
fastboot flash --slot=b boot mobile-nixos_oneplus-fajita_boot.img 
fastboot -S 100M flash userdata mobile-nixos_oneplus-fajita.img 

but not see a USB-Interface with a IP

Can not login, because no onscreen Keyboard... only Console A USB-Keyboard did not work (USB-C -> USB-A Adapter)

You can Download the Image here: https://www.swisstransfer.com/d/900571ab-4cc0-448c-9972-4c095d0f0cb0 but until 10/30/2022

ds2k5 avatar Sep 30 '22 21:09 ds2k5

found something about apr

if run like this:

./configure --host=aarch64-unknown-linux-gnu

got alter this error:

checking for shmdt... yes checking for shmctl... yes checking for create_area... no checking for mprotect... yes checking for MAP_ANON in sys/mman.h... yes checking for /dev/zero... configure: error: cannot check for file existence when cross compiling

How to fix this ?

and how to change the "phosh" that apr will run configure with: --host=aarch64-unknown-linux-gnu

With this command:

./configure ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_mutex_robust_shared="no" apr_cv_process_shared_works="yes" apr_cv_tcp_nodelay_with_cork="yes" --host=aarch64-unknown-linux-gnu

got this error:

configure: creating ./config.status config.status: creating Makefile config.status: creating include/apr.h config.status: creating build/apr_rules.mk config.status: creating build/pkg/pkginfo config.status: creating apr-1-config config.status: creating apr.pc config.status: creating test/Makefile config.status: creating test/internal/Makefile config.status: creating include/arch/unix/apr_private.h config.status: executing libtool commands rm: cannot remove 'libtoolT': No such file or directory config.status: executing default commands

config.log

ds2k5 avatar Sep 30 '22 21:09 ds2k5

It is expected that you have "nothing" useful when using the "unconfigured build" using:

 $ nix-build --argstr device oneplus-fajita -A outputs.default

This is because you're building a NixOS system with nothing configured except the defaults. Such system has no user configured, no services except basic system services.

Furthermore, with the current state of the SDM845 mainline devices, IIRC switching the port from device/host mode is unsupported. This is why you cannot use a USB device on your phone at this point in time.

samueldr avatar Sep 30 '22 22:09 samueldr

Hello samueldr, thank you for explain

how can I crossCompile the phosh ?

nix-build examples/phosh --argstr device oneplus-fajita -A outputs.default beacuse this fail at apr compile

Or how to add the user, USB-Networking + OpenSSH that I can login over USB-Cable to the hello Image that builds file for example. to get Log files, dmesg, uname -a etc.

Thanks

ds2k5 avatar Oct 01 '22 09:10 ds2k5

Hi had build a aarch64 VM in qemu.

Build there worked... but takes around: 9 hours

[user1@nixos:~/mobile-nixos/result]$ ls -la
total 5216736
dr-xr-xr-x    2 root root         4096 Jan  1  1970 .
drwxrwxr-t 1752 root nixbld     880640 Oct  1 21:57 ..
-r--r--r--    1 root root     21544960 Jan  1  1970 boot.img
-r-xr-xr-x    1 root root          319 Jan  1  1970 flash-critical.sh
-r--r--r--    1 root root   5828927488 Jan  1  1970 system.img

Here is the way I did it:

https://releases.nixos.org/nixos/22.05-aarch64/nixos-22.05.209.d1086907f56/nixos-minimal-22.05.209.d1086907f56-aarch64-linux.iso

as user root:


useradd -m user1
passwd user1

nix-env -iA vim
nix-env -iA nmon
nix-env -iA git
nix-env -iA nixos.simg2img


as user: user1


git clone https://github.com/NixOS/mobile-nixos.git
git clone https://github.com/NixOS/nixpkgs.git



cd mobile-nixos
git fetch origin pull/511/head:test2
git checkout test2

nix-build examples/phosh --argstr device oneplus-fajita -A outputs.default

cd /home/user1/mobile-nixos/result
img2simg system.img ~/Oneplus6T_nixos.img
cp boot.img ~/Oneplus6T_nixos.boot.img

fastboot flash boot --slot=a Oneplus6T_nixos.boot.img
fastboot flash boot --slot=b Oneplus6T_nixos.boot.img

fastboot -S 100M flash userdata Oneplus6T_nixos.img


did a 2nd build with this changes in: mobile-nixos/examples/phosh/configuration.nix


    mobile.boot.stage-1.networking.enable = lib.mkDefault true;
    mobile.boot.stage-1.ssh.enable = true;

but user alice can not login with SSH how to fix this ?

ssh is running:


$ ssh [email protected]
From a mobile-nixos device oneplus-fajita
[email protected]'s password: 

ds2k5 avatar Oct 01 '22 20:10 ds2k5

Made a new build with this lines in

mobile-nixos/examples/phosh/configuration.nix

    services.openssh.forwardX11 = true;
    security.pam.services.sudo.sshAgentAuth = true;    
    services.openssh.passwordAuthentication = true;
    mobile.boot.stage-1.ssh.enable = true;

But now it not work

got GUI but with this error:

INIT_EXCEPTION
Uncaught Exception
Command failed.... e2fsck -fp /dev/disk/by-label/NIXOS_SYSTEM (4) (System: CommandError)

Error_1 Error_2

ds2k5 avatar Oct 02 '22 20:10 ds2k5

From man e2fsck :

EXIT CODE
       The exit code returned by e2fsck is the sum of  the  following  condi‐
       tions:
            0    - No errors
            1    - File system errors corrected
            2    - File system errors corrected, system should
                   be rebooted
            4    - File system errors left uncorrected
            8    - Operational error
            16   - Usage or syntax error
            32   - E2fsck canceled by user request
            128  - Shared library error

So "the" filesystem has errors, and has been left untouched. There could be many reasons for this.

The most common one is having multiple partitions with a filesystem with the NIXOS_SYSTEM label, and one of them being a bogus/unfinished flash.

samueldr avatar Oct 02 '22 20:10 samueldr

thank you!

how to check the image before flash if the IMAGE is OK?

ds2k5 avatar Oct 02 '22 20:10 ds2k5