宿主机: Kubuntu 8.04 (linux-2.6.24-19) gcc-4.2.3 目标机: s3c2440 linux-2.6.26 cramfs 交叉编译器(由crosstool-0.43制作): arm-linux-gcc-4.1.0 工具: busybox-1.9.2 目标: 进入console操作 问题伊始: VFS: Mounted root (cramfs filesystem) readonly. Freeing init memory: 124K cramfs: bad compressed blocksize 989432407 cramfs: bad compressed blocksize 4274059297 Failed to execute /linuxrc. Attempting defaults... Kernel panic - not syncing: No init found. Try passing init= option to kernel. 怀疑可能是文件系统的问题导致上面红色部分的错误,因此参考网上文章做一个cramfs文件系统。 ------------------------------------------------------------- 参考资料: 《 BusyBox——嵌入式Linux中的瑞士军刀 》 《 使用busybox-1.9.2制作根文件系统 》 《 使用Busybox制作CRAMFS文件系统成功 》 ------------------------------------------------------------- 1. 修改Makefile #ARCH ?= $(SUBARCH) #CROSS_COMPILE ?= ARCH := armCROSS_COMPILE := $HOME/toolchain/crosstool/gcc-4.1.0-glibc-2.3.2/arm-linux-gnu/bin/arm-linux-gnu- 2. 修改applets/applets.c中的警告信息 //#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__) #if 0 #warning Static linking against glibc produces buggy executables #warning (glibc does not cope well with ld --gc-sections). #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 #warning Note that glibc is unsuitable for static linking anyway. #warning If you still want to do it, remove -Wl,--gc-sections #warning from scripts/trylink and remove this warning. #error Aborting compilation. #endif 这段警告的意思是告诉你最好用uclibc编译,而不是用glibc因为glibc比较大,busybox在寸土寸金的嵌入式系统中运用比较多,所以会有这样的要求。 如果没有注释掉这段警告或者没有采用uclibc的话,在make install的时候则会出现如下的错误: applets/applets.c:15:2: warning: #warning Static linking against glibc produces buggy executables applets/applets.c:16:2: warning: #warning (glibc does not cope well with ld --gc-sections). applets/applets.c:17:2: warning: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 applets/applets.c:18:2: warning: #warning Note that glibc is unsuitable for static linking anyway. applets/applets.c:19:2: warning: #warning If you still want to do it, remove -Wl,--gc-sections applets/applets.c:20:2: warning: #warning from scripts/trylink and remove this warning. applets/applets.c:21:2: #error Aborting compilation. make[1]: *** [applets/applets.o] 错误 1 make: *** [applets] 错误 2 3. 配置busybox 首先可以先恢复一下默认配置 $ make defconfig 然后,配置busybox可以采用如下命令: $ make menuconfig 或 $ make xconfig 配置内容参考 《 使用busybox-1.9.2制作根文件系统 》 《 使用Busybox制作CRAMFS文件系统成功 》 4. 编译busybox $ make install 如若成功,会有如下信息: -------------------------------------------------- You will probably need to make your busybox binary setuid root to ensure all configured applets will work properly. --------------------------------------------------并在busybox/_install 目录下会生成下列文件: drwxr-xr-x 5 wang wang 4096 2008-09-10 17:32 . drwxr-xr-x 32 wang wang 4096 2008-09-10 17:32 .. drwxr-xr-x 2 wang wang 4096 2008-09-10 17:32 bin lrwxrwxrwx 1 wang wang 11 2008-09-10 17:32 linuxrc -> bin/busybox drwxr-xr-x 2 wang wang 4096 2008-09-10 17:32 sbin drwxr-xr-x 4 wang wang 4096 2008-09-10 17:32 usr 5. 修改_install/bin/busybox的属性 $ chmod 4755 ./_install/bin/busybox 必须要要修改属性,否则在busybox中很多命令会受限制 6. 打包_install文件夹的内容 首先要删除_install/linuxrc文件,这个文件将在后面重新被创建,这里先删除 $ rm ./_install/linuxrc 然后将剩下的三个文件夹打包起来 $ tar cvf 1.tar ./install/ 7. 创建cramfs所需的一些目录 首先创建一个文件夹,作为暂时存放cramfs的临时目录,以方便在其下建立文件系统。所有命令如下 $ mkdir /opt/rootfs $ cd /opt/rootfs $ mkdir bin dev etc home lib mnt proc sbin sys tmp var usr $ mkdir etc/init.d (其中假设你的普通用户已经取得/opt的操作所有权或者也可以放在用户目录下完成; 总之,对于rootfs及其以下目录,当前用户必须拥有读、写和执行的所有权) 8. 准备启动所需的文件:linuxrc、rcS、inittab、fstab四个文件 (以下均假定当前路径在/opt/rootfs) a. linuxrc $ vim linuxrc 内容: #!/bin/sh echo "mount /etc as ramfs" /bin/mount -f -t cramfs -o remount,ro /dev/bon/2 / /bin/mount -t ramfs ramfs /var /bin/mkdir -p /var/tmp /bin/mkdir -p /var/run /bin/mkdir -p /var/log /bin/mkdir -p /var/lock /bin/mkdir -p /var/empty #/bin/mount -t usbdevfs none /proc/bus/usb exec /sbin/init 更改其所有权: $ chmod 775 linuxrc b. rcS $ vim etc/init.d/rcS 内容: #!/bin/sh # mount all filesystem defined in "fstab" echo "#mount all......." /bin/mount -a 更改其所有权: $ chmod 775 etc/init.d/rcS c. inittab $ vim etc/inittab 内容: # This is run first except when booting ::sysinit:/etc/init.d/rcS # Start an "askfirst" shell on the console #::askfirst:-/bin/bash ::askfirst:-/bin/sh # Stuff to do when restarting the init process ::restart:/sbin/init # Stuff to do before rebooting ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r d. fstab $ vim etc/fstab 内容: none /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0 tmpfs /dev/shm tmpfs defaults 0 0 9. 创建节点console、null 否则就会提示“Warning: unable to open an initial console. Kernel panic - not syncing: Attempted to kill init!”的类似错误。 创建时,必须以root身份才可以 sudo mknod -m 600 dev/console c 5 1 sudo mknod -m 666 dev/null c 1 3 10. 使用之前打包的_install 将刚才在busybox的_install下的三个文件夹的打包文件复制到rootfs目录,解压后删除打包文件。 $ tar xvf 1.tar $ rm 1.tar 11. 复制常用的lib文件 我用的是开发板的文件系统中的lib/下的文件,直接拷贝过来用 12. 创建cramfs $ cd /opt $ mkcramfs rootfs s3c2440.cramfs 如果没有mkcramfs命令,请参见《 交叉编译环境,内核映像和文件系统生成 》 13. 烧录文件系统到开发板并启动 启动信息: Read chip id = ec76 Nand flash status = c0 Set boot params = root=/dev/mtdblock2 init=/linuxrc load_ramdisk=0 console=ttySAC1,115200 mem=65536K devfs=mount display=shp480 Load Kernel... Linux version 2.6.26 (wang@wang-desktop) (gcc version 4.1.0) #7 Thu Sep 4 17:18:03 CST 2008 CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177 Machine: SMDK2440 ATAG_INITRD is deprecated; please update your bootloader. Memory policy: ECC disabled, Data cache writeback CPU S3C2440A (id 0x32440001) S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz S3C24XX Clocks, (c) 2004 Simtec Electronics CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on CPU0: D VIVT write-back cache CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256 Kernel command line: root=/dev/mtdblock2 init=/linuxrc load_ramdisk=0 console=ttySAC1,115200 mem=65536K devfs=mount display=shp480 irq: clearing pending ext status 00056200 irq: clearing pending ext status 00000200 irq: clearing subpending status 00000092 PID hash table entries: 256 (order: 8, 1024 bytes) timer tcon=00590000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8 Console: colour dummy device 80x30 console [ttySAC1] enabled Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory: 64MB = 64MB total Memory: 61708KB available (2732K code, 277K data, 124K init) Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok net_namespace: 192 bytes NET: Registered protocol family 16 S3C2440: Initialising architecture S3C2440: IRQ Support S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics DMA channel 0 at c4800000, irq 33 DMA channel 1 at c4800040, irq 34 DMA channel 2 at c4800080, irq 35 DMA channel 3 at c48000c0, irq 36 S3C244X: Clock Support, DVS off SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb NET: Registered protocol family 2 IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 2048 (order: 2, 16384 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) TCP reno registered NET: Registered protocol family 1 NetWinder Floating Point Emulator V0.97 (double precision) msgmni has been set to 120 io scheduler noop registered io scheduler anticipatory registered (default) io scheduler deadline registered io scheduler cfq registered Console: switching to colour frame buffer device 30x40 fb0: s3c2410fb frame buffer device s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440 s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440 s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440 brd: module loaded usbcore: registered new interface driver ub dm9000 Ethernet Driver, V1.30 Linux video capture interface: v2.00 NFTL driver: nftlcore.c $Revision: 1.98 $, nftlmount.c $Revision: 1.41 $ S3C24XX NAND Driver, (c) 2004 Simtec Electronics s3c2440-nand s3c2440-nand: Tacls=1, 10ns Twrph0=4 40ns, Twrph1=1 10ns NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit) s3c2410_nand_update_chip: chip c3d784bc: 9 NAND_ECC_NONE selected by board driver. This is not recommended !! Scanning device for bad blocks Bad eraseblock 357 at 0x00594000 Bad eraseblock 3335 at 0x0341c000 Bad eraseblock 3995 at 0x03e6c000 Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit": 0x00000000-0x00030000 : "boot" 0x00030000-0x00200000 : "kernel" 0x00200000-0x02000000 : "rootfs" 0x02000000-0x04000000 : "ext-fs1" usbmon: debugfs is not available s3c2410-ohci s3c2410-ohci: S3C24XX OHCI s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1 s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000 usb usb1: configuration #1 chosen from 1 choice hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected Initializing USB Mass Storage driver... usbcore: registered new interface driver usb-storage USB Mass Storage support registered. mice: PS/2 mouse device common for all mice i2c /dev entries driver s3c2440-i2c s3c2440-i2c: slave address 0x10 s3c2440-i2c s3c2440-i2c: bus frequency set to 390 KHz s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled Registered led device: led4 Registered led device: led5 Registered led device: led6 Registered led device: led7 TCP cubic registered RPC: Registered udp transport module. RPC: Registered tcp transport module. VFS: Mounted root (cramfs filesystem) readonly. Freeing init memory: 124K mount /etc as ramfs init started: BusyBox v1.9.2 (2008-09-05 13:54:16 CST) starting pid 813, tty '': '/etc/init.d/rcS' #mount all....... mount: mounting none on /dev/pts failed: No such file or directory mount: mounting tmpfs on /dev/shm failed: No such file or directory # starting mdev.... ****************************************** linux-2.6.26 boot 2008-9-5 ****************************************** Please press Enter to activate this console. starting pid 815, tty '': '/bin/sh' / # / # 终于可以进入console了 |
|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )
GMT+8, 2024-9-30 01:33 , Processed in 0.213873 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5
© 2001-2023 Discuz! Team.