Prife 发表于 2012-07-16 11:17

mini2440上运行netbsd 6 beta2

本帖最后由 Prife 于 2012-07-16 11:36 编辑

host: ubuntu 12.04 32bit
netbsd版本: ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0_BETA2/evbarm/
板子:mini2440

最近netbsd增加了对mini2440的支持,参见这里http://xpg.dk/projects/netbsd-support-for-the-mini2440/

上面的网页点击后,内部有一个HOWTO的链接即,http://xpg.dk/projects/netbsd-support-for-the-mini2440/nb-mini2440-ht/,点击进入之后,就有详细的步骤。

尽管笔者照着他给的howto操作,但依然遇到了困难
1. 问题1, bootmini2440无法通过nfs/tftp加载netsd
beta2中自带的bootmini2440好像有些问题,无法正常初始化DM9000,也就无法使用NFS来加载netbsd,但是u-boot却可以使用nfs和tftp。为了顺利启动内核,我不得不利用uboot将netbsd(bin格式,非elf格式)加载到指定RAM(0x30200000) 然后修改bootmini2440代码,使其设置完MMU后,直接跳转到 0x30200000处运行。

终于成功启动内核。

2.制作ramfs后启动失败
参考 http://bbs.chinaunix.net/thread-801055-1-1.html 中的步骤,制作了一个3M的 ramdisk,并启动,但却提示如下信息:

下面是uboot中的操作:

MINI2440 # tftp 30a00000 bootmini2440
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
TFTP from server 10.0.0.107; our IP address is 10.0.0.105
Filename 'bootmini2440'.
Load address: 0x30a00000
Loading: ########
done
Bytes transferred = 110208 (1ae80 hex)
MINI2440 # tftp 30200000 ramdisk   
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
TFTP from server 10.0.0.107; our IP address is 10.0.0.105
Filename 'ramdisk'.
Load address: 0x30200000
Loading: #################################################################
       #################################################################
       #################################################################
       #################################################################
       #################################################################
       ###############################
done
Bytes transferred = 5224448 (4fb800 hex)
MINI2440 # go 30a00000
## Starting application at 0x30A00000 ...
S3C: CLK=405 HCLK=101 PCLK=50 UCLK=48
S3C: CLK=405 HCLK=101 PCLK=50 UCLK=48

接下里就可以看到netbsd的启动信息了,如下所示

>> NetBSD/evbarm boot2440, revision 1.0 (Sun Jul 15 11:13:29 CST 2012)
Argument count: 1
Boot string: 30a00000
val = 29282b2a, DM9000 Chip not found
suppose it runs in qemu, run all the same
begin open tftp file, add by prife 2012/07/14 17:42:51
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012
    The NetBSD Foundation, Inc.All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.All rights reserved.

NetBSD 6.0_BETA2 (MY_2440) #0: Mon Jul9 22:47:41 CST 2012
        prife@smart:/usr/src/sys/arch/evbarm/compile/MY_2440
total memory = 65536 KB
avail memory = 58468 KB
mainbus0 (root)
cpu0 at mainbus0: ARM920T rev 0 (ARM9TDMI core)
cpu0: DC enabled IC enabled WB enabled EABT
cpu0: 16KB/32B 64-way Instruction cache
cpu0: 16KB/32B 64-way write-back-locking-A Data cache
ssio0 at mainbus0: fclk 405 MHz hclk 101 MHz pclk 50 MHz
ohci0 at ssio0 intr 26
ohci0: OHCI version 0.0
ohci0: unsupported OHCI revision
ohci0: init failed, error=4
sscom0 at ssio0 unit 0
sscom0: console (major=104)
ssextio0 at ssio0
dme0 at ssextio0 addr 0x20000300 intr 7
dme0: Unable to get mac-address property
lcd0 at ssio0
s3c_lcd_write: attempt to enable LPC3600
wsdisplay0 at lcd0
lcd0: Allocating LCD frame buffer of size 153600
sssdi0 at ssio0
sdmmc0 at sssdi0
ssiis0 at ssio0
udassio0 at ssiis0
audio0 at udassio0: half duplex, playback, capture
sstouch0 at ssio0
wsmouse0 at sstouch0 mux 0
ssrtc0 at ssio0: RTC
clock: hz=100 stathz = 64 PCLK=50625000 prescaler=2 tc=24719
boot device: <unknown>
root on md0a dumps on md0b
root file system type: ffs
warning: no /dev/console
exec /sbin/init: error 2
init: trying /sbin/oinit
exec /sbin/oinit: error 2
init: trying /sbin/init.bak
exec /sbin/init.bak: error 2
init path (default /sbin/init):

但实际上在/sbin/init文件是存在的。不知道为什么无法加载。
笔者google了很久也没有找到解决方案。。。如果有人知道,请多多指点。

