2011-11-09
Setting up ZyXEL NWD2105 for CentOS-5 and Ubuntu (10.04)
$ edit /etc/Wireless/RT2870STA/RT2870STA.dat for
$ edit /etc/modprobe.conf; append "alias ra0 rt3070sta" to it.
For Ubuntu (10.04):
* edit /etc/modprobe.d/wireless.conf; add "alias ra0 rt3070sta" to it.
2011-10-21
負整數 - 正整數 = 正整數?
「負整數 - 正整數 = 正整數」在數學上是不正確的,但在計算機上是可能的,詳細原因可以從布林代數的整數加減法的推算得到解答,這裡列舉一個可能的情形:
以下是對映的 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);
}
- 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:
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
- Build the compat-wireless device driver manually for backport-maverick kernel
- Here's the Building and Installing steps
cd compat-wireless-`date -I`; make; sudo make install - Reboot
2010-08-25
Approaches to Trim OR1200
2010-08-21
Customize minsoc as an OpenRISC sub-system
GOAL
To create a SoC sub-system based on minsoc and OpenRISC
STEPS
CONS
To create a SoC sub-system based on minsoc and OpenRISC
STEPS
- 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 - follow steps for "GNU tool chain with newlib"
- build and install or1ksim
edit /etc/ld.so.conf.d/or32.conf, and add /opt/or1ksim/lib
- install required library (MFP, MPFR) for building toolchain
$ sudo apt-get install libgmp3-dev libmpfr-dev dejagnu expectk
- build toolchain with newlib
$ cd openrisc/gnu-src
$ sudo ./bld.sh --prefix /opt/or32-elf-new --or1ksim /opt/or1ksim --force - add or32-gcc and or1ksim binary to $PATH
export PATH=${PATH}:/opt/or32-elf/bin:/opt/or1ksim/bin
- build and install or1ksim
- 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"
;;
- follow the minsoc-HOWTO for simulation
evince minsoc/doc/howto.pdf - FPGA Impmentation
- add minsoc_sub to your toplevel
- 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)
- check out openrisc repository from opencores
svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk openrisc - build up toolchain
cd toolchain_install_scripts/- sudo ./crossbuild.sh
build or32 toolchain and install it to /usr/local/ - sh MOF_ORSOC_TCHN_v5c_or32-elf.sh
build toolchain and or1ksim to specified path
- sudo ./crossbuild.sh
CONS
- or32 ld does not support --gc-sections
2010-05-14
2009-11-12
tips
tips
= unison (bi-directional synchronization)
-testServer
$ unison -sshargs -axC teal ssh://joulee.dyndns.org/proj/teal
= rsync (uni-directional synchronization)
rsync -e 'ssh -ax' -avz ./teal joulee.dyndns.org:proj/teal
= LVM:
= octave, rlab: replacement of matlab
= gnuplot
* gnuplot -persist <script>: keep x11 window after exec <script>
* x11 plot window
- help: move to x11 plot window; press 'h'
- u: unzoom
- p: previous zoom region
- right-mouse-button: select zoom region
- e:
= ssh: Warning: No xauth data; using fake authentication data for X11 forwarding
details are here ; to fix this problem, run the following command on the local host:
$ xauth add `echo "${DISPLAY}" | sed 's/.*\(:.*\)/\1/'` . `mcookie`
= Cygwin/X and ssh ForwardX11
- copy ssh_config to ~/.ssh/config; and set ForwardX11 as yes
- Or, ssh -Y <remote_host>
= Cygwin/X: Clean way to auto-read ~/.Xresources
add the following to startxwin.bat:
%RUN% xrdb -wait -merge ~/.Xresources
=Ten Steps To Higher Cygwin Productivity
$ updatedb --localpaths='c:/ d:/'
$ crontab ...
$ ssh daemon ...
= ssh per-host configuration: specify to login as "ethan" for Host "pc*"
- ~/.ssh/config:
Host pc*
User ethan
= keychain
IBM article OpenSSH key management, Part 1
- generate ssh key pairs (id_dsa)
$ ssh-keygen.exe -t dsa
- copy public DSA key to remote host
$ scp .ssh/id_dsa.pub ethan@pc2005:
- login to remote host and concatenate id_dsa.pub to .ssh/authorized_keys
$ cat id_dsa.pub >> .ssh/authorized_keys
- edit .bash_profile; add the following to it
keychain ~/.ssh/id_dsa
source ~/.keychain/`uname -n`-sh
= emacs
- indent region: C-M-\
- mark region: M-< C-SPC M-> C-M-\
= vim
- include-search / definition-search [I, ]I, [i, ]i
:checkpath
:set path+=../inc
:set path+=/usr/include/*
- TODO: apply auto command for "set path"
= cscope
- cscope -Rb
- vim: ctrl \ s
= C: Bit Operators (Programming in C: A Tutorial)
= bzr
Bazaar for CVS Users
- bzr pull
- bzr revert
- bzr update
- bzr missing
Using Launchpad and Bazaar
= unison (bi-directional synchronization)
-testServer
$ unison -sshargs -axC teal ssh://joulee.dyndns.org/proj/teal
= rsync (uni-directional synchronization)
rsync -e 'ssh -ax' -avz ./teal joulee.dyndns.org:proj/teal
= LVM:
- pvdisplay - display attributes of a physical volume
- lvdisplay - display attributes of a logical volume
- pvscan
- vgexport vg_backup
- vgimport vg_backup
- vgchange -ay vg_backup
- mount /dev/vg_backup/LogVol00 /mnt/backup
- initializing disk partition
$ pvcreate /dev/sda2 - adding physical volume to an existing
volume group
$ lvdisplay
$ lvextend -l +100%FREE /dev/vg_system/eda_tools
$ umount /dev/vg_system/eda_tools
$ e2fsck -f /dev/vg_system/eda_tools
$ resize2fs /dev/vg_system/eda_tools
$ mount /tools
= octave, rlab: replacement of matlab
= gnuplot
* gnuplot -persist <script>: keep x11 window after exec <script>
* x11 plot window
- help: move to x11 plot window; press 'h'
- u: unzoom
- p: previous zoom region
- right-mouse-button: select zoom region
- e:
= ssh: Warning: No xauth data; using fake authentication data for X11 forwarding
details are here ; to fix this problem, run the following command on the local host:
$ xauth add `echo "${DISPLAY}" | sed 's/.*\(:.*\)/\1/'` . `mcookie`
= Cygwin/X and ssh ForwardX11
- copy ssh_config to ~/.ssh/config; and set ForwardX11 as yes
- Or, ssh -Y <remote_host>
= Cygwin/X: Clean way to auto-read ~/.Xresources
add the following to startxwin.bat:
%RUN% xrdb -wait -merge ~/.Xresources
=Ten Steps To Higher Cygwin Productivity
$ updatedb --localpaths='c:/ d:/'
$ crontab ...
$ ssh daemon ...
= ssh per-host configuration: specify to login as "ethan" for Host "pc*"
- ~/.ssh/config:
Host pc*
User ethan
= keychain
IBM article OpenSSH key management, Part 1
- generate ssh key pairs (id_dsa)
$ ssh-keygen.exe -t dsa
- copy public DSA key to remote host
$ scp .ssh/id_dsa.pub ethan@pc2005:
- login to remote host and concatenate id_dsa.pub to .ssh/authorized_keys
$ cat id_dsa.pub >> .ssh/authorized_keys
- edit .bash_profile; add the following to it
keychain ~/.ssh/id_dsa
source ~/.keychain/`uname -n`-sh
= emacs
- indent region: C-M-\
- mark region: M-< C-SPC M-> C-M-\
= vim
- include-search / definition-search [I, ]I, [i, ]i
:checkpath
:set path+=../inc
:set path+=/usr/include/*
- TODO: apply auto command for "set path"
= cscope
- cscope -Rb
- vim: ctrl \ s
= C: Bit Operators (Programming in C: A Tutorial)
C has several operators for logical bit-operations.
For example,
For example,
x = x & 0177;
forms the bit-wise AND of x and 0177, effectively
retaining only the
last seven bits of x. Other operators are
retaining only the
last seven bits of x. Other operators are
| inclusive OR
^ (circumflex) exclusive OR
~ (tilde) 1's complement
! logical NOT
<< left shift (as in x<<2)
>> right shift
^ (circumflex) exclusive OR
~ (tilde) 1's complement
! logical NOT
<< left shift (as in x<<2)
>> right shift
= bzr
Bazaar for CVS Users
- bzr pull
- bzr revert
- bzr update
- bzr missing
Using Launchpad and Bazaar
bzr init-repo libmodbus
cd libmodbus
bzr branch lp:libmodbus/trunk
bzr branch trunk mou
cd mou
(hack, hack, hack)
bzr commit -m "..."
cd ../trunk
bzr pull
cd ../mou
bzr status
bzr info
bzr merge
(resolve any conflicts)
bzr commit -m "initial modbus_over_usb"
bzr push lp:~yishin-li/libmodbus/mou
cd libmodbus
bzr branch lp:libmodbus/trunk
bzr branch trunk mou
cd mou
(hack, hack, hack)
bzr commit -m "..."
cd ../trunk
bzr pull
cd ../mou
bzr status
bzr info
bzr merge
(resolve any conflicts)
bzr commit -m "initial modbus_over_usb"
bzr push lp:~yishin-li/libmodbus/mou
= svn
- setup subversion on CentOS
- Note for SELinux / Fedora Core 3+ / Red Hat Enterprise users:
$ chcon -R -h -t httpd_sys_content_t PATH_TO_REPOSITORY
- consult docs and faqs from svn site
- CVS to SVN Crossover Guide
- Choosing a Repository Layout . repo/
projA/
branches/
tags/
trunk/
projB/ branches/
tags/
trunk/
$ create Repository Layout;
$ cd repo; svn import . file:///wrk/svn/ssd/repos (import empty layout dirs only) $ svn import teal/ file:///wrk/svn/ssd/repos/teal/trunk --message "initial teal import"
$ svn import csim/ file:///wrk/svn/ssd/repos/csim/trunk --message "initial csim import"
$ svn co file:///wrk/svn/ssd/repos/teal/trunk teal
$ svn co file:///wrk/svn/ssd/repos/csim/trunk csim
- how to patch [1 ] [2]
$ sudo svn import proto/ file:///home/svn/repos/proto/trunk --message "initial proto import"
$ svn co http://taipei/repos/proto/trunk proto
= x264 related (TODO)
x264.exe -b 1 --qp 10 -B 1000 -o output.h264 foreman_part_qcif.yuv 176x144
mplayer.exe -vo yuv4mpeg -vf dect -nosound dolby-city.vob
x264 -o output.h264 stream.y4m --frames 200 --crf 24 -b3 -m9 -r3 --me tesa -8 -t1 --mixed-refs --progress
gprof path-to-x264.exe gmon.out > x264.profile
the most critical part is Motion Estimation (~50%)
what are you trying to do ? output a raw video file ?
ffmpeg -i input -f rawvideo -vcodec rawvideo output
or -f yuv4mpegpipe -vcodec rawvideo (or -f rawvideo -vcodec yuv4mpegpipe ?)
= change login shell: ypchsh
3 cp ~ethan/.bash_profile .
4 cp ~ethan/.bashrc .
5 cp ~ethan/.sh_alias .
6 cp ~ethan/.profile .
15 cp ~ethan/bin/* .
23 cp ~ethan/.eda_tools .
77 cp -a ~ethan/.vim .
78 cp -a ~ethan/.vimrc .
79 cp -a ~ethan/.gvimrc .
= dnsmasq: a light weight tool for DHCP and DNS
= gdbtui
+ CTRL-L to refresh/redraw the screen
= hime (中文輸入法), ubuntu 12.04
sudo apt-get install hime
gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
sudo cp noseeing.gtab /usr/share/hime/table/
= gcin, ubuntu 10.04
+ im-switch -s gcin
+ noseeing: /usr/share/gcin/script/noseeing-inst (install boshimi)
+ 系統->偏好設定->gcin 輸入法設定->Default input method and toggle key->勾選 Remote client support (port 9999-) (解決 gcin 被 GDM 預先啟動的問題)
= wagig, ubuntu
sudo apt-get install wajig
installr Install package and associated recommended packages
installrs Install package and recommended and suggested packages
installs Install package and associated suggested packages
sudo wajig installrs mozilla-thunderbird
(replace wajig with apt-get)
http://ubuntuforums.org/showthread.php?t=43382
= update-rc.d, ubuntu
- update-rc.d cadence defaults 99
- How-To: Managing services with update-rc.d
= how to create torrent file
- maketorrent: http://www.dessent.net/btfaq/#maketorrent
- tracker list: http://torrentfreak.com/how-to-create-a-torrent/
- example:
maketorrent-console http://open.tracker.thepiratebay.org/announce <file/dir>
= dpkg-query -S (Find the package a file is from)
= Setting up VMWare shared folders on Ubuntu guest (for both 12.04 and 10.04)
- setup subversion on CentOS
- Note for SELinux / Fedora Core 3+ / Red Hat Enterprise users:
$ chcon -R -h -t httpd_sys_content_t PATH_TO_REPOSITORY
- consult docs and faqs from svn site
- CVS to SVN Crossover Guide
- Choosing a Repository Layout . repo/
projA/
branches/
tags/
trunk/
projB/ branches/
tags/
trunk/
$ create Repository Layout;
$ cd repo; svn import . file:///wrk/svn/ssd/repos (import empty layout dirs only) $ svn import teal/ file:///wrk/svn/ssd/repos/teal/trunk --message "initial teal import"
$ svn import csim/ file:///wrk/svn/ssd/repos/csim/trunk --message "initial csim import"
$ svn co file:///wrk/svn/ssd/repos/teal/trunk teal
$ svn co file:///wrk/svn/ssd/repos/csim/trunk csim
- how to patch [1 ] [2]
$ sudo svn import proto/ file:///home/svn/repos/proto/trunk --message "initial proto import"
$ svn co http://taipei/repos/proto/trunk proto
= x264 related (TODO)
x264.exe -b 1 --qp 10 -B 1000 -o output.h264 foreman_part_qcif.yuv 176x144
mplayer.exe -vo yuv4mpeg -vf dect -nosound dolby-city.vob
x264 -o output.h264 stream.y4m --frames 200 --crf 24 -b3 -m9 -r3 --me tesa -8 -t1 --mixed-refs --progress
gprof path-to-x264.exe gmon.out > x264.profile
the most critical part is Motion Estimation (~50%)
what are you trying to do ? output a raw video file ?
ffmpeg -i input -f rawvideo -vcodec rawvideo output
or -f yuv4mpegpipe -vcodec rawvideo (or -f rawvideo -vcodec yuv4mpegpipe ?)
= change login shell: ypchsh
3 cp ~ethan/.bash_profile .
4 cp ~ethan/.bashrc .
5 cp ~ethan/.sh_alias .
6 cp ~ethan/.profile .
15 cp ~ethan/bin/* .
23 cp ~ethan/.eda_tools .
77 cp -a ~ethan/.vim .
78 cp -a ~ethan/.vimrc .
79 cp -a ~ethan/.gvimrc .
= dnsmasq: a light weight tool for DHCP and DNS
= gdbtui
+ CTRL-L to refresh/redraw the screen
= hime (中文輸入法), ubuntu 12.04
sudo apt-get install hime
gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
sudo cp noseeing.gtab /usr/share/hime/table/
= gcin, ubuntu 10.04
+ im-switch -s gcin
+ noseeing: /usr/share/gcin/script/noseeing-inst (install boshimi)
+ 系統->偏好設定->gcin 輸入法設定->Default input method and toggle key->勾選 Remote client support (port 9999-) (解決 gcin 被 GDM 預先啟動的問題)
= wagig, ubuntu
sudo apt-get install wajig
installr Install package and associated recommended packages
installrs Install package and recommended and suggested packages
installs Install package and associated suggested packages
sudo wajig installrs mozilla-thunderbird
(replace wajig with apt-get)
http://ubuntuforums.org/showthread.php?t=43382
= update-rc.d, ubuntu
- update-rc.d cadence defaults 99
- How-To: Managing services with update-rc.d
= how to create torrent file
- maketorrent: http://www.dessent.net/btfaq/#maketorrent
- tracker list: http://torrentfreak.com/how-to-create-a-torrent/
- example:
maketorrent-console http://open.tracker.thepiratebay.org/announce <file/dir>
= dpkg-query -S (Find the package a file is from)
= Setting up VMWare shared folders on Ubuntu guest (for both 12.04 and 10.04)
訂閱:
文章 (Atom)