# AT91SAM9260 linux system migration log ------ jffs2 File System Customization

Source: Internet
Author: User
Tags parse error

# AT91SAM9260 linux system migration log ------ jffs2 File System Customization
AT91SAM9260 linux system migration log-jffs2 File System Customization


Objective: To optimize and crop the u-boot, linux, and file systems, Master System transplantation, and master the principles of linux, file systems, and uboot.

On the first day, we attempted to port the linux system on AT91SAM9260. Previously, we always wanted everything to be built by ourselves. Therefore, we started to customize the system from 0. Due to lack of knowledge and experience, the transplantation on mini2440 fails until now. This has seriously affected the enthusiasm and progress of learning. Therefore, we need to change the learning method from the very beginning to the simplest.
Today, we use the built-in u-boot and Linux kernel images to customize the jffs2 file system and learn how to customize the file system.
The method provided by the manufacturer is as follows ():
1. Build a cross-compilation environment
SecureCRT ssh to ubuntu
<1> go to the working directory and copy the disc information.Arm-2007-01-21.iso under newmsg/tools/

cd /home/works
cp newmsg/tools/arm-2007-01-21.iso ./
mkdir tmp
chmod 777 tmp


<2> install the cross-compilation tool
cd tmp
./install –d ../eldk41gcc40
<3> set the path of the Cross-compilation tool as follows:
vi ~/.bashrc
Add the following path to the last line,

export PATH=$PATH:/home/newmsg/works/tools/eldk41gcc40/usr/bin

<4> test and install
Log On again to make the environment variable take effect
exit
sudo su
Check whether the cross-compilation tool version is correct and the test path is as follows:
arm-linux-gcc –v

1. Create a root file system
This article uses busybox as the root file system. busybox is famous for its small size and is suitable for linux File Systems with embedded devices. The following describes the detailed production process:
SecureCRT ssh to ubuntu, switch to root
1. busybox Compilation
1> prepare source code
cd /home/newmsg/works
tar –xzvf busybox-1.15.3.tar.gz
cd busybox-1.15.3
make clean distclean

Make menuconfig configures busybox, removes unnecessary projects, and generates the. config file.
2> Cross-Compilation
make ARCH=arm CROSS_COMPILE=arm-linux- install
After compilation is successful, the following file is generated in the busybox-1.15.3/_ install/folder:

