The following switches to the root user to operate (the rootfs compiled in other user modes does not log in as root, which seems to be more troublesome, so let's keep it simple first)
Modify Makefile:
CROSS_COMPILE = /opt/arm-2010q1/bin/arm-none-linux-gnueabi-
ARCH = arm
After saving and exiting:
make menuconfig
1.18.1 has changed the make install directory to ./_install by default. And I don't plan to change it to a static library, so there is nothing to change. Let's take a look at it after saving and exiting:
make (build busybox)
make install (generate files to the _install directory)
Then modify the permissions of _install/bin/busybox:
chmod 4755 _install/bin/busybox
(Give busybox everyone readable and executable, the owner readable, writable and executable, 4 read, 2 write, 1 execute, 7=4+2+1, 5=4+1, the three are the owner, the owner group, and other groups. The first 4 means that when other users execute the file, the permissions are the same as the owner)
Enter the _install directory and create some directories required by Linux:
mkdir -p dev etc home lib mnt proc root sys tmp usr var/lib/misc var/lock var/log var/run var/tmp
And modify the permissions:
chmod 1777 tmp
chmod 1777 var/tmp
(The first one is prevented from being deleted by other users)
Create console and null devices under dev:
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3
(These two devices are used for init startup)
Now let's take a look at what dynamic link libraries busybox needs. Return to the busybox directory and enter:
/opt/arm-2010q1/bin/arm-none-linux-gnueabi-readelf -a busybox | grep Shared
It shows that libm.so.6 and libc.so.6 are required
Copy the library in the cross compiler to the _install/lib directory. Codesourcery's arm-2010q1, the default is armv5te, in the directory
In the lib under /opt /arm-2010q1/arm-none-linux-gnueabi/libc (corresponding to ARMv4T in armv4t, corresponding to armv7- a thumb2 in thumb2), since future applications may use these libraries except libm.so.6 and libc.so.6, copy all of them and execute under _install:
cp /opt/arm-2010q1/arm-none-linux-gnueabi/libc/lib/*.so* lib -a
Then create some configuration files under _install/etc:
1 #
2 # /etc/fstab: static file system information.
3 #
4 #
5 #
6 # file system mount type options dump pass
7
8 #for mdev
9 proc /proc proc defaults 00
10 sysfs /sys sysfs defaults 00
11
12 #make sure /dev /tmp /var are tmpfs(tmpfs use ram as media) thus can be r/w
13 tmpfs /tmp tmpfs defaults 00
14 tmpfs /dev tmpfs defaults 00
15 tmpfs /var tmpfs defaults 00
16
17 #usbfs /proc/bus/usb usbfs defaults 0 0
The file system in fstab will be mounted by mount -a.
1 # see busybox/examples/inittab
2
3 # Boot-time system configuration/initialization script.
4 # This is run first except when booting in single-user mode.
5 ::sysinit:/etc/init.d/rcS
6
7 #Start an "askfirst" shell on the console (whatever that may be)
8 #use respawn instead askfirst to make sure console always active
9 ::respawn:-bin/sh
10
11 # Stuff to do when restarting the init process
12 ::restart:/sbin/init
13
14 # Stuff to do before rebooting
15 ::ctrlaltdel:/sbin/reboot
16 ::shutdown:/bin/umount -a -r
17 ::shutdown:/sbin/swapoff -a
18
19
inittab will be executed by init
1 #!/bin/sh
2
3 #add setting here for auto start program
4 PATH=/sbin:/bin:/usr/sbin:/usr/bin
5 runlevel=S
6 prevleval=N
7 umask 022
8 export PATH runlevel prevlevel
9
10 #See docs/mdev.txt
11 #mount all fs in fstab,proc and sysfs are must for mdev
12 mount -a
13
14 #create device nodes
15 echo /sbin/mdev >/proc/sys/kernel/hotplug
16
17 #seed all device nodes
18 mdev -s
19
20 #create pts directory for remote login such as SSH and telnet
21 mkdir -p /dev/pts
22 mount -t devpts devpts /dev/pts
23
24
25
26 if [ -f/etc/hostname ]; then
27 /bin/hostname -F/etc/hostname
28 fi
29
30 if [ -e /sys/class/net/eth0 ]; then
31 ifconfig eth0 192.168.1.15
32 fi
33
34 echo "etc init.d rcS done"
35
init.d/rcS will be automatically executed at boot time.
Change the permissions of rcS and inittab to 777:
chmod 777 init.d/rcS
chmod 777 inittab
There are also several files and directories:
The rc.d directory can store some self-starting scripts
mdev.conf (the content can be empty, you can also refer to busybox docs/mdev.txt)
profile
1 #id -un = whoami
2 export USER="id -un"
3 export LOGNAME=$USER
4 export PATH=$PATH
5
6 #a colorful prompt begin with "e[" end with "m"
7 export PS1='e[1;32mu@e[1;31mh#e[0m'
resolve.conf (marks the DNS server, just one sentence nameserver 202.96.134.133)
hostname (read by init.d/rcS, just a hostname, such as mx27)
passwd, group, shadow user/group/password can be replaced with those on the PC. Here are some instructions:
1 passwd consists of 7 fields, separated by 6 colons. Their meanings are:
2 1 Username
3 2 Whether there is an encryption password, x means yes, blank means no, MD5 and DES encryption are used.
4 3 User ID
5 4 Group ID
6 5 Comments field
7 6 Login Directory
8 7 Shell program used
9
10 Group consists of 4 fields, separated by 3 colons, and their meanings are:
11 1 Group Name
12 2 Is there an encrypted password? Same as passwd
13 3 Group ID
14 4 Array of pointers to user names
15
16 shadow consists of 9 fields, separated by 8 colons, and their meanings are:
17 1 Username
18 2 The encrypted password. If it is empty, it means that the user can log in without a password. If it is an asterisk, it means that the account is disabled. The above shows the encrypted password of 123456.
19 3 The number of days from January 1, 1970 to the last time the password was changed
20 4 The password cannot be changed by the user within a certain number of days
21 5 The number of days after which the password must be changed (0 means no change)
22 6 How many days after the password expires will the user account be banned?
23 7 How many days before the password expires should the user be warned?
24 8 Number of days the password has been banned since January 1, 1970
25 9 Reserved Domain
Now, except for the files in lib/modules/`uname -r`/kernel (`uname -r` is the Linux version of the development board, you can enter echo `uname -r` to view it), the rootfs is basically completed. Find the git address of mkfs in the FAQ of www.infradead.org (sweat, it's hard to find):
git clone git://git.infradead.org/mtd-utils.git
cd mtd-utils
git describe master (version number is v1.3.1-138-gf0cc488)
An error occurred when entering mkfs.ubifs. In the FAQ, I saw that three libraries were needed. I installed them:
sudo apt-get install zlib1g-dev
sudo apt-get install liblzo2-dev
sudo apt-get install uuid-dev
make successfully generates mkfs.ubifs
Then make _install into a ubifs file system:
./mkfs.ubifs -r
Among them, -m indicates the page size, -e indicates the logical erase block size, and -c indicates the maximum number of logical erase blocks. The specific information can be seen when executing ubiattach in barebox.
Power on and enter barebox:
erase /dev/nand0.root
ubiattach /dev/nand0.root
ubimkvol /dev/ubi0 root 0 (Note that the name here must match bootargs, the default is ubi0.root)
dhcp
tftp ubifs.img /dev/ubi0.root
Previous article:Successfully create CRAMFS file system using Busybox
Next article:Linux UART serial port driver development documentation
Recommended ReadingLatest update time:2024-11-16 09:31
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- CPU and peripherals of TMS320C6000 series DSP
- Overview of air conditioning automatic control system 2
- Realization of Simple Single Chip Microcomputer Calculator
- See how many PA posts have been viewed in the forum
- 【PLC based on IoT】---Testing RPI-400 performance based on AI
- Smart car based on ESP32 road sign recognition
- Regarding the issue of isolated communication:
- Please recommend a cheap and available microcontroller
- Seven lines of code to implement an ultrasonic rangefinder (Oled screen display)
- New forum feature: Post by uploading a word document (good news for those who like to post a lot of pictures)