2015-07-31

tips - how to convert jpeg to pdf wtih A4 size


To convert 300dpi JPG file to A4 size PDF file with imageMagick:
convert -density 300 -define pdf:fit-page=A4 source.jpg dest.pdf
Command line options of imageMagick
Scale PDF to A4 with imageMagick

2014-12-27

Debian Wheezy Tips

hime (中文輸入法)

sudo apt-get install hime im-config
sudo cp noseeing.gtab /usr/share/hime/table/
hime-setup > Default input method and toggle key > 勾選自已習慣的輸入法,例:詞音,希臘文
im-config -n hime
登出,再登入,啟動中文輸入法

2011-11-09

Setting up ZyXEL NWD2105 for CentOS-5 and Ubuntu (10.04)

driver info page: http://www.wikidevi.com/wiki/ZyXEL_NWD2105

driver installation guide: http://eimer.ch/nwd2105.html 

$ cd 2011_0107_RT3070_RT3370_Linux_STA_v2.5.0.1_DPO/

$ make; make install

$ edit /etc/Wireless/RT2870STA/RT2870STA.dat for
    SSID=_YOUR_AP's_SSID_
    NetworkType=Infra   
    WirelessMode=5
    Channel=0
    AuthMode=OPEN
    EncrypType=WEP
    DefaultKeyID=1
    Key1Type=1    # (for ASCII key)
    Key1Str=_YOUR_ASCII_PASSWORD_

$ refer to README_STA_usb for further parameter details

For CentOS-5:

$ edit /etc/modprobe.conf; append "alias ra0 rt3070sta" to it.
$ edit /etc/sysconfig/network-scripts/ifcfg-ra0:
   DEVICE='ra0'
   ONBOOT='yes'
   BOOTPROTO='dhcp'
$ edit /etc/sysconfig/network-scripts/ifup-wireless
   comment out the following two lines:
       line-65: iwconfig $DEVICE key off
       line-98: iwconfig $DEVICE essid any >/dev/null 2>&1

$ /sbin/reboot # to check if the wireless is working after reboot

For Ubuntu (10.04):

* edit /etc/modprobe.d/wireless.conf; add "alias ra0 rt3070sta" to it.
* edit /etc/network/interface:
        auto lo
        iface lo inet loopback
        auto wlan0
        iface wlan0 inet dhcp
* /etc/init.d/networking restart
* /sbin/reboot # to check if the wireless is working after reboot

 

2011-10-21

負整數 - 正整數 = 正整數?

「負整數 - 正整數 = 正整數」在數學上是不正確的,但在計算機上是可能的,詳細原因可以從布林代數的整數加減法的推算得到解答,這裡列舉一個可能的情形:
  • a, b, c 均是 32-bit 的整數 (signed integer)  
  • a = 2147483647
  • b = -2147483648
  • c = b - a = 1
  • 十進位表示:
    c(1) = b(-2147483648) - a(2147483647)
  • 十六進位表示:
    c(0x00000001) = b(0x80000000) - a(0x7FFFFFFF)

以下是對映的 C 程式:

void main(void)
{
    int32_t a;
    int32_t b;
    int32_t c;

    a = 0x7FFFFFFF;
    printf ("a(%d)\n", a);
    b = a+1;
    printf ("b(%d)\n", b);
    c = b - a;
    printf ("c(%d) = b(%d) - a(%d)\n", c, b, a);
    printf ("c(0x%08X) = b(0x%08X) - a(0x%08X)\n", c, b, a);
}

2011-06-30

Ubuntu 10.04 LTS for DELL Vostro 3350

I got my newly arrived Dell vostro 3350 on Jun 29, 2011. I love its anti-glare LCD screen as well as the back-lit keyboard. It was smooth to install Ubuntu 10.04 LTS on it. Everything works after rebooting, except that the LCD resolution was incorrect; also, the Wireless LAN was not working.

Here are my workaround to have them work correctly:

VGA:
  • Install backport-maverick kernel for LCD resolution detection (1366x768)
    sudo apt-get install linux-image-generic-pae-lts-backport-maverick \
    linux-headers-generic-pae-lts-backport-maverick
  • Reboot
Wireless LAN:

2010-08-25

Approaches to Trim OR1200



OR1200 Module Level Utilization:
1954 Slices, initial slice utilization for or1200_top


After removing CUST5 instruction from or1200_alu:
1873 slices, (1954-1873)/1873 = 4.32% area improvement.


After modifying "SHIFT and ROTATE" logic of or1200_alu:
1839 slices, (1954-1839)/1839 = 6.25% area improvement

2010-08-21

Customize minsoc as an OpenRISC sub-system

GOAL
To create a SoC sub-system based on minsoc and OpenRISC

STEPS
  1. obtain minsoc and OpenRISC from SVN repository
    $ (origin) svn co http://opencores.org/ocsvn/minsoc/minsoc/trunk minsoc
    $ (subsoc) git clone git://github.com/artek/minsoc.git minsoc
    $ svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk openrisc
  2. follow steps for "GNU tool chain with newlib"
    1. build and install or1ksim
      edit /etc/ld.so.conf.d/or32.conf, and add /opt/or1ksim/lib
    2. install required library (MFP, MPFR) for building toolchain
      $ sudo apt-get install libgmp3-dev libmpfr-dev dejagnu expectk
    3. build toolchain with newlib
      $ cd openrisc/gnu-src
      $ sudo ./bld.sh --prefix /opt/or32-elf-new --or1ksim /opt/or1ksim --force
    4. add or32-gcc and or1ksim binary to $PATH
      export PATH=${PATH}:/opt/or32-elf/bin:/opt/or1ksim/bin
  3. refer to "Howto: Porting Newlib" to bring up your own BSP
    • config new target as "NON-REENTRANT", "NOT NAMESPACE CLEAN" to reduce generated code size
    • config new target with "-DSMALL_MEMORY" to reduce page size from 4KB to 128B for malloc
    • edit configure.host:
      or32-*-*)
      # syscall_dir=syscalls
      newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DSMALL_MEMORY"
      ;;

  4. follow the minsoc-HOWTO for simulation
    evince minsoc/doc/howto.pdf
  5. FPGA Impmentation
    1. add minsoc_sub to your toplevel
    2. update "Verilog Include Directories" for minsoc to Synthesis options of ISE
      ../../rtl/minsoc/rtl/verilog/ (for minsoc)
      |../../rtl/minsoc/rtl/verilog/or1200/rtl/verilog/ (for or1200)
      |../../rtl/minsoc/rtl/verilog/uart16550/rtl/verilog/ (for uart16550)
  1. check out openrisc repository from opencores
    svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk openrisc
  2. build up toolchain
    cd toolchain_install_scripts/
    1. sudo ./crossbuild.sh
      build or32 toolchain and install it to /usr/local/
    2. sh MOF_ORSOC_TCHN_v5c_or32-elf.sh
      build toolchain and or1ksim to specified path


CONS
  • or32 ld does not support --gc-sections