Entware and pyLoad on Android 7.1 TV Box

Entware is repository full of apps for embeded linux like android on tv box. I have prepared installation script to install it from scratch because android is different. You have to rebuild folders in root on every reboot. Root partition is rebuilt on every boot from the image. I will use /data partition to store files (path /data/opt) and mount –bind on /opt.

Check your architecture of processor and os. My TV Box has Amlogic S912 armv8 – aarch64. Just run two commands:

uname -a
cat /proc/cpuinfo

Processor : AArch64 Processor rev 4 (aarch64)
processor : 0
processor : 1
processor : 2
processor : 3
processor : 4
processor : 5
processor : 6
processor : 7
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 wp half thumb fastmult vfp edsp neon vfpv3 tlsi vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Hardware : Amlogic

Script will download binaries for aarch64. For another you have to change URL= and DLOADER and busybox binary.

Source of the install script and repository: http://bin.entware.net/aarch64-k3.10/installer/

First you have to root your device!

On windows you will need Minimal ADB: https://forum.xda-developers.com/showthread.php?t=2317790
On linux just install android-tools-adb android-tools-fastboot.

  1. Install WiFi ADB: https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb
    or http://www.mediafire.com/file/zki6u53zom8d684/WiFi_ADB_2.0.1.zip
  2. Run WiFi ADB and connect to via adb:
    adb connect ip:5555

    Accept and remember connection on TV Box

  3. Download script (source code is on the bottom):
  4. Download busybox for armv8 because my wget on TV Box was broken (it can’t finish any download):
  5. Push the script from disk to TV Box:
    adb push C:\Users\user\Desktop\ent-armv8-android.sh /storage/emulated/0/

    If there is permission denied use another directory.

  6. Push busybox binary:
    adb push C:\Users\user\Desktop\busybox-armv8l /storage/emulated/0/

    If there is permission denied use another directory.

  7. Run ADB shell an run all below as root with su:
    adb shell
  8. Move script from emulated internal memory to another without noexec flag:
    mv /storage/emulated/0/ent-armv8-android.sh /data/local
    chmod +x /data/local/ent-armv8-android.sh

    If there will be error Read only file system, just remount it to write and run again above commands:

    mount -o rw,remount /
    mount -o rw,remount /system
  9. Run the script:
    /system/bin/sh /data/local/ent-armv8-android.sh

    If there is a /bin you will be asked for delete. Do not delete it if it is not empty, just remove that part from script. It will delete /opt as well. Then will create neccesary folders and instsall opkg, basic enteware and dropbear for SSH.

  10. Script will create autorun script in /system/etc/init.d/entstart.sh It has to be run every boot to make entware and entware services to work. If your Android rom support init.d you dont’t have to do nothing.
  11. Another Auto Start options:
    • Try to enable init.d support with Uni-Init apk or sh script: https://forum.xda-developers.com/showthread.php?t=1933849 It does not work for me.
    • Try to modify init rc scripts. (it does not work for me i’ve still got init: Service exec () does not have a SELinux domain defined.)
      1. Try to rebuild image to modify /init.rc
      2. Modify init scripts from /system/rtc/init/
    • Check for any autorun static script:

      $ find /etc -type f -perm +110
      $ find /etc -name "*rc"
      $ find /etc -name "init*"
      $ grep -R /data /etc
      $ grep -R /system /etc

      I have checked either:

      dmesg | grep .sh

      I’ve got few candidates:

      init: cannot find /system/bin/kodi.sh’ (No such file or directory), disabling ‘kodiconf’
      init: cannot find ‘/system/bin/dtvdata.sh’ (No such file or directory), disabling ‘dtvdatas’
      init: cannot find ‘/system/bin/factoryreset.sh’ (No such file or directory), disabling ‘factoryreset’

      You can try run init.d
      First use app Uni-init to create all files ant contexts: https://forum.xda-developers.com/showthread.php?t=1933849 and hen link your built-in in rom script to sysinit created by this app:

      ln -s /system/etc/init.d/sysinit /system/bin/kodi.sh

      now you have properly working init.d.

      There is exmaple of script to run all init.d if your need yor own:

      touch $AUTO_START
      echo -e "#!/system/bin/sh" > $AUTO_START 
      echo -e "\n" >> $AUTO_START 
      echo -e "sleep 1" >> $AUTO_START 
      echo -e "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> $AUTO_START 
      echo -e "/system/bin/busybox run-parts /system/etc/init.d" >> $AUTO_START 
      echo -e "\n" >> $AUTO_START
      chmod 0755 $AUTO_START

      If SELINUX blocked you…

    • Just install app SManager: https://play.google.com/store/apps/details?id=os.tools.scriptmanager or http://www.mediafire.com/file/skh4dkla2e1d5bo/SManager_3.0.7.zip and add /system/etc/init.d/entstart.sh to autostart with su privileges. (to do that click still upper directory even there is access denied)
  12. Modify /system/etc/mkshrc and add
    export PATH=$PATH
  13. Install pyload:
    opkg install ca-bundle ca-certificates
    opkg install pyload
    opkg install python-pyopenssl openssl-util
    opkg install duktape
    opkg install pillow tesseract
    opkg install python-crypto
    opkg install unrar unzip
    opkg install p7zip
    pyload --configdir=/opt/var/pyload


