diff --git a/README.md b/README.md index 3f3dd04..3fdbf85 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ busybox and then launch the telnetd service. To run Linux kernel with modified i uses the standard RouterBOOT ability - loading via the network using dhcp/bootp and tftp server. dhcp/bootp server can be deployed on another device with RouterOS and OpenWRT or even tftp32 program. For a one-time launch with tftp, You can use this commands in RouterOS: - + /system/routerboard/settings/set boot-device=try-ethernet-once-then-nand /system/reboot @@ -54,7 +54,7 @@ For Developers: cd ./finder ./Build.sh cd .. - edit ./globals.sh and set your target device ARCH: arm or mips + edit ./globals.sh and set your target device ARCH: aarch64 or arm or mips ./unpack-npk.sh ./ros/routeros-mipsbe-6.45.6.npk ./unpack-kernel.sh cd ./init @@ -65,3 +65,6 @@ For Developers: 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 + + If you want to boot the modified kernel from a flash drive, then place it in the /flash/boot dir: + nc x.x.x.y 1111 > /flash/boot/kernel diff --git a/cpio-fs-aarch64/bin/busybox b/busyboxes/aarch64/busybox similarity index 100% rename from cpio-fs-aarch64/bin/busybox rename to busyboxes/aarch64/busybox diff --git a/cpio-fs-aarch64/bin/busybox.readme b/busyboxes/aarch64/busybox.readme similarity index 100% rename from cpio-fs-aarch64/bin/busybox.readme rename to busyboxes/aarch64/busybox.readme diff --git a/cpio-fs-arm/bin/busybox b/busyboxes/arm/busybox similarity index 100% rename from cpio-fs-arm/bin/busybox rename to busyboxes/arm/busybox diff --git a/cpio-fs-mips/bin/busybox b/busyboxes/mips/busybox similarity index 100% rename from cpio-fs-mips/bin/busybox rename to busyboxes/mips/busybox diff --git a/cpio-fs-aarch64/oldinit b/cpio-fs-aarch64/oldinit index fbec3a8..e1309ac 100755 Binary files a/cpio-fs-aarch64/oldinit and b/cpio-fs-aarch64/oldinit differ diff --git a/cpio-fs-aarch64/readme.txt b/cpio-fs-aarch64/readme.txt index ced3b38..79a4913 100644 --- a/cpio-fs-aarch64/readme.txt +++ b/cpio-fs-aarch64/readme.txt @@ -1,3 +1,3 @@ -binary files from routeros arm64 7.1rc4! +binary files from routeros arm64 7.2rc1! routeros needs armv7 compiler! -In fact, the entire user space in it is still use 32bit! \ No newline at end of file +In fact, the entire user space in it is still use 32bit! diff --git a/cpio-fs-arm/init b/cpio-fs-arm/init index 54837aa..07fa874 100755 Binary files a/cpio-fs-arm/init and b/cpio-fs-arm/init differ diff --git a/cpio-fs-arm/oldinit b/cpio-fs-arm/oldinit index d2087e9..7380362 100755 Binary files a/cpio-fs-arm/oldinit and b/cpio-fs-arm/oldinit differ diff --git a/cpio-fs-arm/order b/cpio-fs-arm/order deleted file mode 100755 index fb01c1c..0000000 Binary files a/cpio-fs-arm/order and /dev/null differ diff --git a/cpio-fs-arm/readme.txt b/cpio-fs-arm/readme.txt index e9adba0..4808da1 100644 --- a/cpio-fs-arm/readme.txt +++ b/cpio-fs-arm/readme.txt @@ -1 +1 @@ -binary files from routeros arm 6.44! \ No newline at end of file +binary files from routeros arm 7.2rc1! \ No newline at end of file diff --git a/cpio-fs-mips/bin/busybox.readme b/cpio-fs-mips/bin/busybox.readme deleted file mode 100644 index 217122b..0000000 --- a/cpio-fs-mips/bin/busybox.readme +++ /dev/null @@ -1 +0,0 @@ -busybox скомпилен вот тут: /home/prog/openwrt/switch/mikrotik-tools-master/busybox-arm-soft-float diff --git a/for_ftp_upload/pub/OWL/bin/busybox b/for_ftp_upload/pub/OWL/bin/busybox index 4bf7a1a..a5d7f1a 100755 Binary files a/for_ftp_upload/pub/OWL/bin/busybox and b/for_ftp_upload/pub/OWL/bin/busybox differ diff --git a/ftp_upload.sh b/ftp_upload.sh index 75ab09d..25ab320 100755 --- a/ftp_upload.sh +++ b/ftp_upload.sh @@ -1,9 +1,9 @@ #!/bin/sh -HOST="172.20.1.1" +HOST="127.0.0.1" USER="admin" PASS=${FTP_UPLOAD_PASS} -[ -z ${PASS} ] && { +[ -z ${PASS} ] && [ ${HOST} != "127.0.0.1" ] && { echo "just do# export FTP_UPLOAD_PASS=xYz" exit 1 } @@ -11,6 +11,7 @@ FILE=./bins/kernel-new.elf FAKEFNAME="linux_t1.bin" [ "$HOST" = "127.0.0.1" ] && { cat $FILE > /var/lib/tftpboot/$FAKEFNAME + echo "$FILE > /var/lib/tftpboot/$FAKEFNAME" exit 0 } ftp -inv $HOST << EOF diff --git a/globals.sh b/globals.sh index 0fe12ec..1791c04 100644 --- a/globals.sh +++ b/globals.sh @@ -4,9 +4,9 @@ # #rb5009 -TARGET_ARCH="aarch64" +#TARGET_ARCH="aarch64" #rb3011(ipq806x), rb450dx4(ipq401x) -#TARGET_ARCH="arm" +TARGET_ARCH="arm" #ath79, ramips #TARGET_ARCH="mips" @@ -19,10 +19,14 @@ TOOLS_BINS_PREFIX="openwrt-linux" } [ ${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-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=arm-linux-gnueabi-gcc + OBJDUMP=arm-linux-gnueabi-objdump + OBJCOPY=arm-linux-gnueabi-objcopy + LD=arm-linux-gnueabi-ld } [ ${TARGET_ARCH} = "mips" ] && { @@ -31,7 +35,7 @@ TOOLS_BINS_PREFIX="openwrt-linux" export STAGING_DIR=$OPENWRT_DIR/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl } -GCC=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-gcc -OBJDUMP=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objdump -OBJCOPY=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objcopy -LD=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-ld +#GCC=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-gcc +#OBJDUMP=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objdump +#OBJCOPY=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-objcopy +#LD=$STAGING_DIR/bin/${TARGET_ARCH}-${TOOLS_BINS_PREFIX}-ld diff --git a/init/init.c b/init/init.c index 8c208bb..7be102b 100644 --- a/init/init.c +++ b/init/init.c @@ -7,9 +7,11 @@ #include #include #include +#include #include -void my_system(char *cmd, char *arg1, char *arg2, char *arg3){ +void my_system(char *cmd, char *arg1, char *arg2, char *arg3) +{ char *new_argv[] = { cmd, arg1, arg2, arg3, NULL }; pid_t pid; pid = fork(); @@ -21,8 +23,23 @@ void my_system(char *cmd, char *arg1, char *arg2, char *arg3){ waitpid(pid, NULL, 0); } +static void do_chmod(const char *fname, int perm) +{ + int fd; + fd = open(fname, O_RDONLY); + if (fd < 0) { + printf("do_chmod(): can't set permissions: %d to file: %s\n", + perm, fname); + return; + } + printf("Making %s executable\n", fname); + fchmod(fd, perm); + close(fd); +} + static char *work_dirs[ ] = { "/flash/rw/disk/pub", "/flash/rw/disk/flash/rw/disk/pub", NULL }; -void daemonized_OWL(void){ +void daemonized_OWL(void) +{ int a = 0; int ret = 0; static char bin_busybox[128]; @@ -46,17 +63,17 @@ void daemonized_OWL(void){ printf("work_dir found at: '%s'\n", work_dir); snprintf(bin_busybox, sizeof(bin_busybox), "%s/OWL/bin/busybox", work_dir); snprintf(owl_sh, sizeof(owl_sh), "%s/OWL.sh", work_dir); - if(stat(bin_busybox, &sb) == 0 && !(sb.st_mode & S_IXUSR)){ - printf("Making %s executable\n", bin_busybox); - my_system("/bin/busybox", "chmod", "777", bin_busybox); + if(stat(bin_busybox, &sb) == 0) { + if (sb.st_mode & S_IXUSR)) + do_chmod(bin_busybox, 777); + my_system(bin_busybox, "sh", owl_sh, work_dir); } - if(stat(owl_sh, &sb) == 0) - my_system("/bin/busybox", "sh", owl_sh, work_dir); - //my_system("/bin/busybox", "rm", "-Rf", "/flash/rw/disk/pub/OWL"); - //my_system("/bin/busybox", "ls", "-l", "/flash/rw/disk/flash/rw/disk"); - //my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh"); - //my_system("/bin/busybox", "ls", "-l", "/system/flash/rw/disk/pub"); - //my_system("/bin/busybox", "--help", NULL); + //my_system(bin_busybox, "sh", owl_sh, work_dir); + //my_system(bin_busybox, "rm", "-Rf", "/flash/rw/disk/pub/OWL"); + //my_system(bin_busybox, "ls", "-l", "/flash/rw/disk/flash/rw/disk"); + //my_system(bin_busybox, "ls", "-l", "/system/flash/rw/disk/pub/OWL.sh"); + //my_system(bin_busybox, "ls", "-l", "/system/flash/rw/disk/pub"); + //my_system(bin_busybox, "--help", NULL); //my_system("/order", "--help", NULL); sleep(1); } diff --git a/owl/bin/busybox b/owl/bin/busybox new file mode 100755 index 0000000..a5d7f1a Binary files /dev/null and b/owl/bin/busybox differ diff --git a/cpio-fs-arm/bin/busybox.readme b/owl/bin/busybox.readme similarity index 100% rename from cpio-fs-arm/bin/busybox.readme rename to owl/bin/busybox.readme diff --git a/owl/init b/owl/init new file mode 100755 index 0000000..8bc5e04 Binary files /dev/null and b/owl/init differ diff --git a/owl/oldinit b/owl/oldinit new file mode 100755 index 0000000..7380362 Binary files /dev/null and b/owl/oldinit differ diff --git a/owl/readme.txt b/owl/readme.txt new file mode 100644 index 0000000..4808da1 --- /dev/null +++ b/owl/readme.txt @@ -0,0 +1 @@ +binary files from routeros arm 7.2rc1! \ No newline at end of file diff --git a/pack-kernel.sh b/pack-kernel.sh index 93f637b..320bcac 100755 --- a/pack-kernel.sh +++ b/pack-kernel.sh @@ -18,4 +18,9 @@ ${OBJCOPY} --update-section initrd=./bins/kernel-new.combo ./bins/kernel.elf ./b #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 +BUSYBOX_FOR_ARCH="./busyboxes/${TARGET_ARCH}/busybox" +if [ -f ${BUSYBOX_FOR_ARCH} ]; then + cat ${BUSYBOX_FOR_ARCH} > ./for_ftp_upload/pub/OWL/bin/busybox +else + echo "Error: No busybox for TARGET_ARCH: ${TARGET_ARCH} !!!" +fi diff --git a/ready-kernels/kernel-new-7.2b1-arm64.elf b/ready-kernels/kernel-new-7.2b1-arm64.elf new file mode 100755 index 0000000..8c4339c Binary files /dev/null and b/ready-kernels/kernel-new-7.2b1-arm64.elf differ diff --git a/releases/7.2rc1-arm64.zip b/releases/7.2rc1-arm64.zip new file mode 100644 index 0000000..0de608d Binary files /dev/null and b/releases/7.2rc1-arm64.zip differ diff --git a/work/rb5009/ros/rootfs/dev/fd b/work/rb5009/ros/rootfs/dev/fd new file mode 120000 index 0000000..e15a8af --- /dev/null +++ b/work/rb5009/ros/rootfs/dev/fd @@ -0,0 +1 @@ +/proc/self/fd \ No newline at end of file diff --git a/work/rb5009/ros/rootfs/dev/log b/work/rb5009/ros/rootfs/dev/log new file mode 120000 index 0000000..6402fa5 --- /dev/null +++ b/work/rb5009/ros/rootfs/dev/log @@ -0,0 +1 @@ +/rw/log \ No newline at end of file