2. Create a root file system
1> create the basic architecture of the root file system
cd /home/newmsg/works/nfsroot
mkdir root usr mnt proc tmp var opt etc dev lib sys
cp -a ../busybox-1.15.3/_install/* ./

2> Add necessary library files
Copy all the library files of arm-linux-gcc to the lib directory. For example, the installation path of my arm-linux-gcc is:/opt/arm_linux_gcc/usr/bin/arm-linux-gccRun the following command:
cp -a /opt/arm_linux_gcc/arm/lib/* ./lib/
3> Add necessary Device Files
mknod ./dev/console c 5 1
mknod ./dev/null c 1 3
mknod ./dev/zero c 1 5

Note: If the mdev option in busybox is configured, these nodes are automatically generated. However, if these nodes are not explicitly created before the file system is created, the following warning will be reported during system startup:
Warning: unable to open an initial console.
Cause: mdev is started through the init process. Before using mdev to construct the/dev directory, init must at least use the device file/dev/console and/dev/null, therefore, you need to create these two Device Files in advance:

lingd@ubuntu:~/arm2410s/rootfs$ cd dev
lingd@ubuntu:~/arm2410s/rootfs/dev$ sudo mknod -m 660 console c 204 64
[sudo] password for lingd:
lingd@ubuntu:~/arm2410s/rootfs/dev$ sudo mknod -m 660 null c 1 3
lingd@ubuntu:~/arm2410s/rootfs/dev$ ls -l
total 0
crw-rw---- 1 root root 5, 1 2010-04-02 15:49 console
crw-rw---- 1 root root 1, 3 2010-04-02 15:50 null


Note: The primary and secondary device numbers of the console should be 5 and 1. however, because init is running/etc/init. after the d/RC Script is run, a shell (or getty + login) will be opened on the console according to the inittab instructions, so that the user will see a prompt prompting the user name ). Before mdev-s is executed, only the/dev/null and/dev/console created in the/dev directory are available. That is to say, no console is available for init to open a shell according to the inittab instructions. The s3c2410_serial is used as the device name in the serial port driver of the s3c24xx series chip (in the kernel source code "drivers/serial/s3c2410. c). Therefore, you can use s3c2410_serial0, s3c2410_serial1, or s3c2410_serial as the init to open a shell console according to the inittab instructions, that is, s3c2410_serial0 (primary and secondary device numbers are 204 and 64) is used as the console. The console is set to s3c2410_serial0, so the Primary and Secondary device numbers of the console are 204 and 64.
4> Add basic configuration files

cd etc
mkdir init.d
touch inittab init.d/rcS profile fstab


vi inittab
Add the following content (the principles and detailed explanations of the following content will be found in the manuals of the same series produced by weibu. You can find the corresponding manuals by referring to the manual User Guide ):

::sysinit:/etc/init.d/rcS
ttyS0::respawn:-/bin/sh
::restart:/sbin/init
::ctrlaltdel:/bin/umount -a –r
vi profile


Add the following content:
PATH=/bin:/sbin
PS1='[\u@\h: \W]\$ '
NOTE: If busybox is not configured during the test

Busybox Settings --->                Busybox Library Tuning --->                        [*] Username completion                        [*] Fancy shell prompts

In the preceding two items, the file system does not correctly identify the parameter of the Environment Variable ps1.
vi fstab
Add the following content:

  tmpfs  /tmp    tmpfs   defaults    0     0  sysfs  /sys    sysfs   defaults    0     0

vi init.d/rcS
Add the following content:

    /bin/mount -n -t proc /proc proc    /bin/mount -n -o  remount,rw  /    /bin/mount -av    /bin/hostname NewMsg    /bin/mount -t tmpfs mdev /dev    mkdir /dev/pts    /bin/mount -t devpts devpts /dev/pts    echo /sbin/mdev>/proc/sys/kernel/hotplug    /sbin/mdev –s
Run the following code to grant the following permissions to the rcS script:

chmod 777 init.d/rcS
In the preceding steps, the basic root file system has been built. The next step is to create a file system image.
3. package it into a root file image in the specified format
cd /home/newmsg/works
Make an image in jffs2 format:
For 64 M nand flash users:
mkfs.jffs2 –r ./nfsroot –o rootfs.jffs2 –e 0x4000 –n –p
For 128 M nand flash users:
mkfs.jffs2 –r ./nfsroot –o rootfs.jffs2 –e 0x20000 –n -p
The concentrator board is a m nand flash.
4. Burn the image and File System

1> go to uboot and set the following parameters: (paste directly) setenv 'bootargs console = ttyS0, 57600 root =/dev/nfs nfsroot = 192.168.0.154: /home/nfsroot ip = 192.168.0.219: 192.168.0.154: 192.168.0.1: 255.255.255.0: eth0: off setenv ipaddr 192.168.0.219 setenv serverip 192.168.0. * setenv gatewayip 192.168.0.1 Note: The above serverip refers to the server ip address, which can be set by yourself. Generally, run tftp32.exe on the local machine as an ftp server and use the Kernel File (uImage_v1. * The kernel is stored in the directory where tftp32.exe is located, and the kernel file name is changed to uImage.'

2> burn and write the Kernel file. The Kernel File is placed in the Kernel directory of the server. Each version is available. For details, run the following command in uboot: (paste it directly)

tftp 0x22000000 uImagenand erase 0xa0000nand write 0x22000000 0xa0000 0x200000

3> burn a File System

  tftp 0x20000000 rootfs_128.jffs2  nand erase 0x400000  nand write 0x20000000 0x400000 0xxxxxxxxx

Compilation supplement:
-----------------------
Cross-compile busybox
Cross-compiler: 3.3.2

# wget -c http://www.busybox.net/downloads/busybox-1.7.0.tar.bz2# tar jxvf busybox-1.7.0.tar.bz2
Modify source code, configuration, and compilation
# cd busybox-1.7.0# vi Makefile +176ARCH            ?= armCROSS_COMPILE   ?= /usr/local/arm/3.3.2/bin/arm-linux-# make menuconfigBusybox Settings --->    Build Options --->        [*] Build BusyBox as a static binary (no shared libs) //(1)    Installation Options --->        [*] Don't use /usr               //(2)Linux System Utilities --->    [*] mdev                             //(3)    [*] Support /etc/mdev.conf    [*] Support command execution at device addition/removalShells --->       Choose your default shell (msh) ---> //(4)

(1) This option must be selected so that busybox can be compiled into an executable file with static links, and the runtime is independent of other function libraries. otherwise, other library files must be required to run and cannot work properly on a single Linux kernel.
(2) This option must also be selected. Otherwise, after make install, busybox will be installed under/usr of the original system, which will overwrite the original command of the system. after this option is selected, make install will generate a directory named _ install under the busybox Directory, which contains busybox and its link.
(3) If udev is not started, no device files exist in/dev. That is to say, all devices are not mounted. The latest busybox contains the simplified udev version, namely mdev, which is very easy to use. To use mdev, you also need to configure it in rootfs.

vi rootfs/etc/init.d/rcS---------------------------mount -t tmpfs mdev /devmkdir /dev/ptsmount -t devpts devpts /dev/ptsmount -t sysfs sysfs /sysmount -aecho /sbin/mdev > /proc/sys/kernel/hotplugmdev -s
Configure linux kernel

Mdev needs to rewrite the/dev and/sys directories. Therefore, ensure that these two directories are writable (sysfs and tmpfs are generally used. So re-compile the kernel ). Then add it to your startup script file./sbin/mdev -s

linux-2.6.19 -- make menuconfigFile systems --->    Pseudo filesystems --->        [*] sysfs file system support          [*] Virtual memory file system support (former shm fs)        [*]   Tmpfs POSIX Access Control Lists

(4) Because ash is not powerful enough, it cannot support advanced functions such as tab filling and history record, so msh in busybox is used to replace ash.
Busybox is mainly used in embedded systems with very strict spatial requirements. Therefore, we recommend that you use uclibc instead of glibc. If you have not installed uclibc, in build Options, you have also selected Build BusyBox as a static binary (no shared libs), which cannot be compiled, of course, if you selected dynamic compilation for the previous build Options, this problem will not occur. Suppose you are in the first case. We can solve this problem by commenting out the lines of warning starting with applets/applets. c.

# vi applets/applets.c/*#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)#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 top-level Makefile and remove this warning.#error Aborting compilation.#endif*/# make# make install

