Skip to content

Commit 322e638

Browse files
committed
init
0 parents  commit 322e638

30 files changed

+454
-0
lines changed

.github/workflows/main.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: rootfs
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "main" branch
8+
push:
9+
branches: [ "master" ]
10+
pull_request:
11+
branches: [ "master" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v3
27+
28+
- name: Install Dependencies
29+
run: sudo apt install build-essential gcc-aarch64-linux-gnu bc flex bison 7zip kmod bash cpio binutils tar git wget dpkg libssl-dev
30+
31+
- name: Build kernel and rootfs.img
32+
run: sudo sh nabu-rootfsKernel_build.sh
33+
34+
- name: Upload rootfs.7z
35+
uses: actions/upload-artifact@v4.0.0
36+
with:
37+
# Artifact name
38+
name: rootfs
39+
path: rootfs.7z
40+
compression-level: 0
41+
42+
- name: Upload deb packages
43+
uses: actions/upload-artifact@v4.0.0
44+
with:
45+
# Artifact name
46+
name: xiaomi-nabu-debs
47+
path: ${{ github.workspace }}/*.deb

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ubuntu rootfs for Xiaomi Pad 5
2+
This repo contians scripts for automatic building of ubuntu rootfs for Xiaomi Pad 5
3+
4+
# Install info
5+
- rootfs.img must be flashed to partition named "linux"
6+
- Partition for efi boot must be named "efs"
7+
- Install grub using grub-install and grub-mkconfig -o /boot/grub/grub.cfg. If done from android make sure that efs partition mounted at /boot/efi, after generating grub.cfg change all of "/dev/block/" to "/dev/"

alsa-xiaomi-nabu/DEBIAN/control

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Package: alsa-xiaomi-nabu
2+
Version: 1.0
3+
Architecture: arm64
4+
Maintainer: map220v <map220v300@gmail.com>
5+
Depends: alsa-ucm-conf
6+
Description: Alsa UCM configurations for Xiaomi Pad 5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Use case configuration for Xiaomi Pad 5
2+
# Author: map220v <map220v300@gmail.com>
3+
#
4+
# Playback Devices
5+
# - Internal Speakers : CS35L41 driver : MultiMedia1 <-> QUAT_TDM_RX_0
6+
# Capture Devices
7+
# - Internal Bottom Mic : WCD9341 driver : MultiMedia2 <-> SLIMBUS_0_TX (AIF1_CAP, ADC1, TX6)
8+
# - Internal Top Mic : WCD9341 driver : MultiMedia2 <-> SLIMBUS_0_TX (AIF1_CAP, ADC3, TX5)
9+
10+
SectionVerb {
11+
EnableSequence [
12+
# SPEAKER PLAYBACK
13+
cset "name='BR PCM Soft Ramp' 4ms"
14+
cset "name='TR PCM Soft Ramp' 4ms"
15+
cset "name='BL PCM Soft Ramp' 4ms"
16+
cset "name='TL PCM Soft Ramp' 4ms"
17+
cset "name='BR Analog PCM Volume' 8"
18+
cset "name='TR Analog PCM Volume' 8"
19+
cset "name='BL Analog PCM Volume' 8"
20+
cset "name='TL Analog PCM Volume' 8"
21+
# Enable Quaternary TDM0 mixer on MultiMedia1
22+
cset "name='QUAT_TDM_RX_0 Audio Mixer MultiMedia1' 1"
23+
24+
# Bottom Mic
25+
cset "name='ADC1 Volume' 8"
26+
cset "name='AIF1_CAP Mixer SLIM TX6' 1"
27+
cset "name='CDC_IF TX6 MUX' DEC6"
28+
29+
# Top Mic
30+
cset "name='ADC3 Volume' 8"
31+
cset "name='AIF1_CAP Mixer SLIM TX5' 1"
32+
cset "name='CDC_IF TX5 MUX' DEC5"
33+
cset "name='AMIC4_5 SEL' AMIC4"
34+
35+
cset "name='MultiMedia2 Mixer SLIMBUS_0_TX' 1"
36+
]
37+
38+
DisableSequence [
39+
# Disable Quaternary TDM0 mixer on MultiMedia1
40+
cset "name='QUAT_TDM_RX_0 Audio Mixer MultiMedia1' 0"
41+
cset "name='MultiMedia2 Mixer SLIMBUS_0_TX' 0"
42+
43+
cset "name='CDC_IF TX6 MUX' ZERO"
44+
cset "name='CDC_IF TX5 MUX' ZERO"
45+
]
46+
47+
# Set initial volumes
48+
BootSequence [
49+
]
50+
51+
Value {
52+
TQ "HiFi"
53+
}
54+
}
55+
56+
SectionDevice."Speaker" {
57+
Comment "Speaker playback"
58+
59+
Value {
60+
PlaybackPriority 150
61+
PlaybackPCM "hw:${CardId},0"
62+
PlaybackChannels 2
63+
}
64+
}
65+
66+
SectionDevice."Mic" {
67+
Comment "Internal Microphones"
68+
69+
EnableSequence [
70+
cset "name='ADC MUX6' AMIC"
71+
cset "name='ADC MUX5' AMIC"
72+
cset "name='AMIC MUX6' ADC1"
73+
cset "name='AMIC MUX5' ADC3"
74+
cset "name='ADC1 Volume' 8"
75+
cset "name='ADC3 Volume' 8"
76+
]
77+
78+
DisableSequence [
79+
cset "name='AMIC MUX6' ZERO"
80+
cset "name='AMIC MUX5' ZERO"
81+
cset "name='ADC1 Volume' 0"
82+
cset "name='ADC3 Volume' 0"
83+
]
84+
85+
Value {
86+
CapturePriority 200
87+
CapturePCM "hw:${CardId},1" # MultiMedia2
88+
PlaybackChannels 2
89+
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Use case configuration for Xiaomi Pad 5
2+
# Author: map220v <map220v300@gmail.com>
3+
4+
Syntax 3
5+
6+
SectionUseCase."HiFi" {
7+
File "/Xiaomi/nabu/HiFi.conf"
8+
Comment "HiFi quality Music."
9+
}

firmware-xiaomi-nabu/DEBIAN/control

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Package: firmware-xiaomi-nabu
2+
Version: 1.0
3+
Architecture: arm64
4+
Maintainer: map220v <map220v300@gmail.com>
5+
Conflicts: linux-firmware
6+
Replaces: linux-firmware
7+
Description: Firmware blobs for Xiaomi Pad 5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"sr_version": {
3+
"major": 1,
4+
"minor": 1,
5+
"patch": 1
6+
},
7+
"sr_domain": {
8+
"soc": "msm",
9+
"domain": "modem",
10+
"subdomain": "wlan_pd",
11+
"qmi_instance_id": 180
12+
},
13+
"sr_service": [
14+
{
15+
"provider": "kernel",
16+
"service": "elf_loader",
17+
"service_data_valid": 0,
18+
"service_data": 0
19+
},
20+
{
21+
"provider": "tms",
22+
"service": "servreg",
23+
"service_data_valid": 0,
24+
"service_data": 0
25+
},
26+
{
27+
"provider": "wlan",
28+
"service": "fw",
29+
"service_data_valid": 0,
30+
"service_data": 0
31+
}
32+
]
33+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

linux-xiaomi-nabu/DEBIAN/control

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Package: linux-xiaomi-nabu
2+
Version: 6.6.0-sm8150
3+
Architecture: arm64
4+
Maintainer: map220v <map220v300@gmail.com>
5+
Section: kernel
6+
Description: Kernel and Modules for Xiaomi Pad 5

nabu-rootfsKernel_build.sh

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/sh
2+
3+
if [ "$(id -u)" -ne 0 ]
4+
then
5+
echo "rootfs can only be built as root"
6+
exit
7+
fi
8+
9+
VERSION="23.10"
10+
11+
#DEPS dpkg, wget, binfmt support(or arm64 device), 7zip, make, aarch64 gcc,
12+
#DEPS openssl headers, bc, bison, flex, bash, kmod, cpio, binutils, tar, git
13+
14+
git clone https://github.com/map220v/sm8150-mainline.git --branch nabu-6.6 --depth 1 linux
15+
cd linux
16+
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig sm8150.config
17+
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
18+
mkdir ../linux-xiaomi-nabu/boot
19+
cp arch/arm64/boot/Image.gz ../linux-xiaomi-nabu/boot/vmlinuz-6.6.0-sm8150
20+
cp arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dtb ../linux-xiaomi-nabu/boot/dtb-6.6.0-sm8150
21+
rm -rf ../linux-xiaomi-nabu/lib
22+
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=../linux-xiaomi-nabu modules_install
23+
rm ../linux-xiaomi-nabu/lib/modules/**/build
24+
cd ..
25+
26+
dpkg-deb --build --root-owner-group linux-xiaomi-nabu
27+
dpkg-deb --build --root-owner-group firmware-xiaomi-nabu
28+
dpkg-deb --build --root-owner-group alsa-xiaomi-nabu
29+
30+
31+
32+
truncate -s 6G rootfs.img
33+
mkfs.ext4 rootfs.img
34+
mkdir rootdir
35+
mount -o loop rootfs.img rootdir
36+
37+
wget https://cdimage.ubuntu.com/ubuntu-base/releases/$VERSION/release/ubuntu-base-$VERSION-base-arm64.tar.gz
38+
tar xzvf ubuntu-base-$VERSION-base-arm64.tar.gz -C rootdir
39+
#rm ubuntu-base-$VERSION-base-arm64.tar.gz
40+
41+
mount --bind /dev rootdir/dev
42+
mount --bind /dev/pts rootdir/dev/pts
43+
mount --bind /proc rootdir/proc
44+
mount --bind /sys rootdir/sys
45+
46+
echo "nameserver 1.1.1.1" | tee rootdir/etc/resolv.conf
47+
echo "xiaomi-nabu" | tee rootdir/etc/hostname
48+
echo "127.0.0.1 localhost
49+
127.0.1.1 xiaomi-nabu" | tee rootdir/etc/hosts
50+
51+
if uname -m | grep -q aarch64
52+
then
53+
echo "cancel qemu install for arm64"
54+
else
55+
wget https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static
56+
install -m755 qemu-aarch64-static rootdir/
57+
58+
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' | tee /proc/sys/fs/binfmt_misc/register
59+
#ldconfig.real abi=linux type=dynamic
60+
echo ':aarch64ld:M::\x7fELF\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' | tee /proc/sys/fs/binfmt_misc/register
61+
fi
62+
63+
64+
#chroot installation
65+
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\$PATH
66+
export DEBIAN_FRONTEND=noninteractive
67+
68+
chroot rootdir apt update
69+
chroot rootdir apt upgrade -y
70+
71+
#u-boot-tools breaks grub installation
72+
chroot rootdir apt install -y bash-completion sudo ssh nano u-boot-tools- ubuntu-desktop
73+
74+
#chroot rootdir gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts-only-mounted true
75+
76+
77+
78+
#Device specific
79+
chroot rootdir apt install -y rmtfs protection-domain-mapper tqftpserv
80+
81+
#Remove check for "*-laptop"
82+
sed -i '/ConditionKernelVersion/d' rootdir/lib/systemd/system/pd-mapper.service
83+
84+
cp *-xiaomi-nabu.deb rootdir/tmp/
85+
chroot rootdir dpkg -i /tmp/linux-xiaomi-nabu.deb
86+
chroot rootdir dpkg -i /tmp/firmware-xiaomi-nabu.deb
87+
chroot rootdir dpkg -i /tmp/alsa-xiaomi-nabu.deb
88+
rm rootdir/tmp/*-xiaomi-nabu.deb
89+
90+
91+
#EFI
92+
chroot rootdir apt install -y grub-efi-arm64
93+
94+
sed --in-place 's/^#GRUB_DISABLE_OS_PROBER=false/GRUB_DISABLE_OS_PROBER=false/' rootdir/etc/default/grub
95+
sed --in-place 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT=""/' rootdir/etc/default/grub
96+
97+
#this done on device for now
98+
#grub-install
99+
#grub-mkconfig -o /boot/grub/grub.cfg
100+
101+
#create fstab!
102+
echo "PARTLABEL=linux / ext4 errors=remount-ro,x-systemd.growfs 0 1
103+
PARTLABEL=esp /boot/efi vfat umask=0077 0 1" | tee rootdir/etc/fstab
104+
105+
mkdir rootdir/var/lib/gdm
106+
touch rootdir/var/lib/gdm/run-initial-setup
107+
108+
chroot rootdir apt clean
109+
110+
if uname -m | grep -q aarch64
111+
then
112+
echo "cancel qemu install for arm64"
113+
else
114+
#Remove qemu emu
115+
echo -1 | tee /proc/sys/fs/binfmt_misc/aarch64
116+
echo -1 | tee /proc/sys/fs/binfmt_misc/aarch64ld
117+
rm rootdir/qemu-aarch64-static
118+
rm qemu-aarch64-static
119+
fi
120+
121+
umount rootdir/sys
122+
umount rootdir/proc
123+
umount rootdir/dev/pts
124+
umount rootdir/dev
125+
umount rootdir
126+
127+
rm -d rootdir
128+
129+
echo 'cmdline for legacy boot: "root=PARTLABEL=linux"'
130+
131+
7zz a rootfs.7z rootfs.img

0 commit comments

Comments
 (0)