2013年11月15日 星期五

Installing MySQL with phpMyAdmin On NAS4Free

* Platform OS        : FreeBSD 9.1-RELEASE-p5 (kern.osreldate: 901000)
* Version               : 9.1.0.1 - Sandstorm (revision 847)
* Build date           : Sun Aug 18 03:49:41 CEST 2013

Install MySQL server

First.
ADD a new Group on WebGUI and called mysql
ADD a new User on WebGUI and called mysql
Set the Set the account's primary group to mysql.

§  Log into NAS4Free using SSH or Telnet, for instance by using Putty
§  Create the MySQL data directory:
# mkdir /<directory_name>/db/mysql
§  Create the MySQL symbolic link:
# ln -s /<directory_name>/db/mysql /var/db/mysql
§  Change the owner:
# chown -R mysql:mysql /<directory_name>/db/mysql/
§  Allow anyone access the temporary directory:
# chmod 777 /tmp
# chmod 777 /var/tmp
# chmod 777 /ftmp
§  Install MySQL server:
# pkg_add -r mysql50-server
§  Create database:
# /usr/local/bin/mysql_install_db --user=mysql
# chown -R mysql /var/db/mysql
§  Start MySQL:
# /usr/local/bin/mysqld_safe &
§  Change the password:
# /usr/local/bin/mysqladmin -u root password 'root_password'
§  Edit config file:
# vi /etc/rc.conf
§  Start MySQL automatically by adding contents like that in this file:
mysql_enable="YES"
§  Reboot

Install PHP

§  The file cause WebGUI crash, Backup this file:
cp /usr/local/lib/libxml2.so.5 /tmp/libxml2.so.5
§  Install PHP packages:
# pkg_add -r php5-extensions
# pkg_add -r php5-xmlrpc
# pkg_add -r php5-gettext
# pkg_add -r php5-mcrypt
# pkg_add -r php5-mysql
# pkg_add -r php5-mbstring
# pkg_add -r php5-mysqli
§  Fix WebGUI crash problem:
# mv /usr/local/bin/php /usr/local/bin/php-cli
# cp /usr/local/bin/php-cgi /usr/local/bin/php
# rm /usr/local/lib/libxml2.so.5
# cp /tmp/libxml2.so.5 /usr/local/lib/libxml2.so.5

Install phpMyAdmin

  • Create the phpMyAdmin directory:
# mkdir /<directory_name>
§  Extract the contents of the phpMyAdmin to the new directory. Run the following command in Linux terminal.
# cd /<directory_name>
# fetch http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.9/phpMyAdmin-4.0.9-all-languages.tar.gz
# tar -zxvf phpMyAdmin-4.0.9-all-languages.tar.gz
§  Create the phpMyAdmin symbolic link:
# ln -s /<directory_name>/phpMyAdmin-4.0.9-all-languages /<directory_name>/phpMyAdmin
# ln -s /<directory_name>/phpMyAdmin /<web_directory>/phpMyAdmin
§  Access phpMyAdmin:
http://< NAS4Free_IP >/phpMyAdmin

2013年6月1日 星期六

Running Dropbox at Startup on QNAP NAS

* Model              : SS-439 Pro
* Version            : 3.8.3 build0426
* Date               : 2013/04/26

Make a new share on QNAP NAS and called Dropbox