In this case, a _ install directory is generated under your compilation directory, which contains all the generated files and directory structures.

Problems encountered during compilation (1 ):

If busybox is compiled into static linking

Busybox Settings --->    Build Options --->        [*] Build BusyBox as a static binary (no shared libs)# make

You will encounter the following problems:

applets/applets.c:20:2: error: #warning Static linking against glibc produces buggy executablesapplets/applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections).applets/applets.c:22:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400applets/applets.c:23:2: error: #warning Note that glibc is unsuitable for static linking anyway.applets/applets.c:24:2: error: #warning If you still want to do it, remove -Wl,--gc-sectionsapplets/applets.c:25:2: error: #warning from top-level Makefile and remove this warning.make[1]: *** [applets/applets.o] Error 1

This warning is defined in applets/applets. c. Comment out this warning. This warning tells you that it is best to use uclibc for compilation, instead of using glibc because glibc is large, busybox is used in many embedded systems, so there are such requirements.

# Vi/busybox-1.7.0/applets. c + 20 comment out 20 -- 28 rows of content can be miscutils/taskset. c: 17: error: parse error before '*' token

The most fundamental solution is to change the libc library, but I don't know which database is the most suitable yet. I only need to temporarily disable the problematic command.

Miscellaneous Utilities --->    [ ] taskset
runit/runsv.c: In function `gettimeofday_ns':
Runit Utilities --->    [ ] runsv  
Problems encountered during kernel startup:
“could not run '/bin/sh': No such file or directory”

Solution:
To do this, configure:

Shells --->       Choose your default shell (ash) --->     

If it is configured in this way, you can generate ash but cannot generate sh. the above problem will occur during kernel startup:

Shells --->       Choose your default shell (none) --->        [*] ash
After writing, restart. After a busy day, I finally achieved the above achievements. However, there are still many questions to address: 1> what is the basis for determining the uboot command and the write position? 2> mkfs. how to Use jffs2 tools 3> significance of various busybox Options 4> how to build an nfs file system, how to use nfs to log on to the server for development, and how to use the system to write 5> transplantation of the yaffs2 File System, burn write 6> linux system transplantation 7> u-boot modification 8> mdev9> embedded linux System Login Password Account Management

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.