Month: July 2010

Everyday English from HJEnglish

Posted by – July 30, 2010

Let me start to using HJEnglish everyday! Come on!

Vim on Debian

Posted by – July 7, 2010

The default vim configuration file locations on Debian/Ubuntu.

jin@jin-u10:/home/jin$ more  /etc/vim/vimrc
” All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
” /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
” you can find below.  If you wish to change any of those settings, you should
” do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
” everytime an upgrade of the vim packages is performed.  It is recommended to
” make changes after sourcing debian.vim since it alters the value of the
” ‘compatible’ option.

” This line should not be removed as it ensures that various options are
” properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

” Uncomment the next line to make Vim more Vi-compatible
” NOTE: debian.vim sets ‘nocompatible’.  Setting ‘compatible’ changes numerous
” options, so any other options should be set AFTER setting ‘compatible’.
“set compatible

” Vim5 and later versions support syntax highlighting. Uncommenting the
” following enables syntax highlighting by default.
if has(“syntax”)
syntax on

” If using a dark background within the editing area and syntax highlighting
” turn on this option as well
“set background=dark

” Uncomment the following to have Vim jump to the last position when
” reopening a file
“if has(“autocmd”)
”  au BufReadPost * if line(“‘\””) > 1 && line(“‘\””) <= line(“$”) | exe “normal! g’\”” | endif

” Uncomment the following to have Vim load indentation rules and plugins
” according to the detected filetype.
if has(“autocmd”)
filetype plugin indent on

” The following are commented out as they cause vim to behave a lot
” differently from regular Vi. They are highly recommended though.
set showcmd        ” Show (partial) command in status line.
“set showmatch        ” Show matching brackets.
“set ignorecase        ” Do case insensitive matching
set smartcase        ” Do smart case matching
“set incsearch        ” Incremental search
“set autowrite        ” Automatically save before commands like :next and :make
“set hidden             ” Hide buffers when they are abandoned
set mouse=a        ” Enable mouse usage (all modes)
set hls            ” Highlight search

” Source a global configuration file if available
if filereadable(“/etc/vim/vimrc.local”)
source /etc/vim/vimrc.local


Posted by – July 2, 2010

Refers to:

PMON是一个兼有BIOS和boot loader部分功能的开放源码软件,多用于嵌入式系统。

与BIOS相比功能不足,与常见的bootloader 相比,功能要丰富的多。基于龙芯的系统采用 pmon 作为类 BIOS 兼 bootloader,并做了很多完善工作。

* 支持ext2 fat32 ram 文件系统
* 支持网络引导(tftp),磁盘引导,flash 引导
* 内建调试功能(强大,调试内核举重若轻)
* USB 2.0 Mass Storage 支持
* 支持MIPS、ARM、PowerPC 平台
* BSD Licensed

1. pmon 日常命令
a. load — 加载文件
load [-options] pathname
-o offset     将文件加载到内存 load_address + offset 处
-f addr       将文件加载到 flash 的地址 addr 处
pathname     要加载的文件路径或URL
其他选项 h load 查看
加载位于硬盘第一个分区的(pmon 只认第一个分区)内核:
load /dev/fs/ext2@wd0/boot/vmlinux   # 第一个分区是ext2文件系统
load /dev/fs/ext2@wd0b/boot/vmlinux #加载第二个分区上的内核文件,wd0c,wd0d,为第三,四个分区。

从远程tftp服务器上加载内核: (该功能在反复编译调试内核中很方便)

load tftp://   # 先要配置好网络


load /dev/fs/iso9660@cd0/boot/vmlinux
load /dev/ram@address
load /dev/ram@address,size
load /dev/ram/logger


PS: 以上 wd0, cd0, ram 为pmon 对设备的命名,可以用 devls 命令查看他发现并支持
的所有设备, 龙梦电脑上常见的设备为:

wd0 ——— 磁盘
rtl0 ——— 网卡
usb0 ——— usb 存储设备

cd0 ——— 光盘
ram ——— 内存

b. g —— 执行程序

g [-st] [-b addr] [-e addr] [– args…]

当 load 完一个文件后, 通过 g 命令告诉 pmon 开始执行刚刚载人的文件


g  # 从 epc 寄存器指定的地址处开始执行

g -e addr # 从内存地址 addr 处开始执行

g -e addr -b add2 # 从内存地址 addr 处开始执行, 在addr2处设置一个临时断点
# 在下一次执行挂起时删除该断点

g console=tty root=/dev/hda1 # 从 epc 寄存器指定的地址处开始执行, 并将参数
# console=tty root=/dev/hda1 传递给程序(内核)

c. devls ——- 显示设备

devls [-a]


devls -a # 显示所有设备

d. ifaddr —— 配置网卡

ifaddr ifname ipaddr[:ifparameters]

其中 第二个字段可以为 ipaddr:netmask:broadcast:gateway


ifaddr rtl0 # 设置网卡 rtl0 的 IP 地址

ifaddr rtl0 # 设置网卡 IP 地址和网关

e. ping

ping # 测试网络是否配置好


A. PMON 更新命令

load -r -f bfc00000 tftp://SERVER_IP/gzrom.bin

load -r -f bfc00000 /dev/fs/ext2@wd0/gzrom.bin


modprobe physmap     [装上mtd驱动以识别eeprom]

mknod /dev/mtd0 c 90 0     [创建mtd设备文件]

cp gzrom.bin /dev/mtd0     [写入]


B. 从 USB 光驱加载 kernel:

load iso9660/usb0/path/to/kernel

C. 从 U 盘或者移动硬盘加载 kernel:

load /dev/fs/ext2@usb0/path/to/kernel

注意:如果根文件系统位于 U 盘或者移动硬盘的话,传给内核的参数应为:

root=8:1 rootdelay=5

set novga 1/0

setvga 0/1

set al /dev/fs/ext2@wd0a/boot/vmlinux-2.6.18-godson2e

set karg “console=tty root=/dev/hda2 init=/sbin/runit-init”

load /dev/fs/ext2@usb0/path/to/netboot.image

g console=tty root=/dev/hda1