droid4 alpine-bring up

Note:Modifying or replacing your device’s software will void your device’s warranty, and can cause to damage to the device and to your computer or losing data(of device and computer), execute the following commands is entirely at your own risk.



Note:this guide try to apply the bringup of droid4 flowing Tony Lindgren blog. there still missing parts such as camera or connact to internet, that i hope that will fill up in the next time

requires:linux computer,Motorola Droid4(XT894),sdcard(more then 3G),usb cable.

optional-Debug UART

you need also a micro-USB-B breakout board and USB-TTL Adapter with 3.3V signal-A detailed explanation is available in Tony Lindgren blog Debug UART.

get started

go to the path that you want to create the project(replace “/path/to/project/” with the path):
pushd /path/to/project/
create directory hierarchy structure for boot components:
install -d bringup/{linux/{linux-stable,images},mnt,archives/{stock_rom/droid4,kexecboot/droid4,buildroot,firmware,basic_rootfs/{ubuntu-base,alpine}},mnt,rootfs/{alpine,ubuntu,buildroot}}
go into bringup directory:
cd bringup

update stock rom

first of all we need to update the stock rom to VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml.zip.
for that we need fastboot, if you don’t have fastboot you can install it by:
sudo apt-get install android-tools-fastboot
download and extract VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml.zip into droid4/archives/stock_rom:
wget https://maedevu.maemo.org/images/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml.zip -P archives/stock_rom/droid4
unzip archives/stock_rom/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml.zip -d archives/stock_rom/droid4
rm archives/stock_rom/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml.zip
download Tony Lindgren script for update the stock_rom:
wget -P archives/stock_rom/droid4 -c wget https://raw.githubusercontent.com/omerlle/droid4-bringup/alpine/boot/flash-droid-4-fw.sh
turn on the device by press on Vol Down & Power buttons this will go into Fastboot mode(the first line in the screen is:”AP Fastboot Flash Mode (S)”)
connect the device to the computer via usb and make sure the bottom lines are “Transfer Mode: USB Connected”
make sure you see the device by the command:
fastboot devices
the output supposed to be something like:
0123456789ABCDEF fastboot
if you get this output:
permissions fastboot
try:
sudo fastboot devices
if it solve the problem change the script to run “sudo fastboot” by the command:
sed -i 's/fastboot=fastboot/fastboot="sudo fastboot"/' archives/stock_rom/droid4/flash-droid-4-fw.sh
go into VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml directory:
pushd archives/stock_rom/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml
and run the script:
bash ../flash-droid-4-fw.sh
return to base directory by:
popd

install Kexecboot bootloader

if you don’t have git you can install it by:
sudo apt-get install git
clone Tony Lindgren repository for droid4 kexecboot by the command:
git clone https://github.com/tmlind/droid4-kexecboot.git archives/kexecboot/droid4/
install the Kexecboot by the commands(you can remove sudo keyword if you don’t need sudo for fastboot)[my current version is 2021-01-28]:
sudo fastboot flash mbm archives/stock_rom/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml/allow-mbmloader-flashing-mbm.bin;
sudo fastboot reboot bootloader;
sudo fastboot flash bpsw archives/kexecboot/droid4/current/droid4-kexecboot.img;
sudo fastboot flash utags archives/kexecboot/droid4/utags-mmcblk1p13.bin;
sudo fastboot flash mbm archives/stock_rom/droid4/VRZ_XT894_9.8.2O-72_VZW-18-8_CFC.xml/mbm.bin
you can poweroff the device for now by press Power button

build kernel

if you don’t have the following tools you can install it by:
sudo apt-get install libncurses5-dev make exuberant-ctags bc libssl-dev
and the arm cross compailer:
apt-get install gcc-arm-linux-gnueabihf
clone tony lindgren kernel repository:
git clone https://github.com/tmlind/linux linux/tmlind_linux
go into tmlind_linux:
pushd linux/tmlind_linux
checkout the latest kernel branch:
git checkout -b local/droid4-pending-v5.12 origin/droid4-pending-v5.12
setup your default kernel configuration:
make ARCH=arm omap2plus_defconfig
compaile the kernel:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap4-droid4-xt894.dtb bzImage modules -j9
return to base directory by:
popd

build rootfs

