Transfer huge amount of source files via network (SCP + GZip)

Scenario

I’ve got a modified AOSP (Mokee, ~50GB with repo cache) need to be transferred from my Mac to my Thinkpad. But macOS does not support linux file systems while Linux does not support apple file systems too.

Solution

After a quick Google, I’ve found a way to solve this issue by using WiFi to transfer.

Simply transfer the file with SCP/FTP is not fast enough as the source tree is way too large. Here we use GZip to compress the data, then put it to SCP’s pipe, and decompress the data on the target machine.

The command is:

tar zcvf - mokee | ssh [email protected] "cd /home/hu/target/mokee/directory; tar zx"

Efficiency

Looks good, 25~35MB/s with 802.11ac (867Mbps, 2×2 MIMO) connection.

15074458869506.jpg

Compile Android kernel without AOSP buildroot environment

Intro

Recently I’ve started a kernel porting project for Xiaomi Mi 6, porting optimisation patches from open source community (e.g. XDA-Developer’s OnePlus 5 forum). Here is a quick note for environment setup and compiling the kernel only without AOSP buildroot.

Preparation

  1. Install dependencies: sudo apt install kernel-package git-core
  2. Download the source: git clone https://github.com/huming2207/Popkern-sagit.git
  3. Toolchain setup: you can either try using Android perbuilt toolchains (may not work on my kernel project due to compiler argument in CFLAG is not supported with GCC 4.9), or build by your own with crosstool-ng

Compilation

  • Set environment variables:
export CROSS_COMPILE=aarch64-your-toolchain-name-
export ARCH=arm64
  • Load configuration file
make defconfig sagit_user_defconfig
  • Build the kernel
make -j8

Creating flashable package

  • Create a DTB-bundled kernel image. Since Xiaomi’s kernel building script somehow messed up, the Image.gz-dtb is the same as Image.gz. So we have to do the merge by our own:
cat arch/arm64/boot/Image.gz arch/arm64/boot/dts/qcom/*.dtb > zImage

Android kernel compilation on macOS

Intro

I’m trying to port some linux kernel optimisation patches from OnePlus 5 to my Xiaomi Mi 6. Here are some quick notes for some issues and errors I’ve encountered.

Btw here is the kernel repo: https://github.com/huming2207/sagit-daily-kernel

For someone who cares about this kernel, please use with precaution, I’m not sure if it works or not.

Issue 1

Issue

build/core/config.mk:608: *** Error: could not find jdk tools.jar 
at /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/../lib/tools.jar, 
please check if your JDK was installed correctly.  Stop.

Android buildroot script (makefiles) need two Java home path variables to make it works. The variables are JAVA_HOMEand ANDROID_JAVA_HOME.

Solution:

Add two lines to ~/.zshrc or ~/.bashrc:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export ANDROID_JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Issue 2

Issue

I terminated the iTerm session by mistake, so I didn’t get the full error log. But it should be something like this:

...
Could not find a supported mac sdk
...

Solution

Download macOS SDK package from here: https://github.com/phracker/MacOSX-SDKs/releases

Then unzip to /Developer/SDKs

Issue 3

Issue

**********************************************
The boot animation could not be generated as
ImageMagick is not installed in your system.

Please install ImageMagick from this website:
https://imagemagick.org/script/binary-releases.php
**********************************************
./vendor/mk/bootanimation/Android.mk:39: *** stop.

Solution

Install ImageMagick via brew: brew install imagemagick