diff --git a/README.md b/README.md index f2c094d..6f194f4 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ All that you do is at your own risk! The author has not liable for any of you actions and their consequences! This code is presented as is and is solely for educational purposes ONLY! -0) Use RouterOS 6.44 or 7.0b1! +0) Use RouterOS 6.45.6 or 7.0b1! 1) Upload(using FTP) content of ./for_ftp_upload/pub/* to /pub - (or /flash/rw/disk/pub) folder on target RouterOS device -2) Netboot with kernel-new.elf + (or /flash or /flash/rw/disk/pub) folder on target RouterOS device +2) Netboot(via bootp and tftp) with kernel-new.elf 3) telnet x.x.x.x 22111 Все что вы делаете, вы делаете на свой страх и риск! @@ -21,13 +21,14 @@ For Developers: cd ./finder ./Build.sh cd .. - ./unpack-npk.sh ./ros/routeros-7.0beta1-arm.npk + edit ./globals.sh and set your target device ARCH: arm or mips + ./unpack-npk.sh ./ros/routeros-mipsbe-6.45.6.npk ./unpack-kernel.sh cd ./init - ./compile_for_arm.sh + ./compile.sh cd .. - Make the necessary changes to the ./cpio-fs(compile add add busybox, etc...) + Make the necessary changes to the ./cpio-fs-ARCH(compile add add busybox, etc...) In the end, when everything is ready, to get ./bins/kernel-new.elf, run: ./pack-kernel.sh - Upload content of ./for_ftp_upload/pub/* to target RouterOS device via FTP(to /pub or /flash/rw/disk/pub) + Upload content of ./for_ftp_upload/pub/* to target RouterOS device via FTP(to /pub or /flash or ...) Put ./bins/kernel-new.elf to your tftp and Netboot from it telnet x.x.x.x 22111 diff --git a/cpio-fs/bin/busybox b/cpio-fs-arm/bin/busybox similarity index 100% rename from cpio-fs/bin/busybox rename to cpio-fs-arm/bin/busybox diff --git a/cpio-fs/bin/busybox.readme b/cpio-fs-arm/bin/busybox.readme similarity index 100% rename from cpio-fs/bin/busybox.readme rename to cpio-fs-arm/bin/busybox.readme diff --git a/cpio-fs/init b/cpio-fs-arm/init similarity index 100% rename from cpio-fs/init rename to cpio-fs-arm/init diff --git a/cpio-fs/oldinit b/cpio-fs-arm/oldinit similarity index 100% rename from cpio-fs/oldinit rename to cpio-fs-arm/oldinit diff --git a/cpio-fs/order b/cpio-fs-arm/order similarity index 100% rename from cpio-fs/order rename to cpio-fs-arm/order diff --git a/cpio-fs-mips/bin/busybox b/cpio-fs-mips/bin/busybox new file mode 100755 index 0000000..0e98981 Binary files /dev/null and b/cpio-fs-mips/bin/busybox differ diff --git a/cpio-fs-mips/bin/busybox.readme b/cpio-fs-mips/bin/busybox.readme new file mode 100644 index 0000000..217122b --- /dev/null +++ b/cpio-fs-mips/bin/busybox.readme @@ -0,0 +1 @@ +busybox скомпилен вот тут: /home/prog/openwrt/switch/mikrotik-tools-master/busybox-arm-soft-float diff --git a/cpio-fs-mips/init b/cpio-fs-mips/init new file mode 100755 index 0000000..020f3f5 Binary files /dev/null and b/cpio-fs-mips/init differ diff --git a/cpio-fs-mips/oldinit b/cpio-fs-mips/oldinit new file mode 100755 index 0000000..4ba3c37 Binary files /dev/null and b/cpio-fs-mips/oldinit differ diff --git a/cpio-fs-mips/order b/cpio-fs-mips/order new file mode 100755 index 0000000..ed380a8 Binary files /dev/null and b/cpio-fs-mips/order differ diff --git a/for_ftp_upload/pub/OWL/bin/busybox b/for_ftp_upload/pub/OWL/bin/busybox index a5d7f1a..0e98981 100755 Binary files a/for_ftp_upload/pub/OWL/bin/busybox and b/for_ftp_upload/pub/OWL/bin/busybox differ diff --git a/globals.sh b/globals.sh new file mode 100644 index 0000000..a3fc602 --- /dev/null +++ b/globals.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +#(C) Sergey Sergeev aka adron, 2019 +# + +#TARGET_ARCH="arm" +TARGET_ARCH="mips" + +[ ${TARGET_ARCH} = "arm" ] && { + 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 +} + +[ ${TARGET_ARCH} = "mips" ] && { + #I use: https://downloads.openwrt.org/releases/18.06.4/targets/ar71xx/generic/openwrt-sdk-18.06.4-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64.tar.xz + OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/openwrt-sdk-18.06.4-ar71xx-generic_gcc-7.3.0_musl.Linux-x86_64 + export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl +} + +GCC=$STAGING_DIR/bin/${TARGET_ARCH}-openwrt-linux-gcc +OBJDUMP=$STAGING_DIR/bin/${TARGET_ARCH}-openwrt-linux-objdump +OBJCOPY=$STAGING_DIR/bin/${TARGET_ARCH}-openwrt-linux-objcopy +LD=$STAGING_DIR/bin/${TARGET_ARCH}-openwrt-linux-ld diff --git a/init/compile.sh b/init/compile.sh new file mode 100755 index 0000000..80d764d --- /dev/null +++ b/init/compile.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +#(C) Sergey Sergeev aka adron, 2019 +# + +. ../globals.sh + +#for 7.0rc1 we need gcc with soft-float ONLY! +#apt-get install gcc-arm-linux-gnueabi +[ ${TARGET_ARCH} = "arm" ] && { + GCC=arm-linux-gnueabi-gcc + OBJCOPY=arm-linux-gnueabi-objcopy +} + +CPIO_FS="../cpio-fs-${TARGET_ARCH}" + +$GCC -static ./init.c -o ${CPIO_FS}/init +$OBJCOPY --strip-all ${CPIO_FS}/init ${CPIO_FS}/init + +#exit 0 + +cd ../ +./pack-kernel.sh +#./ftp_upload.sh diff --git a/init/compile_for_arm.sh b/init/compile_for_arm.sh deleted file mode 100755 index c97812d..0000000 --- a/init/compile_for_arm.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -#(C) Sergey Sergeev aka adron, 2019 -# - -#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/LAST/openwrt -#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-9.2.0_glibc_eabi -#TOOLCHAIN_PREFIX="arm-openwrt-linux" -#OPENWRT_DIR=/home/prog/openwrt/lede-all/2019-openwrt-all/LAST/openwrt -#export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-9.2.0_musl_eabi -#TOOLCHAIN_PREFIX="arm-openwrt-linux" -#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 -#TOOLCHAIN_PREFIX=arm-openwrt-linux -#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/${TOOLCHAIN_PREFIX}-gcc -OD=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-objdump -OC=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-objcopy -LD=$STAGING_DIR/bin/${TOOLCHAIN_PREFIX}-ld - -#for 7.0rc1 we need gcc with soft-float ONLY! -#apt-get install gcc-arm-linux-gnueabi - -#$GCC -static ./init.c -o ../cpio-fs/init -#$GCC -static ./init.c -o ../cpio-fs/init -arm-linux-gnueabi-gcc -static ./init.c -o ../cpio-fs/init -arm-linux-gnueabi-objcopy --strip-all ../cpio-fs/init ../cpio-fs/init -#$OC --strip-all ../cpio-fs/init ../cpio-fs/init - -#exit 0 - -cd ../ -./pack-kernel.sh -./ftp_upload.sh diff --git a/init/oldinit_analiz.sh b/init/oldinit_analiz.sh index a408c07..0d6f6f9 100755 --- a/init/oldinit_analiz.sh +++ b/init/oldinit_analiz.sh @@ -3,16 +3,9 @@ #(C) Sergey Sergeev aka adron, 2019 # -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 +. ../globals.sh -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 - -$OD ../cpio-fs/oldinit -x > ./oldinit.objdump -$OD ../cpio-fs/init -x > ./init.objdump +CPIO_FS="../cpio-fs-${TARGET_ARCH}" +$OBJDUMP ${CPIO_FS}/oldinit -x > ./oldinit.objdump +$OBJDUMP ${CPIO_FS}/init -x > ./init.objdump diff --git a/pack-kernel.sh b/pack-kernel.sh index ac67038..93f637b 100755 --- a/pack-kernel.sh +++ b/pack-kernel.sh @@ -3,19 +3,10 @@ #(C) Sergey Sergeev aka adron, 2019 # - -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 +. ./globals.sh ROOT=$(pwd) -cd ./cpio-fs +cd ./cpio-fs-${TARGET_ARCH} find . 2>/dev/null | cpio --quiet -o --format='newc' | \ xz --check=crc32 --lzma2=dict=512KiB > ${ROOT}/bins/kernel.p3-new.xz cd ${ROOT} @@ -25,3 +16,6 @@ cat ./bins/kernel.p2.xz ./bins/kernel.p3-new.xz > ./bins/kernel-new.combo ${OBJCOPY} --update-section initrd=./bins/kernel-new.combo ./bins/kernel.elf ./bins/kernel-new.elf #cat ./bins/kernel-new.elf > /var/lib/tftpboot/linux_t1.bin + +#now update busybox for current ARCH +cat ./cpio-fs-${TARGET_ARCH}/bin/busybox > ./for_ftp_upload/pub/OWL/bin/busybox diff --git a/unpack-kernel.sh b/unpack-kernel.sh index ebc5ed7..a0f81d6 100755 --- a/unpack-kernel.sh +++ b/unpack-kernel.sh @@ -3,6 +3,8 @@ #(C) Sergey Sergeev aka adron, 2019 # +. ./globals.sh + _kernel_bin_binwalk="" kernel_bin_binwalk(){ [ -z "${_kernel_bin_binwalk}" ] && \ @@ -86,10 +88,11 @@ truncate_kernel_p3(){ extract_kernel_cpiofs(){ local ROOT=$(pwd) - rm -Rf ./cpio-fs - mkdir ./cpio-fs - cd ./cpio-fs + rm -Rf ./cpio-fs-${TARGET_ARCH} + mkdir ./cpio-fs-${TARGET_ARCH} + cd ./cpio-fs-${TARGET_ARCH} xzcat ${ROOT}/bins/kernel.p3.xz | cpio -idv + cp ./init ./oldinit } unpack_kernel_bin @@ -102,4 +105,6 @@ unpack_kernel_bin extract_kernel_elf -#extract_kernel_cpiofs +#if cpio-fs dir is empty +ls -1qA ./cpio-fs-mips/ | grep -q . || \ +extract_kernel_cpiofs