Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
laityts committed May 17, 2022
0 parents commit 7d02acf
Show file tree
Hide file tree
Showing 40 changed files with 6,215 additions and 0 deletions.
404 changes: 404 additions & 0 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# You only need the A1 ROM link to port the ROM to the 5x

**如何使用a1to5x转换a1包成5x可用的刷机包**

* 登录你的github,fork这个项目到你的github

## 说明
### 1. 创建token
转到你的`repo settings > Developer settings > Personal access tokens > Generate new token`
- `note`: 填写RELEASE
- `Expiration`: 改为No expiration
- `Select scopes`: 全部勾选
- `Generate token`: 点击创建token
- `token`: 复制得到的token令牌

### 2. 添加secrets
转到你的`repo settings > secrets > new repository secret`
- `Name`: 填写RELEASE
- `Value`: 填写刚刚复制的token

### 3. Running workflow
- 转到你的 repo `Actions`
- 选择 `a1to5x` 工作流程(workflow)
- 打开 `Run workflow`
- 输入 ROM文件名 在 `ROM NAME` (可选)
- 输入 ROM链接地址 在 `ROM LINK`
- 点击`Run workflow` 按钮运行工作流程
13 changes: 13 additions & 0 deletions boby.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
> **First Time Installation:**

- [ ] Format data (if encrypted)
- [ ] Reboot to recovery
- [ ] Back up your efs, persist, modem partitions(Backup 5x baseband)
- [ ] Wipe system, vendor, cache, dalvik, data
- [ ] Flash ROM zip and magisk (optional)
- [ ] Flash [A1-V10.0.24.0_Pie_Baseband.zip](https://t.me/TiffanyUpdates/523?single)**(First Time)**
- [ ] Reboot & Enjoy

> **Notes:**

- [ ] To restore the 5X baseband, please use twrp to restore the efs, persist, modem backup files.
Binary file added cpio/ramdisk-sar.cpio
Binary file not shown.
Binary file added dtc
Binary file not shown.
Binary file added fdtget
Binary file not shown.
Binary file added fdtput
Binary file not shown.
Binary file added magiskboot
Binary file not shown.
Binary file added mkbootimg/dtbTool
Binary file not shown.
Binary file added mkbootimg/dtbToolCM
Binary file not shown.
Binary file added mkbootimg/dtc
Binary file not shown.
Binary file added mkbootimg/lz4
Binary file not shown.
305 changes: 305 additions & 0 deletions mkbootimg/mkboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#boot.img tool
#by xiaolu
trap "clean" 2 3 4
workdir=$(pwd)
toolpath=$(readlink -f $0)
tooldir=$(dirname $toolpath)
mkbootimg=$tooldir/mkbootimg
mkbootfs=$tooldir/mkbootfs
C_OUT="\033[0;1m"
C_ERR="\033[31;1m"
C_CLEAR="\033[0;0m"

pout() {
printf "${C_OUT}${*}${C_CLEAR}\n"
}
perr() {
printf "${C_ERR}${*}${C_CLEAR}\n"
}
clean()
{
rm -rf /tmp/mkboot.*
pout "..."
exit
}

unpack_complete()
{
[ ! -z $format ] && echo format=$format >> ../img_info
pout "Unpack completed."
exit
}

zip_command()
{
if [ "$1" == lzop ]; then
zcommand="lzop -n -f -9"
elif [ "$1" == lz4 ]; then
zcommand="lz4 -f -9"
elif [ "$1" == lzma ]; then
zcommand="lzma -f -c"
elif [ "$1" == xz ]; then
zcommand="xz -f -c"
else
zcommand="gzip -n -f"
fi
}

usage()
{
pout "<Unpack and repack boot.img tool>"
pout "----------------------------------------------------------------------"
pout "Not enough parameters or parameter error!"
pout "unpack boot.img & decompress ramdisk:\n $(basename $0) [img] [output dir]"
pout " $(basename $0) boot.img boot20130905"
pout "Use the unpacked directory repack boot.img(img_info):\n $(basename $0) [unpacked dir] [newbootfile]"
pout " $(basename $0) boot20130905 newboot.img"
clean
}

print_info()
{
[ ! -z "$board" ] && pout " board : $board"
pout " kernel : $kernel"
pout " ramdisk : $ramdisk"
pout " page size : $page_size"
pout " kernel size : $kernel_size"
pout " ramdisk size : $ramdisk_size"
[ ! -z $second_size ] && [ $second_size -gt 0 ] && \
pout " second_size : $second_size"
[ $dtb_size -gt 0 ] && pout " dtb size : $dtb_size"
pout " base : $base_addr"
pout " kernel offset : $kernel_offset"
pout " ramdisk offset : $ramdisk_offset"
[ ! -z $second_size ] && [ $second_size -gt 0 ] && \
pout " second_offset : $second_offset"
pout " tags offset : $tags_offset"
[ $dtb_size -gt 0 ] && pout " dtb img : $dt"
pout " cmd line : $cmd_line"
}

mkboot_img()
{
error=0
[ $second_size -gt 0 ] && second="--second ${second}"
[ $dtb_size -gt 0 ] && dtb="--dt ${dt}"

$mkbootimg --kernel $kernel --ramdisk $ramdisk --board "$board" \
--base $base_addr --ramdisk_offset $ramdisk_offset \
--tags_offset $tags_offset --cmdline "$cmd_line" \
--pagesize $page_size $second $dtb -o $1 || error=1

[ $error -eq 1 ] && return $error
ramdisk_size=$(stat -c "%s" $ramdisk)
boot_size=$(stat -c "%s" $1)
pout "Kernel size: $kernel_size, new ramdisk size: $ramdisk_size, $(basename $1): $boot_size."
pout "$(basename $1) has been created."
}

#decide action
[ $# -lt 2 ] || [ $# -gt 3 ] && usage
if [ $# -eq 2 ] && [ -d $1 ]; then
mkboot_from_dir=1
elif [ $# -eq 2 ] && [ -s $1 ]; then
split_boot_to_dir=1
else
usage
fi

#mkboot_from_dir, img_info
if [ ! -z $mkboot_from_dir ]; then
pout "mkbootimg from $1/img_info."
unpacked_dir=$(readlink -f $1)
new_img=$(readlink -f $2)
cd $unpacked_dir
if [ ! -s img_info ]; then
pout "not found img_info file! can't rebuild img."
clean
fi
eval $(cat img_info)
if [ -z $kernel ] || [ -z $ramdisk ] || [ -z $base_addr ]; then
pout "img_info file have not enough parameters."
clean
fi
[ -z $second_size ] && second_size=0
[ -z $dtb_size ] && dtb_size=0
if [ -d $ramdisk ]; then
[ -z $format ] && format=gzip
zip_command $format
#cd $ramdisk; find . | fakeroot cpio -R 0:0 -H newc -o 2>/dev/null \
# | $zcommand > $unpacked_dir/new_ramdisk; cd $unpacked_dir
$mkbootfs $ramdisk | $zcommand > new_ramdisk
ramdisk=new_ramdisk
ramdisk_size=$(stat -c "%s" $ramdisk)
fi
print_info
pout "ramdisk is $format format."
rm -f $new_img
mkboot_img $new_img || perr "Make boot.img Error! pls check img_info file."
#pout "Add SEANDROIDENFORCE tag."
#printf SEANDROIDENFORCE >> $new_img
rm -f new_ramdisk
clean
fi

#split boot.img to dir.
if [ -e $2 ]; then
read -p "$2 exists, delete?(N/y)" reply
case $reply in
y | Y)
rm -rf $2
;;
*)
exit
;;
esac
fi
tempdir="$(readlink -f $2)"
mkdir -p $tempdir
pout "Unpack & decompress $1 to $2"

#get boot.img info
cp -f $1 $tempdir/
cd $tempdir
bootimg=$(basename $1)
offset=$(grep -abo ANDROID! $bootimg | cut -f 1 -d :)
[ -z $offset ] && clean
if [ $offset -gt 0 ]; then
dd if=$bootimg of=bootimg bs=$offset skip=1 2>/dev/null
bootimg=bootimg
fi

kernel_addr=0x$(od -A n -X -j 12 -N 4 $bootimg | sed 's/ //g' | sed 's/^0*//g')
ramdisk_addr=0x$(od -A n -X -j 20 -N 4 $bootimg | sed 's/ //g' | sed 's/^0*//g')
second_addr=0x$(od -A n -X -j 28 -N 4 $bootimg | sed 's/ //g' | sed 's/^0*//g')
tags_addr=0x$(od -A n -X -j 32 -N 4 $bootimg | sed 's/ //g' | sed 's/^0*//g')

kernel_size=$(od -A n -D -j 8 -N 4 $bootimg | sed 's/ //g')
#base_addr=0x$(od -A n -x -j 14 -N 2 $bootimg | sed 's/ //g')0000
ramdisk_size=$(od -A n -D -j 16 -N 4 $bootimg | sed 's/ //g')
second_size=$(od -A n -D -j 24 -N 4 $bootimg | sed 's/ //g')
page_size=$(od -A n -D -j 36 -N 4 $bootimg | sed 's/ //g')
dtb_size=$(od -A n -D -j 40 -N 4 $bootimg | sed 's/ //g')
#cmd_line=$(od -A n --strings -j 64 -N 512 $bootimg)
#board=$(od -A n --strings -j 48 -N 16 $bootimg)
cmd_line=$(od -A n -S1 -j 64 -N 512 $bootimg)
board=$(od -A n -S1 -j 48 -N 16 $bootimg)

base_addr=$((kernel_addr-0x00008000))
kernel_offset=$((kernel_addr-base_addr))
ramdisk_offset=$((ramdisk_addr-base_addr))
second_offset=$((second_addr-base_addr))
tags_offset=$((tags_addr-base_addr))

base_addr=$(printf "%08x" $base_addr)
kernel_offset=$(printf "%08x" $kernel_offset)
ramdisk_offset=$(printf "%08x" $ramdisk_offset)
second_offset=$(printf "%08x" $second_offset)
tags_offset=$(printf "%08x" $tags_offset)

base_addr=0x${base_addr:0-8}
kernel_offset=0x${kernel_offset:0-8}
ramdisk_offset=0x${ramdisk_offset:0-8}
second_offset=0x${second_offset:0-8}
tags_offset=0x${tags_offset:0-8}

k_count=$(((kernel_size+page_size-1)/page_size))
r_count=$(((ramdisk_size+page_size-1)/page_size))
s_count=$(((second_size+page_size-1)/page_size))
d_count=$(((dtb_size+page_size-1)/page_size))
k_offset=1
r_offset=$((k_offset+k_count))
s_offset=$((r_offset+r_count))
d_offset=$((s_offset+s_count))

#kernel
dd if=$bootimg of=kernel_tmp bs=$page_size skip=$k_offset count=$k_count 2>/dev/null
dd if=kernel_tmp of=kernel bs=$kernel_size count=1 2>/dev/null
#ramdisk.packed
dd if=$bootimg of=ramdisk_tmp bs=$page_size skip=$r_offset count=$r_count 2>/dev/null
dd if=ramdisk_tmp of=ramdisk.packed bs=$ramdisk_size count=1 2>/dev/null
#second
if [ $second_size -gt 0 ]; then
dd if=$bootimg of=second.img.tmp bs=$page_size skip=$s_offset count=$s_count 2>/dev/null
dd if=second.img.tmp of=second.img bs=$second_size count=1 2>/dev/null
s_name="second=second.img\n"
s_size="second_size=$second_size\n"
fi
#dtb
if [ $dtb_size -gt 0 ]; then
dd if=$bootimg of=dt.img_tmp bs=$page_size skip=$d_offset count=$d_count 2>/dev/null
dd if=dt.img_tmp of=dt.img bs=$dtb_size count=1 2>/dev/null
dt="$tempdir/dt.img"
dt=$(basename $dt)
dt_name="dt=$dt\n"
dt_size="dtb_size=$dtb_size\n"
fi
rm -f *_tmp $(basename $1) $bootimg

kernel=kernel
ramdisk=ramdisk
[ ! -s $kernel ] && clean
#print boot.img info
print_info

esq="'\"'\"'"
escaped_cmd_line=`echo $cmd_line | sed "s/'/$esq/g"`

#write info to img_info,decompression ramdisk.packed
printf "kernel=kernel\nramdisk=ramdisk\n${s_name}${dt_name}page_size=$page_size\n\
kernel_size=$kernel_size\nramdisk_size=$ramdisk_size\n${s_size}${dt_size}base_addr=$base_addr\nkernel_offset=$kernel_offset\n\
ramdisk_offset=$ramdisk_offset\ntags_offset=$tags_offset\ncmd_line=\'$escaped_cmd_line\'\nboard=\"$board\"\n" > img_info
mkdir ramdisk
cd ramdisk

gzip -t ../ramdisk.packed 2>/dev/null
if [ $? -eq 0 ]; then
pout "ramdisk is gzip format."
format=gzip
gzip -d -c ../ramdisk.packed | cpio -i -d -m --no-absolute-filenames 2>/dev/null
unpack_complete
fi
lzma -t ../ramdisk.packed 2>/dev/null
if [ $? -eq 0 ]; then
pout "ramdisk is lzma format."
format=lzma
lzma -d -c ../ramdisk.packed | cpio -i -d -m --no-absolute-filenames 2>/dev/null
unpack_complete
fi
xz -t ../ramdisk.packed 2>/dev/null
if [ $? -eq 0 ]; then
pout "ramdisk is xz format."
format=xz
xz -d -c ../ramdisk.packed | cpio -i -d -m --no-absolute-filenames 2>/dev/null
unpack_complete
fi
lzop -t ../ramdisk.packed 2>/dev/null
if [ $? -eq 0 ]; then
pout "ramdisk is lzo format."
format=lzop
lzop -d -c ../ramdisk.packed | cpio -i -d -m --no-absolute-filenames 2>/dev/null
unpack_complete
fi
$tooldir/lz4 -d ../ramdisk.packed 2>/dev/null | cpio -i -d -m --no-absolute-filenames 2>/dev/null
if [ $? -eq 0 ]; then
pout "ramdisk is lz4 format."
format=lz4
else
pout "ramdisk is unknown format,can't unpack ramdisk"
fi
unpack_complete

Binary file added mkbootimg/mkbootfs
Binary file not shown.
Binary file added mkbootimg/mkbootimg
Binary file not shown.
Binary file added mkbootimg/split-appended-dtb
Binary file not shown.
Binary file added mkdtimg
Binary file not shown.
Empty file added output/.gitkeep
Empty file.
Binary file not shown.
29 changes: 29 additions & 0 deletions template/META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
ui_print("--------------------------------------------------");
ui_print("| |");
ui_print("| A1 TO 5X |");
ui_print("| |");
ui_print("--------------------------------------------------");
ui_print("--------------------------------------------------");
ui_print("| TG:- @Eytan_Tan |");
ui_print("--------------------------------------------------");
ui_print(" ");
#
ui_print("- Flashing system image");
show_progress(0.040000, 0);
package_extract_file("system.img", "/dev/block/bootdevice/by-name/system") ||
abort("E1001: Failed to flash system image.");
#
ui_print("- Flashing boot image");
show_progress(0.090000, 0);
package_extract_file("boot.img", "/dev/block/bootdevice/by-name/boot");
#
ui_print("- Flashing tz image");
package_extract_file("tz.img", "/dev/block/bootdevice/by-name/tz");
#
ui_print("- Flashed successfully...");
ui_print("- Enjoy!");
ui_print(" ");
#
show_progress(0.100000, 10);
set_progress(1.000000);
Binary file added template/tz.img
Binary file not shown.
Empty file added tmp/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions update-payload-extractor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
Loading

0 comments on commit 7d02acf

Please sign in to comment.