Linux kernel transplantation based on S3C2440 and yaffs2 file system production--root file system

Publisher:cyzceeLatest update time:2019-03-07 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Chapter 2 Creating a Root File System

2.1 Preliminary knowledge of the root file system
In embedded Linux, a root file system needs to be built. The rules for building a root file system are in the FHS (Filesystem Hierarchy Standard) document. The following is the top-level directory of the root file system.

Table of contents

content

bin

Stores basic commands that can be used by all users.

sbin

It stores basic system commands, which are used to start the system, repair the system, etc.

usr

It contains shared, read-only programs and data.

proc

This is an empty directory, often used as the mount point of the proc file system.

dev

This directory stores device files and other special files.

etc

Stores system configuration files, including startup files.

lib

Stores shared libraries and loadable blocks (i.e. drivers). Shared libraries are used to start the system and run executable programs in the root file system.

boot

Static files used by the bootloader

home

User home directories, including home directories used by service accounts, such as FTP

mnt

A mount point used to temporarily mount a file system, usually an empty directory. You can also create empty subdirectories in it.

opt

The directory where additional software installed on the host is placed.

root

Home directory for the root user

tmp

A directory for storing temporary files, usually an empty directory.

was

Stores mutable data.

2.2. Build the root file according to the system
2.2.1. Create the root file system directory
Enter the /opt/studyarm directory, create a new script file create_rootfs_bash to create the root file system directory, use the command chmod +x create_rootfs_bash to change the executable permission of the file, and run the script ./create_rootfs_bash to complete the creation of the root file system directory.

#!/bin/sh

echo "------Create rootfs directons start...--------"

mkdir rootfs

cd rootfs

echo "--------Create root,dev....----------"

mkdir root dev etc boot tmp var sys proc lib mnt home

mkdir etc/init.d etc/rc.d etc/sysconfig

mkdir usr/sbin usr/bin usr/lib usr/modules

 

echo "make node in dev/console dev/null"

mknod -m 600 dev/console c 5 1

mknod -m 600 dev/null    c 1 3

 

mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp

 

mkdir var/lib var/lock var/run var/tmp

 

chmod 1777 tmp

chmod 1777 var/tmp

 

echo "-------make direction done---------"

Changed the usage rights of the tmp directory to enable the sticky bit. Enabling this bit for the usage rights of the tmp directory ensures that only the user who created it has the right to delete the files created under the tmp directory. Although most embedded systems are single-user, some embedded applications do not necessarily need to be executed with root permissions, so they need to be designed in accordance with the basic regulations of the root file system permission bits.

2.2.2. Create a dynamic link library. To
use the dynamic link library directly with Friendly Arm, first unzip the root file package of Friendly Arm and copy the contents of lib to the newly created root file directory lib.

cd /mnt/hgfs/share

tar –zxvf root_qtopia.tgz –C /opt/studyarm

