Embedded Linux compiler kernel steps/focus on solving machine code problems

Source: Internet
Author: User
Tags assert unsupported

Embedded system Update Kernel 1. Objective

There is a friendly arm of the MINI2451 board, this week to try to compile the kernel, and then update the board of the Linux kernel, want to update the Linux Kernel 4.1 version, but for a variety of reasons is not updated successfully, so use friendly ARM Board provides the 3.6 version of the kernel, but their kernel is all configured, you just need to follow the usual method of compiling, it seems that can not be more in-depth understanding of the kernel, Later I downloaded the original kernel from the Kernel.org official website, and then a little bit of the 2451 this board need to transplant the past, can be described as a problem, but also learned a lot of things.

2. Preparation of materials
    • Friendlyarm's mini2451 board piece
    • The bootloader used is the closed source provided by Friendarm Superboot2451.bin
    • Linux3.6 Kernel source code (in the official website, pure)
    • . config file provided by mini2451
3. Burn a few key points in the kernel 3.1 steps to get the new kernel

When we get the new kernel, we must pay attention to a few steps, as if not a few books written by me so detailed, basically is to give a general idea, but to the real thing to play, really is a problem. The following is a discussion about these aspects.

A) modify the top layer makefile

b) Machine ID processing (add c file, modify Kconfig, modify makefile file in arch/arm/Mach)

c) Add machine ID in the Arch/arm/tools/mach-types file

3.1.1 Modifying the makefile of the top layer

Makefile altogether to modify 2 places can:

    • Modify Arch Architecture: Arch = arm Note that the arm is not a space after these few, otherwise make the time does not recognize.

    • Modify Cross_compile path: cross_compile?=/home/user/toolchian/arm-linux-

Pay attention to 1,cross_compile's statement, I give here is the full path, and not like books and web blog to give the arm-linux-, here for what? Because your computer may contain a tool chain that is not a cross-compiling environment, it is highly recommended to use the absolute path of the cross-compilation environment, absolutely no error, and can be assured of bold use.

Note that the 2,arm-linux-does not add a space, otherwise it will not be recognized, and arch that option, do not have spaces. Otherwise it will be thrown: "Make: * */home/delvis/work/linux-3.6/arch/arm: is a directory. Stop it. "Error.

Makefile only need to change these two positions on it, large can be saved.

3.1.2 Modify c file for machine ID

The path is a./arch/arm/inside about mach-"Various models", you often see the following instructions in the instructional video or book:

Find a C file similar to your board model and copy it out.

I am using the Linux3.2 kernel and, my board model is s3c2451, so it is rightfully found mach-s3c24xx this folder, ! But I found in the Linux4.1 and Linux2.4 version of the kernel does not mach-s3c24xx this folder, in fact, there is no relationship, as long as you find and your board chip model similar to the can.

I am here to copy Friendlyarm provided mach-mini2451.c This file, in this file need to pay attention to a few places, I still do not quite understand what this file is doing, look inside a lot of initialization program including GPIO, clock, timer, interrupt and so on, The 2451 board should be initialized. For the time being I can't write it, just transplant it.

    • File End Machine_start (user_define_string, "user_define_string") {...} This is where the machine ID is.
    • There are functions defined in it, need to rely on a lot of files, the original kernel is not inside, I have to copy from the friendlyarm inside the corresponding directory.

The user_define_string of the arguments passed at the end of the file is the Machine_start we are going to write to the machine ID, the string I defined here is mach_mini2451

3.1.3 Modifying the Kconfig file in Mach-xxxx

Just now add the new mach-mini2451.c file, in the same directory with this file Kconfig to add this configuration item, I give my configuration items:

config MACH_MINI2451        bool "MINI2451BYDELVIS"        #select S3C24XX_SMDK        select S3C_DEV_FB        select S3C_DEV_HSMMC        select S3C_DEV_HSMMC1        select S3C_DEV_NAND        select S3C_DEV_USB_HOST        select S3C2416_SETUP_SDHCI        select WIRELESS_EXT        select WEXT_SPY        select WEXT_PRIV        select AVERAGE        help          Say Y here if you are using an FriendlyARM MINI2451

Add this string in Kconfig, this option will come out when making menuconfig at the top level, when we make menuconfig, the first thing we should do is select the structure of the board.

1) System Type--ARM sytem Type (Samsung s3c24xx Socs)--Samsung S3C24XX Socs

Select to return to the previous layer

2) Sasung s3c24xx SoCs Support---> first select Sasung s3c2416/s3c2450---> below to automatically mini2451bydelvis a moment to say how the menu's display logic

3) Exit and Save becomes. config

The logic and attribution of these menus is kconfig decided, our config mach_mini2451 this entry to the right place, not just a place to go, each of our sub-menu is a configuration for. config.

Look at the picture, first note the position of the two red circle, we say the config mach_mini2451 this lump in the If cpu_s3c2416 ... endif this inside, that is, we chose in make Menuconfig " Mini2451bydelvis "This option, Mach_ MINI2451 default in the. config file CPU is s3c2416, (also visible, our mach-mini2451.c files are copied mach-s3c2416.c files are converted from)

In the Make Menuconfig menu, only select s3c2416 this CPU model, this option will appear

