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 :-)
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)
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:
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:
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-
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:
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
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.
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.
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.
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.
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.
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:
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:
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
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
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
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
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
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
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.
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
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?
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
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
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.
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