cp –rfd /opt/studyarm/root_qtopia/lib/* /opt/studyarm/rootfs/lib/*

2.2.3 Cross-compile Bosybox
Bosybox is an open source project that complies with the GPL v2 protocol. It always optimizes the file size during the writing process and takes into account the limited system resources (such as memory, etc.). Using Busybox, you can automatically generate the bin, sbin, usr directories and linuxrc files required for the root file system.

1. Unzip busybox

cd /mnt/hgfs/share

tar –zxvf busybox-1.13.3.tar.tgz –C /opt/studyarm

2. Enter the source code and modify the Makefile file:

cd /opt/studyarm/busybox-1.13.3

Revise:

       CROSS_COMPILE ?=arm-linux- //Line 164

       ARCH ?=arm //Line 189

3. Configure busybox

Enter make menuconfig to configure

(1)、Busybox Settings--->

             General Configuration--->

                            [*] Show verbose applet usage messages

                            [*] Store applet usage messages in compressed form

                            [*] Support –install [-s] to install applet links at runtime

                            [*] Enable locale support(system needs locale for this to work)

                            [*] Support for –long-options

                            [*] Use the devpts filesystem for unix98 PTYs

                            [*] Support writing pidfiles

                            [*] Runtime SUID/SGID configuration via /etc/busybox.config

                            [*]  Suppress warning message if /etc/busybox.conf is not readable

Build Options--->

                        [*] Build BusyBox as a static binary(no shared libs)

                            [*] Build with Large File Support(for accessing files>2GB)

Installation Options->

                            []Don’t use /usr

                            Applets links (as soft-links) --->

                                   (./_install) BusyBox installation prefix

Busybox Library Tuning --->

                            (6)Minimum password legth

                            (2)MD5:Trade Bytes for Speed

                            [*]Fsater /proc scanning code(+100bytes)

                            [*]Command line editing

                            (1024)Maximum length of input

   [*]   vi-style line editing commands

                            (15) History size

                            [*]   History saving

                            [*]   Tab completion

                            [*]Fancy shell prompts

                            (4) Copy buffer size ,in kilobytes      

[*]Use ioctl names rather than hex values in error messages

[*]Support infiniband HW

(2)、Linux Module Utilities--->

                    (/lib/modules)Default directory containing modules

                     (modules.dep)Default name of modules.dep

[*]   insmod

[*]   rmmod

[*] lsmod

[*]   modprobe

-----options common to multiple modutils

[ ] support version 2.2/2.4 Linux kernels

[*]Support tainted module checking with new kernels

[*]Support for module .aliases file

[*] support for modules.symbols file

(3) Configure support for device types under dev in busybox

There are three ways to create dev:

Manual creation: When making the root file system, create the device files to be used in the dev directory. After the system mounts the root file system, you can use the device files in the dev directory.

Use devfs file system: This method is outdated, has uncertain device mapping, not enough major/minor device numbers, and devfs consumes a lot of memory.

udev: It is a user program that can dynamically update device files according to the status of hardware devices in the system, including the creation and deletion of device files. Its operation is relatively complex, but it is very flexible.

mdev is a simplified version of udev that comes with busybox, suitable for embedded applications. It is easy to use. Its function is to automatically generate the node files required by the driver when the system starts and hot-plugs or dynamically loads the driver. It is the best choice when building an embedded Linux root file system based on busybox. The following options will add support for mdev.

Linux System Utilities  --->              

           [*]Support /etc/mdev.conf        

           [*]Support command execution at device addition/removal

4. Compile busybox

Compile busybox to the specified directory:

cd /opt/studyarm/busybox-1.13.3

make CONFIG_PREFIX=/opt/studyarm/rootfs install

The contents of the directories bin, sbin, usr and the file linuxrc will be generated under the rootfs directory.

2.2.4 Create the configuration file in the etc directory
1. etc/mdev.conf file, the content is empty.

2. Copy the passwd, group, and shadow files in the host etc directory to the rootfs/etc directory.

3. Create a new file HOSTNAME in the etc/sysconfig directory with the content "MrFeng".

4. etc/inittab file:

#etc/inittab

::sysinit:/etc/init.d/rcS

::askfirst:-/bin/sh

::ctrlaltdel:/sbin/reboot

::shutdown:/bin/umount -a –r

5. etc/init.d/rcS file:

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

runlevel=S

prevleve=N

umask 022

export PATH runlevel prevlevel

 

echo "----------munt all----------------"

mount -a

 

echo /sbin/mdev>/proc/sys/kernel/hotplug

mdev -s

 

echo "***********************************************"

echo "****************Studying ARM*********************"

echo "Kernel version:linux-2.6.29.1"

echo "Student:Feng dong rui"

echo "Date:2009.07.15"

echo "***********************************************"

 

/bin/hostname -F /etc/sysconfig/HOSTNAME

Use the following command to change the execution permission of rcS:

Chmod +x rcS

6. etc/fstab file:

#device    mount-point     type     option     dump   fsck   order

proc          /proc        proc     defaults    0        0

none          /tmp        ramfs    defaults    0        0

sysfs         /sys          sysfs    defaults    0        0

mdev          /dev        ramfs    defaults    0        0

7. etc/profile file:

#Ash profile

#vim:syntax=sh

 

#No core file by defaults

#ulimit -S -c 0>/dev/null 2>&1

 

USER="id -un"

LOGNAME=$USER

PS1='[\u@\h=W]#'

PATH=$PATH

HOSTNAME='/bin/hostname'

export USER LOGNAME PS1 PATH

2.2.5 Make the root file system image file
Use the following command to install the yaffs file system creation tool:

cd /mnt/hgfs/share

tar –zxvf mkyaffs2image.tgz –C /

In the /opt/studyarm directory, run the command mkyaffs2image rootfs rootfs.img to generate the root file system image file.


Keywords:S3C2440 Reference address:Linux kernel transplantation based on S3C2440 and yaffs2 file system production--root file system

Previous article:Linux kernel transplantation based on S3C2440 and yaffs2 file system production--starting system
Next article:Linux kernel transplantation based on S3C2440 and yaffs2 file system production--compile kernel

Recommended ReadingLatest update time:2024-11-16 13:01

Implementation of touch screen driver in Linux (1) - based on s3c6410 processor
These articles are mainly about touch screen drivers in Linux, based on the s3c6410 processor. This article is mainly about the implementation of touch screen devices as platform devices, as well as the source code analysis of the corresponding probe function and remove function. 1. Loading and unloading functions o
[Microcontroller]
Implementation of touch screen driver in Linux (1) - based on s3c6410 processor
I2C bus learning - check for deficiencies and fill in the gaps - S3C2440 I2C controller
                 After learning the theoretical part of IIC bus protocol, I think I should learn the specific operation of 2440 IIC controller. After all, the purpose is to learn S3C2440, so I will make up this part. The I2C interface of S3C2440 has four working modes: master transmitter, master receiver, slave transmi
[Microcontroller]
I2C bus learning - check for deficiencies and fill in the gaps - S3C2440 I2C controller
Linux driver learning (3)--synchronization, semaphores and spin locks
In a driver, when multiple threads access the same resource at the same time (global variables in a driver are a typical shared resource), a "race state" may occur, so we must perform concurrency control on shared resources. The most common methods for solving concurrency control in the Linux kernel are spin locks a
[Microcontroller]
The growth path of single-chip microcomputer (51 basic chapters) - 006 Building a development and programming environment under Linux
There is no easy-to-use IDE like Keli to develop 51 microcontrollers under Linux, so the development environment can only be built by yourself.  Step 1: Install cross-compilation tools  a) Install SDCC  sudo apt-get install sdcc  b) Test whether SDCC is available. This is a simple running light code test.c found on
[Microcontroller]
The growth path of single-chip microcomputer (51 basic chapters) - 006 Building a development and programming environment under Linux
Linux device tree learning (1) basic knowledge points
1. Example of device tree structure Device tree of jz2440: s3c2440-jz2440.dts   (include)---- s3c2440.dtsi         (include)---- s3c24xx.dtsi                 (include)---- skeleton.dtsi         (include)---- s3c2440-pinctrl.dtsi  Device tree after make dtbs: s3c2440-jz2440.dtb A device tree is a data structure
[Microcontroller]
Linux device tree learning (1) basic knowledge points
Linux-2.6.39 porting on Tiny6410 - Peripheral driver porting
Linux kernel version number: linux 2.6.39 Cross-compilation tool: arm-linux-gcc 4.5.1 Linux kernel download: www.kernel.org Development board: Friendly Arm Tiny6410 LCD: Friendly Arm S70 1. Transplant LED driver Open arch/arm/mach-s3c64xx/mach-mini641
[Microcontroller]
Things about S3C2440’s interrupts (2) C language part explained
 1 void init_irq( )  2 {  3 //Set the two pins corresponding to S2 and S3 as interrupt pins EINT0 and ENT2  4 GPFCON &= ~(GPF0_msk | GPF2_msk);  5 GPFCON |= GPF0_eint | GPF2_eint;  6   7 //The pin corresponding to S4 is set as the interrupt pin EINT11  8 GPGCON &= ~GPG3_msk;  9 GPGCON |= GPG3_eint; 10      11 // For E
[Microcontroller]
S3C2440 Watchdog Analysis
The watchdog timer of S3C2440A is used to restore the controller's operation when it is disturbed by faults caused by noise and system errors. It can be used as a normal 16-bit internal timer to request interrupt service. The watchdog timer generates a reset signal of 128 PCLK cycles. That is to say, in some environme
[Microcontroller]
S3C2440 Watchdog Analysis
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号