PS:笔者在 mini2440-qemu上和开发板上都作了尝试,同样的错误。关于如何使用qemu来模拟2440可以参考笔者的qemu配置笔记,在这里:
https://github.com/prife/documents/blob/master/mini2440_qemu_install.txt

3. SD卡安装netbsd失败
然后尝试参考HOWTO的第一节,尝试将netbsd安装到SD卡上,同样遇到问题,笔者使用的是2G的SD卡,在安装时选择分区后,始终提示遇到错误,无法安装,然后就会返回第一页继续安装,整个过程如下所示。













到下一步就出错了,然后就会回到第一个页面继续。

ulovko 发表于 2012-07-16 11:20

感谢分享宝贵的经验 ^_^ :emn31:

Prife 发表于 2012-07-16 11:25

回复 2# ulovko


   晕啊,我是想求一下解决方案啊。有没有同学在玩2440上跑netbsd的?

send_linux 发表于 2012-07-17 09:38

Prife 发表于 2012-07-16 11:25 static/image/common/back.gif
回复 2# ulovko




这个可能嵌入式开发板块的人多点,玩嵌入式板子的嘛,呵呵

arm_zwinger 发表于 2012-07-18 16:04

mark

帮顶!

gvim 发表于 2012-07-18 16:48

回复 1# Prife


手上没系统,只能根据印象看看了.
第一个问题前面都起来了,内核和ramdisk看起来都合法,剩下应该是文件系统里的东西没做好,包括/dev/console等等.
第二个问题分区没弄对.没记错的话,应该有地方指定swap和/分区,你给的图上没看见.

Prife 发表于 2012-07-18 17:51

回复 7# gvim


ramdisk的大小是严格要求的,在conf/INSTALL文件(该文件由SMDK2410_INSTALL包含进去)中有一句MEMORY_DISK_ROOT_SIZE=6150,它是以512字节的快形式给出,具体的换算是6150*512/1024 = 6150/2 =3075k 稍微大于3m(所以我们在第4步的nbmakefs 的时候 -s参数给的是3m),这里内核本身预留的空间至少要大于后等于nbmakefs产生的ramdisk大小。

这个ramdisk只有3m,如果要制作更大的ramdisk,放更多的东西进去,需要修改2行内核代码,有兴趣咱们再另外说

请问修改哪里的代码?

我现在的程序有了些新的进展。

原来的ramdisk里我忘记添加 /lib下加入动态链接库,导致内核无法启动init。现在我加入库之后,ramdisk超过3M,因此我修改INSTALL文件,将ramdisk修改为5M后,制作ramdisk,并启动运行,这次我得到的信息是:

>> NetBSD/evbarm boot2440, revision 1.0 (Sun Jul 15 11:13:29 CST 2012)
Argument count: 1
Boot string: 30a00000
val = 29282b2a, DM9000 Chip not found
suppose it runs in qemu, run all the same
begin open tftp file, add by prife 2012/07/14 17:42:51
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012
    The NetBSD Foundation, Inc.All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.All rights reserved.

NetBSD 6.0_BETA2 (MY_2440) #1: Wed Jul 18 15:31:44 CST 2012
        prife@smart:/usr/src/sys/arch/evbarm/compile/MY_2440
total memory = 65536 KB
avail memory = 56456 KB
mainbus0 (root)
cpu0 at mainbus0: ARM920T rev 0 (ARM9TDMI core)
cpu0: DC enabled IC enabled WB enabled EABT
cpu0: 16KB/32B 64-way Instruction cache
cpu0: 16KB/32B 64-way write-back-locking-A Data cache
ssio0 at mainbus0: fclk 405 MHz hclk 101 MHz pclk 50 MHz
ohci0 at ssio0 intr 26
ohci0: OHCI version 0.0
ohci0: unsupported OHCI revision
ohci0: init failed, error=4
sscom0 at ssio0 unit 0
sscom0: console (major=104)
ssextio0 at ssio0
dme0 at ssextio0 addr 0x20000300 intr 7
dme0: Unable to get mac-address property
lcd0 at ssio0
s3c_lcd_write: attempt to enable LPC3600
wsdisplay0 at lcd0
lcd0: Allocating LCD frame buffer of size 153600
sssdi0 at ssio0
sdmmc0 at sssdi0
ssiis0 at ssio0
udassio0 at ssiis0
audio0 at udassio0: half duplex, playback, capture
sstouch0 at ssio0
wsmouse0 at sstouch0 mux 0
ssrtc0 at ssio0: RTC
clock: hz=100 stathz = 64 PCLK=50625000 prescaler=2 tc=24719
boot device: <unknown>
root on md0a dumps on md0b
root file system type: ffs
warning: no /dev/console
panic: init died (signal 0, exit 11)
Stopped in pid 1.1 (init) at    c0218d3c:       mov   r15, r14
db>