#set paths
SYS_DIRS="/etc /lib /bin /tmp /lib/opkg /var/lock"
echo "Mount to write"
mount -o rw,remount /
mount -o rw,remount /system
echo "Set DNS for future wget"
echo -e "nameserver\nnameserver" > /etc/resolv.conf
echo "Installing busybox for fix wget"
if [ -f "$BBOX_BIN" ]
	cp -rf $BBOX_BIN /system/xbin/busybox
	chmod 0755 /system/xbin/busybox
	#for i in $(/system/xbin/busybox ); do
	#	echo "$i"
	/system/xbin/busybox --install -s /system/xbin
	echo "Can't find $BBOX_BIN . Download it and push with adb push busybox-armv8l /storage/emulated/0/"
	echo "Sorry you have to do that manually"
	exit 1
echo -e "Before installation we have to delete all directories in: $OPT_DIR. Just CTR+C if you are not sure or run manually\nrm -rf $OPT_DIR\nrm -rf $MAIN_DIR"
umount $MAIN_DIR
rm -ri $OPT_DIR
rm -ri $MAIN_DIR
if [ -d "$MAIN_DIR" ]
	echo "Warning: Folder $MAIN_DIR exists! Remove an re run script"
	exit 1
	echo "Make $MAIN_DIR and mount --bind $OPT_DIR $MAIN_DIR"
	mkdir -p $OPT_DIR
	mkdir -p $MAIN_DIR
	mount --bind $OPT_DIR $MAIN_DIR
	#ln -s $OPT_DIR $MAIN_DIR
if [ -d "/bin" ]
	echo "Warning: Folder /bin exists! Deleting it may break you device if you are not sure just CTRL+C"
	echo "Removing /bin - if you know what are you doing just run rm -rf /bin"
	umount /bin
	rm -ri /bin
	echo "Make /bin and mount --bind $OPT_DIR/bin /bin"
	mkdir -p $OPT_DIR/bin
	mkdir -p /bin
	mount --bind $OPT_DIR/bin /bin
	#ln -s $OPT_DIR/bin /bin
	echo "Link shell /bin/sh"
	ln -s /system/bin/sh /bin/sh
echo "Checking folders..."
for folder in $SYS_DIRS
  if [ -d "$OPT_DIR$folder" ]
    echo "Warning: Folder $OPT_DIR$folder exists!"
    mkdir -p $OPT_DIR$folder
echo "Exporting path"
export PATH=/bin:$PATH:/$OPT_DIR/bin:$OPT_DIR/sbin
# Fix for multiuser environment
chmod 777 $MAIN_DIR/tmp
echo "Info: Opkg package manager deployment..."
wget $URL/opkg -O /opt/bin/opkg
chmod 755 /opt/bin/opkg
wget $URL/opkg.conf -O /opt/etc/opkg.conf
wget $URL/ld-2.27.so -O /opt/lib/ld-2.27.so
wget $URL/libc-2.27.so -O /opt/lib/libc-2.27.so
wget $URL/libgcc_s.so.1 -O /opt/lib/libgcc_s.so.1
wget $URL/libpthread-2.27.so -O /opt/lib/libpthread-2.27.so
cd /opt/lib
chmod 755 ld-2.27.so
ln -s ld-2.27.so $DLOADER
ln -s libc-2.27.so libc.so.6
ln -s libpthread-2.27.so libpthread.so.0
echo "Info: Basic packages installation..."
/opt/bin/opkg update --force-space
/opt/bin/opkg upgrade --force-space
/opt/bin/opkg install busybox --force-space
/opt/bin/opkg install entware-opt --force-space
echo "Install ca certs for curl https support"
/opt/bin/opkg install ca-bundle ca-certificates --force-space
# Fix for multiuser environment
chmod 777 /opt/tmp
# now copy default files - it is an alternative installation
cp -f /opt/etc/passwd.1 /opt/etc/passwd
cp -f /opt/etc/group.1 /opt/etc/group
cp -f /opt/etc/shells.1 /opt/etc/shells
if [ -f /etc/localtime ]
    ln -sf /etc/localtime /opt/etc/localtime
