S5PV210 (TQ210) study notes - kernel transplantation and file system construction

Publisher:advancement3Latest update time:2015-08-19 Source: eefocusKeywords:S5PV210 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Since I have worked on 2440 and 6410 before, due to time constraints, I will temporarily skip the bare metal driver and uboot porting of other modules and directly enter the study of kernel porting and driver development.

Kernel transplantation is actually very simple, because the kernel is developed and maintained by the Linux kernel development team led by Linus. We only need to cross-compile it with our platform to use it. However, kernel transplantation is not simple, because any problems may be stuck during kernel transplantation. Because the kernel code is very large, we cannot read the kernel code. The following are various tragic problems and solutions I encountered during the transplantation. The first is the necessary development environment:

a) Linux kernel code, version 3.8.3

b) S5PV210 development board (mine is TQ210)

c) The HOST environment is an Ubuntu virtual machine (12.10) installed under WIN7 (64-bit)

1. Kernel compilation

Download the kernel code from the Linux kernel website (kernel.org), unzip it and enter the kernel directory

(1) Modify the Makefile and change lines 195 and 196 to:

  1. ARCH = arm  
  2. CROSS_COMPILE   ?= arm-linux-  
(2) Perform the default configuration and enter the arch/arm/configs directory. You can find that the configuration file closest to our development board is s5pv210_defconfig.
  1. make s5pv210_defconfig  
(3) Compile the kernel. If you need to generate zImage, execute
  1. make zImage  
If you need to generate uImage, execute
  1. make uImage  
(4) Download and run the program using uboot. The result is tragic. After uboot prints "Starting kernel...", no more output is seen. Obviously, there are two reasons:

 

a. The compiled kernel type is wrong. For example, your uboot uses uImage, but you compiled zImage.

b. There is a problem with the transplanted uboot, which fails to correctly copy the kernel to the correct memory address and start it.

c. The kernel has some configurations that we do not have.

After checking the kernel configuration items, we know that the kernel uses UART1 by default to print debugging information. Therefore, execute:

  1. make menuconfig  
In the dialog box that appears, select System type => (1) S3C UART to use for low-level messages, change 1 to 0 in the edit box, save the configuration and compile the kernel again, and execute make directly without making clean. If you execute make menuconfig for the first time, you will encounter an error. This is because make menuconfig depends on a library, I forgot the name here. If it is Ubuntu, you can directly install it using the command. You can search it online and it will be done.

 

After compiling the kernel, download and try to run it again. At this time, you can see the information printed by the kernel. If you unfortunately only see "Uncompressing Linux... done, booting the kernel." and no other output, then check whether the machine code passed by uboot matches the kernel machine code. If they do not match, please correct them, and then recompile and run the kernel or uboot. If you still cannot see other output after the correction, then check the bootargs parameter of uboot. Console=ttySAC0 must be configured in bootargs, otherwise you will not see the printed information.

If the above error does not appear, your kernel can print a lot of information, but because the kernel does not provide support for Nand or network card by default, the file system cannot be mounted, so it still cannot run normally. In order to enable the kernel to enter the console and provide an environment for subsequent driver development, we first make the file system, then transplant the network card driver, let the kernel mount the file system in NFS mode, and then we can develop other drivers, such as Nand, LCD, sound card, etc.

2. Build the file system

In fact, building a file system is relatively simple. Just pay attention to a few points and follow the steps.

(1) To create the root file system directory structure, you can use the following script:

  1. #!/bin/sh  
  2. echo "------Create rootfs directons start...--------"  
  3. mkdir rootfs  
  4. cd rootfs  
  5. echo "--------Create root,dev....----------"  
  6. mkdir root dev etc boot tmp var sys proc lib mnt home usr   
  7. mkdir etc/init.d etc/rc.d etc/sysconfig  
  8. mkdir usr/sbin usr/bin usr/lib usr/modules  
  9. echo "make node in dev/console dev/null"  
  10. sudo mknod -m 600 dev/console c 5 1  
  11. sudo mknod -m 600 dev/null  c 1 3  
  12. mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp  
  13. mkdir var/lib var/lock var/run var/tmp  
  14. chmod 1777 tmp  
  15. chmod 1777 var/tmp  
  16. echo "-------make direction done---------"  

