2012年11月28日 星期三

install tftpd

apt-get install tftpd tftp xinetd

cd /etc/xinetd.d/
vi tftp 
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

Setup up my development environment

# Common development environment
sudo apt-get install cscope vim subversion screen
# Android Developer
sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
#Add jdk and jre

#Add eclipse

openwrt build environment

sudo apt-get gawk bison
sudo apt-get install flex autoconf
sudo apt-get install gettext
sudo apt-get install cmake

sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 --slave /usr/bin/gcov gcov /usr/bin/g++-4.4

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 --slave /usr/bin/gcov gcov /usr/bin/g++-4.6

sudo update-alternatives --config gcc



ssh-keygen -f "/home/myhome/.ssh/known_hosts" -R IP_Address

remove eclipse plugins

Help -> About eclipse -> Installation Details -> remove selected item

2012年11月27日 星期二

Build universal architecture library for iPhone -- lipo hints

When developing a ios library for both simulator and iPhone/iPad(s),
the steps are :
1. build each architecture one by one and put into identical path, ie
build.armv6 --- armv6 library
build.armv7 --- armv7 library
build.i386 --- i386 library for simulator

2. use lipo command
lipo -create ./build.armv6/lib1.a ./build.armv7/lib1.a ./build.i386/lib1.a -output ./build.all/lib1.a

lib1.a will contain all three libraries which can be used by iPhone cross ompiler.

3. To see what archs are supported by a library, we can use
lipo -info library_file can get the supported architecture of the library

4. The iPhone/iPad family architectures :
ARMv7s = iPhone 5, iPad 4
ARMv7  = iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini  
ARMv6  = iPhone 2G/3G, iPod 1G/2G


2012年11月25日 星期日

uninstall xcode

sudo /Developer/Library/uninstall-devtools --mode=all
rm -rf /Developer/Applications/Xcode.app
rm -rf /Developer/Platforms/iPhoneOS.platform

2012年11月20日 星期二

openwrt codebase

https://dev.openwrt.org/wiki/GetSource

  • Attitude Adjustment 12.09 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/attitude_adjustment
    
  • Backfire 10.03 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/backfire
    
  • Kamikaze 8.09 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/8.09
    
  • Kamikaze 7.09 (deprecated): ChangeLog
    svn co svn://svn.openwrt.org/openwrt/tags/kamikaze_7.09
    
  • Development branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/trunk/
    
  • Kamikaze packages: ChangeLog

    *Note: Kamikaze only contains the essential set of packages, extra packages can be enabled with the command "make package/symlinks" or can be checked out from the following URL:
    svn co svn://svn.openwrt.org/openwrt/packages/
    
  • Updating to the latest sources:
    svn up
    

Attitude Adjustment

backfire

root

  •  

2012年11月19日 星期一

linux domain socket

int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid)
{  
    struct sockaddr_un addr;
    int fd, ret;
#ifdef HAVE_SELINUX
    char *secon;
#endif
   
    fd = socket(PF_UNIX, type, 0);
    if (fd < 0) {
        ERROR("Failed to open socket '%s': %s\n", name, strerror(errno));
        return -1;
    }
       
    memset(&addr, 0 , sizeof(addr));
    addr.sun_family = AF_UNIX;
    snprintf(addr.sun_path, sizeof(addr.sun_path), ANDROID_SOCKET_DIR"/%s",
             name);

    ret = unlink(addr.sun_path);
    if (ret != 0 && errno != ENOENT) {
        ERROR("Failed to unlink old socket '%s': %s\n", name, strerror(errno));
        goto out_close;
    }

#ifdef HAVE_SELINUX
    secon = NULL;
    if (sehandle) {
        ret = selabel_lookup(sehandle, &secon, addr.sun_path, S_IFSOCK);
        if (ret == 0)
            setfscreatecon(secon);
    }
#endif

    ret = bind(fd, (struct sockaddr *) &addr, sizeof (addr));
    if (ret) {
        ERROR("Failed to bind socket '%s': %s\n", name, strerror(errno));
        goto out_unlink;
    }

#ifdef HAVE_SELINUX
    setfscreatecon(NULL);
    freecon(secon);
#endif

    chown(addr.sun_path, uid, gid);
    chmod(addr.sun_path, perm);

    INFO("Created socket '%s' with mode '%o', user '%d', group '%d'\n",
         addr.sun_path, perm, uid, gid);

    return fd;

out_unlink:
    unlink(addr.sun_path);
out_close:
    close(fd);
    return -1;
}

2012年11月13日 星期二

Multimedia library source codes

VLC :
1. Download page
http://www.videolan.org/vlc/download-sources.html
2. Repository
git://git.videolan.org/vlc.git
3. 

# FLV, AAC audio
ffmpeg -i in.flv -q 1 -map a out.mp3
# Apply max noclip gain
mp3gain -r -k -m 10 out.mp3

# FLV, MP3 audio
ffmpeg -i in.flv -c copy -map a out.mp3

# MP3 file
ffmpeg -i in.mp3 -c copy -map a out.mp3

# WAV source
ffmpeg -i in.wav -b:a 320k out.mp3

# Flac source
ffmpeg -i in.flac -b:a 320k out.mp3

2012年11月7日 星期三

MAC OSX 上的開發環境

1. 首先我們需要安裝 MacPort --- mac 上的 package 管理工具庫
安裝的網頁是 www.macports.org/install.php
找到對應的 OSX 版本,我的是 Snow Leopard,下載後安裝

2. 安裝 git,參考網頁 http://alvinalexander.com/mac-os-x/how-install-git-mac-os-x-osx
sudo port install git-core +svn +doc +bash_completion +gitweb

3. Install xcode. Under Snow Leopard, we only have xcode v4.2, which can support until iOS 5.0
    For 5.1 and above, we have to upgrade :
    A. Upgrade xcode with newer iOS SDK
      A.1 Download new version xcode, extract it, then go under
             /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
             Here lists all supported SDKs
      4.2  4.3  5.0  5.1 (9B176) Latest 
   A.2 Create these 2 folders
            sudo mkdir /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
            sudo mkdir /Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.1\ \(9B176\)/
      A.3 Copy the SDK to those 2 new folder
            sudo cp -Rf ./5.1\ \(9B176\)/ /Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.1\ \(9B176\)/
            sudo cp -Rf ./5.1\ \(9B176\)/ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/
    B. Upgrade to Lion ...