echo "Install SSH dropbear"
/opt/bin/opkg install dropbear --force-space
/opt/sbin/dropbear -p 22 -a
if [ $? == 0 ]; then
    echo "Info: Using standard port 22 for dropbear"
   /opt/sbin/dropbear -p 12345 -a
   echo "Warning: Using non-standard port 12345 for dropbear. Please check your init.d"
echo -e "\n\n\n"
echo "Now you can login via SSH on port 22 login: root and password: 12345"
echo -e "\n"
echo "Creating autostart script"
mkdir -p /system/etc/init.d/
chmod 0755 $AUTO_START
echo -e "#!/system/bin/sh" >> $AUTO_START 
echo -e "\n" >> $AUTO_START 
echo -e "sleep 5" >> $AUTO_START 
echo -e "mount -o rw,remount /" >> $AUTO_START 
echo -e "mount -o rw,remount /system" >> $AUTO_START 
echo -e "mkdir -p $MAIN_DIR" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR $MAIN_DIR" >> $AUTO_START 
echo -e "mkdir -p /bin" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR/bin /bin" >> $AUTO_START 
echo -e "mkdir -p /tmp" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR/tmp /tmp" >> $AUTO_START 
echo -e "export PATH=\$PATH:/opt/bin:/opt/sbin" >> $AUTO_START 
echo -e "/opt/etc/init.d/rc.unslung start" >> $AUTO_START 
echo -e "mount -o ro,remount /" >> $AUTO_START 
echo -e "mount -o ro,remount /system" >> $AUTO_START 
echo -e "\n" >> $AUTO_START 
echo "If init.d supported there is a script $AUTO_START or run via autostart SManager app"
echo -e "\n\n\n"
echo "Mount to read-only"
mount -o ro,remount /
mount -o ro,remount /system

Simultaneous dual wan access and bind app (pyload, transmission) on interface to ip on Asus Router

Asus routers has builtin DualWan in two modes. First one, Failover disables second WAN until first one stop works so you cannot use it. Loadbalancing – no one know what it is doing, it has closed sources and you do not know when do you connect which interface. First disable builtin DualWAN and leave as main WAN.

I will describe dual wan with dual default gateways: First cable WAN and second USB hilink modem. We want use main WAN but some apps just bind to second WAN. It is called Source Based Routing. We will use iproute2 and routing tables. Basically we will set rule: if source address is from app using second wan interface use other table rule with other default gateway/router. You can create much more than two.

Check that you have routing tables, if not create one:

cat /etc/iproute2/rt_tables

100 wan0
111 ovpnc1
112 ovpnc2
113 ovpnc3
114 ovpnc4
115 ovpnc5
200 wan1

We will use wan1, if it is empty:

ip route list table wan1

My second WAN is USB Modem HiLink so I have to manually turn on the modem on Asus Router via command line. Router has preinstalled drivers. So just look in dmesg which interface it brings:

dmesg | grep usb
dmesg | grep USB

cdc_ether 2-2:1.0: eth3: register 'cdc_ether' at usb-0000:00:0a.1-2, CDC Ethernet Device
My interface for 3G usb modem is eth3. Bring it up:

ifconfig eth3 up

We have to assign ip address, mask and subnet to this interface. Asus has dhcp client called: udhcpc. It works but you have to create script:

touch /jffs/scripts/udh.sh
chmod +x /jffs/scripts/udh.sh
nano /jffs/scripts/udh.sh

Content of udh.sh

[ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
IFS=. read -r i1 i2 i3 i4 <<EOF
IFS=. read -r m1 m2 m3 m4 <<EOF
SUBIP=$(printf "%d.%d.%d.%d" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))")
mask2cidr() {
    for dec in $1 ; do
case $dec in
    255) let nbits+=8;;
    254) let nbits+=7;;
    252) let nbits+=6;;
    248) let nbits+=5;;
    240) let nbits+=4;;
    224) let nbits+=3;;
    192) let nbits+=2;;
    128) let nbits+=1;;
    *) echo "Error: $dec is not recognised"; exit 1
    printf "$nbits"
