Monday, January 22, 2007

嘗試加入一個客製化應用軟體

以下示範加入一個極小型應用軟體, 在您手上的 SPG290 ScoreLinux

Saturday, January 20, 2007

SPG290 uClinux make 生成 linux & romfs.img

SPG290 uClinux 是port自於 uClinux-dist-20060803.tar.bz2, 這版本所採用kernel是基於 Linux kernel 2.6.17

依照內定值, make 的結果回升成一份 2.6.17 uClinux kernel, 以及romfs.img 這樣一份 root filesystem (以下簡稱微 rootfs)

export PATH=your_score_tool_path:$PATH
make CROSS_COMPILE=score-linux-elf-

這時候生成以下兩個檔案, 一個是Linux kernel一個是 rootfs
kernel: linux-2.6.x/linux
rootfs: images/romfs.img

一個展開的 rootfs 放在 romfs/
drwxr-xr-x 2 root root 4096 Jan 19 15:25 bin
drwxr-xr-x 2 root root 4096 Jan 19 14:20 dev
drwxr-xr-x 2 root root 4096 Jan 19 15:34 etc
drwxr-xr-x 2 root root 4096 Jan 19 14:20 home
drwxr-xr-x 2 root root 4096 Jan 19 14:20 lib
drwxr-xr-x 2 root root 4096 Jan 19 14:20 mnt
drwxr-xr-x 2 root root 4096 Jan 19 14:20 proc
lrwxrwxrwx 1 root root 4 Jan 19 15:25 sbin -> /bin
lrwxrwxrwx 1 root root 8 Jan 19 15:25 tmp -> /var/tmp
drwxr-xr-x 2 root root 4096 Jan 19 14:20 usr
drwxr-xr-x 2 root root 4096 Jan 19 14:20 var

手動做一份測試用 SPG290 ramdisk.img root filesystem

手動做一份測試用 ramdisk.img root filesystem

首先, 如步驟0, 先完成ramdisk.img, 其次kernel本身至少要打開initrd & ext2, 如步驟1, 這兩部分的kernel功能應該都沒有architecture-dependent, 另外也讓kernel自帶參數, 範例中的參數可能需要修改的有ttyS1以及0x80a00000, 打開這幾個組態也要打開相映程式

kernelrootfs兩份image file都準備好了, 依照原本的方法準備下載到板子

RAM, 線在規劃一段RAM來放ramdisk.img (4MB), 大約是扣除掉kernel size 往上一點, 假設說0x80a00000

假設這時候我們已經下載kernel & root filesystem 兩份imageRAM, 啟動start_kernel, 這時候, kernel執行的後面階段會到0x80a00000這段地址來mount rootfs

<0>

dd if=/dev/zero of=ramdisk.img bs=1024 count=4096 # create 4MB image

mkfs.ext2 ramdisk.img

mount ramdisk.img /mnt –o loop

mkdir /mnt/dev

mknod /mnt/dev/ram0 b 1 0

ls –l /mnt ## 空的image, 沒有檔案系統內容

umount /mnt

<1>

.config # kernel configuration

CONFIG_BLK_DEV_INITRD=y

CONFIG_CMDLINE="console = ttyS1 , 115200 root = / dev / ram0 rw initrd = 0x80a00000 "

CONFIG_EXT2_FS=y

Monday, January 08, 2007

elf2flt porting

Things needed to be changed
1. elf2flt.ld 2. elf2flt.c (elf2flt tool) 3. binfmt_flat.c (in kernel)

elf2flt.c (around line 1300)
case SCOPE_SPG290:
relocation_needed = 1;
pflags = 0x40000; // need to fix this value
sym_vma = bfd_section_vma(abs_bfd, sym_section);
sym_addr += sym_vma + q->addend;
sym_addr &= 0x000003ff;
sym_addr |= (
htonl(*(unsigned long *)r_mem)
& 0xfffffc00
);
break;

--
ld-elf2flt -- A linker replacement that implements a -elf2flt option for the
linker and runs elf2flt automatically for you. It auto
detects PIC/non-PIC code and adjusts its option accordingly.
It uses the environment variable FLTFLAGS when running
elf2flt. It runs /.../m68k-elf-ld.real to do the actual
linking.

Monday, December 25, 2006

uClinux with FLT, without MMU

1. genext2fs -b 8192 -f dev.txt -d /home/yuan/uClinux-dist/romfs /home/yuan/uClinux-dist/images/ramdisk
2. GCC flag "-fpic -msingle-pic-base -Wl,--fatal-warnings -Wl,-elf2flt "
3. uClinux defaults "ld entry symbol lf2flt; defaulting to 000080d0"

elf2flt [options] bfd.file
-v : verbose operation
-r : force load to RAM
-z : compress code/data/relocs
-d : compress data/relocs
-p abs-pic-file : GOT/PIC processing with files
-s stacksize : set application stack size
-o output-file : output file name
[root@localhost uClinux-dist]#

Monday, December 11, 2006

elf2flt & default entry 000080d0

uClinux already has default compile flag -elf2flt
ld relink user init program to 000080d0 during compile, need to verify if this is correct setting.
Once this is corrected, there may be no memory address loading issue.
FLT user program has distinct file header from of
text/data/bss for program loader

we may need addition program elf2flt.ld to score_tool toolchain.

Thursday, December 07, 2006

genext2fs commands

genext2fs command is missing from uClinux200805 distribution
download from http://nchc.dl.sourceforge.net/sourceforge/genext2fs/genext2fs-1.4rc1.tar.gz
genext2fs: too many arguments, need to fix uClinux commands

Tuesday, October 17, 2006

About Documentation

Exchange idea with Henry
Henry tends to have bigger scope idea about the future book writting like
"Embedded OS design guide with Sunplus Score"


If user wants to compile 2.6.x kernel directly without uClinux UI?
cd uClinux-dist/linux-2.6.x/
export PATH=$PATH:Score_tool_path/bin
make menuconfig CROSS_COMPILE=score-linux-elf-
make CROSS_COMPILE=score-linux-elf-