"FL2400" Linux3.0 kernel porting One

Source: Internet
Author: User

Contact Arm + Linux has been nearly two years, before the great God's shoulder to transplant the Linux kernel, for the requirements of the transplant is not very understanding! In order to gain a deeper understanding of the kernel, I decided to port the Linux kernel again from the beginning. The transplant is a complete transplant from a novice perspective , including possible problems, and how to resolve the problems that arise.

Environment:

Operating system: CentOS 6.2

Compilation environment: GCC version 4.3.6 (buildroot 2011.11)

Development Board: Infineon 2440 (s3c2440) (arm920t)

u-boot:u-boot-2010.09 (Machid = 1999)

Linux kernel: linux-3.0

"Prior to the transplant, the above environment was well-configured, including the u-boot-2010.09 can already be run on the board."


The Linux kernel has provided us with many config files already configured, and under arch/arm/configs/we choose a configuration that is more like s3c2410_defconfig than ours.

Make Menuconfig into configuration mode-->load an Alternate configuration file--> enter the specific path required: arch/arm/configs/s3c2410_ Defconfig--> Exit and save

Since there are so many modules in it that he automatically loads, we need to get rid of most of them, that is, the legendary system clipping, then make Menuconfig into configuration mode. This is based on the English meaning of the choice, I say a place, in the system Type, if not a little bit of clipping, he will compile for most of the kernel, if you just want to compile for your own, in the system MMU under the s3c2440 option is removed! when make is finished, the kernel is finished, and of course it needs uboot mkimage tool to compress the kernel in a certain format ;

Mkimage-a arm-o linux-t kernel-c none-a 30008000-e 30008040-n "Linux kernel"-D zimage uimage-s3c2440.gzimage Name:   Linux kernelcreated:      Tue 09:26:51 2014Image Type:   ARM Linux Kernel Image (uncompressed) Data Size:    1984356 Bytes = 1937.85 KB = 1 . mbload address:30008000entry Point:  30008040
"Note: The Mkimage tool will be generated under the Tools folder after Uboot compilation is successful"

The generated uimage-s3c2440.gz is placed inside the TFTP server and then into the Uboot debug mode, with the TFTP command to download the compiled kernel to the SRAM:

TFTP 30008000 Uimage-s3c2440.gz;bootm 30008000
The address here must be consistent with the mkimage parameters above. I deliberately tested it if the effect was inconsistent:

[[email protected]]# tftp 30009000 uimage-s3c2440.gz;bootm 30009000dm9000 I/o: 0x20000300, Id:0x90000a46 dm9000:r Unning in + bit modemac:08:00:3e:26:0a:6bcould not establish linkoperating @ 100M full duplex modeusing dm9000 DEVICETF TP from server 192.168.1.2; Our IP address is 192.168.1.244Filename ' uimage-s3c2440.gz '. Load address:0x30009000loading:t ################################################################# ############# #################################################### ##### #doneBytes transferred = 1984420 (1e47a4 hex) # # Booting   Kernel from Legacy Image at 30009000 ...   Image Name:linux Kernel created:2014-08-12 1:26:51 UTC image type:arm Linux Kernel Image (uncompressed) Data size:1984356 Bytes = 1.9 MiB Load address:30008000 Entry point:30008040 Verifying Checksum ... OK Loading Kernel Image from 30009040 to 30008000 ... Okokos Entry Point:30008040image Entry point=30008040
So, after the download is complete, if your previous uboot Machid is the same as your Linux kernel ID, then the kernel will start normally, of course, I am not so fortunate, I have said above, I uboot Machid is 1999. The kernel default machid is 000016a. So there are the following consequences (hint Machid not supported):

Starting kernel ... Uncompressing Linux ... done, booting the kernel. Error:unrecognized/unsupported machine ID (r1 = 0x33edffc4). Available machine Support:id (hex)        name0000016a        smdk24400000043c        smdk2443please Check your kernel config and/or bootloader.
Then we need to change the ID of Mach-type:

[09:42:50 @ linux-3.0]$ vim arch/arm/tools/mach-typess3c2440         arch_s3c2440        s3c2440         362
Change 362 to 1999, recompile, load the kernel, here is a little trick, because we want to constantly test the kernel, if kept to NAND flash constantly erase read and write, very troublesome, wasting time, but also reduce the service life of Nandflash, so the correct debugging method is, Download the kernel directly to the specified address space, directly run, I use this method above!

After the modification, make,make image, download, after running there is no such situation, but he stopped here do not output:

[[email protected]]# run tbdm9000 I/o: 0x20000300, id:0x90000a46 dm9000:running i N-bit modemac:08:00:3e:26:0a:6bcould not establish linkoperating @ 100M full duplex modeusing dm9000 devicetftp from Server 192.168.1.2; Our IP address is 192.168.1.244Filename ' uimage-s3c2440.gz '. Load address:0x30008000loading:t ################################################################# ############# #################################################### ##### #doneBytes transferred = 1984424 (1e47a8 hex) # # Booting   Kernel from Legacy Image at 30008000 ...   Image Name:linux Kernel created:2014-08-12 1:51:01 UTC image type:arm Linux Kernel Image (uncompressed) Data size:1984360 Bytes = 1.9 MiB Load address:30008000 Entry point:30008040 Verifying Checksum ... OK XIP Kernel Image ... Okokos entry Point:30008040image entry point=30008040starting kernel ... Uncompressing Linux ... done, booting the kernel. 
Note: The TB here is a variable that I define in uboot, variable content (tb=tftp 30008000 uimage-s3c2440.gz;bootm 30008000) So I don't have to enter that much each time;
But I was surprised to find that my monitor's LCD has a small penguin, although the small penguin is incomplete? According to the current speculation is because the driver parameters are not set, and later we set up, and now say that the next serial port does not print the kernel information.

Uboot has a Bootargs parameter, let's take a look at this parameter, this parameter is passed to the kernel, you can also make menuconfig inside set this parameter (Boot options---) default kernel Command string):

bootargs=console=ttys0,115200 mem=64m initrd=0x30800000,16m root=/dev/ram0 rw loglevel=7

Here the console port ttyS0, since the kernel has no output, then he created the console device name is not him, so we will now find the kernel serial name. Looking for a half day in the drivers/tty/serial/samsung.c found this drive, has the following definition:

/* UART name and device definitions */#define S3C24XX_SERIAL_NAME "Ttysac" #define S3c24xx_serial_major    204#define S3 C24xx_serial_minor    64
Note that Serial_name is TTYSAC, then we need to change our Bootargs parameter to

bootargs=console=ttySAC0,115200 mem=64m initrd=0x30800000,16m root=/dev/ram0 rw loglevel=7
Restart the kernel, you will be pleasantly surprised to find that the kernel has something output, but is a bunch of garbled? According to my common sense, this must be the baud rate is wrong, but the baud rate in the Bootargs set is 115200 ah, with my PC baud rate is the same AH! Where's the problem? It must be the wrong frequency in that place, which causes the system to appear this problem!


Figure a serial port baud rate is not correct, resulting in kernel printing information is garbled

