Page 1 of 2 12 LastLast
Results 1 to 50 of 82

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

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

    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
    445
    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; 2019-08-18 at 08:50.

  3. #3
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    445
    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; 2019-08-18 at 09:33.

  4. #4
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    445
    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; 2019-08-18 at 09:32.

  5. #5
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    445
    @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
    124
    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
    124
    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
    445
    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
    124
    Give me time F it Zulu/Greenwich, or east us

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

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

  12. #12
    Join Date
    2019-Jan
    Posts
    124
    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
    445
    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; 2019-08-14 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
    124
    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
    124
    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
    445
    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
    124
    Are you installing the zip like it says I keep getting error N

  19. #19
    Join Date
    2019-Jan
    Posts
    124
    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
    124
    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
    445
    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
    124
    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
    124
    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
    445
    Boot your phone normally and install connectbot
    Open a localhost session and type in those commands

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

  26. #26
    Join Date
    2019-Jan
    Posts
    124
    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
    124
    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
    124
    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
    124
    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
    445
    Perfect, thanks.
    Can you mount data and system in TWRP?

  31. #31
    Join Date
    2019-Jan
    Posts
    124
    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
    124
    under modifying kernel what do i replace msm8974_sec_defconfig with?

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

  34. #34
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    445
    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; 2019-08-18 at 11:24.

  35. #35
    Join Date
    2019-Jan
    Posts
    124
    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
    124
    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
    445
    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
    124
    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
    124
    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
    445
    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

  41. #41
    Join Date
    2019-Jan
    Posts
    124
    well Tomas edision once said he didn't fail a hundred times he learned a hundred ways how not to make a light bulb first, i got no were id say dont do the fstab thing in his post. thank god they have those unbrick scripts, so ill keep at it. its personal now its a song stuck in my head. ill get it . its probably one simple line

  42. #42
    Join Date
    2019-Jan
    Posts
    124
    do not setup security or file system wont mount everytime in twrp

    ok first get img here https://drive.google.com/file/d/1gGw...w?usp=drivesdk
    paste these 3 lines in terminal at same time

    fastboot flash boot_a boot.img
    fastboot flash boot_b boot.img
    fastboot reboot

    then get kernel here http://arter97.com/browse/aura/kernel/
    paste these 3 lines in terminal at same time

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

    do not do the file system change recommended on kernel page or root wont stick. ive tryed for 2 hours my best (im good at breaking stuff) to break to make sure. its still rooted. so its rooted, but nethunter wont flash generic or magisk tryed the apk with kalifs nightly. get java runtime error

    all credit goes to arter97 and Warrior1988
    Last edited by nikmel420; 2019-08-21 at 18:38. Reason: give credit were credit due

  43. #43
    Join Date
    2019-Jan
    Posts
    124
    right on. the nethunter.apk works fine. now i guess i start lol on to post 2

  44. #44
    Join Date
    2019-Jan
    Posts
    124
    https://forum.xda-developers.com/raz...0407@nikmel420
    is probably the best explained. the file change arter97 suggests on his kernel post that screws with root. and reading other peoples comments it messes up other things also.

  45. #45
    Join Date
    2015-Nov
    Location
    Australia
    Posts
    445
    Are you comfortable enough with reflashing, rooting, installing twrp and unbricking your phone for us to continue?

  46. #46
    Join Date
    2019-Jan
    Posts
    124
    yes sorry would of done over weekend but was busy. were do you want me to get to? reflash the stock script from razor. flash up untill r10 kernel. i put 4 posts up? actually r11 out

  47. #47
    Join Date
    2019-Jan
    Posts
    124
    I dont get an error
    20190826_123335.jpg

  48. #48
    Join Date
    2019-Jan
    Posts
    124

  49. #49
    Join Date
    2019-Jan
    Posts
    124
    Nevermind missed step

  50. #50
    Join Date
    2019-Jan
    Posts
    124
    ok phones reset rooted twrp. spent day doing posts 2, 3 so should understand your instructions.

Similar Threads

  1. Building Nethunter kernel for Mi a2 kernel 4.4
    By balramrexwal in forum NetHunter General Questions
    Replies: 4
    Last Post: 2020-08-23, 15:53
  2. OnePlus 7 Pro kernel building help
    By joelstitch in forum Building NetHunter
    Replies: 2
    Last Post: 2020-08-12, 08:09
  3. Razor phone 2
    By nikmel420 in forum Building NetHunter
    Replies: 7
    Last Post: 2019-08-13, 01:44
  4. 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
  •