first commit

This commit is contained in:
Sergey Sergeev 2019-03-09 18:09:44 +03:00
commit 1423b9e5c7
13 changed files with 103 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.*
!.gitignore
kernel.headers
bins/*
kernel-new.elf

1
README.md Normal file
View file

@ -0,0 +1 @@
# mtik_initrd_hacks

BIN
cpio-fs/bin/busybox Executable file

Binary file not shown.

7
cpio-fs/etc/rc.d/rc.S Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
/bin/busybox --install /bin
mount -v proc /proc -n -t proc
sh

BIN
cpio-fs/init Executable file

Binary file not shown.

BIN
cpio-fs/oldinit Executable file

Binary file not shown.

BIN
cpio-fs/order Executable file

Binary file not shown.

20
dump_elf.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq4xxx
#export STAGING_DIR=${OPENWRT_DIR}/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.4.0_musl_eabi
GCC=$STAGING_DIR/bin/arm-openwrt-linux-gcc
OBJDUMP=$STAGING_DIR/bin/arm-openwrt-linux-objdump
OBJCOPY=$STAGING_DIR/bin/arm-openwrt-linux-objcopy
LD=$STAGING_DIR/bin/arm-openwrt-linux-ld
${OBJDUMP} -x kernel.elf > ./kernel.headers
#${OBJDUMP} -x kernel-new.elf > ./kernel.headers
#${OBJCOPY} -j .text -j initrd -S ./kernel.elf ./kernel.OWL1
#${OBJCOPY} -R initrd -S ./kernel.elf ./kernel.OWL1
#${OBJCOPY} -j .rodata -O binary ./kernel.elf ./kernel.OWL1
#initrd is kernel.p2-p3

14
init/compile_for_arm.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq4xxx
#export STAGING_DIR=${OPENWRT_DIR}/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.4.0_musl_eabi
GCC=$STAGING_DIR/bin/arm-openwrt-linux-gcc
OD=$STAGING_DIR/bin/arm-openwrt-linux-objdump
OC=$STAGING_DIR/bin/arm-openwrt-linux-objcopy
LD=$STAGING_DIR/bin/arm-openwrt-linux-ld
$GCC -static ./init.c -o ../cpio-fs/init
$OC --strip-all ../cpio-fs/init ../cpio-fs/init

16
init/init.c Normal file
View file

@ -0,0 +1,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
extern char** environ;
int main(int argc, char *argv[]){
char *new_argv[] = { "/bin/busybox", "sh", "/etc/rc.d/rc.S", NULL };
environ[0] = "PATH=/sbin:/bin";
environ[1] = NULL;
execvp(new_argv[0], new_argv);
return 0;
}

BIN
kernel.elf Normal file

Binary file not shown.

24
pack.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq806x
export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-7.4.0_musl_eabi
#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-ipq4xxx
#export STAGING_DIR=${OPENWRT_DIR}/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-7.4.0_musl_eabi
GCC=$STAGING_DIR/bin/arm-openwrt-linux-gcc
OBJDUMP=$STAGING_DIR/bin/arm-openwrt-linux-objdump
OBJCOPY=$STAGING_DIR/bin/arm-openwrt-linux-objcopy
LD=$STAGING_DIR/bin/arm-openwrt-linux-ld
cd cpio-fs
#find . 2>/dev/null | cpio --quiet -o --format='newc' > ../bins/x1.cpio
find . 2>/dev/null | cpio --quiet -o --format='newc' | \
xz --check=crc32 --lzma2=dict=512KiB > ../bins/kernel.p3-new.xz
#cat ../initramfs.cpio | xz --check=crc32 --lzma2=dict=512KiB > ../bins/kernel.p3-new.xz
cd ..
cat ./bins/kernel.p2.xz ./bins/kernel.p3-new.xz > ./bins/kernel-new.combo
${OBJCOPY} --update-section initrd=./bins/kernel-new.combo ./kernel.elf ./kernel-new.elf
cat ./kernel-new.elf > /var/lib/tftpboot/linux_t1.bin

16
unpack.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
exit 0
dd if=kernel.elf bs=1 skip=0 count=43504 of=./bins/kernel.HEAD
dd if=kernel.elf bs=1 skip=43504 count=1605632 of=./bins/kernel.p2.xz
dd if=kernel.elf bs=1 skip=1649136 count=84812 of=./bins/kernel.p3.xz
dd if=kernel.elf bs=1 skip=1733948 of=./bins/kernel.TAIL
#( xz -dc --single-stream > ./bins/initramfs.cpio && cat > ./bins/p3-tail.bin ) < ./bins/kernel.p3.xz
xz -dc > ./bins/initramfs.cpio < ./bins/kernel.p3.xz
rm -Rf cpio-fs
mkdir cpio-fs
cd cpio-fs
cpio -idv < ../bins/initramfs.cpio