为MIPS编译Linux内核 [英] Compiling the Linux kernel for MIPS

查看:525
本文介绍了为MIPS编译Linux内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台32位MIPS机器,并且想在其上运行Linux.我需要使用Windows 7计算机将Linux交叉编译为MIPS.我对如何解决这个问题感到困惑.有人可以告诉我这是什么步骤,为什么?我不了解此过程涉及的所有不同工具.谢谢.

I have a 32 bit MIPS machine and would like to run Linux on it. I need to cross compile Linux to MIPS using my Windows 7 machine. I am confused on how to go about this. Could someone tell me what the steps to this are and why? I do not understand all the different tools involved in this process. Thanks.

推荐答案

操作系统问题

那么,您可以(理论上)在Windows下构建内核和BusyBox rootfs,请参见 MIPS Windows工具链.但是要在Windows中准备正确的构建环境(可能不确定Cygwin或MinGW,我不确定)会很困难.例如,在Ubuntu中,您可以直接使用所有东西.

OS concerns

Well, you can (theoretically) build kernel and BusyBox rootfs under Windows, see MIPS toolchain for Windows. But it can be rather hard to prepare the correct build environment in Windows (probably Cygwin or MinGW, I'm not sure). For example, in Ubuntu you have everything ready just out-of-the-box.

另一点是开发-使用Linux进行Linux内核开发更加容易和自然.我认识的每个在Linux内核(包括MIPS架构)上工作的人都在使用Linux进行开发以及构建内核和rootfs.

Another point is development -- it's much more easy and natural to use Linux for Linux kernel development. Everyone I know who is working on Linux kernel (including MIPS architecture) is using Linux for development and building the kernel and rootfs.

简而言之:Windows是Linux开发的外来环境,请尝试避免使用它.

In short: Windows is an alien environment for Linux development, try to avoid using it.

因此,我建议您安装Linux发行版,并将其用于构建内核和rootfs,并将已构建的映像刷新到设备中.最新的Ubuntu LTS可以使用(目前为 Ubuntu 14.04 ).

So I suggest you to install Linux distribution and use it for building the kernel and rootfs, and flashing built images to your device. Latest Ubuntu LTS will do (which is Ubuntu 14.04 for now).

首先,您需要确定需要构建哪些组件.如果您具有嵌入式系统-对于初学者,我建议您下一步:

First of all, you need to figure out which components need to be built. If you have embedded system -- for the starters I'd recommend you to do next:

  • 构建引导程序;我建议 U-Boot
  • 仅构建Linux内核(此处git clone稳定版本)
  • 构建基于 BusyBox /Root_directory"rel =" nofollow noreferrer> rootfs
  • flash 自举程序,内核和将rootfs图片移至您的设备上
  • build bootloader; I recommend U-Boot
  • build Linux kernel alone (git clone stable version from here)
  • build BusyBox-based rootfs
  • flash bootloader, kernel and rootfs images to your device

现在您的工作环境最少了.

Now you have minimal working environment.

在构建任何东西之前,请确保已安装MIPS 工具链和您的环境(外壳)的配置正确.有2种工具链:

Before building anything, make sure that you have MIPS toolchain installed and your environment (shell) is configured properly. There are 2 kinds of toolchains out there:

  1. ELF 工具链(具有 -none-eabi 的名称):适用于裸机程序.您应该使用它来构建引导加载程序和内核.
  2. GNU/Linux 工具链(其-linux-gnu-linux-gnueabi名称):取决于Linux 系统调用,并且具有C标准库,因此旨在用于构建在Linux下运行的用户空间应用程序.您应该使用它来构建BusyBox,因为它是用户空间程序.
  1. ELF toolchain (has -elf or -none-eabi in its name): intended for bare-metal programs. You should use it to build your bootloader and kernel.
  2. GNU/Linux toolchain (has -linux-gnu or -linux-gnueabi in its name): it depends on Linux system calls and has C Standard Library, so it's intended for building user-space applications running under Linux. You should use it for building BusyBox, as it's user-space program.

我可能建议您研究 Sourcery CodeBench 工具链.特别是您对下一步感兴趣:

I may recommend you to look into Sourcery CodeBench toolchains. Particularly you are interested in next:

  • ELF toolchain
  • GNU/Linux toolchain

安装了工具链后,您需要在工作环境(外壳)中执行下一步操作.

Once toolchain installed you need to do next things in your working environment (shell).

  1. 更新您的PATH环境变量,在其中添加工具链的bin/目录:

  1. Update your PATH environment variable, adding bin/ directory of your toolchain to it:

$ export PATH=/opt/path/to/your/toolchain/bin:$PATH

  • 导出CROSS_COMPILE环境变量,该变量应包含工具链的前缀.例如,如果在工具链bin/目录中看到mips-sde-elf-gcc,则应执行下一步:

  • Export CROSS_COMPILE environment variable, which should contain prefix for your toolchain. E.g., if you see mips-sde-elf-gcc in your toolchain bin/ directory, then you should do next:

    $ export CROSS_COMPILE=mips-sde-elf-
    

  • 导出ARCH环境.变种设置为您的架构:

  • Export ARCH env. var. set to your architecture:

    $ export ARCH=mips
    

  • 现在,您可以像在x86上一样构建内核和BusyBox:

    Now you can build your kernel and BusyBox the same way as you do it for x86:

    $ make <target>
    

    有用的阅读内容

    正如评论中所建议的那样,可能值得研究OpenWrt项目,因为它是针对MIPS体系结构(它是用于各种路由器的相当流行的开源固件)并且广泛使用MIPS工具.查看 OpenWrt构建系统文档,以了解有关这些方面的线索工具.

    Useful reading

    As it was recommended in comments, it may be worth to look into OpenWrt project, as it's intended for MIPS architecture (it's quite popular open-source firmware for various routers) and it's extensively using MIPS tools. Take a look at OpenWrt build system documentation to get some clue about those tools.

    这篇关于为MIPS编译Linux内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