大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
———————————————————————————————————————
交叉编译器环境:arm-linux-gcc-4.5.4
开发板平台: FL2440
Linux内核版本: linux-3.0
制作文件系统类型:INITRAMFS
邮箱:leiyuxing205@gmail.com
———————————————————————————————————————
1. initramfs
initramfs在编译内核的同时被编译并与内核生成一个映像文件,可以压缩也可以不压缩,但是目前只支持cpio包格式。它是根文件系统制作和制作的一种非常简单的方法,也可以通过执行这个文件系统中的程序引导真正的文件系统,这样加载根文件系统的工作就不是内核的工作,而是initramfs的工作。由于initramfs使用cpio包格式,所以很容易将一个单一的文件、目录、node编译链接到系统中去,这样很简单的系统中使用起来很方便,不需要另外挂接文件系统。
但是因为cpio包实际是文件、目录、节点的描述语言包,为了描述一个文件、目录、节点,要增加很多额外的描述文字开销,特别是对于目录和节点,本身很小额外添加的描述文字却很多,这样使得cpio包比相应的image文件大很 多
2.对根文件系统进行修改
由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在上面制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。
[leiyuxing@centos6 rootfs]$ ln -s bin/busybox init
[leiyuxing@centos6 rootfs]$ ll
总用量 60
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 apps
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 22 11:14 bin
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 data
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 11:58 dev
drwxrwxr-x. 4 leiyuxing leiyuxing 4096 7月 21 16:55 etc
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 info
lrwxrwxrwx. 1 leiyuxing leiyuxing 11 7月 22 11:15 init -> bin/busybox
drwxrwxr-x. 3 leiyuxing leiyuxing 4096 7月 21 11:05 lib
lrwxrwxrwx. 1 root root 11 7月 22 11:14 linuxrc -> bin/busybox
drwxrwxr-x. 6 leiyuxing leiyuxing 4096 7月 21 10:19 mnt
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 proc
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 root
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 22 11:14 sbin
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 sys
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 10:19 tmp
drwxrwxr-x. 6 leiyuxing leiyuxing 4096 7月 21 10:19 usr
drwxrwxr-x. 2 leiyuxing leiyuxing 4096 7月 21 12:00 var
3. 添加内核对initramfs的支持
[leiyuxing@centos6 kernel]$ ls
linux-3.0 linux-3.0.tar.bz2
[leiyuxing@centos6 kernel]$ cd linux-3.0
[leiyuxing@centos6 linux-3.0]$ export TERM=vt100
[leiyuxing@centos6 linux-3.0]$ make menuconfig
。 。 。 。 。 。
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/home/leiyuxing/fl2440/rootfs/rootfs) Initramfs source file(s) #输入根文件系统的所在目录
。 。 。 。 。 。
[leiyuxing@centos6 linux-3.0]$ ls
arch fs linuxrom-s3c2440.bin README usr
block include MAINTAINERS REPORTING-BUGS virt
COPYING init Makefile samples vmlinux
CREDITS ipc mm scripts vmlinux.o
crypto Kbuild modules.builtin security
Documentation Kconfig modules.order sound
drivers kernel Module.symvers System.map
firmware lib net tools
[leiyuxing@centos6 linux-3.0]$ du -h linuxrom-s3c2440.bin
6.8M linuxrom-s3c2440.bin
4.制作映像文件
因为文件系统和内核是集成在一起的,所以不需要制作文件系统映像
5.添加uboot对initramfs支持
Uboot源码基本上不做修改。
下面对uboot进行修改。
[fl2440@lingyun]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 8000000;nand write 30008000 100000 800000'
[fl2440@lingyun]# set bootcmd_initramdisk 'nand read 30008000 100000 800000;bootm 30008000'
[fl2440@lingyun]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
[fl2440@lingyun]# set bootcmd 'run bootcmd_initramdisk'
[fl2440@lingyun]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[fl2440@lingyun]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:51
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.168
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###############################
done
Bytes transferred = 7121280 (6ca980 hex)
NAND erase: device 0 offset 0x100000, size 0x8000000
Skipping bad block at 0x005c0000
Skipping bad block at 0x031a0000
Erasing at 0x80e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
Skip bad block 0x005c0000
8388608 bytes written: OK
6. 启动引导
[fl2440@lingyun]# boot
NAND read: device 0 offset 0x100000, size 0x800000
Skipping bad block 0x005c0000
8388608 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2016-07-22 4:38:45 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 7121216 Bytes = 6.8 MiB
Load Address: 30008040
Entry Point: 30008040
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 (leiyuxing@centos6.7.localdomain) (gcc version 4.5.4 (Buildroot 2012.08) ) #5 Fri Jul 22 12:38:30 CST 2016
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7
PID hash table entries: 256 (order: -2, 1024 bytes)
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: 45936k/45936k available, 19600k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0e12000 (14376 kB)
.text : 0xc0e12000 - 0xc122c000 (4200 kB)
.data : 0xc122c000 - 0xc124fd60 ( 144 kB)
.bss : 0xc124fd84 - 0xc1287a90 ( 224 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080800
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
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
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 89
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 46 at 0x0000005c0000
Bad eraseblock 397 at 0x0000031a0000
Creating 6 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000001000000 : "mtdblock1 kernel 15MB"
0x000001000000-0x000005000000 : "mtdblock2 rootfs 64MB"
0x000005000000-0x00000a000000 : "mtdblock3 apps 80MB"
0x00000a000000-0x00000d000000 : "mtdblock4 data 48MB"
0x00000d000000-0x000010000000 : "mtdblock5 backup 48MB"
dm9000 Ethernet Driver, V1.31
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
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
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2410_udc: debugfs dir creation failed -19
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
Freeing init memory: 14376K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: new full speed USB device number 3 using s3c2410-ohci
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: new full speed USB device number 4 using s3c2410-ohci
usb 1-1: device not accepting address 4, error -62
usb 1-1: new full speed USB device number 5 using s3c2410-ohci
usb 1-1: device not accepting address 5, error -62
hub 1-0:1.0: unable to enumerate USB device on port 1
Copyright (C) 2016 Reagan
root login: root
Password:
>: ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr
这样initramfs文件系统就自作成功
制作过程中遇到的问题
问题一:
根文件系统里没有init 和linuxrc
解决方法:
[lingyun@localhost rootfs]$ ln -s bin/busybox init
[lingyun@localhost rootfs]$ ll
total 60
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
lrwxrwxrwx 1 lingyun trainning 11 Apr 27 21:19 init -> bin/busybox
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
lrwxrwxrwx 1 root root 11 Apr 26 15:16 linuxrc -> bin/busybox
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/169685.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...