Results 1 to 40 of 40

Thread: Building a kernel for the Razor Phone 2 - Live feed

  1. #1
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258

    Post Building a kernel for the Razor Phone 2 - Live feed

    I am going to build a kernel for the Razor Phone 2 from scratch and log all my steps in this post for everyone that's interested in building their own kernel. I encourage everyone to follow along, try these steps and raise questions or propose better ways of doing things as we go along.

    I am going to list the prerequisites in post #2, a raw log with all mistakes, dead ends and troubleshooting in post #3, and a sanitised version of the working steps in post #4.

    Everything after that is open discussion. Let the games begin :-)

  2. #2
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Prerequisites:

    Identify device model:
    ----------------------
    - getprop ro.product.device = aura
    - getprop ro.product.model = Phone 2
    - getprop ro.product.name = cheryl2 (chery12)
    - OS =
    - OS version =
    - Architecture =


    Confirm prerequisites:
    ----------------------
    - Magisk root is installed
    - TWRP is installed
    - Kernel source is available for that particular model: Yes, we are going to use https://github.com/arter97/android_kernel_razer_sdm845
    - If an alternative kernel is already available as update.zip, install it as a test (and to have a fallback)
    Last edited by re4son; 2 Days Ago at 08:50.

  3. #3
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Raw log:
    --------------

    Prepare build environment (Kali VM):
    --------------------------------------------------
    - Install Virtualbox
    - Download Kali VM from https://www.offensive-security.com/k...mage-download/
    - Import Kali VM into VirtualBox
    - Start VBox, log on as root/toor, change password and prep OS:
    Code:
    apt update && apt full-upgrade
    adduser nethunter
    usermod -a -G sudo nethunter
    - reboot & login as nethunter


    Next:

    - Install (google) toolchains and dependencies:
    Code:
    cd ~
    mkdir toolchain toolchain64
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 -b  pie-release toolchain64
    export ARCH=arm64
    export SUBARCH=arm64
    export CROSS_COMPILE=`pwd`/toolchain64/bin/aarch64-linux-android-

    Prepare kernel:
    ------------------
    - Clone kernel source:
    Code:
    git clone https://github.com/arter97/android_kernel_razer_sdm845
    - install bc
    Code:
    apt install bc
    - Build test kernel without any mods:
    Code:
    cd android_kernel_razer_sdm845
    
    cp defconfig .config ## This seems to be the original authors config
    make menuconfig
    cp .config arch/arm64/configs/nethunter_defconfig
    make
    Results in this error
    Code:
    arch/arm64/Makefile:74: *** /home/arter97/arm32-gcc/bin/arm-eabi-gcc not found, check CROSS_COMPILE_ARM32.  Stop.
    There seem to be some paths hardcoded somewhere. Probably in the Makefile but let's do a search:
    Code:
    grep -r "arter97" *
    And there it is:
    Code:
    <snip>
    Makefile:override CROSS_COMPILE	:= /home/arter97/arm64-gcc/bin/aarch64-elf-
    Makefile:override CROSS_COMPILE_ARM32	:= /home/arter97/arm32-gcc/bin/arm-eabi-
    <snip>
    Let's edit the Makefile and remove the offending lines:
    Code:
    vi Makefile
    # searching for "override" takes us to the following three lines, let's comment them out like this:
    
    override ARCH           := arm64
    override CROSS_COMPILE  := /home/arter97/arm64-gcc/bin/aarch64-elf-
    override CROSS_COMPILE_ARM32    := /home/arter97/arm32-gcc/bin/arm-eabi-

    Running make again causes this error:
    Code:
    arch/arm64/Makefile:74: *** /home/nethunter/toolchain/bin/arm-eabi-gcc not found, check CROSS_COMPILE_ARM32.  Stop.
    Let's get a 32bit toolchain too then:
    Code:
    cd ~
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7 toolchain
    export CROSS_COMPILE_ARM32=~/toolchain/bin/arm-eabi-

    Let's compile again:
    Code:
    cd ~/android_kernel_razer_sdm845
    make
    Results in another error:

    Code:
    make: *** [Makefile:1189: prepare-compiler-check] Error 1
    Looks like we need other toolchains. Let's try linaro:

    Code:
    cd ~
    rm -rf toolchain toolchain64
    mkdir toolchain toolchain64
    wget https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-eabi/gcc-linaro-7.4.1-2019.02-x86_64_arm-eabi.tar.xz
    wget https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-elf/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-elf.tar.xz
    tar xJf gcc-linaro-7.4.1-2019.02-x86_64_arm-eabi.tar.xz -C toolchain --strip-components=1
    tar xJf gcc-linaro-7.4.1-2019.02-x86_64_aarch64-elf.tar.xz -C toolchain64 --strip-components=1
    Same error. Looking around I found pre-compiled toolchains in the github account of the original author of this kernel. Let's use these:

    Code:
    cd ~
    rm -rf toolchain toolchain64
    mkdir toolchain toolchain64
    
    git clone https://github.com/arter97/arm32-gcc toolchain
    git clone https://github.com/arter97/arm64-gcc toolchain64
    export ARCH=arm64
    export SUBARCH=arm64
    export CROSS_COMPILE=~/toolchain64/bin/aarch64-elf-
    export CROSS_COMPILE_ARM32=~/toolchain/bin/arm-eabi-

    And let's try again:
    Code:
    cd ~/android_kernel_razer_sdm845
    make
    Bingo. We have a kernel.


    Let's wait for everyone to catch up and aim for step two: packaging up and installing the test kernel tomorrow, ok?
    Last edited by re4son; 2 Days Ago at 09:33.

  4. #4
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Pretty log:
    ----------------

    Prepare build environment (Kali VM):
    --------------------------------------------------
    - Install Virtualbox
    - Download Kali VM from https://www.offensive-security.com/k...mage-download/
    - Import Kali VM into VirtualBox
    - Start VBox, log on as root/toor, change password and prep OS:

    Code:
    apt update && apt full-upgrade
    adduser nethunter
    usermod -a -G sudo nethunter
    - reboot & login as nethunter


    Next:

    - Install toolchains and dependencies:

    Code:
    cd ~
    mkdir toolchain toolchain64
    git clone https://github.com/arter97/arm32-gcc toolchain
    git clone https://github.com/arter97/arm64-gcc toolchain64
    sudo apt install bc
    export ARCH=arm64
    export SUBARCH=arm64
    export CROSS_COMPILE=~/toolchain64/bin/aarch64-elf-
    export CROSS_COMPILE_ARM32=~/toolchain/bin/arm-eabi-
    - Download, configure, and build vanilla kernel:
    Code:
    cd ~
    git clone https://github.com/arter97/android_kernel_razer_sdm845
    cd android_kernel_razer_sdm845
    cp defconfig .config
    vi Makefile
    # Delete three lines starting with "override"
    make menuconfig
    cp .config arch/arm64/configs/nethunter_defconfig
    make
    Last edited by re4son; 2 Days Ago at 09:32.

  5. #5
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    @nikmel420:

    Could you run these commands for me and post the output please?

    getprop ro.product.device
    getprop ro.product.model
    getprop ro.product.name

    Many thanks

  6. #6
    Join Date
    2019-Jan
    Posts
    76
    Sorry sorry, ok different timezone but saint bernard puppy wore me out went to bed early. I'll make sure all notifications are on so I dont miss you again.

  7. #7
    Join Date
    2019-Jan
    Posts
    76
    Ok um let me do 6am feed walk dog feed me drink coffee and the start. Thank you.

  8. #8
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    I'm not sure that's a good idea. My day seems to be your night and there will be a lot of alarms getting you out of bed ;-)
    That's ok though because I can spend my day experimenting and posting my result and you can have a go at it when I'm in bed.

    If you could get me those details and install Kali, that will set us up for tomorrow.
    The toolchain and kernel config will take a day because I've already had a little peek and there are a few minor courve b.a.l.l.s. (first time censored - yeah) along the way.

  9. #9
    Join Date
    2019-Jan
    Posts
    76
    Give me time F it Zulu/Greenwich, or east us

  10. #10
    Join Date
    2019-Jan
    Posts
    76
    I'll have all this and be ready then

  11. #11
    Join Date
    2019-Jan
    Posts
    76
    Kali always installed not get reinstall after every chapter in the book. Thsts a long book

  12. #12
    Join Date
    2019-Jan
    Posts
    76
    Can we secedual for this weekend works kicking my *** . I dont want to make I committment I cant keep.

  13. #13
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    No problems at all.


    I have picked a kernel and toolchain and will document the process of how I arrived at those decisions.
    If you could run those commands, root your phone and install TWRP then we can hit the ground running on the weekend.

    I also encourage everyone else that is interested in porting NetHunter to new phones to follow along. Doesn't matter if you have a Razor phone or not, it is still a useful and fun exercise that you can apply to your own device.
    Last edited by re4son; 6 Days Ago at 09:00.

  14. #14
    Join Date
    2019-Aug
    Posts
    1
    Ok sorry I'm late to the game between work and family I have a lot going on. Let me know if there's anything you need me to test etc. Right now Im rooted running magisk w/the AT&T firmware. Had a hard time getting TWRP to ever work with the bootloader, but maybe there was something I was missing. I can't thank you enough for taking on this challenge. I know this is sold as a "gaming" phone. Truth be told I don't really even do mobile gaming. I liked the specs and I think it will make a great penetration device.

  15. #15
    Join Date
    2019-Jan
    Posts
    76
    How did you get twrp? I'm got magick and magick manager. But I cant even get twrp even from twrp app. Is that the one u using. I been stuck awhile

  16. #16
    Join Date
    2019-Jan
    Posts
    76
    I dont game on my phone. But tmobile new upgrade program this was less then a downpayment and so I went with this one. But been years using adb not Odin.

  17. #17
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Welcome aboard @Rabid_Root

    @nikmel420 - It seems that the only option to get TWRP for the Razer 2 is to install it together with the Arter97 kernel:
    https://forum.xda-developers.com/raz...one-2-t3914996

    That's ok though because this is the kernel I picked as basis for NetHunter anyway.

  18. #18
    Join Date
    2019-Jan
    Posts
    76
    Are you installing the zip like it says I keep getting error N

  19. #19
    Join Date
    2019-Jan
    Posts
    76
    Found it run:
    adb shell get ro.boot.slot_suffif
    Get _a or _b
    Fastboot flash boot_a/b arter97*

  20. #20
    Join Date
    2019-Jan
    Posts
    76
    Since u already made one how about I test it for ya. You can show me how when your not busy

  21. #21
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    I don't have anything yet except an idea of which kernel source to use. That might change down the track but I am going to start with this one:

    https://github.com/arter97/android_kernel_razer_sdm845

    The reason that I picked that on is because it has the most activity in the xda forum:
    https://forum.xda-developers.com/raz...one-2-t3914996

    And no major issues reported.

    First things first through, I need someone to confirm that TWRP works, system & data can be mounted in TWRP and I need the output of the following commands:

    https://forum.xda-developers.com/raz...one-2-t3914996

    getprop ro.product.device
    getprop ro.product.model
    getprop ro.product.name

    Please don't run these commands in TWRP but when you are booted into the normal system please.

  22. #22
    Join Date
    2019-Jan
    Posts
    76
    Ok I'm on it. The arter97. I haven't tested. But says it has a couple realtek drivers already. Let me do those things you asked

  23. #23
    Join Date
    2019-Jan
    Posts
    76
    Quote Originally Posted by re4son View Post
    I don't have anything yet except an idea of which kernel source to use. That might change down the track but I am going to start with this one:

    https://github.com/arter97/android_kernel_razer_sdm845

    The reason that I picked that on is because it has the most activity in the xda forum:
    https://forum.xda-developers.com/raz...one-2-t3914996

    And no major issues reported.

    First things first through, I need someone to confirm that TWRP works, system & data can be mounted in TWRP and I need the output of the following commands:

    https://forum.xda-developers.com/raz...one-2-t3914996

    getprop ro.product.device
    getprop ro.product.model
    getprop ro.product.name

    Please don't run these commands in TWRP but when you are booted into the normal system please.
    ok it deleted twrp i got a few ideas . but getprop is giving unknown command. im on kali but installed not virtual. might need more clarification were to run those

  24. #24
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Boot your phone normally and install connectbot
    Open a localhost session and type in those commands

  25. #25
    Join Date
    2019-Jan
    Posts
    76
    twrp wont mount storage. conectbot wont connect. i cant help. maybe some rest

  26. #26
    Join Date
    2019-Jan
    Posts
    76
    ok already said i was an idiot. i dont recall putting my pin in twrp to mount it. buti forget alot moving forward again

  27. #27
    Join Date
    2019-Jan
    Posts
    76
    ok already said i was an idiot. i don't recall putting my pin in twrp to mount it. but i forget alot moving forward again. reflashed original FW

    fastboot boot_a arter97-kernel-r10-20190804.img
    fastboot boot_b arter97-kernel-r10-20190804.img

    fastboot reboot

    im not sure why or why there's a b. but running the _a _b at same time keeps twpr over hard resets. im switching pc's i don't know why i cant get a shell. but cant hurt

  28. #28
    Join Date
    2019-Jan
    Posts
    76
    i asked before just want to be sure. do i need to use a VM? i dont see why would matter but i dont see much

  29. #29
    Join Date
    2019-Jan
    Posts
    76
    getprop ro.product.device
    aura
    getprop ro.product.model
    Phone 2
    getprop ro.product.name
    cheryl2 (chery12)images.jpeg

  30. #30
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Perfect, thanks.
    Can you mount data and system in TWRP?

  31. #31
    Join Date
    2019-Jan
    Posts
    76
    after i entered pin code yes, was also able to mount usb storage. but i tried a nethunter generic install and the magisk module install. both say succeed but not installed when boots. im pretty sure all safeties off

  32. #32
    Join Date
    2019-Jan
    Posts
    76
    under modifying kernel what do i replace msm8974_sec_defconfig with?

  33. #33
    Join Date
    2019-Jan
    Posts
    76
    im going to guess deconfig (i missed it)

  34. #34
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    Let's install suitable toolchains. I'm continuing with my log in post #3

    First we need both a 32bit and a 64bit toolchain
    Next the google one is not suitable and the linaro one isn't either
    I ended up using one build very recently by the author of the original kernel we are using

    We also have to edit the Makefile to get rid of some hardcoded paths
    Last edited by re4son; 2 Days Ago at 11:24.

  35. #35
    Join Date
    2019-Jan
    Posts
    76
    keernal mod.jpg


    shoot sorry i was adjusting my time. hers were im at i stopped since no real errors. except the golum things you need first could t find it. is it wearing the ring

  36. #36
    Join Date
    2019-Jan
    Posts
    76
    im here a ran the first 3 comands. was gonna do the pach line when came and saw about make file
    i missed the post on tolchains and the cusom makefilekeernal mod.jpg

  37. #37
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    I'd stick to following these steps:

    https://forums.kali.org/showthread.p...7030#post87030


    That'll get you a test kernel. Next we are going to package it up and install it.
    There's no point working with a kernel that doesn't work out of the box.

    There are a lot of changes in the Android build of the Razer 2 and we have to go slowly and systematically.

  38. #38
    Join Date
    2019-Jan
    Posts
    76
    will do slow is cool with me. i rushed on the last one the gemini. i like the keybord but the gpd pocket better anyway. andthis one just feals solid idea why i cant get any nethunter flashed even the magisk one they say succeed but are gone or never ther after reboot,the 5 inch one was cool but i cant find it in this mes

  39. #39
    Join Date
    2019-Jan
    Posts
    76
    root and twrp wont stick ive been on xda looking for the step i missed.looks like they still figuring the fix. its passed my pay grade

  40. #40
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    258
    The final rooting solution determines the location of the nethunter kernel so we can't really do anything until that's sorted.
    How about we check-in to this thread every Friday to confirm the status? Would you mind posting a link to the relevant xda discussion @nikmel420 so we can stay up to date?

    Many thanks

Similar Threads

  1. Razor phone 2
    By nikmel420 in forum Building NetHunter
    Replies: 7
    Last Post: 1 Week Ago, 01:44
  2. OnePlus 7 Pro kernel building help
    By joelstitch in forum Building NetHunter
    Replies: 1
    Last Post: 1 Week Ago, 01:28
  3. Building for any phone ! Post Requests .
    By zinister in forum Building NetHunter
    Replies: 55
    Last Post: 2018-01-03, 04:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •