Tuesday, December 11, 2018

RASPBERRY PI 2 MODEL B WITH TL-WN725N Version 2

#********************************************************************************
# RASPBERRY PI 2 MODEL B ON DEBIAN STRETCH 9.6
#********************************************************************************

root@raspime:~# cat /etc/debian_version
9.6

root@raspime:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

root@raspime:~# uname -a
Linux raspime 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

root@raspime:~# cat /proc/cpuinfo | grep Revision
Revision        : a01041

Note :
Hardware revision code from Cpuinfo for Pi 2 Model B is a01041 (Sony, UK) or a21041 (Embest, China).


If you are not sure for your TP-LINK wifi dongle version , please refer to this page
#*******************************************************************************
# WIFI DONGLE TL-WN725N Version 2
#*******************************************************************************

root@raspime:~# lsusb
Bus 001 Device 005: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter


#*******************************************************************************
# DRIVER FOR TL-WN725N Version 2
#*******************************************************************************

root@raspime:~# sudo wget http://downloads.fars-robotics.net/wifi-drivers/install-wifi -O /usr/bin/install-wifi
root@raspime:~# sudo chmod +x /usr/bin/install-wifi
root@raspime:~# /usr/bin/install-wifi

Then run install-wifi to install driver automatically, for more information (updated information) please refer to this site




MINIDLNA - AUTO SCAN WHEN USB DISK INSERTED

READ THIS BEFORE CONTINUE

#
#*******************************************************************************
# RASPBERRY PI 2 MODEL B ON DEBIAN STRETCH 9.6
#*******************************************************************************
#
# /etc/os-release
#
root@raspime:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Instal needed package using this command
root@raspime:~# apt-get install udisks-glue policykit-1 supervisor

#
#*******************************************************************************
# MINIDLNA CONFIGURATION
#*******************************************************************************
#
# /etc/minidlna.conf
#
root@raspime:~# cat /etc/minidlna.conf

media_dir=V,/media/minidlna/MOVIES
media_dir=A,/media/minidlna/MUSICS
media_dir=P,/media/minidlna/PICTURES

friendly_name=Raspime Media Server
inotify=yes
notify_interval=30
db_dir=/var/cache/minidlna
log_dir=/var/log
log_level=warn


Check minidlna version
root@raspime:~# apt show minidlna

Package: minidlna
Version: 1.2.1-1
Status: install ok installed
Priority: extra
Section: checkinstall
Maintainer: diantokam@raspime
Installed-Size: 598 kB
Provides: minidlna
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: MiniDLNA Version 1.2.1 Compiled December 4, 2018
Compiled for Debian 9.6 by  diantokam.blogspot.com


root@raspime:~# minidlnad -V

Version 1.2.1

#
# /etc/init.d/minidlna status
#
root@raspime:~# /etc/init.d/minidlna status

minidlna.service - LSB: minidlna server
Loaded: loaded (/etc/init.d/minidlna; generated; vendor preset: enabled)
Active: active (exited) since Thu 2018-12-06 20:00:02 WIB; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 7385 ExecStop=/etc/init.d/minidlna stop (code=exited, status=0/SUCCESS)
Process: 7395 ExecStart=/etc/init.d/minidlna start (code=exited, status=0/SUCCESS)

Dec 06 20:00:02 raspime systemd[1]: Started LSB: minidlna server.

#*******************************************************************************
# SUPERVISOR
#*******************************************************************************

root@raspime:~# cat /etc/supervisor/conf.d/minidlna_scanmedia.conf

[program:minidlna_scanmedia]
command=/usr/local/bin/minidlna_scanmedia.sh
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/minidlna_scanmedia-out.log
stderr_logfile=/var/log/supervisor/minidlna_scanmedia-err.log



root@raspime:~# /etc/init.d/supervisor restart

[ ok ] Restarting supervisor (via systemctl): supervisor.service.


root@raspime:~# supervisorctl

minidlna_scanmedia               RUNNING   pid 10259, uptime 0:01:45
udisks-glue                      RUNNING   pid 10260, uptime 0:01:45

supervisor>

* Type quit for quit

#*******************************************************************************
# MINIDLNA_SCANMEDIA.SH
#*******************************************************************************
#
# /usr/local/bin/minidlna_scanmedia.sh
#
root@raspime:~# cat /usr/local/bin/minidlna_scanmedia.sh

#!/bin/bash
# Created by diantokam.blogspot.com
# December 8, 2018
# This script will runing continuous to check if any
# flashdisk mounted on /media/ by checking log from
# udisk-glue fromsupervisord


while :
do
cat /var/log/supervisor/udisks-glue-out.log | grep -v "BOOTLOADER" | grep media | grep Successfully
cat /var/log/supervisor/udisks-glue-out.log | grep media | grep Successfully
        if [ $? -eq 0 ]
                then
                echo `date`
                echo "mounted media successfully and minidlna will force-reload"
                sleep 10

                service minidlna force-reload
                sleep 5
                echo "" >/var/log/supervisor/udisks-glue-out.log
                break
        fi
                #echo "scan terus gan"
sleep 3
done


WHEN USB FLASHDISK INSERTED AND MOUNTED BY UDISK-GLUE

Supervisord continously run minidlna_scanmedia.sh until it recognize there is usb disk mounted on /media/SLAX9.4, it will run "service minidlna force-reload" and then clear "/var/log/supervisor/udisks-glue-out.log" so it becomes empty

#*******************************************************************************
#ACTION !
#*******************************************************************************
root@raspime:~# mount | grep media

/dev/sdb1 on /media/SLAX9.4 type fuseblk (rw,nosuid,nodev,noatime,sync,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks)


root@raspime:~# cat /var/log/supervisor/minidlna_scanmedia-out.log

Successfully automounted /dev/sdb1 at /media/SLAX9.4
Thu 6 Dec 20:31:43 WIB 2018
mounted media successfully and minidlna will force-reload

The script will then clear udisks-glue-out log

root@raspime:~# cat /var/log/supervisor/udisks-glue-out.log
** EMPTY **

Configure automount for usb drives using UDISK-GLUE and SUPERVISOR

#
#*******************************************************************************
# RASPBERRY PI 2 MODEL B ON DEBIAN STRETCH 9.6
#*******************************************************************************
#
# /etc/os-release
#
root@raspime:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
root@raspime:~# apt-get install udisks-glue policykit-1 supervisor


#
#*******************************************************************************
# UDISK-GLUE
#*******************************************************************************
#
# /etc/udisks-glue.conf
#
root@raspime:~# cat /etc/udisks-glue.conf
filter disks {
    optical = false
    partition_table = false
    usage = filesystem
}

match disks {
           automount = true
          # For NTFS mount with read and write
           automount_options = { sync, noatime, 'dmask=0000', 'fmask=0000', 'umask=0000' }
           post_mount_command = "mount-notify mounted %device_file %mount_point"
           post_unmount_command = "mount-notify unmounted %device_file %mount_point"
}


#
#*******************************************************************************
# SUPERVISOR
#*******************************************************************************
#
# /etc/supervisor/supervisord.conf
#
root@raspime:~# cat /etc/supervisor/supervisord.conf
[unix_http_server]

[supervisord]

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]