CIDR=$(mask2cidr $subnet)
case "$1" in
        echo "Clear existing config"
        ifconfig $interface
        ip addr flush dev $interface
        echo "Setting IP $ip/$CIDR"
        #ip addr add $ip/$CIDR broadcast $BROADCAST dev $interface
        ifconfig $interface $ip $BROADCAST $NETMASK
        echo "Route subnet"
        ip route add $SUBIP/$CIDR dev $interface src $ip table $TABLE
        echo "Route in local subnet"
        ip route add $SUBIP/$CIDR dev $interface 
        echo "Setting default gateway"
        if [ -n "$router" ] ; then
            echo "Deleting routers"
            while ip route del default dev $interface table $TABLE  ; do
            while ip route del default dev $interface ; do
            for i in $router ; do
                echo "Adding router $i"
                ip route add default via $i dev $interface metric $metric table $TABLE
                : $(( metric += 1 ))
        #from and to
        echo "IP Rule"
        ip rule add from $ip/32 table $TABLE
        ip rule add to $ip/32 table $TABLE
        #set firewall
        echo "Firewall set"
        iptables -t nat -A POSTROUTING -o $interface -j MASQUERADE
exit 0

Now run test of udhcpc:

udhcpc -i eth3 -s /jffs/scripts/udh.sh

If everything works and interface has IP address you can add it to autostart. But do not forget add -b switch for udhcpc to work in background for renew the dhcp leases. I will add autostart to post-mount because i has USB modem so i have to wait until it is initialized. Edit post-mount

nano /jffs/scripts/post-mount

add :
ifconfig eth3 up
udhcpc -i eth3 -b -s /jffs/scripts/udh.sh

Now you can bind pyload to second wan interface. Open Config > Menu > General > Download > Download interface to bind (ip or Name)
Enter your interface name for example eth3:

Now check it is works. Add download job with URL to html web page which shows your ip (it cannot be js/html5) for example http://www.whatismyip.net. Open downloaded html file and check it is second wan ip adress.

List of commands without script:
MASK: or /24
SUBNET: 192.168.0

ifconfig eth3 up
ifconfig eth3
ifconfig eth3
ip route add 192.168.0/24 dev eth3 src table wan1
ip route add 192.168.0/24 dev eth3
ip route del default dev eth3 table wan1
ip route del default dev eth3
ip route add default via dev eth3 metric 0 table wan1
ip rule add from table wan1
ip rule add to table wan1
iptables -t nat -A POSTROUTING -o eth3 -j MASQUERADE

There is much more routes because i want to access second gateway config page on 192.168.1 from local subnet.
Use MASQUERADE on last step only if you enabled firewall in router settings. If you disabled you have to create forward rule. You can check iptables for correct one:

iptables -t nat -vL
iptables -vL

You can change DNS servers by adding in script:

echo "Recreating $RESOLV_CONF"
# If the file is a symlink somewhere (like /etc/resolv.conf
# pointing to /run/resolv.conf), make sure things work.
realconf=$(readlink -f "$RESOLV_CONF" 2&gt;/dev/null || echo "$RESOLV_CONF")
&gt; "$tmpfile"
[ -n "$domain" ] &amp;&amp; echo "search $domain" &gt;&gt; "$tmpfile"
for i in $dns ; do
	echo " Adding DNS server $i"
	echo "nameserver $i" &gt;&gt; "$tmpfile"
mv "$tmpfile" "$realconf"

Of course you can built your own dual wan script and switch to second wan in failover:

ip route change default via dev eth3 metric 0

LoadBalancing is much more complicated.

mask2cidr – https://www.linuxquestions.org/questions/programming-9/bash-cidr-calculator-646701/#post3173472
subnet ip from ip and mask: https://stackoverflow.com/questions/15429420/given-the-ip-and-netmask-how-can-i-calculate-the-network-address-using-bash
script for udhcpc simple.script – https://github.com/brgl/busybox/tree/master/examples/udhcp

Segmentation fault by unrar parts of archive on Asus Router

Unrar and unzip installation:

opkg install unrar unzip

UNRAR 5.50 freeware Copyright (c) 1993-2017 Alexander Roshal
Just simply change dir and use short paths.
First cd to your directory with parts of archive:

cd /home/Downloads
unrar x archive.part01.rar

Continue reading

Aria2 on Asus Router with AsusWRT Merlin

Built-in Download Master from Asus is not very good. So you can install Entware and Aria2 Download manager on your router. You have to connect USB hard drive but first create and Linux partition on it (recommended ext4). On Windows you can use MiniTool Partition Wizard on linux just use GParted. You can shrink main partition and create second with ext4 or ext3 file system.

  • Enable SSH in Administration > System > Enable SSH > LAN Only
  • Log in with Putty on Windows or terminal on Linux toy your router via SSH and run script and put number of tour partition (remember to create ext4). Login and password is the same for admin in web panel.

  • Install Aria2, lighttpd and certificates to support SSL and php (not necessary for this gui)
    opkg install aria2 ca-bundle ca-certificates lighttpd lighttpd-mod-fastcgi php7-fastcgi
  • Install WEB GUI for Aria2:
    wget -c -O /opt/tmp/webui-aria2.zip https://github.com/ziahamza/webui-aria2/archive/master.zip --no-check-certificate
    unzip /opt/tmp/webui-aria2.zip -d /opt/tmp/
    rm /opt/tmp/webui-aria2.zip
    mv /opt/tmp/webui-aria2-master /opt/share/www/aria2
  • Configure lighttpd for php and port 81:
    sed -i 's/#server.port = 81/server.port = 81/g' "/opt/etc/lighttpd/lighttpd.conf"
    sed -i "/server.upload-dirs*/cserver.upload-dirs = ( \"/opt/tmp\" )" "/opt/etc/lighttpd/lighttpd.conf"
    cat &gt;&gt; /opt/etc/lighttpd/conf.d/30-fastcgi.conf &lt;&lt; EOF server.modules += ( "mod_fastcgi" ) fastcgi.server = ( ".php" =&gt;
    ( "localhost" =&gt;
    ( "socket" =&gt; "/tmp/php-fcgi.sock",
    "bin-path" =&gt; "/opt/bin/php-fcgi",
    "max-procs" =&gt; 1,
    "bin-environment" =&gt;
    ( "PHP_FCGI_CHILDREN" =&gt; "2",
    "PHP_FCGI_MAX_REQUESTS" =&gt; "1000" )
  • Edit configuration of Aria2 in /opt/etc/aria2.conf. If you create a small partition with ext4 you should change download directory to main partition (it should be sub-directory for example Downloads):
  • Run aria2 and lighttpd:
    /opt/etc/init.d/S81aria2 start
    /opt/etc/init.d/S80lighttpd start
  • Open in web browser (replace your router address):
  • Configure Secret Token in Settings > Connection Settings > Enter the secret token default token is Passw0rd. Save settings on the bottom.
  • Done. You can download via http(s), ftp(s) and torrents.

Windows 10 black screen and cannot boot after windows update 11.2017 – November 2017

Yesterday i’ve got system updates:


I shut down my computer. Today when i turn it on i’ve got error 0xc0000225. One of them killed my system.
My Windows 10 is 1703 Creators Update.

There is a new version 1709 Fall Creators Update.

To solve it you have to boot computer from usb or cd.
You can download newest image from Microsoft:
If you have problem you can go to english version, then you can choose language for the iso:
For older compilations you have to search in the web.

First try to System Restore point

If that not help you have to run run command line and backup current system registry and thenrestore registry.
Copy from:
ren C:\WINDOWS\system32\config\system system.bak
cp C:\Windows\System32\config\RegBack\system C:\WINDOWS\system32\config\

Reboot the PC.

Then i’ve got error 0xc0000001

So boot again from USB and copy the acpu.sys or another file(be sure you have booted from correct version of windows x64 or x86):
Run command line in troubleshoting.
Copy acpi.sys from drive X – this is booted partition image from pendrive. (Or you can grab needed file from antoher computer and copy it from pendrive)
cp X:\Windows\System32\drivers\acpi.sys C:\WINDOWS\system32\drivers\

My computer is working. Enjoy if it helps you.

Windows 7 cannot run apps as admin by UAC prompt

I had a problem with running apps as admin on the administrators accounts (users in group administrators). But not only as admin, nothing happen on every UAC prompt when i click Yes to run. I cannot run any elevated application.

Some time ago i had set auto login on non admin user account via netplwiz.exe and when i disable auto login everything works fine!

Solution is: in netplwiz check box user must enter login and password.