Build an embedded Linux distro from scratch 从无到有打造Linux发布包 之3 构建内核

英文原文来自

http://www.ibm.com/developerworks/linux/tutorials/l-embedded-distro/section4.html


Building the kernel


Downloading the source

Download Technologic's Linux source and TS-7800 configuration files and unzip them in a suitable location.

下载源文件

将Technologic的Linux源文件和TS-7800配置文件下载并解压到合适的位置。


Kernel configuration

A complete discussion of kernel configuration is beyond the scope of this tutorial. In this case, thets7800_defconfig target gave me a default usable configuration for the 7800, with one small hiccup: theCONFIG_DMA_ENGINE setting ended up off when it should have been on.

内核配置

对于内核配置的完整的讨论超出了本教程的范围。在本实例中,ts7800_defconfig为7800给出了一个默认的可用的配置,里边有一个小问题:CONFIG_DMA_ENGINE配置本应该打开的,事实上却是关闭的。


Tweaking the kernel

It is usually best to edit the kernel using make menuconfig, which offers a semi-graphical interface to kernel configuration. This interface is navigated using arrow keys to move the cursor, theTab key to select options from the bottom of the screen, and the space orEnter keys to select options. For instance, to exit without changing anything, pressTab until the <Exit> at the bottom of the screen is highlighted, then pressEnter. Running make menuconfig again reopens the editor.

调整内核

通常,编辑内核最好是使用 make menuconfig,它为内核配置提供了一个半图形化的接口。这个接口通过使用箭头键移动光标进行导航,Tab键选择屏幕底部的选项,空格或者Enter键选择选项。例如,为了不做任何修改的退出,按Tab键指导屏幕底部的<Exit>被高亮,之后,按Enter键。运行make menuconfig 会再一次打开编辑器。


Changing the default console

The TS-7800 normally boots silently, because the default kernel configuration specifies a null console device to keep the display quiet. To change this, use the arrow keys to navigate down to "Boot options," and pressEnter. The third line shows the default kernel options, which select the ramdisk, the startup script, and the console. Use the arrow keys to navigate down to this line, pressEnter, and change console none to console ttyS0,115200. Then, pressTab to move the cursor to the <Ok> at the bottom of the panel, and pressEnter. Now press Tab to select <Exit> and pressEnter, bringing you back to the main menu.

For the goal of booting as fast as possible, the console device isn't useful, and indeed, even at a high baud rate, sending kernel messages can take a noticeable fraction of the time the system takes to boot. For debugging and playing around, though, you want the console.

改变默认的控制台

正常来讲,TS-7800启动时是安静的,因为默认的内核配置指定了null的控制台设备以便保持显示屏是安静的。要改变这一点,使用箭头键向下导航到“Boot options”,按Enter键。第三行显示了默认的内核选项,选择了ramdisk,启动脚本,还有控制台。使用箭头键导航到这一行,按Enter键,之后,改变 console none 为 console ttyS0, 115200。之后,按Tab键移动光标到控制面板底部的<Ok>,并按下Enter键。现在,按Tab键选择<Exit>,并按下Enter,这会把你带回主菜单。

为了尽可能快启动的目标,控制台设备不是很有用,并且,确实地,即使设置了比较高的波特率,在系统花费在启动的时间中,发送内核信息也会占用可观的时间。如果打算调试,或者玩一玩,你会需要控制台的。


Enabling the DMA engine

Navigate down to "Device drivers" and press Enter. This list is longer than the usual display, so you will have to scroll down to the very end to reach the option for "DMA Engines." Navigate to that with the arrow keys, and pressEnter. There are two options at the top of this page that have square brackets indicating a boolean option. The second, "Support for DMA engines," was not enabled by default in the download I started with. Navigate to it with the arrow keys, and press space to toggle its state. Now use Tab and Enter to select <Exit> from each screen to navigate out to the top level of the program, and then <Exit> one more time to leave the program. When asked whether you wish to save your new kernel configuration, tab to <Yes> and press Enter.

开启DMA引擎

导航到“Device Drivers”,按Enter键。显示的列表较长,因此,需要下滑到结尾才能到“DMA Engines”选项。使用箭头键导航到该选项,按Enter。在本页的顶端有2个选项,带有方括号,这表示有选项是布尔型的。第二个,“Support for DMA engines”,默认是没有开启的。使用箭头键导航到它,按空格键反转它的状态。现在,使用Tab和Enter键选择每一个显示中的<Exit>,以便退出到程序的最高一级,之后,多<Exit>一次离开该程序。当被问及是否希望保存新的内核配置的时候,tab到<Yes>并按下Enter键。


Compiling the kernel

Type make. Yes, it really is that simple. This builds a kernel, as well as a collection of modules. Once again, multi-core users might want multiple jobs; trymake -j 5. For the purposes of this project, I'm going to ignore kernel modules, and favor compiling-in any needed features. The bootstrap ramdisk technique used to get needed drivers into the kernel early seems excessive, and building a root file system is already complicated enough. This, of course, brings up the question of how to get a kernel booting, the subject of the next section.

编译内核

输入make。是的,就是这么简单。这会构建内核,还有各个模块的集合。再一次,多核的用户或许想要多个任务;试试 make -j 5。对于该项目的目的而言,我将忽略内核的模块,并着重编译进内核的任何需要的特性。用来将需要的驱动放进内核的bootstrap ramdisk技术看起来有点多了,况且,构建一个root file system已经足够复杂了。当然,这引出了怎么让内核启动的问题,它正是下一节的主题。





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值