另外,查看 嵌入程序的动态链接库可以使用这个方法:

arm--netbsdelf-readelf -dinit

prife@smart:~/work/ramdisk$ arm--netbsdelf-readelf -dsbin/init

Dynamic section at offset 0x442c contains 20 entries:
Tag      Type                         Name/Value
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x0000000f (RPATH)                      Library rpath:
0x0000000c (INIT)                     0x8f78
0x0000000d (FINI)                     0xbb44
0x00000004 (HASH)                     0x8134
0x00000005 (STRTAB)                     0x89a0
0x00000006 (SYMTAB)                     0x83c0
0x0000000a (STRSZ)                      815 (bytes)
0x0000000b (SYMENT)                     16 (bytes)
0x00000015 (DEBUG)                      0x0
0x00000003 (PLTGOT)                     0x144f4
0x00000002 (PLTRELSZ)                   576 (bytes)
0x00000014 (PLTREL)                     REL
0x00000017 (JMPREL)                     0x8d38
0x00000011 (REL)                        0x8cd0
0x00000012 (RELSZ)                      104 (bytes)
0x00000013 (RELENT)                     8 (bytes)
0x00000000 (NULL)                     0x0
prife@smart:~/work/ramdisk$

这样就可以在主机上查看了,并且可以编写一个脚本,自动对ramdisk文件夹下所有可执行文件调用上面的命令,将输出保存成一个文件 libraw.txt,然后再使用
grep"Shared library"   libraw.txt
取出所有共享库的行,然后再用 sort -u 删除重复的行,

0x00000001 (NEEDED)                     Shared library: >
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library: >>
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:     >>
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:
0x00000001 (NEEDED)                     Shared library:

gvim 发表于 2012-07-18 18:00

VERBOSE_INIT_ARM

你把这个宏打开.

Prife 发表于 2012-07-18 18:13

回复 9# gvim

好像没什么新变化,我修改的是 MINI2440

MINI2440_INSTALL 依赖 MINI2440这个宏。

options   VERBOSE_INIT_ARM # verbose bootstraping messages

然后启动这个新的netbsd。信息如下

    >> NetBSD/evbarm boot2440, revision 1.0 (Sun Jul 15 11:13:29 CST 2012)
Argument count: 1
Boot string: 30a00000
val = 29282b2a, DM9000 Chip not found
suppose it runs in qemu, run all the same
begin open tftp file, add by prife 2012/07/14 17:42:51
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012
    The NetBSD Foundation, Inc.All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.All rights reserved.

NetBSD 6.0_BETA2 (MY_2440) #2: Wed Jul 18 18:06:36 CST 2012
        prife@smart:/usr/src/sys/arch/evbarm/compile/MY_2440
total memory = 65536 KB
avail memory = 56456 KB
mainbus0 (root)
cpu0 at mainbus0: ARM920T rev 0 (ARM9TDMI core)
cpu0: DC enabled IC enabled WB enabled EABT
cpu0: 16KB/32B 64-way Instruction cache
cpu0: 16KB/32B 64-way write-back-locking-A Data cache
ssio0 at mainbus0: fclk 405 MHz hclk 101 MHz pclk 50 MHz
ohci0 at ssio0 intr 26
ohci0: OHCI version 0.0
ohci0: unsupported OHCI revision
ohci0: init failed, error=4
sscom0 at ssio0 unit 0
sscom0: console (major=104)
ssextio0 at ssio0
dme0 at ssextio0 addr 0x20000300 intr 7
dme0: Unable to get mac-address property
lcd0 at ssio0
s3c_lcd_write: attempt to enable LPC3600
wsdisplay0 at lcd0
lcd0: Allocating LCD frame buffer of size 153600
sssdi0 at ssio0
sdmmc0 at sssdi0
ssiis0 at ssio0
udassio0 at ssiis0
audio0 at udassio0: half duplex, playback, capture
sstouch0 at ssio0
wsmouse0 at sstouch0 mux 0
ssrtc0 at ssio0: RTC
clock: hz=100 stathz = 64 PCLK=50625000 prescaler=2 tc=24719
boot device: <unknown>
root on md0a dumps on md0b
root file system type: ffs
warning: no /dev/console
panic: init died (signal 0, exit 11)
Stopped in pid 1.1 (init) at    c0218d3c:       mov   r15, r14
db>

gvim 发表于 2012-07-18 18:17

回复 10# Prife


    你用的/sbin/init和/netbsd编译器用的一样吗?看下他们的abi是不是一样的,编译指令的版本是不是一样的.
页: [1] 2
查看完整版本: mini2440上运行netbsd 6 beta2