Here I named the script mkrootfs.sh, then gave it executable permissions (chmod a+x mkrootfs) and ran it. My script runs in the /nfsroot directory, so the root directory of my root file system is /nfsroot/rootfs, and this directory is used as an example in the following descriptions.

 

(2) Compile Busybox

Go to Busybox to download the latest version of Busybox source code. I used version 1.21.0. After downloading, unzip it and enter the busybox directory. The first step is to configure busybox.

  1. make menuconfig  

The configuration menu is similar to the kernel configuration. Enter Busybox Settings => Build Options => Cross Compiler prefix (NEW) and set it to the compiler prefix. I use arm-linux-. Some friends on the Internet also recommend selecting Busybox Settings => Build Options => Build BusyBox as a static binary (no shared libs), but if we have copied the compiler runtime library correctly, it is also OK not to set it. Now we can compile Busybox. Execute
  1. make  

The compilation process went smoothly and I did not encounter any errors. Next, install the compiled Busybox to /nfsroot/rootfs and execute
  1. make CONFIG_PREFIX=/nfsroot/rootfs install  

(3) Copy the compiler runtime library

 

My compiler is version 4.5.1. Copy all dynamic libraries of arm-none-linux-gnueabi/sys-root/lib to /nfsroot/rootfs/lib. In order not to copy the link, you should add the "-d" option and execute

  1. cp *so* /nfsroot/rootfs/lib -d  

Similarly, copy all dynamic libraries under arm-none-linux-gnueabi/sys-root/usr/lib to /nfsroot/rootfs/usr/lib and execute
  1. cp *so* /nfsroot/rootfs/usr/lib -d  

(4) Build etc directory

[page]

Create an Inittab file in the etc directory with the following content

  1. ::sysinit:/etc/init.d/rcS  
  2. console::askfirst:-/bin/sh  
  3. ::restart:/sbin/init  
  4. ::ctrlaltdel:/sbin/reboot  
  5. ::shutdown:/bin/umount -a -r  
  6. ::shutdown:/sbin/swapoff -a  

Create the rcS file in the etc/init.d/ directory with the following content
  1. echo "----------mount all.........."  
  2. mount -a  
  3. echo "----------Starting mdev......"  
  4. echo /sbin/mdev > /proc/sys/kernel/hotplug  
  5. mdev -s  
  6. /bin/hostname -F /etc/sysconfig/HOSTNAME  

Add executable permissions to inittab and rcS files
  1. chmod a+x inittab  
  2. chmod a+x rcS  

Create the fstab file in the etc directory with the following content
  1. #evice mount-point type       option       dump   fsck   order  
  2. proc /proc proc defaults 0 0  
  3. none /tmp ramfs defaults 0 0  
  4. mdev /dev ramfs defaults 0 0  
  5. sysfs /sys sysfs defaults 0 0  

Create a profile file in the etc directory with the following content
  1. PATH=/bin:/sbin:/usr/bin:/usr/sbin    
  2. export PATH    
  3. #set hostname    
  4. HOSTNAME='/bin/hostname'    
  5. export HOSTNAME    
  6. # Set PS1    
  7. PS1='[u@h W]$'  
  8. export PS1  

Copy the passwd and group files in the host's /etc directory to the etc directory.

(5) Set up the HOSTNAME file

Create a HOSTNAME file in the etc/sysconfig directory and write the host name in the file. I wrote bruce here.

(6) Install kernel modules

Enter the kernel source directory and execute

  1. make modules  