Declaring a Dropbox QPKG which launches script at startup.
§  Log into QNAP device using SSH or Telnet, for instance by using Putty
§  Edit QPKG config file:
# vi /etc/config/qpkg.conf
§  Declare a new Dropbox package by adding contents like that in this file:
[Dropbox]
Name = Dropbox
Version = 2.0.22
Author = Dropbox
Date = 2013-05-06
Shell = /share/MD0_DATA/.qpkg/Dropbox /Dropbox.sh
Install_Path = /share/MD0_DATA/.qpkg/Dropbox
Enable = TRUE
Note: if NAS doesn't have /share/MD0_DATA (i.e. is a one-drive NAS), put the right directory into the Shell and Install_Path variables.
§  Create the Dropbox package directory:
# mkdir -p /share/MD0_DATA/.qpkg/Dropbox
§  Extract the contents of the Dropbox package to the new directory. Run the following command in Linux terminal.
# cd /share/MD0_DATA/.qpkg/Dropbox
# wget https://www.dropbox.com/download?plat=lnx.x86 --no-check-certificate
# tar -xzf dropbox-lnx.x86-2.0.22.tar.gz
§  Create the Dropbox symbolic link:
# ln -sf /share/MD0_DATA/Dropbox /share/MD0_DATA/.qpkg/Dropbox/Dropbox
§  Create the .dropbox directory:
# mkdir -p /share/MD0_DATA/.qpkg/Dropbox/.dropbox
§  Create the Dropbox script with the contents:
# vi /share/MD0_DATA/.qpkg/Dropbox/Dropbox.sh
§  To be able to enable and disable the Dropbox feature edit the script
#!/bin/sh

CONF=/etc/config/qpkg.conf
QPKG_NAME="Dropbox"

RETVAL=0
QPKG_BASE=
HOME=

DROPBOX_USER="admin"
DAEMON=.dropbox-dist/dropbox

LOCALE=en_US.UTF-8

HOMEDIR=`getent passwd $DROPBOX_USER | cut -d: -f6`

case "$1" in
  start)
 if [ `/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF` = UNKNOWN ]; then
       /sbin/setcfg $QPKG_NAME Enable TRUE -f $CONF
 elif [ `/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF` != TRUE ]; then
       echo "Dropbox is disabled."
       exit 1
 fi
                 PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
        if [ -z $PID ] ; then
            echo "Starting Dropbox..."
        else
            echo "Dropbox is running. (PID $PID)"
                          exit 1
        fi
         HOME=$(/sbin/getcfg $QPKG_NAME Install_Path -d "" -f $CONF) 
         [ -d $HOMEDIR ] || /bin/mkdir -p $HOMEDIR
#create symbolic links                                    
         [ -d $HOMEDIR/.dropbox ] || ln -sf $HOME/.dropbox $HOMEDIR/.dropbox
         [ -d $HOMEDIR/Dropbox ] || ln -sf $HOME/Dropbox $HOMEDIR/Dropbox
         [ -d /root/.dropbox-dist ] || ln -sf $HOME/.dropbox-dist /root/.dropbox-dist
         [ -d /root/.dropbox ] || ln -sf $HOME/.dropbox /root/.dropbox
         echo 100000 > /proc/sys/fs/inotify/max_user_watches
         OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
         LD_LIBRARY_PATH=$HOME:$LD_LIBRARY_PATH
         export LANG=$LOCALE
         $HOME/$DAEMON > $HOME/Dropbox_status.txt 2>&1 &
         RETVAL=$?
         /bin/sleep 5
         ;;
  stop) 
    PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
         if [ -z $PID ] ; then
        /bin/echo "Dropbox isn't running!"
        exit 1
         fi
         kill -9 $PID
         echo "Dropbox daemon stopped."
         RETVAL=$?
         sleep 3
         ;;
  restart)
         sh $0 stop
         sh $0 start
         RETVAL=$?
         ;;
  status)
    PID=`ps -ef | awk '/[d]ropbox/{print $1}'`
    if [ -z $PID ] ; then
        echo "Dropbox isn't running!"
    else
        echo "Dropbox is running. (PID $PID)"
    fi
         ;;
  *)
         /bin/echo "Usage: $0 {start|stop|restart|status}"
         exit 1
esac

exit $RETVAL
§  Set the execute bit:
# chmod +x /share/MD0_DATA/.qpkg/Dropbox/Dropbox.sh
§  Reboot
References:

2012年8月29日 星期三

How to select suitable crystals and external components

In http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/APPLICATION_NOTE/CD00221665.pdf

External capacitors calculation

CL :   pF (crystal manufacturer)
CS :   pF

CL1 = CL2 =  pF

Gain margin calculation

ESR :   Ω (crystal manufacturer)
F :   Hz (crystal manufacturer)
CO :   pF (crystal manufacturer)
CL :   pF (crystal manufacturer)
gm :   mA/V (microcontroller manufacturer)

