Create an ARM root file system and an arm root file

Source: Internet
Author: User

Create an ARM root file system and an arm root file


1. Cross-compile busybox


Version: busybox-1.22.0.tar.bz2


Modify Makefile to add a cross-compiler path
ARCH? = Arm
CROSS_COMPILE? =/Opt/arm-2009q1/bin/arm-none-linux-gnueabi-
Configure busybox
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
General Configuration --->
[*] Don't use/usr
Linux System Utilities --->
[*] Mount
[*] Support mounting NFS file systems on Linux <2.6.23
Make
Make install
The generated file is in the new directory _ install.


2. Create the filesys directory.
Cd filesys
Create the directory bin boot dev etc home lib media mnt opt proc root sbin srv sys tmp usr var


3. Copy the compiled content in busybox _ install to filesys.
Copy the linked file
Cp-rf "src" "dest"
4 Configure/etc
4.1 Add a file
/Etc/group/etc/passwd/etc/mdev. conf
Content:
/Etc/group
Root: *: 0:
/Etc/passwd
Root: 0: 0: root:/home/root:/bin/sh
/Etc/mdev. conf
Null


4.2 create a file
/Etc/fstab
Content:
Proc/proc defaults 0 0
Tmpfs/tmp tmpfs defaults, size = 5 M 0 0
# Automatic mounting when the mount-a command is executed

4.3 create a file
/Etc/inittab
Content:
: Sysinit:/etc/init. d/rcS
: Askfirst:/bin/sh


# TtyS0: 2345: respawn:/sbin/getty 115200 ttyS0 # I haven't figured it out yet
: Ctrlaltdel:/sbin/reboot


: Shutdown:/bin/umount-a-r


: Restart:/sbin/init
# Init process execution
4.4 create a file
/Etc/init. d/rcS
Content:
#! /Bin/sh
PATH =/bin:/sbin:/usr/bin:/usr/sbin
Runlevel = S
Prevlevel = N
Umask 022
Export PATH runlevel prevlevel
Echo "--------------- mount all --------------"
Mount-


Echo 'mount nand flash file system ...'
Mount-t jffs2/dev/mtdblock4/mnt/nand