After the compilation is complete, install the modules and execute the command
  1. make modules_install INSTALL_MOD_PATH=/nfsroot/rootfs  

At this point, the root file system is built.

 

3. Set uboot startup parameters

My nfs root directory is /nfsroot, and my root file system directory is under this directory, that is, /nfsroot/rootfs directory, so the uboot startup parameters are set as follows

  1. noinitrd console=ttySAC0 root=:/nfsroot/rootfs rw ip=:::::eth0:off init=/linuxrc  

It should be noted that all colons ":" cannot be omitted.

 

4. Network card driver transplantation (DM9000)

The reason why we choose to transplant the network card is that the network card driver is relatively simple, and it is even simpler for DM9000, because the kernel itself provides the DM9000 driver, but there is no management configuration for the development board. Therefore, we can complete the transplantation of the network card driver by configuring the development board related things. Open the arch/arm/mach-s5pv210/mach-smdkv210.c file and make the following changes:

(1) Modify the definition of smdkv210_dm9000_resources as follows

  1. static struct resource smdkv210_dm9000_resources[] = {   
  2.     [0] = {   
  3.         .start = 0x88000000,  
  4.         .end = 0x88000000 + 3,  
  5.         .flags = IORESOURCE_MEM,  
  6.     },    
  7.     [1] = {   
  8.         .start = 0x88000000 + 4,  
  9.         .end = 0x88000000 + 4 + 3,  
  10.         .flags = IORESOURCE_MEM,  
  11.     },    
  12.     [2] = {   
  13.         .start = IRQ_EINT(10),  
  14.         .end = IRQ_EINT(10),  
  15.         .flags = IORESOURCE_IRQ|IORESOURCE_IRQ_HIGHLEVEL,  
  16.     }     
  17. };  

(2) Modify the smdkv210_dm9000_init function as follows
  1. static void __init smdkv210_dm9000_init(void)  
  2. {  
  3.     unsigned long* srom_bw = ioremap(0xE8000000, 4);   
  4.     unsigned long* srom_bc1 = ioremap(0xE8000004, 4);   
  5.   
  6.     *srom_bc1 = ((0<<28)|(0<<24)|(5<<16)|(0<<12)|(0<<8)|(0<<4)|(0<<0));  
  7.     *srom_bw &= ~(0xf << 4);   
  8.     *srom_bw |= (1<<4)|(1<<5);  
  9.   
  10.     gpio_request(S5PV210_MP01(1), "nCS1");  
  11.     s3c_gpio_cfgpin(S5PV210_MP01(1), S3C_GPIO_SFN(2));  
  12.     gpio_free(S5PV210_MP01(1));  
  13.   
  14.     iounmap(srom_bw);  
  15.     iounmap(srom_bc1);  
  16. }  

In this way, the transplantation of the DM9000 network card driver is completed. In fact, this modification is logical. According to the schematic diagram of TQ210, we can know that the chip select of the DM9000 connection is nCS1, that is, the network card is connected to BANK1 of the ROM controller.

 

According to the memory mapping table of S5PV210, the address space of BANK1 of SROMC is 0x88000000~0x8FFFFFFF, so the chip select nCS1 will be enabled only when the CPU addresses the address space within this range. Therefore, we use the address 0x88000000. [page]

In addition, from the DM9000 part of the TQ210 schematic diagram, we can also see that DM9000 uses external interrupt 10, so the interrupt number is changed to 10.

Finally, it is necessary to explain the modification of the smdkv210_dm9000_init function. This is because the data access and command sending of DM9000 work according to a certain timing, and DM9000 is connected to SROMC, so the SROMC timing needs to be configured so that it can correctly drive DM9000. I haven't studied the detailed configuration of the timing yet, but Mr. Wei Dongshan's second video talks about the driver transplantation of DM9000 and the timing configuration. You can refer to it if you need it.

 

Five Mounting File Systems