gmcrit =  mA/V
gainmargin = 
crystal will 

Calculating drive level

ESR :   Ω (crystal manufacturer)
F :   Hz (crystal manufacturer)
CL1 :   pF (calculation)
CS :   pF
Cprobe :   pF (oscilloscope manufacturer)
Vpp :   V (measurement)

DL =  uW

Calculating external resistor

F :   Hz (crystal manufacturer)
CL2 :   pF (calculation)
DL :   uW (measurement)
DL :   uW (crystal manufacturer)

REXT =  Ω

2012年8月3日 星期五

How to determine using which flash device to store the configuration data for configuring Altera FPGA

In http://www.altera.com/literature/hb/cfg/cyc_c51014.pdf

Table 1 lists the supported Altera EPCS devices.


Example 1. Compression Ratio Calculation

EP4SGX530 = 189,000,000 bits

EPCS128 = 134,217,728 bits

Preliminary data indicates that compression typically reduces the configuration bitstream size by 35% to 55%. Assume worst case that is 35% decompression.

189,000,000 bits x 0.65 = 122,850,000 bits

The EPCS128 device is suitable.



For example: Cyclone V E FPGA Device 5CEA7

In http://www.altera.com/literature/hb/cyclone-v/cv_51002.pdf
Table 43 lists the uncompressed raw binary file (.rbf) sizes for Cyclone V devices.


The EPCS64 device is suitable for the  Cyclone V E FPGA Device 5CEA7 .

2011年10月18日 星期二

Dump the Memory

PMDump v1.2


Open up a command prompt type the "pmdump -list" command


"pmdump -listdisplays a list of running Process with their Process ID (PID)


OR type the "tasklist" command


"tasklistdisplays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer.


then dump the memory contents of a process


type the "pmdump <PID> <filename>" command
ex: pmdump 777 dump.bin



pmdump 1.2 - (c) 2002, Arne Vidstrom (arne.vidstrom@ntsecurity.nu)
           - http://ntsecurity.nu/toolbox/pmdump/


Usage: pmdump <pid> <filename>


        - dumps the process memory contents to a file


       pmdump -list


        - lists all running processes and their PID's





ManTech Physical Memory Dump Utility


mdd_1.3.zip



a physical memory acquisition tool for imaging Windows based computers

ManTech Memory DD 1.3 acquires a forensic image of physical memory and stores it as a raw binary file.

Memory DD must be run with Administrator privileges

type the "mdd_1.3 -o <outputfile>" command
ex: mdd_1.3 -o dump.bin

 -> mdd
 -> ManTech Physical Memory Dump Utility
    Copyright (C) 2008 ManTech Security & Mission Assurance

 -> This program comes with ABSOLUTELY NO WARRANTY; for details use option `-w'
    This is free software, and you are welcome to redistribute it
    under certain conditions; use option `-c' for details.


mdd ManTech Physical Memory Dump Utility

Usage:

mdd <-o OUTPUTFILE> [-qvcw]

     -o OUTPUTFILE     output file for dump
     -q                quiet; no output except on error
     -v                verbose; output offsets of failed mappings
     -c                redistribution conditions for GPL
     -w                warranty information for GPL


2011年10月15日 星期六

pkg_add: unable to fetch

For example, if you try to install a convmv package


# pkg_add -r convmv
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.3-release/Latest/convmv.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.3-release/Latest/convmv.tbz' by URL


Modify the PACKAGESITE environment variable
# setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7-stable/Latest/


then
# pkg_add -r convmv
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7-stable/Latest/convmv.tbz... Done.


OR
# pkg_add -r ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7-stable/Latest/convmv.tbz
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7-stable/Latest/convmv.tbz... Done.

2011年10月13日 星期四

Mounting FreeBSD UFS2 File System



Make the directory for mount
sudo mkdir /mnt/<mount-directory>
ex: sudo mkdir /mnt/ufsdisk

Mount the ufs partition
sudo mount -t ufs -r -o ufstype=ufs2 /dev/<partition> /mnt/<mount-directory>
ex: sudo mount -t ufs -r -o ufstype=ufs2 /dev/sda1 /mnt/ufsdisk