# Mount devpts in order to use telnetd
######################################## ###################################
########## Telnet Server ######################
Echo "--------------- mount devpts ------------"
Cp-rf/dev/*/tmp
Mount-t tmpfs/dev
Cp-rf/tmp/*/dev
Rm-rf/tmp /*




Echo "--------------- Start mdev -------------"
Mount-t sysfs/sys
Echo/sbin/mdev>/proc/sys/kernel/hotplug
Mdev-s


Echo "...... Start Telnetd Server ........."
./Etc/init. d/telnetd start


Mount-t devpts/dev/pts


Sleep 1
########## Telnet Server ######################
######################################## ###################################
Echo "**************************************"
Echo "Kernel version: linux-2.6.24"
Echo "DM6467T rootfs"
Echo "Date: 2010.12.22"
Echo "**************************************"
Ifconfig eth0 192.168.1.7
Add executable permissions
Chomd + x/etc/init. d/rcS
4.5 create a file/etc/init. d/telnetd
Content:
#! /Bin/sh


Telnetd =/sbin/telnetd


Test-x "$ telnetd" | exit 0


Case "$1" in
Start)
Echo-n "Starting telnet daemon"
Start-stop-daemon -- start -- quiet -- exec $ telnetd
Echo "."
;;
Stop)
Echo-n "Stopping telnet daemon"
Start-stop-daemon -- stop -- quiet -- pidfile/var/run/telnetd. pid
Echo "."
;;
*)
Echo "Usage:/etc/init. d/telnetd {start | stop }"
Exit 1
Esac


Exit 0
Add executable permissions
Chomd + x/etc/init. d/telnetd
5. telnet Service
./Etc/init. d/telnetd start
Mount-t devpts/dev/pts
Configuration method 1:
Add:
Cp-rf/dev/*/tmp
Mount-t tmpfs/dev
Cp-rf/tmp/*/dev
Rm-rf/tmp /*


Mount-t sysfs/sys
Echo/bin/mdev>/proc/sys/kernel/hotplug
Mdev-s # map the device nodes created by the system driver (relatively complete)
Configuration method 2:
Manually create a node directory
Mkdir/dev/pts
Mknod ptmx c 5 2
Mknod tty c 5 0
Mknod tty0 c 4 0
Mknod tty1 c 4 1
Mknod tty2 c 4 2
Mknod tty3 c 4 3
Mknod tty4 c 4 4


6. Configure/dev
Create a node
Mknod console c 5 1
Mknod null c 1 3
Mknod mtdblock4 B 31 4
......
......
7. Add a dynamic link library
Copy dynamic libraries in the Cross-compilation chain
/Opt/arm-2009q1/arm-none-linux-gnueabi/libc/lib/... filesys/lib
/Opt/arm-2009q1/arm-none-linux-gnueabi/libc/usr/lib/.../. filesys/usr/lib
Otherwise, error while loading shared libraries: libstdc ++. so.6: cannot open shared object file: No such file or directory is reported during the execution of the program.


The file system content has been created.



Package cramfs
The tool mkcramfs is not a cross-compilation tool.
Packaging:
/Opt/cramfs-1.1/mkcramfs/home/zhujinju/workspace/myrootfs/filesys cramfsImage_my6467T


Unpack:
Cd/root/workspace/myfilefs
Mkdir filesys
Mkdir rdmnt2
Mount-t cramfs-o loop cramfsImage_my6467T rdmnt2/
Cd rdmnt2
Tar-cf-. | tar-C ../filesys/-xpf-

Cd/root/workspace/dm6467t_root_fs
Chown-R root filesys/
Chmod-R a + rwx filesys/


Umount rdmnt2/


Run the following command:


Tftpboot 0x82000000 cramfsImage_my6467T # upload the file to the memory address 0x82000000
Nand erase 0x560000 0x1000000 # erase the nand flash Address 0x560000 (16 M = 0x1000000)
Nand write 0x82000000 0x560000 0x1000000 # write the content of the memory address 0x82000000 16 M to the nand flash Address 0x560000 (16 M = 0x1000000)
File System and kernel problems in arm linux

The kernel is the most fundamental program of the system. He directly controls all resources and drives. The current Windows kernel has been evolving from Windows NT. Generally, it is unlikely that people will come into contact. It is said that Windows XP kernel has a size of 40 MB.
The root file system is a file system other than the kernel. Windows does not have this concept, but it is actually a Windows C disk. Of course there is a difference, because Windows is developed and released by an enterprise separately, compared with the Linux kernel, the software environment is different from the Linux kernel.
Yaffs2 and jffs2 are two file systems, which mean FAT32, NTFS, and EXT3. However, they have been specially designed to be suitable for embedded systems. For example, they have the data compression function (which can reduce the data volume) and they have the average number of disk writes (NAND memory has a limit on the number of writes, excessive write operations can cause damage. Therefore, you need to write data in different places on average to distribute the write operations to prevent some data from being written too early in a concentrated manner ).
Busybox is a toolbox written by a madman. It can implement many command functions in Linux and is very small.

These tutorials refer to the readers who have understood a lot of things and then read them again. You do not know these questions, but it is quite normal to understand them.
You can understand the Linux system composition and startup process to understand the reasons.

When do I need to recreate the Linux root file system?

1. When you need to add some common applications, such as ftp and telnet, it is difficult to compile these general applications separately. Instead, you should directly use busybox to add these modules and recreate the file system.
2. When you need to add large files such as dynamic libraries, configuration files, images, and videos, the created file system does not contain these files.
After bootloader is configured with correct NFS parameters, the Network File System can be started. After the device is started, the system maps directly to the network. adding or deleting files on the mapped development machine does not affect the use of embedded devices, ease of Development and debugging.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.