Now that we have configured the network card driver, we still need to configure the kernel slightly to enable it to support network file system mounting. For details, please refer to the following configuration.

(1) Configuring network support

  1. [*] Networking support  --->  
  2.     Networking options  --->  
  3.         <*> Packet socket   
  4.         <*> Unix domain sockets  
  5.         [*] TCP/IP networking  
  6.         [*]   IP: multicasting  
  7.         [*]   IP: kernel level autoconfiguration   
  8.         [*]     IP: DHCP support  
  9.         [*]     IP: BOOTP support  
  10.         [*]     IP: RARP support  
  11.         [*]   IP: multicast routing  
  12.           

(2) Configuring network card device support
  1. Device Drivers  --->  
  2.     [*] Network device support  --->   
  3.         [*]   Ethernet driver support  --->  
  4.             <*>   DM9000 support  

 

 

(3) Configuring network file system support
  1. File systems  --->   
  2.     [*] Network File Systems  --->   
  3.         <*>   NFS client support   
  4.         <*>     NFS client support for NFS version 2  
  5.         <*>     NFS client support for NFS version 3   
  6.         [*]       NFS client support for the NFSv3 ACL protocol extension  
  7.         <*>     NFS client support for NFS version 4  
  8.         [*]   Root file system on NFS  

After configuring the above three items, save the configuration, then compile the kernel again and execute the make command directly.

 

At this time, re-download the kernel and test it. If there are no unexpected problems, the kernel can now work normally. If unfortunately, there are problems, then the problem should be the configuration of the NFS server. It is very simple to configure the NFS server under Ubuntu.

  1. sudo apt-get install nfs-kernel-server  

Then open the /etc/exports file with root privileges. My NFS root directory is /nfsroot, so I set export to
  1. /nfsroot/ *(rw,sync,no_root_squash)  

After the settings are completed, you need to restart the NFS service. Execute in Ubuntu

  1. sudo service nfs-kernel-server restart  

When you restart, you will see some warnings, as shown below

 

However, the above warning does not affect the use. On the contrary, if it is set to no_subtree_check, although the system can be mounted normally, it cannot perform write operations such as creating files. In other words, the mounted file system is read-only. Finally, you need to modify the permissions of /nfsroot for future convenience.

  1. chmod a+x /nfsroot -R  

At this point, the kernel transplantation based on TQ210 has been preliminarily completed, and then we can proceed to driver development.

 

Summary of Six Questions

I encountered many problems during the configuration process, and now I will summarize them briefly.

(1) The serial port interrupt prints "Starting kernel..." and then there is no more output

Configure the kernel and specify the debug information output port as UART0. The detailed configuration is described in the article.

(2) There is no output after decompressing the kernel

a. Check whether the bootargs environment variable is set correctly. You must set console=ttySAC0

b. Check whether the machine code root kernel passed by uboot corresponds

c. Check whether the taglist passed by uboot to the kernel is correct

(3) The kernel cannot mount the NFS file system

a. Correctly transplant the DM9000 network card driver

b. Configure the network part of the kernel, the network card device and the network file system in the file system

c. Confirm whether the configuration of the NFS server is correct. Use another Linux or a Linux that has been transplanted to test it (mount -o nolock xx.xx.xx.xx:/nfsroot/rootfs).

(4) The file system is mounted successfully, but /linuxrc cannot be executed

a. Check the NFS configuration file. It is best to configure it in NFSv2 mode. Problems will occur if the kernel does not support it.

b. It is best to configure the NFS server in the manner recommended in this article.

c. After the configuration is complete, you need to restart the NFS service or restart the system.

7. Other issues

If you have other questions during the transplantation process, please leave a message for discussion.

Keywords:S5PV210 Reference address:S5PV210 (TQ210) study notes - kernel transplantation and file system construction

Previous article:S5PV210 (TQ210) Study Notes - Key Driver
Next article:S5PV210 (TQ210) study notes - Nand configuration

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号