hello, i have that script:
Code:
#!/system/bin/sh
rm -R /cache/download /sd-ext/download
mkdir /cache/download /sd-ext/download
chmod 0771 /cache/download /sd-ext/download
chown 1000:2001 /cache/download /sd-ext/download
mount -o bind /sd-ext/download /cache/download
And i don't know why in mount i have:
Code:
/dev/block/mmbblk0p2 on /cache/download\040(deleted) type ext3 ...
What is this "\040(deleted)"? This same i have in /proc/mounts
http://bytes.com/topic/c/answers/712378-why-backslash-space-combo-escape-sequence-040-a
In a string or character literal, the sequence \040 denotes the octal
value of the character (your C textbook should explain this). 040
octal is 32 decimal, which happens to be the ASCII code for the space
character (though C doesn't require ASCII).
Click to expand...
Click to collapse
It's a space? Idk though for sure
Emmm, no
Currently Building Bootable Android 5.1 Kernel From HTC DEV Source.
(THIS IS THE STOCK 5.0.1 / RUU Version = 1.23.1550.3 CL637541 RELEASE-KEYS)
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.7 (GCC) ) #2 SMP PREEMPT Sat Oct 31 02:35:36 CST 2015
This has been compiled and will boot on the device.
NOTE: WI-FI IS NOW WORKING
NOTE: DT Blobs broken:Fixed by using Blobs pulled from the device.}
WORK IN PROGRESS !!
Currently HTC has not released the Kernel Source for Marshmallow 6.0.1.
Solution: Port the 5.0.1 HTC Source by merging with AOSP device/lge/bullhead-kernel
Current Status:
WORKING KERNEL NO CHANGES FROM STOCK
Will Build for other Devices upon request.
Anyone who wishes to contribute to this project would be appreciated.
I'm in the process of setting up the GIT and the project on XDA.
DOWNLOADS
FOR METRO - PCS VERSION OF DESIRE 626S
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Sat Oct 1 11:53:51 EDT 2016
https://drive.google.com/open?id=0B8jitdIyh2NtdW1uNWdvaWdTdG8
The modules are in the link below.
https://drive.google.com/open?id=0B8jitdIyh2NtODl4ellvd0Y5MW8
XDA:DevDB Information
HTC MSM8909 Qualcom Kernel Port, Kernel for the HTC Desire 626
Contributors
BigCountry907, hp79
Kernel Special Features: Pssible: Change Keys used for flashing firmware: Add Fastboot Commands To Custom Bootloader: Either will allow us to S-OFF
Version Information
Status: Testing
Current Stable Version: Linux version 3.10.4
Stable Release Date: 2015-10-31
Created 2016-09-28
Last Updated 2016-10-01
Setting Up To Test 3.10.49-perf-g26c2269 Kernel Build
First I would like to mention that a full LINUX Development Environment is required to perform most of these tasks. If you don't have the development environment set up then please do the necessary research.
To test YOUR development environment and the HTC-DEV Kernel Source it is necessary to perform the following steps.
1 ) If you are currently running Marshmallow 6.0.1 you will need to downgrade the device to Lollipop 5.0.1 using the RUU. Please note that the Lollipop RUU is no longer available on the HTC-DEV site. Don't worry we will be going back to Marshmallow but need to test in lollipop first.
Please see the following thread for instructions on downgrading the HTC Desire 626s.
http://forum.xda-developers.com/desire-626/development/metropcs-htc-626s-to-lollipop-t3460391
:good:
2) Download the Kernel Source Code from the HTC-DEV Site.
http://www.htcdev.com/devcenter/downloads
If you use the filter for device and select desire 626s you will see only the 626s kernel sources.
The device I have = HTC Desire 626s (a32eul) " Carrier Metro-PCS"
The Kernel Source I am using.
Device= Desire626s Carrier=HTC Region= Gen Unlock Type=CRC
Kernel Version=3.10.49 Android Version=v5.1 Size=548 MB Description=1.06.617.6
Backup the device boot.img & Unpack / Split the kernel + ramdisk + dt.img.
Now we are all on the same page. " Same Setup Fresh Install "
Lets get down to business.
I'm going to go through the steps that I use. If you plan to work along with this project I recommend that you keep the same directory structure that I have. This way all the commands I give you will work. You may wish to change the directory structure but if you do.... remember you will need to adjust the commands accordingly.
So from a brand new fresh install.
#1 install twrp recovery
#2 install supersu
#3 Open supersu on phone
#4 Make sure usb debugging is turned on ect. ect. ect.
#5 Lets get the boot.img from the device.
Connect the device to the computer
From this point forward all commands are executed in the Linux terminal shell.
Code:
adb shell
Code:
su
Copy boot partition to the external sd card.
Code:
dd if=/dev/block/bootdevice/by-name/boot of=sdcard2/Boot.img
Pull the boot.img to the computer.
If still in adb shell exit out.
Code:
exit
exit
adb pull /sdcard2/Boot.img
#6 Setup some directories and move the boot.img into our project.
Code:
mkdir ~/a32e-kernel-build/
mkdir ~/a32e-kernel-build/Device-Files/
mkdir ~/a32e-kernel-build/Device-Files/Boot
mkdir ~/a32e-kernel-build/Tools
mkdir ~/a32e-kernel-build/Tools/AIK-Linux/
mv Boot.img ~/a32e-kernel-build/Device-Files/Boot
cd ~/a32e-kernel-build/Tools/AIK-Linux/
cp ~/a32e-kernel-build/Device-Files/Boot/Boot.img ~/a32e-kernel-build/Tools/AIK-Linux/
#7 We need AIK-Linux boot tools. Download them from the link below.
http://forum.xda-developers.com/showthread.php?t=2073775
Please do use these bootimg tools. You might have others but AIK-Linux unpacks and repacks the image files as "ROOT".
Using other tools or not unpacking / repacking as ROOT will cause a bootloop specifically in Marshmallow even if the boot.img is good.
Code:
mv ~/Downloads/AIK-Linux-v2.4-ALL.tar.gz ~/a32e-kernel-build/Tools/AIK-Linux
tar -xvzf ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux-v2.4-ALL.tar.gz
rm -f ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux-v2.4-ALL.tar.gz
mv -v ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux/* ~/a32e-kernel-build/Tools/AIK-Linux/
rm -d ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux
Ok I know ????????
You want to know what we need the boot image for anyway !!
The a32e_defconfig file that comes with the HTC-DEV source code is not the exact configuration that HTC used when they built the kernel.
We want to start out with the same configuration RIGHT!!
Yes we do...... and after we have a verified working Kernel.......then we can start making changes.
In a nutshell /proc/config.gz will not work to pull the existing configuration. HTC did not enable that option. Lucky for us there is another way to generate the configuration file & that's reason #1 that we need the boot.img. There is another reason but we will get to that later. ( Other than having a Backup of the boot.img LOL. )
#8 Unpack the boot.img
Code:
sudo ./unpackimg.sh Boot.img
Make sure you use "sudo" it is nessessary.
The output should be
~/a32e-kernel-build/Tools/AIK-Linux$ sudo ./unpackimg.sh Boot.img
Android Image Kitchen - UnpackImg Script
by osm0sis @ xda-developers
Supplied image: MM-Boot.img
Removing old work folders and files...
Setting up work folders...
Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk vmalloc=400m androidboot.selinux=enforcing androidboot.hardware=htc_a32e androidusb.pid=0x0668
BOARD_KERNEL_BASE 80000000
BOARD_NAME boot:0
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02000000
BOARD_TAGS_OFFSET 01e00000
BOARD_DT_SIZE 731136
Unpacking ramdisk to "ramdisk/"...
Compression used: gzip
6560 blocks
Done!
#9 Move our unpacked boot.img to our project folder.
Code:
sudo mv ramdisk ~/a32e-kernel-build/Device-Files/Boot/
sudo mv split_img ~/a32e-kernel-build/Device-Files/Boot/
sudo cp ~/a32e-kernel-build/Device-Files/Boot/split_img/Boot.img-dtb ~/a32e-kernel-build/Device-Files/Boot/Boot.img-dtb
sudo cp ~/a32e-kernel-build/Device-Files/Boot/split_img/Boot.img-zImage ~/a32e-kernel-build/Device-Files/Boot/Boot.img-zImage
sudo cp ~/a32e-kernel-build/Device-Files/Boot/Boot.img-zImage ~/a32e-kernel-build/Device-Files/Boot/kernel
Getting Running Kernel Configuration
#1 Lets get the current running Kernel Version
Code:
cd ~/a32e-kernel-build/Device-Files/Boot/
Code:
dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
My output is as follows.
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.7 (GCC) ) #2 SMP PREEMPT Sat Oct 31 02:35:36 CST 2015
7202481+0 records in
7202481+0 records out
7202481 bytes (7.2 MB, 6.9 MiB) copied, 5.4281 s, 1.3 MB/s
Hopefully you see or know why this is important to us.
In order for our new kernel to load and not reject existing modules the version of the new kernel must match.
Linux version 3.10.49-perf-g26c2269
And also the 26c2269 is the number we need,
to match the exact commit of the source code that this specific kernel was built upon.
In theory when we checkout a branch and that would be used as part of the tag.
Right now the most important thing to us is the "-perf"
And the ".-g26c2269"
We will need those soon.
Now lets get that .config / a32e_defconfig file.
Wayy back in step number 2 of the 1st post you were supposed to get the HTC-DEV Kernel source.
If you didn't it's time we need it now.
http://www.htcdev.com/devcenter/downloads
When you get to the HTC-DEV download page just filter by device and select desire 626s.
#1 Set Up Basic HTC-DEV Source Directory Structure
Code:
cd
mkdir ~/android
mkdir ~/android/device
mkdir ~/android/device/a32e
mkdir ~/android/device/a32e/platform
#2 Setup the Kernel Source
Code:
mv ~/Downloads/a32eul-3.10.49-perf-ga4d7327.zip ~/android/device/a32e/a32eul-3.10.49-perf-ga4d7327.zip
unzip ~/android/device/a32e/a32eul-3.10.49-perf-ga4d7327.zip -d ~/android/device/a32e/
rm -f ~/android/device/a32e/a32eul-3.10.49-perf-ga4d7327.zip
cd ~/android/device/a32e/
tar -xvzf ~/android/device/a32e/248_kernel_a32eul-3.10.49-perf-ga4d7327.tar.gz
rm ~/android/device/a32e/248_kernel_a32eul-3.10.49-perf-ga4d7327.tar.gz
mv -v ~/android/device/a32e/248_kernel_a32eul-3.10.49-perf-ga4d7327/* ~/android/device/a32e/
rm -rf ~/android/device/a32e/248_kernel_a32eul-3.10.49-perf-ga4d7327
mv ~/android/device/a32e/platform.tar.gz ~/android/device/a32e/platform/
#3 Pull the config from the kernel
Code:
cd ~/android/device/a32e/scripts/
./extract-ikconfig ~/a32e-kernel-build/Device-Files/Boot/Boot.img-zImage > Big-Country_defconfig
mv -f Big-Country_defconfig ~/android/device/a32e/arch/arm/configs
mkdir ~/a32e-kernel-build/Device-Files/Configs/ORIGINAL/
cp -f ~/android/device/a32e/arch/arm/configs/Big-Country_defconfig ~/a32e-kernel-build/Device-Files/Configs/ORIGINAL/
Open up the Big-Country_defconfig
It is in the folder ~/android/device/a32e/arch/arm/configs
Open it with G-Edit or whatever text editor you use.
Search for CONFIG_LOCALVERSION=
and change it to CONFIG_LOCALVERSION="-g26c2269"
Open up the main makefile. in the folder ~/android/device/a32e/Makefile
VERSION = 3
PATCHLEVEL = 10
SUBLEVEL = 49
EXTRAVERSION =
NAME = TOSSUG Baby Fish
At the top of the file change EXTRAVERSION =
EXTRAVERSION = -perf
Now lets backup the edited Big-Country_defconfig.
Code:
cp -f ~/android/device/a32e/arch/arm/configs/Big-Country_defconfig ~/a32e-kernel-build/Device-Files/
Now were cooking.
Preparing and Building the Kernel
#1 Get the GCC Toolchain
First if you have a dev environment set up you should have a repo set up.
If not go to aosp site to see how yo set up a repo.
https://source.android.com/source/downloading.html
Then get the toolchain
Code:
cd
mkdir ~/android/Toolchains
mkdir ~/android/Toolchains/prebuilts
cd ~/android/Toolchains/prebuilts
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
Were gonna use the 4.8 toolchain.
[email protected]:~/android/Toolchains/prebuilts$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
Cloning into 'arm-eabi-4.8'...
remote: Sending approximately 28.69 MiB ...
remote: Counting objects: 158, done
remote: Finding sources: 100% (158/158)
remote: Total 354 (delta 71), reused 354 (delta 71)
Receiving objects: 100% (354/354), 28.74 MiB | 2.09 MiB/s, done.
Resolving deltas: 100% (71/71), done.
Checking connectivity... done.
#2 Initialize the Kernel Build
Go to the home path of the kernel
Code:
cd
cd ~/android/device/a32e/
Export the required variables.
Code:
export TOP=~/android/Toolchains/
export PATH=$TOP/prebuilts/arm-eabi-4.8/bin:$PATH
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=~/android/Toolchains/prebuilts/arm-eabi-4.8/bin/arm-eabi-
Clean out any old left over stuff from previous builds.
Code:
make clean
make mrproper
Dont worry about this warning it's not a problem.
/home/bigcountry/android/device/a32e/arch/arm/boot/dts/Makefile:228: warning: overriding recipe for target `dtbs'
/home/bigcountry/android/device/a32e/arch/arm/boot/dts/Makefile:228: warning: ignoring old recipe for target `dtbs'
Initialize the configuration for our device.
Code:
make Big-Country_defconfig
This warning is also ok.
In file included from scripts/kconfig/zconf.tab.c:2503:0:
scripts/kconfig/menu.c: In function ‘get_symbol_str’:
scripts/kconfig/menu.c:567:18: warning: ‘jump’ may be used uninitialized in this function [-Wmaybe-uninitialized]
jump->offset = r->len - 1;
^
scripts/kconfig/menu.c:528:19: note: ‘jump’ was declared here
struct jump_key *jump;
^
If your curious and want to see how many settings there are.
Just don't change anything for the first run.
Code:
make menuconfig
Were ready to compile
set -j to the number of cores your computer has.
Code:
make prepare
make all -j8
In about 5 min or less you will have a compiled kernel.
after you see the zimage output message
The last 2 lines output from the build.
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Code:
make modules -j8
Then you should see:
[email protected]:~/android/device/a32e$ make modules -j8
CHK include/generated/uapi/linux/version.h
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
Building modules, stage 2.
MODPOST 24 modules
During the build:
You will see 1 warning message for an uninitialized jump.
And 4 warning messages about relying on default adress.
Thats the broken dtb issue.
No worry for now. We will repack the boot.img with the new kernel zImage and use the original dt.img.
Good enough for this test.
Also as i mentioned we have to build the wifi module out of the tree.
We will get to that. So in this state the kernel will boot and the device functions with exception to wifi.
Remember this run is just to test the baseline system and source code.
Packing The Kernel Into Boot.img
First lets backup our kernel config files.
Code:
mkdir ~/a32e-kernel-build/Device-Files/Configs
cp -f ~/android/device/a32e/.config ~/a32e-kernel-build/Device-Files/Configs
cp -f ~/android/device/a32e/.config.old ~/a32e-kernel-build/Device-Files/Configs
cp -f ~/android/device/a32e/arch/arm/configs/Big-Country_defconfig ~/a32e-kernel-build/Device-Files/Configs
Now lets copy all the modules and kernel z-image we built.
Code:
mkdir ~/a32e-kernel-build/Device-Files/zimage
mkdir ~/a32e-kernel-build/Device-Files/modules
cp -f ~/android/device/a32e/arch/arm/boot/zImage ~/a32e-kernel-build/Device-Files/zimage/kernel
cp -f ~/android/device/a32e/arch/arm/boot/zImage-dtb ~/a32e-kernel-build/Device-Files/
shopt -s globstar
cp **/*.ko ~/a32e-kernel-build/Device-Files/modules/
Compare the new kernel version to the original version.
Code:
cd ~/a32e-kernel-build/Device-Files/zimage
dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
Code:
cd ~/a32e-kernel-build/Device-Files/Boot/
dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
Output Comparison On My System
[email protected]:~/a32e-kernel-build/Device-Files$ cd ~/a32e-kernel-build/Device-Files/zimage
[email protected]:~/a32e-kernel-build/Device-Files/zimage$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Sat Oct 1 11:53:51 EDT 2016
7162737+0 records in
7162737+0 records out
7162737 bytes (7.2 MB, 6.8 MiB) copied, 5.16669 s, 1.4 MB/s
[email protected]:~/a32e-kernel-build/Device-Files/zimage$ cd ~/a32e-kernel-build/Device-Files/Boot/
[email protected]:~/a32e-kernel-build/Device-Files/Boot$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.7 (GCC) ) #2 SMP PREEMPT Sat Oct 31 02:40:46 CST 2015
7202505+0 records in
7202505+0 records out
7202505 bytes (7.2 MB, 6.9 MiB) copied, 4.70855 s, 1.5 MB/s
[email protected]:~/a32e-kernel-build/Device-Files/Boot$
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Sat Oct 1 11:53:51 EDT 2016
Linux version 3.10.49-perf-g26c2269 ([email protected]) (gcc version 4.7 (GCC) ) #2 SMP PREEMPT Sat Oct 31 02:40:46 CST 2015
Linux version 3.10.49-perf-g26c2269 MATCHES.
Repack the Boot Image.
For now we are just using the original ramdisk and original dt.img.
Later on we will make some changes and then repack.
Were just making sure things boot first.
We have to do this as root.
Code:
sudo
Copy all files needed to AIK Linux for Repacking.
Code:
sudo cp -r ~/a32e-kernel-build/Device-Files/Boot/ramdisk ~/a32e-kernel-build/Tools/AIK-Linux/ramdisk
sudo cp -r ~/a32e-kernel-build/Device-Files/Boot/split_img ~/a32e-kernel-build/Tools/AIK-Linux/split_img
sudo cp -f ~/android/device/a32e/arch/arm/boot/zImage ~/a32e-kernel-build/Tools/AIK-Linux/split_img/Boot.img-zImage
Repack the Boot.img.
Code:
cd ~/a32e-kernel-build/Tools/AIK-Linux
sudo ./repackimg.sh
Yaaayyyy Now we have a boot.img we can flash. (For Testing / Developing Only)
Copy the boot image to our project.
Code:
mkdir ~/a32e-kernel-build/Device-Files/New-Boot
sudo cp -f ~/a32e-kernel-build/Tools/AIK-Linux/image-new.img ~/a32e-kernel-build/Device-Files/New-Boot/image-new.img
Flashing the New Boot Image
Flash and test Boot the new Kernel
#1 Boot the phone into download mode
Connect the device to the computer
Boot into download mode using the power and volume down key after turning off the device.
Or boot to download mode using adb.
Code:
adb reboot download
#2 Flash the boot image
Code:
cd ~/a32e-kernel-build/Device-Files/New-Boot/
fastboot flash boot image-new.img
Output is
[email protected]:~/a32e-kernel-build/Device-Files/New-Boot$ fastboot flash boot image-new.img
target reported max download size of 725000000 bytes
sending 'boot' (10476 KB)...
OKAY [ 1.877s]
writing 'boot'...
(bootloader) HOSD CL#637541
(bootloader) [email protected]
(bootloader) [email protected]%
(bootloader) Update partition OK
(bootloader) [email protected]
OKAY [ 2.759s]
finished. total time: 4.636s
Reboot the phone and test it out
I am happy to say that WIFI is working WE are Building the Prima Module
.
Building Proprietary Modules / Not Included in the Source
Adding the New Modules
All 24 of the modules currently being compiled are Tested and Work.
Please carefully install the modules as I demonstrate here.
Do not execute commands against the /system/lib/modules/ using wildcards.
#1 Get rid of any old modules created by previous compiles.
Code:
rm -f ~/a32e-kernel-build/Device-Files/modules/*.ko
#2 Copy our new modules from the source compile
Code:
cp ~/android/device/a32e/crypto/ansi_cprng.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/evbug.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/spi/spidev.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/fs/ecryptfs/ecryptfs.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/gud/mcDrvModule.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/gud/mcKernelApi.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/arch/arm/mach-msm/dma_test.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_axis.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/usb/host/ice40-hcd.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_event.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_input.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_matrix.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_output.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_oobtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_pagetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_readtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_speedtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_stresstest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_nandbiterrs.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_nandecctest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_subpagetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_torturetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/media/radio/radio-iris-transport.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/platform/msm/msm_bus/msm-buspm-dev.ko ~/a32e-kernel-build/Device-Files/modules/
#3 Create a modules directory on the external sd card
Code:
adb shell "su -c 'mkdir /sdcard2/modules/'"
#4 Erase old modules from sd card if there are any
Code:
adb shell "su -c 'rm -f /sdcard2/modules/*.ko'"
#5 Copy the new modules to the sd card
Code:
adb push ~/a32e-kernel-build/Device-Files/modules/ansi_cprng.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/dma_test.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/ecryptfs.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/evbug.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_axis.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_event.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_input.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_matrix.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_output.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/ice40-hcd.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mcDrvModule.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mcKernelApi.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/msm-buspm-dev.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_nandbiterrs.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_nandecctest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_oobtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_pagetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_readtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_speedtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_stresstest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_subpagetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_torturetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/radio-iris-transport.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/spidev.ko /sdcard2/modules/
#6 Connect the phone and start shell
Code:
adb shell
su
#7 Delete the existing modules from the device
Code:
mount -o rw,remount,rw /system
Code:
rm -rf /system/lib/modules/ansi_cprng.ko
rm -rf /system/lib/modules/dma_test.ko
rm -rf /system/lib/modules/ecryptfs.ko
rm -rf /system/lib/modules/evbug.ko
rm -rf /system/lib/modules/gpio_axis.ko
rm -rf /system/lib/modules/gpio_event.ko
rm -rf /system/lib/modules/gpio_input.ko
rm -rf /system/lib/modules/gpio_matrix.ko
rm -rf /system/lib/modules/gpio_output.ko
rm -rf /system/lib/modules/ice40-hcd.ko
rm -rf /system/lib/modules/mcDrvModule.ko
rm -rf /system/lib/modules/mcKernelApi.ko
rm -rf /system/lib/modules/msm-buspm-dev.ko
rm -rf /system/lib/modules/mtd_nandbiterrs.ko
rm -rf /system/lib/modules/mtd_nandecctest.ko
rm -rf /system/lib/modules/mtd_oobtest.ko
rm -rf /system/lib/modules/mtd_pagetest.ko
rm -rf /system/lib/modules/mtd_readtest.ko
rm -rf /system/lib/modules/mtd_speedtest.ko
rm -rf /system/lib/modules/mtd_stresstest.ko
rm -rf /system/lib/modules/mtd_subpagetest.ko
rm -rf /system/lib/modules/mtd_torturetest.ko
rm -rf /system/lib/modules/radio-iris-transport.ko
rm -rf /system/lib/modules/spidev.ko
#7 Copy the new modules to the device
Code:
cp -rf /sdcard2/modules/ansi_cprng.ko /system/lib/modules
cp -rf /sdcard2/modules/dma_test.ko /system/lib/modules
cp -rf /sdcard2/modules/ecryptfs.ko /system/lib/modules
cp -rf /sdcard2/modules/evbug.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_axis.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_event.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_input.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_matrix.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_output.ko /system/lib/modules
cp -rf /sdcard2/modules/ice40-hcd.ko /system/lib/modules
cp -rf /sdcard2/modules/mcDrvModule.ko /system/lib/modules
cp -rf /sdcard2/modules/mcKernelApi.ko /system/lib/modules
cp -rf /sdcard2/modules/msm-buspm-dev.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_nandbiterrs.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_nandecctest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_oobtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_pagetest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_readtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_speedtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_stresstest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_subpagetest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_torturetest.ko /system/lib/modules
cp -rf /sdcard2/modules/radio-iris-transport.ko /system/lib/modules
cp -rf /sdcard2/modules/spidev.ko /system/lib/modules
#8 Set the correct permissions
Code:
chmod 0644 /system/lib/modules/ansi_cprng.ko
chmod 0644 /system/lib/modules/dma_test.ko
chmod 0644 /system/lib/modules/ecryptfs.ko
chmod 0644 /system/lib/modules/evbug.ko
chmod 0644 /system/lib/modules/gpio_axis.ko
chmod 0644 /system/lib/modules/gpio_event.ko
chmod 0644 /system/lib/modules/gpio_input.ko
chmod 0644 /system/lib/modules/gpio_matrix.ko
chmod 0644 /system/lib/modules/gpio_output.ko
chmod 0644 /system/lib/modules/ice40-hcd.ko
chmod 0644 /system/lib/modules/mcDrvModule.ko
chmod 0644 /system/lib/modules/mcKernelApi.ko
chmod 0644 /system/lib/modules/msm-buspm-dev.ko
chmod 0644 /system/lib/modules/mtd_nandbiterrs.ko
chmod 0644 /system/lib/modules/mtd_nandecctest.ko
chmod 0644 /system/lib/modules/mtd_oobtest.ko
chmod 0644 /system/lib/modules/mtd_pagetest.ko
chmod 0644 /system/lib/modules/mtd_readtest.ko
chmod 0644 /system/lib/modules/mtd_speedtest.ko
chmod 0644 /system/lib/modules/mtd_stresstest.ko
chmod 0644 /system/lib/modules/mtd_subpagetest.ko
chmod 0644 /system/lib/modules/mtd_torturetest.ko
chmod 0644 /system/lib/modules/radio-iris-transport.ko
chmod 0644 /system/lib/modules/spidev.ko
Reboot the device and you will be running the newly compiled modules.
Proprietary Modules
Building Proprietary Modules / Not Included in the Source
Lets take a look at the modules that did not build.
-rw-r--r-- root root 137370 2015-10-30 14:45 core_ctl.ko
lrw-r--r-- root root 2015-10-30 14:43 crypto_test_mod.ko -> crypto_test_mod.ko.3.10
-rw-r--r-- root root 287076 2015-10-30 14:43 crypto_test_mod.ko.3.10
lrw-r--r-- root root 2015-10-30 14:43 moc_crypto.ko -> moc_crypto.ko.3.10
-rw-r--r-- root root 510307 2015-10-30 14:43 moc_crypto.ko.3.10
-rw-r--r-- root root 40 2015-10-30 14:43 moc_crypto.ko.sig.3.10
lrw-r--r-- root root 2015-10-30 14:43 moc_crypto_api_tmpl.ko -> moc_crypto_api_tmpl.ko.3.10
-rw-r--r-- root root 176510 2015-10-30 14:43 moc_crypto_api_tmpl.ko.3.10
lrw-r--r-- root root 2015-10-30 14:43 moc_platform_mod.ko -> moc_platform_mod.ko.3.10
-rw-r--r-- root root 8541 2015-10-30 14:42 moc_platform_mod.ko.3.10
-rw-r--r-- root root 258697 2015-10-30 14:41 texfat.ko
lrw-r--r-- root root 2015-10-30 14:34 wlan.ko -> /system/lib/modules/pronto/pronto_wlan.ko
These are the modules we need to fix / get source for.
#1 core_ctl.ko
#2 crypto_test_mod.ko.3.10
#3 moc_crypto.ko.3.10
#4 moc_crypto.ko.sig.3.10
#5 moc_crypto_api_tmpl.ko.3.10
#6 moc_platform_mod.ko.3.10
#7 texfat.ko
#8 /system/lib/modules/pronto/pronto_wlan.ko
These modules require the following symlinks.
#1 crypto_test_mod.ko -> crypto_test_mod.ko.3.10
#2 moc_crypto.ko -> moc_crypto.ko.3.10
#3 moc_crypto_api_tmpl.ko -> moc_crypto_api_tmpl.ko.3.10
#4 moc_platform_mod.ko -> moc_platform_mod.ko.3.10
#5 wlan.ko -> /system/lib/modules/pronto/pronto_wlan.ko
Who is Who and What is What
This is the prima/pronto wireless net driver.
/system/lib/modules/pronto/pronto_wlan.ko
We will need to get source code for this module to build it.
The Mocana Cryptographic Loadable Kernel Module
crypto_test_mod.ko.3.10
moc_crypto.ko.3.10
moc_crypto.ko.sig.3.10
moc_crypto_api_tmpl.ko.3.10
moc_platform_mod.ko.3.10
http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1903.pdf
We will need to get source code from somewhere.
This I believe is a Qualcomm Module for the MSM8909 Board
core_ctl.ko
We will need to figure this one out.
This Is for large sd card support
texfat.ko
We will need to figure this one out.
So far with our extraversion and localversion settings during compile the original modules still work.
Long term we really want to be able to build theese
Building the Prima WIFI Module.
SEE INSTRUCTIONS ON THE NEXT PAGE
Building the msm_core_ctl module .
Export sched_setscheduler_nocheck() so that external kernel modules can use it.
A) Open ~/android/device/a32e/kernel/sched/core.c in a text editor
Search for do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
It is about line number 4239
add
Code:
EXPORT_SYMBOL(sched_setscheduler_nocheck);
The file should look like this
Code:
return __sched_setscheduler(p, &attr, false);
}
[COLOR="Green"][SIZE="4"]EXPORT_SYMBOL(sched_setscheduler_nocheck);[/SIZE][/COLOR]
static int
do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
Save and close the file.
ADD THE MODULE TO BUILD FILES
B) Open ~/android/device/a32e/drivers/soc/qcom/Kconfig in a text editor
config MSM_CORE_CTL_HELPER
It is about line number 558
add
Code:
config MSM_CORE_CTL
tristate "Core control module"
help
Add support for the Qualcomm core control module
The file should look like this
Code:
config MSM_PACMAN
bool "Enable the Peripheral Access Control Manager (PACMan)"
help
Add support for the Peripheral Access Control Manager (PACMan)
This driver allows reconfiguration of the Bus Access Manager
Low Speed Peripheral (BLSP) ownership.
[COLOR="Green"][SIZE="4"]config MSM_CORE_CTL
tristate "Core control module"
help
Add support for the Qualcomm core control module[/SIZE][/COLOR]
config MSM_CORE_CTL_HELPER
tristate "Core control helper functions for dynamically hotplug CPUs"
help
Provide helper functions for core control driver. Core control
driver dynamicatlly hotplugs CPUs from kernel based on current
system load and state. It also supports limiting min and
max online CPUs from userspace.
Save and close the file.
C) Open ~/android/device/a32e/drivers/soc/qcom/Makefile in a text editor
Search for obj-$(CONFIG_MSM_CORE_CTL_HELPER) += core_ctl_helper.o
It is about line number 62
add
Code:
obj-$(CONFIG_MSM_CORE_CTL) += msm_core_ctl.o
msm_core_ctl-objs := core_ctl_$(ARCH).o
The file should look like this
Code:
obj-$(CONFIG_MSM_PERFORMANCE) += msm_performance.o
[COLOR="Green"]obj-$(CONFIG_MSM_CORE_CTL) += msm_core_ctl.o
msm_core_ctl-objs := core_ctl_$(ARCH).o[/COLOR]
obj-$(CONFIG_MSM_CORE_CTL_HELPER) += core_ctl_helper.o
Save and close the file.
D) Open ~/android/device/a32e/arch/arm/configs/Prima_Big-Country_defconfig in a text editor
Search for CONFIG_MSM_CORE_CTL_HELPER
It is about line number 3471
add
Code:
CONFIG_MSM_CORE_CTL=m
CONFIG_MSM_CORE_CTL_HELPER=y
The file should look like this
Code:
# CONFIG_MSM_SHARED_HEAP_ACCESS is not set
# CONFIG_MSM_SYSTEM_HEALTH_MONITOR is not set
# CONFIG_QCOM_EARLY_RANDOM is not set
# CONFIG_MSM_PACMAN is not set
[COLOR="DarkGreen"]CONFIG_MSM_CORE_CTL=m
CONFIG_MSM_CORE_CTL_HELPER=y[/COLOR]
# CONFIG_MSM_PERFORMANCE is not set
CONFIG_HTC_DEBUG_RIL_PCN0002_DUMP_STACK=y
CONFIG_HTC_DEBUG_RIL_PCN0005_HTC_DUMP_SMSM_LOG=y
CONFIG_HTC_DEBUG_RIL_PCN0006_HTC_DUMP_BAM_DMUX_LOG=y
CONFIG_MEM_SHARE_QMI_SERVICE=y
Save and close the file.
E) DOWNLOAD THE SOURCE FILE.
https://drive.google.com/open?id=0B8jitdIyh2NtNjU3NFBIcU1NY0k
Copy the source to the TREE.
Code:
cp -rf ~/Downloads/core_ctl_arm.o_shipped /android/device/a32e/drivers/soc/qcom/core_ctl_arm.o_shipped
Now Go to the Build Prima Module Section on the next page and follow all instructions.
DE-Compile The Factory DT.img To DTB & DTS
How to Compile The Prima / (" PRONTO ") Wlan Module -->>> IN KERNEL TREE
# 1 ) Get the required Source Code ( DOWNLOAD HERE ) or attached to the DEVDB.
https://drive.google.com/open?id=0B8jitdIyh2NtMzB2a2pNeU1iWDg
#2 ) Add it to our Project & Kernel Source Tree
Code:
mkdir ~/a32e-kernel-build/Qualcom-Vendor-Opensource/
mv ~/Downloads/qualcom-vendor-opensource.zip ~/a32e-kernel-build/Qualcom-Vendor-Opensource/
unzip ~/a32e-kernel-build/Qualcom-Vendor-Opensource/qualcom-vendor-opensource.zip -d ~/a32e-kernel-build/Qualcom-Vendor-Opensource/
rm -rf ~/a32e-kernel-build/Qualcom-Vendor-Opensource/qualcom-vendor-opensource.zip
cp -rf ~/a32e-kernel-build/Qualcom-Vendor-Opensource/vendor/qcom/opensource/wlan/prima ~/android/device/a32e/drivers/staging/prima
#2 ) Configure The Module to build in the Kernel Source Tree
A) Open in a text Editor ~/android/device/a32e/drivers/staging/prima/Kconfig
Add to the bottom of the file:
Code:
[COLOR="SeaGreen"][SIZE="4"]config WLAN_OFFLOAD_PACKETS
bool "Enable offload packets feature"
default n[/SIZE][/COLOR]
[COLOR="SeaGreen"][SIZE="4"]config QCOM_TDLS
bool "Enable TDLS (Tunnel Direct Link Setup) feature"
default n[/SIZE][/COLOR]
Or download my Kconfig file
https://drive.google.com/open?id=0B8jitdIyh2Ntc0p6UFNlTGxJNkU
Copy the file to the tree. ( ONLY IF YOU DOWNLOADED IT )
Code:
mv ~/Downloads/Kconfig ~/android/device/a32e/drivers/staging/prima/Kconfig
B) Open in a text Editor ~/android/device/a32e/drivers/staging/Kconfig
Add to the bottom of the file:
Code:
[COLOR="SeaGreen"][SIZE="4"]source "drivers/staging/prima/Kconfig"[/SIZE][/COLOR]
C ) Open in a text Editor ~/android/device/a32e/drivers/staging/Makefile
Add to the bottom of the file:
Code:
[COLOR="SeaGreen"][SIZE="4"]
obj-$(CONFIG_PRIMA_WLAN) += prima/
obj-$(CONFIG_PRONTO_WLAN) += prima/
[/SIZE][/COLOR]
#4 ) Edit the Big-Country_defconfig File
I have made several Changes - USE THIS DOWNLOAD for now.
https://drive.google.com/open?id=0B8jitdIyh2NtZ3VtTTV6Z3dhb0E
Copy the new config to the tree
Code:
cp ~/Downloads/Prima_Big-Country_defconfig ~/android/device/a32e/arch/arm/configs/Prima_Big-Country_defconfig
#4 ) Compile the Kernel and it will build the wlan.ko
Code:
[SIZE="4"][COLOR="DarkGreen"]cd
cd ~/android/device/a32e/
export TOP=~/android/Toolchains/
export PATH=$TOP/prebuilts/arm-eabi-4.8/bin:$PATH
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=~/android/Toolchains/prebuilts/arm-eabi-4.8/bin/arm-eabi-
make clean
make mrproper
make Prima_Big-Country_defconfig
make prepare
make all -j8
make modules[/COLOR][/SIZE]
You Should see this output.
[email protected]:~/android/device/a32e$ make modules
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
Building modules, stage 2.
MODPOST 26 modules
Now we have 26 modules instead of 24.
A new wlan.ko which will get renamed to pronto_wlan.ko.
We also have the WCNSS file for the wlan.
Code:
[SIZE="4"][COLOR="Blue"]
~/android/device/a32e/drivers/staging/prima/wlan.ko
~/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_cfg.dat
~/bigcountry/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_qcom_cfg.ini
~/bigcountry/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_qcom_wlan_nv.bin
~/android/device/a32e/drivers/bluetooth/bluetooth-power.ko
[/COLOR][/SIZE]
Now we are ready to load the new Kernel and Modules
load the new Kernel
Code:
sudo cp -r ~/a32e-kernel-build/Device-Files/Boot/ramdisk ~/a32e-kernel-build/Tools/AIK-Linux/ramdisk
Code:
sudo cp -r ~/a32e-kernel-build/Device-Files/Boot/split_img ~/a32e-kernel-build/Tools/AIK-Linux/split_img
Code:
sudo cp -f ~/android/device/a32e/arch/arm/boot/zImage ~/a32e-kernel-build/Tools/AIK-Linux/split_img/Boot.img-zImage
Code:
cd ~/a32e-kernel-build/Tools/AIK-Linux
sudo ./repackimg.sh
sudo cp -f ~/a32e-kernel-build/Tools/AIK-Linux/image-new.img ~/a32e-kernel-build/Device-Files/New-Boot/image-new.img
adb reboot download
sleep 10s
cd ~/a32e-kernel-build/Device-Files/New-Boot/
fastboot flash boot image-new.img
echo ""
echo ""
echo "Finished Flashing Kernel"
read -p "Press [Enter] to Reboot..."
fastboot reboot
Clean out our project directory.
Code:
rm -f ~/a32e-kernel-build/Device-Files/modules/*.ko
Copy compiled modules to our project directory.
Code:
cp ~/android/device/a32e/drivers/staging/prima/wlan.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_cfg.dat ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_qcom_cfg.ini ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/staging/prima/firmware_bin/WCNSS_qcom_wlan_nv.bin ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/bluetooth/bluetooth-power.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/crypto/ansi_cprng.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/evbug.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/spi/spidev.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/fs/ecryptfs/ecryptfs.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/gud/mcDrvModule.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/gud/mcKernelApi.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/arch/arm/mach-msm/dma_test.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_axis.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/usb/host/ice40-hcd.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_event.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_input.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_matrix.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/input/misc/gpio_output.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_oobtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_pagetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_readtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_speedtest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_stresstest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_nandbiterrs.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_nandecctest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_subpagetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/mtd/tests/mtd_torturetest.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/media/radio/radio-iris-transport.ko ~/a32e-kernel-build/Device-Files/modules/
cp ~/android/device/a32e/drivers/platform/msm/msm_bus/msm-buspm-dev.ko ~/a32e-kernel-build/Device-Files/modules/
Clean the sdcard temporary directory.
Code:
adb shell "su -c 'rm -f /sdcard2/modules/*.ko'"
Copy the new modules to the sd card temp directory.
Code:
adb push ~/a32e-kernel-build/Device-Files/modules/wlan.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/WCNSS_cfg.dat /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/WCNSS_qcom_cfg.ini /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/WCNSS_qcom_wlan_nv.bin /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/bluetooth-power.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/ansi_cprng.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/dma_test.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/ecryptfs.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/evbug.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_axis.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_event.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_input.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_matrix.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/gpio_output.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/ice40-hcd.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mcDrvModule.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mcKernelApi.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/msm-buspm-dev.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_nandbiterrs.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_nandecctest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_oobtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_pagetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_readtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_speedtest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_stresstest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_subpagetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/mtd_torturetest.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/radio-iris-transport.ko /sdcard2/modules/
adb push ~/a32e-kernel-build/Device-Files/modules/spidev.ko /sdcard2/modules/
NOW connect the device and start a shell
Code:
adb shell
su
Re-Mount System as Read Write.
Code:
mount -o rw,remount,rw /system
Remove the existing modules from the device .
Code:
rm -rf /system/lib/modules/wlan.ko
rm -rf /system/lib/modules/pronto/pronto_wlan.ko
rm -rf /system/etc/firmware/wlan/prima/WCNSS_cfg.dat
rm -rf /system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini
rm -rf /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
rm -rf /system/lib/modules/bluetooth-power.ko
rm -rf /system/lib/modules/ansi_cprng.ko
rm -rf /system/lib/modules/dma_test.ko
rm -rf /system/lib/modules/ecryptfs.ko
rm -rf /system/lib/modules/evbug.ko
rm -rf /system/lib/modules/gpio_axis.ko
rm -rf /system/lib/modules/gpio_event.ko
rm -rf /system/lib/modules/gpio_input.ko
rm -rf /system/lib/modules/gpio_matrix.ko
rm -rf /system/lib/modules/gpio_output.ko
rm -rf /system/lib/modules/ice40-hcd.ko
rm -rf /system/lib/modules/mcDrvModule.ko
rm -rf /system/lib/modules/mcKernelApi.ko
rm -rf /system/lib/modules/msm-buspm-dev.ko
rm -rf /system/lib/modules/mtd_nandbiterrs.ko
rm -rf /system/lib/modules/mtd_nandecctest.ko
rm -rf /system/lib/modules/mtd_oobtest.ko
rm -rf /system/lib/modules/mtd_pagetest.ko
rm -rf /system/lib/modules/mtd_readtest.ko
rm -rf /system/lib/modules/mtd_speedtest.ko
rm -rf /system/lib/modules/mtd_stresstest.ko
rm -rf /system/lib/modules/mtd_subpagetest.ko
rm -rf /system/lib/modules/mtd_torturetest.ko
rm -rf /system/lib/modules/radio-iris-transport.ko
rm -rf /system/lib/modules/spidev.ko
Copy the New Compiled Modules to the device .
Code:
cp -rf /sdcard2/modules/wlan.ko /system/lib/modules/pronto/pronto_wlan.ko
cp -rf /sdcard2/modules/WCNSS_cfg.dat /system/etc/firmware/wlan/prima/
cp -rf /sdcard2/modules/WCNSS_qcom_cfg.ini /system/etc/firmware/wlan/prima/
cp -rf /sdcard2/modules/WCNSS_qcom_wlan_nv.bin /system/etc/firmware/wlan/prima/
cp -rf /sdcard2/modules/bluetooth-power.ko /system/lib/modules/
cp -rf /sdcard2/modules/ansi_cprng.ko /system/lib/modules
cp -rf /sdcard2/modules/dma_test.ko /system/lib/modules
cp -rf /sdcard2/modules/ecryptfs.ko /system/lib/modules
cp -rf /sdcard2/modules/evbug.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_axis.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_event.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_input.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_matrix.ko /system/lib/modules
cp -rf /sdcard2/modules/gpio_output.ko /system/lib/modules
cp -rf /sdcard2/modules/ice40-hcd.ko /system/lib/modules
cp -rf /sdcard2/modules/mcDrvModule.ko /system/lib/modules
cp -rf /sdcard2/modules/mcKernelApi.ko /system/lib/modules
cp -rf /sdcard2/modules/msm-buspm-dev.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_nandbiterrs.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_nandecctest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_oobtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_pagetest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_readtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_speedtest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_stresstest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_subpagetest.ko /system/lib/modules
cp -rf /sdcard2/modules/mtd_torturetest.ko /system/lib/modules
cp -rf /sdcard2/modules/radio-iris-transport.ko /system/lib/modules
cp -rf /sdcard2/modules/spidev.ko /system/lib/modules
Create the pronto_wlan.ko / wlan.ko symlink .
Code:
ln -s /system/lib/modules/pronto/pronto_wlan.ko /system/lib/modules/wlan.ko
set the permissions for all the new modules.
Code:
chmod 0644 /system/lib/modules/wlan.ko
chmod 0644 /system/lib/modules/pronto/pronto_wlan.ko
chmod 0644 /system/etc/firmware/wlan/prima/WCNSS_cfg.dat
chmod 0644 /system/etc/firmware/wlan/prima/WCNSS_qcom_cfg.ini
chmod 0644 /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin
chmod 0644 /system/lib/modules/bluetooth-power.ko
chmod 0644 /system/lib/modules/ansi_cprng.ko
chmod 0644 /system/lib/modules/dma_test.ko
chmod 0644 /system/lib/modules/ecryptfs.ko
chmod 0644 /system/lib/modules/evbug.ko
chmod 0644 /system/lib/modules/gpio_axis.ko
chmod 0644 /system/lib/modules/gpio_event.ko
chmod 0644 /system/lib/modules/gpio_input.ko
chmod 0644 /system/lib/modules/gpio_matrix.ko
chmod 0644 /system/lib/modules/gpio_output.ko
chmod 0644 /system/lib/modules/ice40-hcd.ko
chmod 0644 /system/lib/modules/mcDrvModule.ko
chmod 0644 /system/lib/modules/mcKernelApi.ko
chmod 0644 /system/lib/modules/msm-buspm-dev.ko
chmod 0644 /system/lib/modules/mtd_nandbiterrs.ko
chmod 0644 /system/lib/modules/mtd_nandecctest.ko
chmod 0644 /system/lib/modules/mtd_oobtest.ko
chmod 0644 /system/lib/modules/mtd_pagetest.ko
chmod 0644 /system/lib/modules/mtd_readtest.ko
chmod 0644 /system/lib/modules/mtd_speedtest.ko
chmod 0644 /system/lib/modules/mtd_stresstest.ko
chmod 0644 /system/lib/modules/mtd_subpagetest.ko
chmod 0644 /system/lib/modules/mtd_torturetest.ko
chmod 0644 /system/lib/modules/radio-iris-transport.ko
chmod 0644 /system/lib/modules/spidev.ko
RE-Boot and run your new kernel and modules with a smile.
Customizing the Kernel
Changing and Customizing The Kernel
SUCCESS !! ( Build the Prima / Pronto Wlan Module)
Fix ADD the DTB Blob to the Source
reserved space
I'm so glad somone is doing this I've been wanting a new kernel for a while and I think this might help make a path to new roms
This looks great. Can't wait to see where this goes. What can I do to help?
@zixxorb
You can run through with all of this and get the kernel running on your device.
Right now im working on getting the missing modules to build.
So you can work on that to.
The modules that are generated during the compile function properly.
Ok, so I'm more of a noob to doing anything with kernels, idk what I need to do exactly. Plus I'm already on 6.0 (this is my main phone)
The Most Valuable Document Ever
This is exactly what we need to answer some questions.
Authored by Qualcomm and one of the hardest things to find.
Make sure to copy this wile you can.
It's practically Top Secret.
https://github.com/dante198406/Qual...0-NR964-4_C_MSM8909_LA_SW_User_Manual_SPD.pdf
Get it wile you can !!
Just a general update.
I have updated the modules install section.
It now includes the instructions for installing the new modules.
The modules have been tested and seem to operate without issues.
Will this work for the sprint variant?
I'm a noob so pls permit me if this question sounds foolish. All through the tutorial, it seems this kernel is for the Metro PCs. Will it work for the sprint variant of 626s?
This tutorial is based off of the Metro-Pcs version.
The HTC-DEV site has separate source code for each device carrier.
You would follow everything exactly except.
1 ) From the HTC-DEV site download the source code for your specific carrier.
For sprint download sprint.
For t-mobile download t-mobile.
Set the device filter on the website to be desire626s
and you will get this.
2 ) in the section #2 Setup the Kernel Source
There are commands for unzipping the source file.
You will need to change the filename in the command to match the filename you downloaded.
After the first untar / unpack you will need to get the kernel filename.
Change that filename in the commands as well.
3) When you edit the version info.
Open up the Big-Country_defconfig
It is in the folder ~/android/device/a32e/arch/arm/configs
Open it with G-Edit or whatever text editor you use.
Search for CONFIG_LOCALVERSION=
and change it to CONFIG_LOCALVERSION="-g26c2269"
CHANGE
CONFIG_LOCALVERSION="-g26c2269"
CONFIG_LOCALVERSION="-your device version"
You can get the version as i showed you in previous post.
4) The rest is all the same.
AS far as the kernel and modules that have been uploaded here, they are for the Metro Pcs Version. ( And Lollipop NOT Marshmallow)
I will build the others later when i finish more of this project.
ALSO YOU CAN USE THIS TUTORIAL TO BUILD THE KERNEL FOR ANY DEVICE.
Things will change here and there but generally speaking all of the steps you need to follow are the same.
I have a 65 inch XiaomiTV 3 (note, this is a different flavor of OS from MiBox), it works great until Xiaomi starts to push video ads everytime I turn on the TV. Xiaomi has disabled (likely completely removed ADB) from their system (mine is 1.12.10, any newer version would not be allow u to gain root access in anyway, unless you prove me wrong). Since there is no way to install a new recovery on XiaomiTV 3 (not that I know of, I should add), I tried the only tool that can root this system with an exploit, the 360 Root (http://root.360.cn/). Now this tool itself has some ads, so I will need to remove it later. But at least it allows me to use `su` in a terminal emulator.
Once I gain the root access on my device, I first tried to use ADB by running (and I need to add, XiaomiTV 3 does not have USB debugging port) a terminal emulator (I use Android Terminal Emulator):
Code:
su
stop adbd
setprop service.adb.tcp.port 5555
start adbd
Then I try to connect to my XiaomiTV 3 (its ip is 192.168.123.123) by:
Code:
adb connect 192.168.123.123
It connects, meaning ADB is not removed completely. However if I type `adb devices` it shows 192.168.123.123 is offline.
I then upgraded my Android platform tools and adb by:
Code:
android update sdk no-ui
android update adb
Restart the adb server:
Code:
adb kill-server
adb connect 192.168.123.123
Here it still shows offline, so I restarted both the XiaomiTV 3 and my laptop, and regain root (I will lose root everytime I reboot XiaomiTV 3), did the above all over again. No luck. Then I thought to copy my `~/.android/adbkey.pub` to a usb drive, and then plug it in to XiaomiTV 3, then use a terminal emulator to:
Code:
su
mv /mnt/usb/sdcard/adbkey.pub /data/misc/adb/adb_keys
Then
Code:
stop adbd
setprop service.adb.tcp.port 5555
start adbd
Still, after I
Code:
adb kill-server
adb connect 192.168.123.123
the device is still offline.
Then I tried another approach to get get SuperSU to the system by first copying supersu to a USB drive and then copy it to `/data/superuser` in XiaomiTV 3.
Then I did:
Code:
su
mount -o rw,remount /system
mkdir /system/bin/.ext
chmod 777 /system/bin/.ext
chown root /system/bin/.ext
cp /data/superuser/su /system/bin/.ext/.su
chmod 6755 /system/bin/.ext/.su
chown root /system/bin/.ext/.su
cp /data/superuser/su /system/xbin/su
chmod 755 /system/xbin/su
chown root /system/xbin/su
cp /data/superuser/su /system/xbin/daemonsu
chmod 755 /system/xbin/daemonsu
chown root /system/xbin/daemonsu
cp /data/superuser/supolicy /system/xbin/supolicy
chmod 755 /system/xbin/supolicy
cp /data/superuser/libsupol.so /system/lib/libsupol.so
chmod 644 /system/lib/libsupol.so
mkdir /system/etc/init.d
chmod 644 /system/etc/init.d
cp /data/superuser/99SuperSUDaemon /system/etc/init.d/99SuperSUDaemon
chmod 744 /system/etc/init.d/99SuperSUDaemon
busybox_xm touch /system/etc/.installed_su_daemon
echo 1 >> /system/etc/.installed_su_daemon
chmod 644 /system/etc/.installed_su_daemon
mkdir /system/app/SuperSU
chmod 755 /system/app/SuperSU
cp /data/superuser/SuperSU.apk /system/app/SuperSU/SuperSU.apk
chmod 644 /system/app/SuperSU/SuperSU.apk
cp /data/superuser/install-recovery.sh /system/etc/install-recovery.sh
chmod 755 /system/etc/install-recovery.sh
ln -s /system/etc/install-recovery.sh /system/bin/install-recovery.sh
Then I reboot, apparently, the system overwrites the `/system/xbin/su` (either by 360 root or Xiaomi's OS). So I redid everything above, without reboot. Sadly, SuperSU still asks me to upgrade/update my binary file.
So this is when I stopped knowing what to do next. Any ideas?
How to backup the data from the phone using rsync and ssh (including some hints for using sshd on an Android phone)
Like for all computer it's important to have a backup of the data on the phone.
For those who like me don't like to store their private data in one of the suspicious clouds there is a solution with standard Linux tools:
Use rsync and ssh to backup the data from the phone to your local workstation (see the man page for rsync for details regarding rsync and why it is useful for this task)
The neccessary tools for Android for this method can be installed with the Magisk Module MagiskSSH.
Download the Magisk Module with MagiskSSH from here
https://gitlab.com/d4rcm4rc/MagiskSSH_releases
Copy the ZIP file with the Magisk Module to the phone :
Code:
adb push magisk_ssh_v0.14.zip /sdcard/Download/
and install it via the module installation from within the Magisk App or manuell using :
Code:
adb shell su - -c /data/adb/magisk/magisk64 --install-module /sdcard/Download/magisk_ssh_v0.14.zip
Sample output of the installation:
Code:
ASUS_I006D:/ # /data/adb/magisk/magisk64 --install-module /sdcard/Download/magisk_ssh_v0.14.zip
- Current boot slot: _a
- Device is system-as-root
*******************************
OpenSSH for Android
*******************************
[0/7] Preparing module directory
[1/7] Extracting architecture unspecific module files
[2/7] Extracting libraries and binaries for arm64
[3/7] Configuring library path wrapper
[4/7] Recreating symlinks
[5/7] Creating SSH user directories
[6/7] Found sshd_config, will not copy a default one
[7/7] Cleaning up
- Setting permissions
- Done
ASUS_I006D:/ #
A reboot is required now.
Code:
adb shell reboot
For the next tasks open an adb shell and become root user.
Next create the authorized_keys file for the user root :
Code:
touch /data/ssh/root/.ssh/authorized_keys
chmod 600 /data/ssh/root/.ssh/authorized_keys
and add your public ssh key to the file /data/ssh/root/.ssh/authorized_keys.
To make sure that the keys and other data files for the MagiskSSH module are not removed while deinstalling the module you should create the file /data/ssh/KEEP_ON_UNINSTALL:
Code:
touch /data/ssh/KEEP_ON_UNINSTALL
The MagiskSSH module also installs a service to start sshd after each reboot: to disable this start create the file /data/ssh/no-autostart:
Code:
touch /data/ssh/no-autostart
To manually start or stop the sshd use the script /data/adb/modules/ssh/opensshd.init :
Code:
# start the sshd (as user root)
#
/data/adb/modules/ssh/opensshd.init start
# to stop the sshd (as user root)
#
/data/adb/modules/ssh/opensshd.init stop
Now test the access via ssh from your Linux workstation:
Code:
ssh -l root <phone_ip_address> id
Use this command to retrieve the current IP address of the phone:
Code:
PHONE_IP_ADDRESS=$( adb shell ifconfig wlan0 | grep "inet addr:" | sed -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )
example :
Code:
[[email protected] ~]$ ssh -l root ${PHONE_IP_ADDRESS} id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
[[email protected] ~]$
Now you can use rsync to backup the data from the phone, e.g. to backup the photos from the phone do :
Code:
# on your local Linux workstation do:
# start the sshd on the phone via adb if not already running
#
adb shell su - -c /data/adb/modules/ssh/opensshd.init start
# retrieve the current IP address from the phone
#
PHONE_IP_ADDRESS=$( adb shell ifconfig wlan0 | grep "inet addr:" | sed -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )
# backup the new photos from the phone to the Linux workstation (rsync only copies new files from the phone)
# to the local directory /data/backup/ASUS_ZENFONE8/DCIM
#
rsync -av --rsync-path /data/adb/modules/ssh/usr/bin/rsync [email protected]${PHONE_IP_ADDRESS}:/sdcard/DCIM/ /data/backup/ASUS_ZENFONE8/DCIM
# optional stop the sshd on the phone via adb
#
adb shell su - -c /data/adb/modules/ssh/opensshd.init stop
Note: The sshd configuration file used is /data/ssh/sshd_config
Sample Script to backup all data in the directory /sdcard
Code:
##!/bin/bash
#
# simple script to backup the data of an phone using adb, ssh, and rsync
#
# History
# 27.06.2022 /bs
# initial release
#
# for testing
#
#RSYNC_OPTIONS="${RSYNC_OPTIONS} --dry-run"
RSYNC_OPTIONS="${RSYNC_OPTIONS} --del "
# default is to backup the phone connected via adb over LAN
#
[ $# -ne 0 ] && ADB_OPTIONS="$*" || ADB_OPTIONS="-e"
# retrieve the serial number of the attached phone
#
SERIAL_NO="$( adb ${ADB_OPTIONS} shell getprop ro.serialno )"
if [ "${SERIAL_NO}"x = ""x ] ; then
echo "ERROR: Can not read the serial number of the connected phone"
exit 89
fi
VENDOR_MODEL="$( adb ${ADB_OPTIONS} shell getprop ro.product.vendor.model )"
# directory for the backup
#
BACKUP_DIR="/data/backup/ASUS_ZENFONE8/data_backup/${VENDOR_MODEL}_${SERIAL_NO}"
if [ ! -d "${BACKUP_DIR}" ] ; then
echo "ERROR: The directory \"${BACKUP_DIR}\" does not exist"
exit 99
fi
PHONE_IP_ADDRESS="$( adb ${ADB_OPTIONS} shell ifconfig wlan0 | grep "inet addr:" | sed -e "s/.*inet addr://g" -e "s/[[:space:]]*Bcast.*//g" )"
if [ "${PHONE_IP_ADDRESS}"x = ""x ] ; then
echo "ERROR: Can not detect the IP address of the phone"
exit 100
fi
echo "Updating a backup of the data on the phone with the serial number \"${SERIAL_NO}\" and the IP \"${PHONE_IP_ADDRESS}\" to the directory \"${BACKUP_DIR}\" ..."
set -x
# start the sshd if neccessary
#
adb ${ADB_OPTIONS} shell su - -c /data/adb/modules/ssh/opensshd.init start
# do the backup
#
time rsync ${RSYNC_OPTIONS} -av --rsync-path /data/adb/modules/ssh/usr/bin/rsync [email protected]${PHONE_IP_ADDRESS}:/sdcard/ "${BACKUP_DIR}/"
# stop the sshd
#
adb ${ADB_OPTIONS} shell su - -c /data/adb/modules/ssh/opensshd.init stop
set +x
How to enable access via ssh for non-root user
In the standard configuration installed by MagiskSSH ssh access is only allowed as user root because the ssh keys are in the directory /data and all non-root user can not read files in the directory /data. Therefor some efforts are neccessary to add ssh access for non-root user.
e.g. To enable the ssh access for the user shell do:
To configure ssh access for the user shell we must create a .ssh directory for the user shell in a directory tree owned by the user shell. The only directory on the phone owned by the user shell that can be used for this purpose is /storage :
Code:
ASUS_I006D:/ # ls -ld /storage
drwx--x--- 4 shell everybody 80 2022-06-26 18:37 /storage
ASUS_I006D:/ #
But unfortunately all files and directories in this directory are temporary and will be deleted after a reboot of the phone.
Therefor we configure a startup script in Magisk to create this directory tree after each reboot, e.g.
/data/adb/service.d/create_ssh_dir_for_shell.sh:
Code:
# /data/adb/service.d/create_ssh_dir_for_shell.sh
#
mkdir -p /storage/shell/.ssh
chmod -R 700 /storage/shell/
touch /storage/shell/.ssh/authorized_keys
echo "<ssh_public_key>" > /storage/shell/.ssh/authorized_keys
chmod 600 /storage/shell/.ssh/authorized_keys
chown -R shell:shell /storage/shell
Make the script executable:
Code:
su - -c chmod +x data/adb/service.d/create_ssh_dir_for_shell.sh
To test the script just execute it one time manually as user root.
Code:
su - -c sh data/adb/service.d/create_ssh_dir_for_shell.sh
Now create a backup of the sshd config file
Code:
su - -c cp /data/ssh/sshd_config /storage/ssh/sshd_config.org.$$
and add these lines at the end of the file /data/ssh/sshd_config
Code:
Match User shell
AuthorizedKeysFile /storage/shell/.ssh/authorized_keys
Restart the sshd if it's already running
Now test the access as user shell, example:
Code:
[[email protected] ~]$ ssh -l shell 192.168.1.148 id
uid=2000(shell) gid=2000(shell) groups=2000(shell) context=u:r:magisk:s0
[[email protected] ~]$
The reason for this config is the setting "StrictMode yes" in the sshd config file /data/ssh/sshd_config (see the man page for sshd_config for details). So another "solution" is to change this setting:
With the setting "StrictModes no" in the file sshd_config the directory with the authorized_keys file for the non-root users can be anywhere (for example in /sdcard/shell)
Execute as user root:
Code:
sed -i -e "s/.*StrictModes.*//g" -e "s/UsePrivilegeSeparation/StrictModes no\nUsePrivilegeSeparation/g" /data/ssh/sshd_config
and change the entry in the file /data/ssh/sshd_config for the authorized_keys file for the user shell, for example:
Code:
Match User shell
AuthorizedKeysFile /sdcard/shell/.ssh/authorized_keys
Afterwards restart the sshd:
Code:
/data/adb/modules/ssh/opensshd.init stop
/data/adb/modules/ssh/opensshd.init start
Now create the directories and files neccessary for the ssh access (see above) in the directory /sdcard/shell:
Code:
SUS_I006D:/ # find /sdcard/shell -exec ls -ld {} \;
drwxrws--- 3 u0_a118 media_rw 3452 2022-06-26 18:32 /sdcard/shell
drwxrws--- 2 u0_a118 media_rw 3452 2022-06-26 18:32 /sdcard/shell/.ssh
-rw-rw---- 1 u0_a118 media_rw 408 2022-06-26 18:32 /sdcard/shell/.ssh/authorized_keys
ASUS_I006D:/ #
and the access as user shell via ssh should work
I've mentioned this elsewhere in some of my howtos, but I think this feature is important and useful enough to get its own howto.
Nowadays in the current Android OS version a lot filesystems are mounted read-only and remounting the filesystem read-write does not work anymore. Therefor the files in these filesystems can not be changed anymore.
That's pretty good from a safety standpoint, but sometimes a real showstopper.
But fortunately Android is a Linux based system and therefor there is a solution for this problem called bind mounts. bind mounts are some kind of symbolic links that only exist in memory and are therefor also supported for read-only mounted filesystems. Of course, this is a very simple description for this Linux feature but it should be enough here -- for more in depth details I recommend the Linux documentation.
bind mounts are used by Magisk but they can also be used manually without an installed Magisk - the only requirement for using it manually is root access to the phone.
Here is an example to replace the file /system/etc/hosts with a writable file using a bind mount:
Spoiler: replace the file /system/etc/hosts with a changed version of the file
Code:
#
# use a filesystem that supports all necessary permissions and attributes for the new file
#
# Therefor files in /sdcard/<something> can not be used to replace most of the files in the read-only filesystems
#
# Make sure that the file used to replace the other file is readable by all user that can also read the original file
#
ASUS_I006D:/ # cp -a /system/etc/hosts /data/local/tmp/my_hosts
ASUS_I006D:/ #
# add some additional data to the new file
#
ASUS_I006D:/ # echo "127.0.0.1 www.heise.de" >>/data/local/tmp/my_hosts
ASUS_I006D:/ #
# check the result
#
ASUS_I006D:/ # cat /data/local/tmp/my_hosts
127.0.0.1 localhost
::1 ip6-localhost
127.0.0.1 www.heise.de
ASUS_I006D:/ #
ASUS_I006D:/ # ls -l /system/etc/hosts /data/local/tmp/my_hosts
-rw-r--r-- 1 root root 80 2023-06-11 14:57 /data/local/tmp/my_hosts
-rw-r--r-- 1 root root 56 2009-01-01 01:00 /system/etc/hosts
ASUS_I006D:/ #
# "replace" the file /system/etc/hosts now
#
ASUS_I006D:/ # su - -c mount -o bind /data/local/tmp/my_hosts /system/etc/hosts
ASUS_I006D:/ #
# check the results
#
ASUS_I006D:/ # cat /system/etc/hosts
127.0.0.1 localhost
::1 ip6-localhost
127.0.0.1 www.heise.de
ASUS_I006D:/ #
# add some more data to the file
#
ASUS_I006D:/ # echo "127.0.0.1 www.spiegle.de" >>/system/etc/hosts
ASUS_I006D:/ #
# check the result
#
ASUS_I006D:/ # cat /system/etc/hosts
127.0.0.1 localhost
::1 ip6-localhost
127.0.0.1 www.heise.de
127.0.0.1 www.spiegle.de
ASUS_I006D:/ #
bind mounts are only possible for existing files - bind mounts for non-existent files will fail, e.g:
Spoiler: Example for a bind mount for an non-existent file
Code:
ASUS_I006D:/ $ ls /system/bin/bash
ls: /system/bin/bash: No such file or directory
1|ASUS_I006D:/ $
1|ASUS_I006D:/ $ su - -c mount -o bind /system/bin/sh /system/bin/bash
mount: '/system/bin/sh'->'/system/bin/bash': No such file or directory
1|ASUS_I006D:/ $
bind mounts are also allowed for directories therefor to "create" a new file just copy the directory, create the new file in that new directory, and then do a bind mount for the existing directory.
Example:
Spoiler: create the executable bash by copying the executable sh
Code:
#
# "create" the executable "bash" by copying the executable "sh"
#
# This is only an example that should work on every phone! In real life you should copy a real bash executable to the new directory
#
#
# check for a bash executable in the PATH
#
ASUS_I006D:/ $ which bash
1|ASUS_I006D:/ $
# -> bash does currently not exist on the phone
# create a new directory to be used for the bind mount /system/xbin
#
# Note that this directory must be on a filesystem supporting the standard linux file permissions therefor a directory in /sdcard/<something> is not possible here
# And again the directory used must be readable by all uesrs.
#
ASUS_I006D:/ $ mkdir /data/local/tmp/xbin
ASUS_I006D:/ $
# copy all files from /system/xbin to the new directory
#
ASUS_I006D:/ $ su - -c cp -a -r /system/xbin/* /data/local/tmp/xbin
ASUS_I006D:/ $
ASUS_I006D:/ $ ls -l /data/local/tmp/xbin
total 1772
lrwxrwxrwx 1 root shell 3 2009-01-01 01:00 vi -> vim
-rwxr-xr-x 1 root shell 1813848 2009-01-01 01:00 vim
ASUS_I006D:/ $
# create fake "bash" executable in the new directory
#
ASUS_I006D:/ $ cp /system/bin/sh /data/local/tmp/xbin/bash
ASUS_I006D:/ $
ASUS_I006D:/ $ ls -l /data/local/tmp/xbin
total 2080
-rwxr-xr-x 1 shell shell 312024 2023-06-11 13:56 bash
lrwxrwxrwx 1 root shell 3 2009-01-01 01:00 vi -> vim
-rwxr-xr-x 1 root shell 1813848 2009-01-01 01:00 vim
ASUS_I006D:/ $
# bind mount the directory /system/xbin on the new directory
#
ASUS_I006D:/ $ su - -c mount -o bind /data/local/tmp/xbin /system/xbin
ASUS_I006D:/ $
# and now there is "bash" executable in /system/xbin available
#
ASUS_I006D:/ $ ls -l /system/xbin
total 2080
-rwxr-xr-x 1 shell shell 312024 2023-06-11 13:56 bash
lrwxrwxrwx 1 root shell 3 2009-01-01 01:00 vi -> vim
-rwxr-xr-x 1 root shell 1813848 2009-01-01 01:00 vim
ASUS_I006D:/ $ which bash
/system/xbin/bash
# You can now even copy additional files to the bind mounted directory, e.g.:
ASUS_I006D:/ $ cp /sdcard/Download/zip /system/xbin
ASUS_I006D:/ $
ASUS_I006D:/ $ chmod 755 /system/xbin/zip
ASUS_I006D:/ $
ASUS_I006D:/ $ ls -ltr /system/xbin
total 2576
-rwxr-xr-x 1 root shell 1813848 2009-01-01 01:00 vim
lrwxrwxrwx 1 root shell 3 2009-01-01 01:00 vi -> vim
-rwxr-xr-x 1 shell shell 312024 2023-06-11 13:56 bash
-rwxr-xr-x 1 shell shell 503992 2023-06-11 14:03 zip
ASUS_I006D:/ $
ASUS_I006D:/ $ zip -h
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f freshen: only changed files -u update: only changed or new files
-d delete entries in zipfile -m move into zipfile (delete OS files)
-r recurse into directories -j junk (don't record) directory names
-0 store only -l convert LF to CR LF (-ll CR LF to LF)
-1 compress faster -9 compress better
-q quiet operation -v verbose operation/print version info
-c add one-line comments -z add zipfile comment
[email protected] read names from stdin -o make zipfile as old as latest entry
-x exclude the following names -i include only the following names
-F fix zipfile (-FF try harder) -D do not add directory entries
-A adjust self-extracting exe -J junk zipfile prefix (unzipsfx)
-T test zipfile integrity -X eXclude eXtra file attributes
-y store symbolic links as the link instead of the referenced file
-e encrypt -n don't compress these suffixes
-h2 show more help
Hints
bind mounts are supported by the filesystems ext4, vfat, f2fs. and most probably a lot of other filesystems used on machines running Android.
Be careful when replacing executables, especially when replacing an important file like /system/bin/sh. And you should never replace a file that is just a symbolic link for toybox or busybox.
bind mounts created while the OS is running are only useful for files that are dynamically read by the OS. It does not make sense to replace for example one of the *.rc files using a bind mount because these files are only read once while booting the OS.
The filesystems used for source and target for a bind mount should support the same set of attributes and permissions or the result may not be like expected. E.g. you can not bind mount an executable with a file in the directory /sdcard/<something> because that filesystem for /sdcard does not support the executable permission:
Spoiler: Example for bind mount an executable in /sdcard/Download
Code:
ASUS_I006D:/ $ ls -l /bin/ziptool
-rwxr-xr-x 1 root shell 28688 2009-01-01 01:00 /bin/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ cp -a /bin/ziptool /sdcard/Download/
ASUS_I006D:/ $
ASUS_I006D:/ $ chmod 755 /sdcard/Download/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ ls -l /bin/ziptool /sdcard/Download/ziptool
-rwxr-xr-x 1 root shell 28688 2009-01-01 01:00 /bin/ziptool
-rw-rw---- 1 u0_a121 media_rw 28688 2023-06-11 18:09 /sdcard/Download/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ su - -c mount -o bind /sdcard/Download/ziptool /bin/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ ziptool
/system/bin/sh: ziptool: can't execute: Permission denied
126|ASUS_I006D:/ $ /bin/ziptool
/system/bin/sh: /bin/ziptool: can't execute: Permission denied
126|ASUS_I006D:/ $ ls -l /bin/ziptool
-rw-rw---- 1 u0_a121 media_rw 28688 2023-06-11 18:09 /bin/ziptool
ASUS_I006D:/ $
The source for the bind mount must be in a directory that is readable for all user that use the bind mounted file, e.g.
Spoiler: Example for bind mount an executable in a directory not accessable by all user
Code:
ASUS_I006D:/ $ su - -c cp -a /bin/ziptool /data/adb/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ su - -c ls -l /data/adb/ziptool
-rwxr-xr-x 1 root shell 28688 2009-01-01 01:00 /data/adb/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ su - -c mount -o bind /data/adb/ziptool /bin/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ ziptool
/system/bin/sh: ziptool: inaccessible or not found
127|ASUS_I006D:/ $
127|ASUS_I006D:/ $ file /bin/ziptool
/bin/ziptool: cannot open: Permission denied
ASUS_I006D:/ $
Use the mount command to check if a file is bind mounted. e.g.
Spoiler: Check if a file is bind mounted
Code:
|ASUS_I006D:/ # mount | grep /system/etc/hosts
1|ASUS_I006D:/ #
1|ASUS_I006D:/ # mount -o bind /data/local/tmp/hosts /system/etc/hosts
ASUS_I006D:/ #
ASUS_I006D:/ # mount | grep /system/etc/hosts
/dev/block/dm-33 on /system/etc/hosts type f2fs (rw,lazytime,seclabel,nosuid,nodev,noatime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,reserve_root=32768,resuid=0,resgid=1065,inlinecrypt,alloc_mode=default,fsync_mode=nobarrier)
ASUS_I006D:/ #
To remove a bind mount just do a umount, e.g:
Spoiler: Example for remove a bind mount
Code:
#
# remove the bind mount
#
ASUS_I006D:/ $ su - -c umount /bin/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ which ziptool
/system/bin/ziptool
ASUS_I006D:/ $ ziptool
ziptool: run as ziptool with unzip or zipinfo as the first argument, or symlink
1|ASUS_I006D:/ $
Another method to remove all bind mounts is a reboot of the phone
It's recommended to use a sub directory in the directory /data/local/tmp for executables used in bind mounts, example:
Spoiler: Example for bind mount an executable in /data/local/tmp/
Code:
ASUS_I006D:/ $ mkdir /data/local/tmp/bind_mounts
ASUS_I006D:/ $
ASUS_I006D:/ $ cp -a /bin/ziptool /data/local/tmp/bind_mounts
ASUS_I006D:/ $
ASUS_I006D:/ $ ls -l /data/local/tmp/bind_mounts/ziptool
-rwxr-xr-x 1 shell shell 28688 2009-01-01 01:00 /data/local/tmp/bind_mounts/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ su - -c mount -o bind /data/local/tmp/bind_mounts/ziptool /bin/ziptool
ASUS_I006D:/ $
ASUS_I006D:/ $ ziptool
ziptool: run as ziptool with unzip or zipinfo as the first argument, or symlink
1|ASUS_I006D:/ $
bind mounts are also useful for writable files to be able to revert the changes to a file. Example:
Spoiler: Example for using bind mount for a writable file
Code:
ASUS_I006D:/ $ cat /data/local/tmp/testfile.txt
This is a test file
ASUS_I006D:/ $
#
# create a copy of the writable file
#
ASUS_I006D:/ $ cat /data/local/tmp/testfile_for_tests.txt
This is another test file
#
# bind mount the file with the copy of the file
#
ASUS_I006D:/ $ su - -c mount -o bind /data/local/tmp/testfile_for_tests.txt /data/local/tmp/testfile.txt
ASUS_I006D:/ $
#
# check the result
#
ASUS_I006D:/ $ cat /data/local/tmp/testfile.txt
This is another test file
ASUS_I006D:/ $
#
# add some data to the bind mounted file now
#
ASUS_I006D:/ $ echo "This text will not change the original file" >> /data/local/tmp/testfile.txt
ASUS_I006D:/ $
ASUS_I006D:/ $ cat /data/local/tmp/testfile.txt
This is another test file
This text will not change the original file
ASUS_I006D:/ $
#
# remove the bind mount to restore the original file contents
#
ASUS_I006D:/ $ su - -c umount /data/local/tmp/testfile.txt
ASUS_I006D:/ $
ASUS_I006D:/ $ cat /data/local/tmp/testfile.txt
This is a test file
ASUS_I006D:/ $
Of course, this can also be done by creating a backup copy of the file and restoring the backup copy if necessary. But if the changes to the file make the phone unusable or cause it to crash, it is more difficult to restore the file. If you use a bind mount, the file will be restored "automatically" at the next reboot.
Notes
see the forum entry How to upgrade the OS with another Android "distribution" for an example usage for this method
See the forum entry How To change any file or directory using Magisk for how to use this method in Magisk module for persisent changes
See the forum entry How to make files in /system writable for another exampe how to use this feature in Magisk
Up to version 25.x of Magisk (at least in Magisk v24.x and v25.x) Magisk mounted the /system/bin directory read-write, so that temporary changes for the files in /system/bin were possible. But because of the more or less not existent free space in the filesystem used for /system the use of this feature was very limited. And this feature does not exist in Magisk v26.x or newer anymore.
(see also this forum message: https://forum.xda-developers.com/t/magisk-general-support-discussion.3432382/page-2815#post-88617909 )