you can create a ubuntu rootfs instead of alpine rootfs following this page
install qemu-user-static arm emulator:
sudo apt-get install qemu-user-static
download the alpine minimal rootfs archive:
wget -P archives/basic_rootfs/alpine/ -c http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/armv7/alpine-minirootfs-3.12.4-armv7.tar.gz
clone bringup repository for droid4 more rootfs scripts:
git clone https://github.com/omerlle/droid4-bringup.git archives/droid4_bringup
checkout the alpine branch:
git -C archives/droid4_bringup/ checkout alpine
download bluetooth firmware:
wget -c https://github.com/TI-ECS/bt-firmware/raw/master/TIInit_10.6.15.bts -P archives/firmware/ti-connectivity
choose name to rootfs directory and create it:
droid_rootfs="$PWD/rootfs/alpine/3.12.4_armv7"
mkdir ${droid_rootfs}
extract alpine minimal rootfs into the directory:
sudo tar -xzf archives/basic_rootfs/alpine/alpine-minirootfs-3.12.4-armv7.tar.gz -C ${droid_rootfs}/
add usage scripts:
sudo rsync -a --chown=root:root archives/droid4_bringup/overlay/ ${droid_rootfs}
sudo rsync -a --chown=root:root archives/droid4_bringup/src ${droid_rootfs}/tmp/
add tony lindgren pm and droid4-dtmf.sh script:
sudo wget -c https://raw.githubusercontent.com/tmlind/droid4-pm/master/scripts/openrc/droid4-pm -P ${droid_rootfs}/etc/init.d
sudo chmod +x ${droid_rootfs}/etc/init.d/droid4-pm
sudo wget -c https://raw.githubusercontent.com/tmlind/droid4-sms-tools/master/droid4-dtmf.sh -P ${droid_rootfs}/usr/local/bin
sudo chmod +x ${droid_rootfs}/usr/local/bin/droid4-dtmf.sh
add files and mount some directories for chroot work properly:
sudo cp /etc/resolv.conf ${droid_rootfs}/etc/
sudo cp -a /usr/bin/qemu-arm-static ${droid_rootfs}/usr/bin/
sudo mount -t proc /proc ${droid_rootfs}/proc
sudo mount -o bind /dev ${droid_rootfs}/dev
run chroot to config the rootfs on pc:
sudo chroot ${droid_rootfs} sh
install useful packages:
apk update
apk upgrade
apk add openrc udev openssh python3 alsa-utils util-linux rsync xorg-server xinit i3wm evince xterm tmux eog linux-headers build-base python3-dev sqlite kbd libqmi emacs linux-firmware wpa_supplicant bluez wireless-tools py3-pip iw mpg123 sqlite-dev dhclient xf86-input-evdev
pip3 install --upgrade pip
pip3 install evdev
build the bins:
make install -C /tmp/src/droid4_hardware
emacs -batch -f batch-byte-compile /usr/local/share/emacs/client_app.el
set the databases:
sqlite3 /root/.droid4/hardware.db < /usr/local/share/python/hardware/config/hardware_db.back
sqlite3 /root/.droid4/modem/dynamic_data.db < /usr/local/share/python/droid4_modem/config/modem_db.back

set the password for root user:
passwd
[for uart debug:echo ttyS2 >> /etc/securetty;sed -i 's/^#ttyS0\:\:respawn\:\/sbin\/getty -L ttyS0 115200 vt100/ttyS2\:\:respawn\:\/sbin\/getty -L ttyS2 115200 vt100/' /etc/inittab]
exit from chroot:
exit
unmount /proc and /dev from the rootfs:
sudo umount ${droid_rootfs}/dev
sudo umount ${droid_rootfs}/proc
copy TIInit_10.6.15 to the rootfs:
sudo cp archives/firmware/ti-connectivity/TIInit_10.6.15.bts ${droid_rootfs}/lib/firmware/ti-connectivity/

create bootable sd

format the sdcard:

note:this part is very dangerous because you can erase your hard disk if you will not do it right

use this command to figure out your sdcard name, you need be sure it appear and disappear when you connect it and disconnect it otherwise you can erase important data:
lsblk
when you are sure what the name of the sd replace the “mmcblk0” keyword with your name and run the following commands:
sdcard="mmcblk0"
set -u
mount | grep /dev/$sdcard | cut -d ' ' -f 3 | xargs umount
echo "1 : start= 2048, size= 102400, type=83
2 : start= 104448, size= 4194304, type=83
3 : start= 4298752, size= $(($(cat /sys/block/$sdcard/size)-4298752)), type=83" | sudo sfdisk /dev/$sdcard
sudo partprobe /dev/${sdcard}
sudo mkfs.ext4 /dev/${sdcard}p1 -L boot -O^metadata_csum,^64bit
sudo mkfs.ext4 /dev/${sdcard}p2 -L rootfs
sudo mkfs.vfat /dev/${sdcard}p3 -n USER_DATA
set +u
mount the first partition of sdcard:
sudo mount /dev/${sdcard}p1 mnt
copy the boot components:
sudo rsync --chown=root:root archives/droid4_bringup/boot/boot.cfg linux/tmlind_linux/arch/arm/boot/zImage linux/tmlind_linux/arch/arm/boot/dts/omap4-droid4-xt894.dtb mnt/boot
[for uart debug:sudo rsync --chown=root:root archives/droid4_bringup/boot/boot.cfg.uart mnt/boot/boot.cfg ]
unmount the first partition of sdcard and mount the second partition:
sync
sudo umount mnt
sudo mount /dev/${sdcard}p2 mnt
copy the rootfs to the second partition:
sudo rsync --delete -av ${droid_rootfs}/ mnt/
install the modules in the rootfs:
sudo make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=${PWD}/mnt/ -C linux/tmlind_linux
save and umount the second partition of sdcard:
sync
sudo umount mnt
return to your original path:
popd
for droid4 usage you can see droid4-alpine-usage.