[include]
files = /etc/supervisor/conf.d/*.conf
[inet_http_server]

# For web accesses
port=*:9001
username=admin
password=admin

#
# /etc/supervisor/conf.d/udisks-glue.conf
#
root@raspime:~# cat /etc/supervisor/conf.d/udisks-glue.conf
[program:udisks-glue]
user = root
command = udisks-glue -f
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/udisks-glue-out.log
stderr_logfile = /var/log/supervisor/udisks-glue-err.log


root@raspime:~# ls -al /etc/supervisor/conf.d/
total 16
drwxr-xr-x 2 root root 4096 Dec  6 20:15 .
drwxr-xr-x 3 root root 4096 Dec  6 13:29 ..
-rw-r--r-- 1 root root  209 Dec  6 14:25 udisks-glue.conf

Restart service after create configuration file
root@raspime:~# /etc/init.d/supervisor restart
[ ok ] Restarting supervisor (via systemctl): supervisor.service.

Check if udisk-glue process from supervisor running or not
root@raspime:~# supervisorctl
udisks-glue                      RUNNING   pid 10260, uptime 0:01:45
supervisor>
* Type quit for quit

OR check via web

Wednesday, January 31, 2018

How To Install TWRP-3.0.2.0 on MIUI 9 (Mi Note Marshmallow)

1. First, be sure to have android drivers for your Mi note. You will need it to use fastboot or adb...
  • Personally, I use PDANet driver for windows. plug your device and install it, if it fail, restart your computer using "Disable driver signature enforcement" explained here.
  • Or use Mi PC Suite
2. Don't forget to have USB Debugging in Developer options (you know how to do it )

3. Next, reboot your phone in fastboot (power +volume down pressed).

4. Now, you have to download a special version of TWRP for Mi note  TWRP-3.0.2.0-Virgo (unzip it to get the img file)

5. Next, reboot your phone in fastboot (power +volume down pressed).
  • in fastboot mode. You can do the next step to test if TWRP Image is working, it will boot your device temporary usig TWRP (not installed yet)
Code:
fastboot boot twrp-virgo.img

  • if everything okay, then flash it using fastboot with this command
Code:
fastboot flash recovery twrp-virgo.img

6. Reboot your device wuth this command


Code:
fastboot reboot
If you want to root your device using TWRP, you can read it here

Source : miui forum

How To Root MIUI 9 (Mi Note Marshmallow)

1. First, be sure to have android drivers for your Mi note. You will need it to use fastboot or adb...
  • Personally, I use PDANet driver for windows. plug your device and install it, if it fail, restart your computer using "Disable driver signature enforcement" explained here.
  • Or use Mi PC Suite
2. Don't forget to have USB Debugging in Developer options (you know how to do it )

3. Next, reboot your phone in fastboot (power +volume down pressed).
  • You can also find others mini adb/fastboot like in xda...
4. Now, you have to download the last version of SuperSU, and a special version of TWRP for Mi note :
5. Put the SuperSu zip in your device (/sdcard/ for example, somewhere accessible with twrp)

6. FINALLY, you have all to root your device !
  • I recommend you to put the fastboot/adb mini unzipped in the top of the c: directory, just to be more easier to access, like c:\adb
  • put TWRP img next to adb and fastboot file (like in my example in c:\adb)
  • Run a command promt :
Code:
cd c:\adb device
List of devices attached
57d7493e
  • If you see a number with fastboot like "12345678 fastboot", your smartphone is recognize and in fastboot mode. You can do the next step :
Code:
fastboot boot twrp-virgo.img
7. Your Mi note will reboot with TWRP started (and not installed).
  • Touch "Install" and select the SuperSu zip to flash
  • Swipe to install...
  • For me, it was installed without any error
  • BE ATTENTIVE, for any reason, after installing the zip, twrp will you recommend to install their SuperSu, don't do it !! Don't swipe it !!Select the middle button to ignore it, it's an automated function, which is useless and you will need to re-flash your ROM and re root it... (or worst)
  • reboot your device
  • After reboot, I do not remember but if there is no SuperSu app displayed, just install it from the playstore. Run it. It can ask you to update SuperSu, update it choosing NORMAL mode and Reboot :)
8. Your Mi note is rooted !!

Source : miui forum

Sqlite3 on Android Marshmallow (armv7)

This is only updated info for installing Sqlite3-3.21.0 on Android Marshmallow, you can get binary from here (i got from XDA), For installation instruction you can follow this tutorial.