2009年1月30日星期五

[uClinux-dev mailing list] 摘录之 "如何驾驭uclinux-dist开发包?"

挺不错的一个帖子,告诉大家如何驾驭uClinux-dist这套开发包.用skyeye模拟硬件,无须任何实体硬件资源,适合初学者入门!

Message: 8
Date: Fri, 30 Jan 2009 22:02:42 +1000
From: Greg Ungerer <gerg@snapgear.com>
Subject: Re: [uClinux-dev] why no-mmu cannot support binfmt_aout.c
To: uClinux development list <uclinux-dev@uclinux.org>
Message-ID: <4982EC62.8020408@snapgear.com
>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

loody wrote:
>> What target did you use as your base for this?
>> (What I really want to know is what is set in the
>> config.arch file).
>>
>> Regards
>> Greg
> Dear Greg:
> I use GDB/armulator.
> attach the config and config.arch for your reference.
> Thanks for your help,

Here is what I did:

1. downloaded uClinux-dist-20080808.tar.gz
2. downloaded arm-linux-tools-20061213.tar.gz
3. mkdir user/hello
4. vi user/hello/hello.c and put in it:

int main()
{
printf("hello world\n");
}

5. vi user/hello/Makefile and put in it:

all: hello

romfs:
$(ROMFSINST) /bin/hello

clean:
-rm -f hello *.elf *.gdb *.o

6. vi user/Kconfig, adding in the "Miscellaneous Applications section:

config USER_HELLO_HELLO
bool "hello"

7. vi user/Makefile, adding in a line:

dir_$(CONFIG_USER_HELLO_HELLO) += hello

8. configured uClinux-dist to build "GDB/ARMulator" selecting to
use a linux-2.6.x kernel, and selected the new "hello" program
for inclusion as well

9. make
10. cd images
11. cp .
12. run "skyeye -e linux" and see:

Your elf file is little endian.
arch: arm
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name at91, mach_init addr 0x4189a0
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm7100 mmu ops
Loaded ROM boot.rom
exec file "linux"'s format is elf32-little.
load section .text.head: addr = 0x01008000 size = 0x00000190.
load section .init: addr = 0x010081a0 size = 0x0000ee60.
load section .text: addr = 0x01017000 size = 0x000ce870.
not load section .rodata: addr = 0x010e6000 size = 0x00000000 .
not load section .pci_fixup: addr = 0x010e6000 size = 0x00000000 .
not load section .rio_route: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_gpl: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_unused: addr = 0x010e6000 size = 0x00000000 .
not load section __ksymtab_unused_gpl: addr = 0x010e6000 size =
0x00000000 .
not load section __ksymtab_gpl_future: addr = 0x010e6000 size =
0x00000000 .
not load section __kcrctab: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_gpl: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_unused: addr = 0x010e6000 size = 0x00000000 .
not load section __kcrctab_unused_gpl: addr = 0x010e6000 size =
0x00000000 .
not load section __kcrctab_gpl_future: addr = 0x010e6000 size =
0x00000000 .
load section __param: addr = 0x010e6000 size = 0x00001000.
load section .data: addr = 0x010e8000 size = 0x00009f98.
not load section .bss: addr = 0x010f1fa0 size = 0x00008f20 .
not load section .comment: addr = 0x00000000 size = 0x000013b0 .
call ARMul_InitSymTable,kernel filename is linux.
start addr is set to 0x01008000 by exec file.
Linux version 2.6.25-uc0 (gerg@goober) (gcc version 3.4.4) #2 Fri Jan 30
21:38:07 EST 2009
CPU: Atmel-AT91M40xxx [14000040] revision 0 (ARMvundefined/unknown),
cr=00000000
Machine: Atmel AT91 EB01
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 4064
Kernel command line:
PID hash table entries: 64 (order: 6, 256 bytes)
console [ttyS0] enabled
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 15268KB available (832K code, 75K data, 60K init)
Mount-cache hash table entries: 512
io scheduler noop registered (default)
Atmel USART driver version 0.99
ttyS0 at 0xfffd0000 (irq = 2) is a builtin Atmel APB USART
ttyS1 at 0xfffcc000 (irq = 3) is a builtin Atmel APB USART
brd: module loaded
uclinux[mtd]: RAM probe address=0x1400000 size=0x103000
Creating 1 MTD partitions on "ROM":
0x00000000-0x00103000 : "ROMfs"
uclinux[mtd]: set ROMfs to be root filesystem
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 60K
Shell invoked to run file: /etc/rc
Command: hostname GDB-ARMulator
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: mkdir /var/empty
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|

GDB/ARMulator support by <davidm@snapgear.com>
For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/>




13. from the command line I run "hello":

/> hello
hello world
/>


All seems to work...

Regards
Greg

--
Anders Remark:

//-----tools & package-----
http://ftp.snapgear.org/pub/snapgear/tools/arm-linux/
http://www.uclinux.org/uClinux/dist/uClinux-dist-20080808.tar.gz
//-----end of tools & package-----

//-----skyeye.conf-----
cpu: arm7tdmi
mach: at91
mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000
mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=boot.rom
mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000
mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000
mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000
mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000
lcd: state=on
//-----end of skyeye.conf-----

2009年1月29日星期四

BASH练习之“目录轮回”

写了一个bash脚本当作练习内容,为bash添加了qu和hui命令.

qu "去"
hui "回"

anders@~#qu .tencent/
/home/anders /home/anders/.tencent/
anders@~/.tencent#qu qq
/home/anders /home/anders/.tencent/ /home/anders/.tencent/qq
anders@~/.tencent/qq#hui
anders@~/.tencent#hui
anders@~#

--------.bashrc-------
# anders bash exercise
declare -a FOLDER_ARRAY
export FOLDER_ARRAY
FOLDER_ARRAY[0]=$(pwd)

qu ()
{
dirname=$1

if [ $# -eq 0 ] || [ ! -d $1 ]; then
echo "usage:qu "
return
else
if [ ${dirname:0:1} != "/" ]; then
dirname=$(pwd)/$dirname
fi
FOLDER_ARRAY[${#FOLDER_ARRAY[@]}]=$dirname
cd $dirname
echo ${FOLDER_ARRAY[@]}
fi
}

hui ()
{
if [ ${#FOLDER_ARRAY[@]} -le 1 ]; then
echo "no back way"
return
else
unset FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]
cd ${FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]}
fi
}