Headless setup (no external monitor or keyboard)

Updated: according to the Raspibian Documentation, use Raspberry Pi Imagger is strongly recommended

Networking

create an wpa_supplicant.conf file in boot partition

country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid="Your-SSID"
 psk="replace-with-your-password"
 priority=100
}

Refer to https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

Enable SSH

Simply create an empty ssh file in the root directory of boot partition.

Refer to https://www.raspberrypi.org/documentation/remote-access/ssh/

Get IP of your pi

With Computer

sudo nmap -sP 192.168.21.*

# results 
MAC Address: B8:27:EB:40:A9:D7 (Raspberry Pi Foundation)
Nmap scan report for 192.168.31.158

With Android Phone

Now you can ssh to your raspberry pi with this ip.

Compiling kernel manually

Refer to https://www.raspberrypi.org/documentation/linux/kernel/building.md

Note that you may need to change /dev/sdbX with /dev/mmcblk0pN

mmcblk0     179:0    0    29G  0 disk 
├─mmcblk0p1 179:1    0  43.9M  0 part 
└─mmcblk0p2 179:2    0  28.9G  0 part

Prevent kernel package from being automatically installed

sudo apt-mark hold raspberrypi-kernel

Android

Refer to https://konstakang.com/devices/rpi3/LineageOS15.1/

Just for fun, not recommend to use it as a real android device.

Change Raspbian mirror source

Refer to https://mirror.tuna.tsinghua.edu.cn/help/raspbian/

Reference