3.1.3 Modify the Makefile file under the mach-s3c24xx file

We add the mach-mini2451.c file for no reason, if the global compilation is not compiled, because there is no makefile to guide the compilation, so we need to modify this layer of makefile, when I do a global compilation, there are rules to guide the compiler to compile.

# add by Carlos 2017.12.6obj-$(CONFIG_MACH_MINI2451)             += mach-mini2451.o mini2451-lcds.o

Find a location in the makefile file in this layer, and then output the file in this format.

3.1.4 Add machine code

Speaking of machine code, I really had to spit it out. Friendly arm, in the purchase of friendly arm, the purchase of the propaganda interface, said they spent a lot of money to develop superboot2451.bin enterprise-class bootloader, the focus is closed source , bootloader is still good, from the SD card boot, support serial, driver support of the very whole, there is an original visual interface Minitools usbmode One-click Installation System, one-click Download program. but at least at the same time, the bootloader key parameters to give Ah!!! I found their wiki, find the official website, manual, is not know Superboot2451.bin machine ID, at least give the ID value out AH.

Well, after the experimental output, a powerful closed-source Superboot2451.bin machine ID is: 0x00000695

Well, the groove ends, I still suggest to develop uboot, so convenient.

Only the machine code in bootloader and kernel, the kernel can start normally, otherwise it will be thrown:

Error:unrecognized/unsupported machine ID (r1 = 0x33f60264).

We either correct the ID in the uboot, or correct the ID in the kernel, in short, whatever the number is, the same.

Well, since the Superboot2451.bin is closed source can not be corrected, then we can only correct kernel in the ID, then kernel in the ID how to correct it?

Switch to: arch/arm/tools/folder, there is a mach-types file, we add a later:

mini2451 MACH_MINI2451 MINI2451 0x695

Careful friends have found, in the above chapters, fragmented's files are also these characters, that is, mini2451, mach_mini2451, MINI2451 This macro definition is the ID value.

This is where our kernel configuration is complete.

3.2 Make Menuconfig configuration

Switch to the last step, make menuconfig for. config, in the Vedon teacher's video, mention this. config file from three parts

  1. After making the make Menuconfig configuration, you need to configure the strips.
  2. Using the default configuration, modify the
  3. Use of factory-provided

Here, I use the Mini2451_linux_config file provided by the manufacturer to make the modification above, first copy the config file from the run, and change the name to. config to overwrite the original. config file and make Menucofig , in the system type as described above, select the correct board model. If you do not have a choice, there will be such an exception, when the kernel compiles to the last time, the compilation kernel appears the No machine record defined error. Then some ghosts like the site to give a bad idea, but also by a large number of blog reprint, is simply misleading, you pass Google or Baidu, there will be a solution like this :

Here to one! Anti -! Surface! Teach! Material! :

After the dog search, according to the following methods can be resolved. Put the last two lines of Arch/arm/kernel/vmlinux.lds (below), to annotate, but not to say what
ASSERT ((__proc_info_end-__proc_info_begin), "Missing CPU support"),
ASSERT ((__arch_info_end-__arch_info_begin), "No machine record defined")

A negative source: Uncompressing Linux ..... ..... .... ..... ..... ...................... After no response to the first half of the solution

is simply the same as the operation of God, error, comments up can be maintained, what logic, is simply an insult to technology!!! I have tried, and it is true that the kernel has been compiled, the kernel can be transferred to arm, to the next step of load kernel, the error:unrecognized/unsupported machine ID (r1 = 0x33f60264) is thrown. The exception, apparently no machine code is undefined.

Note This ghost method can't be used at all, okay? Who's the bad idea!!

The correct solution is:

According to the above section of our configuration, it is logical to solve the problem of machine ID:

1) Machine ID processing (add c file, modify Kconfig, modify makefile file in arch/arm/Mach)

2) Add machine ID in the Arch/arm/tools/mach-types file

3) Select the system type in the Make Menuconfig menu and select the correct model, which will be automatically configured to the. config

3.3 Make

Then start make on it, compile the kernel, I generally like to use make-j8 multithreaded programming, fast, but very burning CPU ...

This is basically the state ... Look at the temperature.

After compiling, follow the documentation provided by friendly arm, copy the Zimage file to the correct path of the SD card, and then start the normal burn-in from the SD card.

4 Summary

See this output, really excited, finally the kernel began to decompress normally. Grind for several days.


The 15th week mainly engaged in the core of the finished, and recently busy to review the exam, kernel things may be a little slowly. Study slowly later.

Reference documents:

[1] The blog of your QI. Error:unrecognized/unsupported machine ID (r1 = 0x33f60264): Sina Blog. 2011-03-20.

[2] Vedon. "Embedded Linux Full Development Handbook-Application Development" books.

[3] Friendlyarm. 2451 Development Manual-User manual.

Copyright Notice:

1. This article for the Multibeans Team research and development follow the article, without permission shall not be reproduced.

2 · If there is infringement, please contact with me, I will promptly delete.

3 · Respect the results, this article will be used in all the references to the selfless engineers, enthusiasts salute.

Embedded Linux compiler kernel steps/focus on solving machine code problems

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.