(I'm sure someone will ask me, how can you be so accurate?) Yes, it's all about experience, how do you have this experience? More practice, more understanding, more remember, first you want to the kernel of each directory is what to understand it? And then you need to know what's going on with the Linux kernel, his device driver? These problems, the Internet is said countless. )

This reminds me of the s3c2410 and s3c2440 's frequency is different, and because I use the s3c2410 config file, so I need to see his main kernel is how the clock is configured. The general clock is in the chip core initialization, we need to go to the mach-s3c2440 directory below to see.

Vim arch/arm/mach-s3c2440/mach-smdk2440.c

Find Machine_init Place, this must be the system initialization, found that there is such a code:

static void __init Smdk2440_map_io (void) {    s3c24xx_init_io (Smdk2440_iodesc, Array_size (Smdk2440_iodesc));    S3c24xx_init_clocks (16934400);    S3c24xx_init_uarts (Smdk2440_uartcfgs, Array_size (SMDK2440_UARTCFGS));} static void __init Smdk2440_machine_init (void) {    s3c24xx_fb_set_platdata (&smdk2440_fb_info);    S3c_i2c0_set_platdata (NULL);    Platform_add_devices (Smdk2440_devices, Array_size (smdk2440_devices));    Smdk_machine_init ();}
There is a sentence s3c24xx_init_clocks (16934400); this thing 16.934MHz crystal, and my board system crystal is 12MHz, so I need to change this crystal frequency: s3c24xx_init_clocks ( 12000000);

Note: Perhaps the crystal on your board is not 12MHz, so you have to look at the schematic diagram or the development Board of the crystal oscillator is how much.
Reset, make image, download, Bootm.


Figure II s3c2440 Crystal oscillator circuit diagram

This time the kernel has successfully printed the message:

Bytes transferred = 1984424 (1e47a8 hex) # # booting kernel from Legacy Image at 30008000 ...   Image Name:linux Kernel created:2014-08-12 2:23:33 UTC image type:arm Linux Kernel Image (uncompressed) Data size:1984360 Bytes = 1.9 MiB Load address:30008000 Entry point:30008040 Verifying Checksum ... OK XIP Kernel Image ... Okokos entry Point:30008040image entry point=30008040starting kernel ... Uncompressing Linux ... done, booting the kernel. Linux version 3.0.0 ([email protected]) (GCC version 4.3.6 (buildroot 2011.11)) #3 Tue 10:20:31 CST 2014CPU: arm920t [41129200] revision 0 (ARMV4T), CR=C0007177CPU:VIVT data cache, VIVT instruction Cachemachine:smdk2440memory pol ICY:ECC disabled, Data cache writebackcpu s3c2440a (id 0x32440001) s3c24xx clocks, Copyright 2004 Simtec electronicss3c244 X:core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 Mhzclock:slow mode (1.500 MHz), fast, MPLL on, UPLL onbuilt 1 Zonelists in Zone order, mobilityGrouping on. Total pages:16256kernel command line:console=ttysac0,115200 mem=64m initrd=0x30800000,16m root=/dev/ram0 rw loglevel= 7PID Hash Table entries:256 (Order:-2, 1024x768 bytes) Dentry Cache Hash Table entries:8192 (order:3, 32768 bytes) INODE-CAC He hash table entries:4096 (order:2, 16384 bytes) MEMORY:64MB = 64MB totalmemory:44520k/44520k available, 21016k Reserv Ed, 0K highmemvirtual Kernel memory layout:vector:0xffff0000-0xffff1000 (4 KB) fixmap:0xfff00000-0xf ffe0000 (896 KB) dma:0xffc00000-0xffe00000 (2 MB) vmalloc:0xc4800000-0xf6000000 (792 MB) L owmem:0xc0000000-0xc4000000 (MB) modules:0xbf000000-0xc0000000 (MB). init:0xc0008000-0x       c002b000 (KB). text:0xc002b000-0xc0399000 (3512 KB). data:0xc039a000-0xc03c5080 (173 KB) . bss:0xc03c50a4-0xc03e9d84 (148 KB) nr_irqs:99
system default NAND Flash Partition:

Creating 8 MTD partitions on "NAND": 0x000000000000-0x000000004000: "Boot Agent" mtd:partition "boot agent" doesn ' t end on An erase block – Force read-only0x000000000000-0x000000200000: "S3C2410 Flash partition 1" 0x000000400000-0x00000080000  0: "s3c2410 Flash partition 2" 0x000000800000-0x000000a00000: "s3c2410 Flash partition 3" 0x000000a00000-0x000000e00000: "S3C2410 Flash partition 4" 0x000000e00000-0x000001800000: "s3c2410 Flash partition 5" 0x000001800000-0x000003000000: "S 3c2410 Flash partition 6 "0x000003000000-0x000010000000:" s3c2410 Flash partition 7 "
However, the prompt does not have a file system:

List of all partitions:1f00 mtdblock0 (driver?) 1F01 2048 mtdblock1 (driver?) 1F02 4096 Mtdblock2 (driver?) 1f03 2048 mtdblock3 (driver?) 1f04 4096 Mtdblock4 (driver?) 1f05 10240 mtdblock5 (driver?) 1f06 24576 mtdblock6 (driver?) 1f07 212992 mtdblock7 (driver?) No filesystem could mount Root, tried:ext2 Cramfs vfat msdos iso9660 ntfs romfskernel panic-not syncing:VFS:Unable t o Mount Root fs on Unknown-block (1,0) BackTrace: [<c003b734>] (dump_backtrace+0x0/0x104) from [<c02bb4f0>] ( dump_stack+0x18/0x1c) r6:c3889000 r5:00008000 R4:c3819f5c[<c02bb4d8>] (dump_stack+0x0/0x1c) from [<c02bb548 (PANIC+0X54/0X1A8) [<c02bb4f4>] (panic+0x0/0x1a8) from [<c0008ff0>] (mount_block_root+0x264/0x2d0) r3:00000000 r2:c3819f5c r1:c3819f5c R0:c034e9e8[<c0008d8c>] (mount_block_root+0x0/0x2d0) from [<c00090b0 (mount_root+0x54/0x6c) [<c000905c>] (mount_root+0x0/0X6C) from [<c00091dc>] (prepare_namespace+0x114/0x1e4) r5:c0026600 R4:c03c5120[<c00090c8>] (prepare_ NAMESPACE+0X0/0X1E4) from [<c0008490>] (kernel_init+0xe8/0x128) r5:c002584c R4:c0025bdc[<c00083a8>] ( kernel_init+0x0/0x128) from [<c0050554>] (do_exit+0x0/0x6e8) r6:c0050554 r5:c00083a8 r4:00000000
Looking specifically at his list of all partitions, some partitions overlap with my kernel and filesystem partitions, so we have to modify the filesystem partition (I don't have a detailed description of the filesystem here, because this is for Linux kernel porting)

"If there is any problem, please leave a message and point out"

e-mail: [Email protected]

If reproduced please indicate the source, thank you!

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.