Fail to Download Firmware to LPC2103

不知為什麼, 有時候要 Download Firmware to LPC2103 時會出現
下列錯誤訊息:

No Algorithm found for: 00000000H - 00001FC3H
Programming skipped!

後來發現要檢查 Options for Target -> Utilities -> Setting 設定:
1. RAM for Algorithm: Star: 0x40000000, Size: 0x0800
2. Programming Algorithm: LPC2000 IAP2 32KB Flash

How to Outputs PDF File from Gnuplot

之前都是直接在 視窗輸出 之後再手動 列印成 PDF File
其實也可以直接輸出 PDF File:

gnuplot> set term pdf (will produce PDF output)
gnuplot> set output "printme.pdf" (output to any filename you use)
gnuplot> replot (recreates plot but you don't see it, goes to file)

搞定收工。

OpenSuSE 11.1 上的 TCL Library

閒閒沒事
把之前在 Mac OS 上 跑的 NAND Flash Static Wear Leveling 的 EV程式
拿到 SuSE 上跑,結果居然 Compile 不起來
發現是 “-ltcl” 無法 link 到 正確的 TCL Library
若將之改為 “-ltcl8.5” 就 OK

好像是 TCL Library 在 Install 時有問題
自己動手修正:

$ (cd /usr/lib; sudo ln -s libtcl8.5.o libtcl.o)
$ (cd /usr/lib64; sudo ln -s libtcl8.5.o libtcl.o)

這樣 “-ltcl” 就 OK 了。

SVN + http + NIS Authentication on OpenSUSE 11.2

Step.1 Install OpenSUSE 11.2

  • New Installation
  • English
  • select GNOME Desktop
  • LVM Partitioning
      /boot : 70.57MB
      / : 40GB
      /srv : max
      swap : 4GB
  • disable Fireware
  • NTP: time.stdtime.gov.tw

Step.2 Network

  • IP : 192.168.103.xxx
  • Gateway : 192.168.103.254
  • Subnet Mask : 255.255.0.0
  • DNS : 192.168.xxx.xxx
  • Hostname : svn

Step.3 NIS Client

  • domain: xxx
  • server: 192.168.xxx.xxx
  • Enable automount
  • Check /etc/nsswitch.conf setting
      passwd: files nis
      group: files nis
      shadow: files nis
      hosts: files nis dns

Step.4 Add Software Repository

  • Apache Module
      http://download.opensuse.org/repositories/Apaches:/Modules/OpenSUSE_11.2
  • RemoteDesktop
      http://download.opensuse.org/repositories/X11:/RemoteDesktop/OpenSUSE_11.2

Step.5 Install Nvidia Driver

    Visit http://en.opensuse.org/NVIDIA_drivers

Step.6 Software Install by using yast2

  • Update All Patches
  • Install Apache
      apache2
      apache2-mod_perl, apache2-mod_php5,
      apache2-mod_authnz_external
      apache2-mod_security2
      yast2-http-server
  • Install FTP server
      pure-ftpd
      yast2-ftp-server
  • Install Development Tools
      gcc, gcc-c++, make, autoconf, compat

Step.7 Enable Network Service

    enable sshd, autofs, httpd service

Step.8 SVN Repository

  • create directory

      #mkdir /srv/svn/projects
      #mkdir /srv/svn/users
  • Change Owner

      # chown -R wwwrun /srv/svn
      # chgrp -R www /srv/svn
  • Create SVN Repository

      # sudo -u wwwrun svnadmin create /srv/svn/projects
      # sudo -u wwwrun svnadmin create /srv/svn/users

Step.9 Apache + NIS Auth

    Reference: http://forums.opensuse.org/get-help-here/network-internet/436171-nis-system-auth-apache-subversion.html
  • Download pwauth source code, modify and Recompile
      Download pwauth-2.3.8.tar.gz from http://code.google.com/p/pwauth/downloads/list


        # tar -zxvf pwauth-2.3.8.tar.gz
        # cd pwauth-2.3.8
        # vi config.h

          change

            #define SERVER_UIDS 72 /* user "nobody" */

          to

            #define SERVER_UIDS 30 /* user "wwwrun" */

        # make
        # cp ./pwauth /usr/bin
        # chmod 4755 /usr/bin/pwauth

  • Install checkpassword-pam
      Download checkpassword-pam-0.99.tar.gz from http://sourceforge.net/projects/checkpasswd-pam/files


        # tar -zxvf checkpassword-pam-0.99.tar.gz
        # cd checkpassword-pam-0.99
        # ./configure
        # make
        # make install
  • create /etc/pam.d/httpd is

      auth include common-auth
      account include common-account
      password include common-password
      session include common-session
  • In /etc/apache2/default-server.conf, add:

      AddExternalAuth pwauth /usr/bin/pwauth
      AddExternalAuth checkpassword-pam "/usr/local/bin/checkpassword-pam -H --noenv --debug --stdout -s httpd -- /bin/true"
      SetExternalAuthMethod checkpassword-pam checkpassword
      AddExternalGroup unixgroup /usr/bin/unixgroup
      SetExternalGroupMethod unixgroup environment
  • In the /etc/apache2/conf.d/subversion.conf:

        DAV svn
        SVNParentPath /home/srv/svn
        SVNListParentPath on
        # Limit write permission to list of valid users.
        # Require SSL connection for password protection.
        # SSLRequireSSL
        AuthType Basic
        AuthName "Subversion Server"
        AuthExternal checkpassword-pam
        AuthBasicProvider external
        Require valid-user
        AuthzSVNAccessFile /srv/svnaccess.conf

  • In the /etc/apache2/conf.d/authnz_external.conf :
      AddExternalAuth pwauth /usr/sbin/pwauth
      SetExternalAuthMethod pwauth pipe
  • Enable aoache module and restart apache2

      # a2enmod authnz_external
      # a2enmod dav
      # a2enmod dav_svn
      # a2enmod authz_svn
      # a2enmod perl
      # rcapache2 restart

Step.10 Setup FreeNX

    # nxsetup –install –setup-nomachine-key –clean

Display Localized Directory Name on Mac OS X

如果你想建立一個目錄
並希望目錄名稱可以隨著『不同的系統語言設定』而『顯示不同的名稱』
範例:目錄 Work,在中文環境下顯示『工作』
步驟如下
1. change directory “Work” to “Work.localized”
2. create a diectory ./Work.localized/.localized
3. create a file ./Work.localized/.localized/en.strings

"Work" = "Work";

4. create a file ./Work.localized/.localized/zh_TW.strings

"Work" = "工作";

自動影片分割

因為要上傳影片到 Youtube
必須將影片分割成數個不超過10分鐘長度的小片段
可是在 Mac OS X 下好像沒有好用的軟體
可又不想用 Quicktime 來一個一個手動分割
所以參考了一些資料後
寫了一個 AppleScript
File name : splite.scpt

(*
    Splite Quicktime Movie into equally sized for Youtube
    YF Chen
    yfc@yfchen.com
*)

    set sourceFile to choose file with prompt "choose video file as source"
    set theFolder to (choose folder with prompt "Choose a folder for the slices:") as text

    tell application "Finder"
        my splitteVideo(sourceFile, theFolder)
    end tell

    on splitteVideo(sourceFile, theFolder)
    
    tell application "QuickTime Player 7"
        activate
        try
            open sourceFile
            on error
            display dialog "Open a movie first" buttons ["OK"] with title "Error"
            return
        end try

        -- get active movie
        set sourceDoc to document 1
        set theDuration to duration of sourceDoc
        set theTitle to name of sourceDoc
        set DurOverlap to 2 -- 2sec overlaping
        set DurScal to (90 * 1000)

        -- calculate segments
        set DurCut to (9 * 60) -- 9 min
        set DurDoc to (duration of sourceDoc) / DurScal
        set NumOfSeg to DurDoc div DurCut

        -- loop each segment
        repeat with i from 0 to NumOfSeg
            -- set segment selection
            set durStart to (i * DurCut) * DurScal
            set durEnd to ((i + 1) * DurCut + DurOverlap) * DurScal
            if durEnd > theDuration then
                set durEnd to theDuration
            end if
            set selection start of sourceDoc to durStart
            set selection end of sourceDoc to durEnd
            -- copy selection into new movie
            copy sourceDoc
            set newdoc to make new document
            paste newdoc
            set theSlice to i as integer as string
            set theFile to (theTitle & "_" & theSlice) & ".mov" as string
            set theFile_full to (theFolder & theFile) as string
            try
                save self contained newdoc in theFile_full
            end try
            close document theFile
        end repeat

        close sourceDoc
        quit

    end tell

end splitteVideo