收藏官网首页
查看: 17297|回复: 4

[资料] 将Linux 4.x移植到STM32F7上

4

主题

25

帖子

231

积分

中级会员

Rank: 3Rank: 3

积分
231
跳转到指定楼层
楼主
发表于 2016-10-6 23:21:40 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
汉枫LPB120模块
本帖最后由 绿林科技 于 2016-10-6 23:28 编辑

mainline linux kernel porting to STM32f7.


测试:NUCLEO-F746ZG 或 stm32f7disco





  1. Linux kernel release 4.x <http://kernel.org/>

  2. These are the release notes for Linux version 4.  Read them carefully,
  3. as they tell you what this is all about, explain how to install the
  4. kernel, and what to do if something goes wrong.

  5. WHAT IS LINUX?

  6.   Linux is a clone of the operating system Unix, written from scratch by
  7.   Linus Torvalds with assistance from a loosely-knit team of hackers across
  8.   the Net. It aims towards POSIX and Single UNIX Specification compliance.

  9.   It has all the features you would expect in a modern fully-fledged Unix,
  10.   including true multitasking, virtual memory, shared libraries, demand
  11.   loading, shared copy-on-write executables, proper memory management,
  12.   and multistack networking including IPv4 and IPv6.

  13.   It is distributed under the GNU General Public License - see the
  14.   accompanying COPYING file for more details.

  15. ON WHAT HARDWARE DOES IT RUN?

  16.   Although originally developed first for 32-bit x86-based PCs (386 or higher),
  17.   today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and
  18.   UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
  19.   IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
  20.   Xtensa, Tilera TILE, AVR32, ARC and Renesas M32R architectures.

  21.   Linux is easily portable to most general-purpose 32- or 64-bit architectures
  22.   as long as they have a paged memory management unit (PMMU) and a port of the
  23.   GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has
  24.   also been ported to a number of architectures without a PMMU, although
  25.   functionality is then obviously somewhat limited.
  26.   Linux has also been ported to itself. You can now run the kernel as a
  27.   userspace application - this is called UserMode Linux (UML).

  28. DOCUMENTATION:

  29. - There is a lot of documentation available both in electronic form on
  30.    the Internet and in books, both Linux-specific and pertaining to
  31.    general UNIX questions.  I'd recommend looking into the documentation
  32.    subdirectories on any Linux FTP site for the LDP (Linux Documentation
  33.    Project) books.  This README is not meant to be documentation on the
  34.    system: there are much better sources available.

  35. - There are various README files in the Documentation/ subdirectory:
  36.    these typically contain kernel-specific installation notes for some
  37.    drivers for example. See Documentation/00-INDEX for a list of what
  38.    is contained in each file.  Please read the Changes file, as it
  39.    contains information about the problems, which may result by upgrading
  40.    your kernel.

  41. - The Documentation/DocBook/ subdirectory contains several guides for
  42.    kernel developers and users.  These guides can be rendered in a
  43.    number of formats:  PostScript (.ps), PDF, HTML, & man-pages, among others.
  44.    After installation, "make psdocs", "make pdfdocs", "make htmldocs",
  45.    or "make mandocs" will render the documentation in the requested format.

  46. INSTALLING the kernel source:

  47. - If you install the full sources, put the kernel tarball in a
  48.    directory where you have permissions (e.g. your home directory) and
  49.    unpack it:

  50.      xz -cd linux-4.X.tar.xz | tar xvf -

  51.    Replace "X" with the version number of the latest kernel.

  52.    Do NOT use the /usr/src/linux area! This area has a (usually
  53.    incomplete) set of kernel headers that are used by the library header
  54.    files.  They should match the library, and not get messed up by
  55.    whatever the kernel-du-jour happens to be.

  56. - You can also upgrade between 4.x releases by patching.  Patches are
  57.    distributed in the xz format.  To install by patching, get all the
  58.    newer patch files, enter the top level directory of the kernel source
  59.    (linux-4.X) and execute:

  60.      xz -cd ../patch-4.x.xz | patch -p1

  61.    Replace "x" for all versions bigger than the version "X" of your current
  62.    source tree, _in_order_, and you should be ok.  You may want to remove
  63.    the backup files (some-file-name~ or some-file-name.orig), and make sure
  64.    that there are no failed patches (some-file-name# or some-file-name.rej).
  65.    If there are, either you or I have made a mistake.

  66.    Unlike patches for the 4.x kernels, patches for the 4.x.y kernels
  67.    (also known as the -stable kernels) are not incremental but instead apply
  68.    directly to the base 4.x kernel.  For example, if your base kernel is 4.0
  69.    and you want to apply the 4.0.3 patch, you must not first apply the 4.0.1
  70.    and 4.0.2 patches. Similarly, if you are running kernel version 4.0.2 and
  71.    want to jump to 4.0.3, you must first reverse the 4.0.2 patch (that is,
  72.    patch -R) _before_ applying the 4.0.3 patch. You can read more on this in
  73.    Documentation/applying-patches.txt

  74.    Alternatively, the script patch-kernel can be used to automate this
  75.    process.  It determines the current kernel version and applies any
  76.    patches found.

  77.      linux/scripts/patch-kernel linux

  78.    The first argument in the command above is the location of the
  79.    kernel source.  Patches are applied from the current directory, but
  80.    an alternative directory can be specified as the second argument.

  81. - Make sure you have no stale .o files and dependencies lying around:

  82.      cd linux
  83.      make mrproper

  84.    You should now have the sources correctly installed.

  85. SOFTWARE REQUIREMENTS

  86.    Compiling and running the 4.x kernels requires up-to-date
  87.    versions of various software packages.  Consult
  88.    Documentation/Changes for the minimum version numbers required
  89.    and how to get updates for these packages.  Beware that using
  90.    excessively old versions of these packages can cause indirect
  91.    errors that are very difficult to track down, so don't assume that
  92.    you can just update packages when obvious problems arise during
  93.    build or operation.

  94. BUILD directory for the kernel:

  95.    When compiling the kernel, all output files will per default be
  96.    stored together with the kernel source code.
  97.    Using the option "make O=output/dir" allows you to specify an alternate
  98.    place for the output files (including .config).
  99.    Example:

  100.      kernel source code: /usr/src/linux-4.X
  101.      build directory:    /home/name/build/kernel

  102.    To configure and build the kernel, use:

  103.      cd /usr/src/linux-4.X
  104.      make O=/home/name/build/kernel menuconfig
  105.      make O=/home/name/build/kernel
  106.      sudo make O=/home/name/build/kernel modules_install install

  107.    Please note: If the 'O=output/dir' option is used, then it must be
  108.    used for all invocations of make.

  109. CONFIGURING the kernel:

  110.    Do not skip this step even if you are only upgrading one minor
  111.    version.  New configuration options are added in each release, and
  112.    odd problems will turn up if the configuration files are not set up
  113.    as expected.  If you want to carry your existing configuration to a
  114.    new version with minimal work, use "make oldconfig", which will
  115.    only ask you for the answers to new questions.

  116. - Alternative configuration commands are:

  117.      "make config"      Plain text interface.

  118.      "make menuconfig"  Text based color menus, radiolists & dialogs.

  119.      "make nconfig"     Enhanced text based color menus.

  120.      "make xconfig"     Qt based configuration tool.

  121.      "make gconfig"     GTK+ based configuration tool.

  122.      "make oldconfig"   Default all questions based on the contents of
  123.                         your existing ./.config file and asking about
  124.                         new config symbols.

  125.      "make silentoldconfig"
  126.                         Like above, but avoids cluttering the screen
  127.                         with questions already answered.
  128.                         Additionally updates the dependencies.

  129.      "make olddefconfig"
  130.                         Like above, but sets new symbols to their default
  131.                         values without prompting.

  132.      "make defconfig"   Create a ./.config file by using the default
  133.                         symbol values from either arch/$ARCH/defconfig
  134.                         or arch/$ARCH/configs/${PLATFORM}_defconfig,
  135.                         depending on the architecture.

  136.      "make ${PLATFORM}_defconfig"
  137.                         Create a ./.config file by using the default
  138.                         symbol values from
  139.                         arch/$ARCH/configs/${PLATFORM}_defconfig.
  140.                         Use "make help" to get a list of all available
  141.                         platforms of your architecture.

  142.      "make allyesconfig"
  143.                         Create a ./.config file by setting symbol
  144.                         values to 'y' as much as possible.

  145.      "make allmodconfig"
  146.                         Create a ./.config file by setting symbol
  147.                         values to 'm' as much as possible.

  148.      "make allnoconfig" Create a ./.config file by setting symbol
  149.                         values to 'n' as much as possible.

  150.      "make randconfig"  Create a ./.config file by setting symbol
  151.                         values to random values.

  152.      "make localmodconfig" Create a config based on current config and
  153.                            loaded modules (lsmod). Disables any module
  154.                            option that is not needed for the loaded modules.

  155.                            To create a localmodconfig for another machine,
  156.                            store the lsmod of that machine into a file
  157.                            and pass it in as a LSMOD parameter.

  158.                    target$ lsmod > /tmp/mylsmod
  159.                    target$ scp /tmp/mylsmod host:/tmp

  160.                    host$ make LSMOD=/tmp/mylsmod localmodconfig

  161.                            The above also works when cross compiling.

  162.      "make localyesconfig" Similar to localmodconfig, except it will convert
  163.                            all module options to built in (=y) options.

  164.    You can find more information on using the Linux kernel config tools
  165.    in Documentation/kbuild/kconfig.txt.

  166. - NOTES on "make config":

  167.     - Having unnecessary drivers will make the kernel bigger, and can
  168.       under some circumstances lead to problems: probing for a
  169.       nonexistent controller card may confuse your other controllers

  170.     - Compiling the kernel with "Processor type" set higher than 386
  171.       will result in a kernel that does NOT work on a 386.  The
  172.       kernel will detect this on bootup, and give up.

  173.     - A kernel with math-emulation compiled in will still use the
  174.       coprocessor if one is present: the math emulation will just
  175.       never get used in that case.  The kernel will be slightly larger,
  176.       but will work on different machines regardless of whether they
  177.       have a math coprocessor or not.

  178.     - The "kernel hacking" configuration details usually result in a
  179.       bigger or slower kernel (or both), and can even make the kernel
  180.       less stable by configuring some routines to actively try to
  181.       break bad code to find kernel problems (kmalloc()).  Thus you
  182.       should probably answer 'n' to the questions for "development",
  183.       "experimental", or "debugging" features.

  184. COMPILING the kernel:

  185. - Make sure you have at least gcc 3.2 available.
  186.    For more information, refer to Documentation/Changes.

  187.    Please note that you can still run a.out user programs with this kernel.

  188. - Do a "make" to create a compressed kernel image. It is also
  189.    possible to do "make install" if you have lilo installed to suit the
  190.    kernel makefiles, but you may want to check your particular lilo setup first.

  191.    To do the actual install, you have to be root, but none of the normal
  192.    build should require that. Don't take the name of root in vain.

  193. - If you configured any of the parts of the kernel as `modules', you
  194.    will also have to do "make modules_install".

  195. - Verbose kernel compile/build output:

  196.    Normally, the kernel build system runs in a fairly quiet mode (but not
  197.    totally silent).  However, sometimes you or other kernel developers need
  198.    to see compile, link, or other commands exactly as they are executed.
  199.    For this, use "verbose" build mode.  This is done by passing
  200.    "V=1" to the "make" command, e.g.

  201.      make V=1 all

  202.    To have the build system also tell the reason for the rebuild of each
  203.    target, use "V=2".  The default is "V=0".

  204. - Keep a backup kernel handy in case something goes wrong.  This is
  205.    especially true for the development releases, since each new release
  206.    contains new code which has not been debugged.  Make sure you keep a
  207.    backup of the modules corresponding to that kernel, as well.  If you
  208.    are installing a new kernel with the same version number as your
  209.    working kernel, make a backup of your modules directory before you
  210.    do a "make modules_install".

  211.    Alternatively, before compiling, use the kernel config option
  212.    "LOCALVERSION" to append a unique suffix to the regular kernel version.
  213.    LOCALVERSION can be set in the "General Setup" menu.

  214. - In order to boot your new kernel, you'll need to copy the kernel
  215.    image (e.g. .../linux/arch/i386/boot/bzImage after compilation)
  216.    to the place where your regular bootable kernel is found.

  217. - Booting a kernel directly from a floppy without the assistance of a
  218.    bootloader such as LILO, is no longer supported.

  219.    If you boot Linux from the hard drive, chances are you use LILO, which
  220.    uses the kernel image as specified in the file /etc/lilo.conf.  The
  221.    kernel image file is usually /vmlinuz, /boot/vmlinuz, /bzImage or
  222.    /boot/bzImage.  To use the new kernel, save a copy of the old image
  223.    and copy the new image over the old one.  Then, you MUST RERUN LILO
  224.    to update the loading map! If you don't, you won't be able to boot
  225.    the new kernel image.

  226.    Reinstalling LILO is usually a matter of running /sbin/lilo.
  227.    You may wish to edit /etc/lilo.conf to specify an entry for your
  228.    old kernel image (say, /vmlinux.old) in case the new one does not
  229.    work.  See the LILO docs for more information.

  230.    After reinstalling LILO, you should be all set.  Shutdown the system,
  231.    reboot, and enjoy!

  232.    If you ever need to change the default root device, video mode,
  233.    ramdisk size, etc.  in the kernel image, use the 'rdev' program (or
  234.    alternatively the LILO boot options when appropriate).  No need to
  235.    recompile the kernel to change these parameters.

  236. - Reboot with the new kernel and enjoy.

  237. IF SOMETHING GOES WRONG:

  238. - If you have problems that seem to be due to kernel bugs, please check
  239.    the file MAINTAINERS to see if there is a particular person associated
  240.    with the part of the kernel that you are having trouble with. If there
  241.    isn't anyone listed there, then the second best thing is to mail
  242.    them to me (torvalds@linux-foundation.org), and possibly to any other
  243.    relevant mailing-list or to the newsgroup.

  244. - In all bug-reports, *please* tell what kernel you are talking about,
  245.    how to duplicate the problem, and what your setup is (use your common
  246.    sense).  If the problem is new, tell me so, and if the problem is
  247.    old, please try to tell me when you first noticed it.

  248. - If the bug results in a message like

  249.      unable to handle kernel paging request at address C0000010
  250.      Oops: 0002
  251.      EIP:   0010:XXXXXXXX
  252.      eax: xxxxxxxx   ebx: xxxxxxxx   ecx: xxxxxxxx   edx: xxxxxxxx
  253.      esi: xxxxxxxx   edi: xxxxxxxx   ebp: xxxxxxxx
  254.      ds: xxxx  es: xxxx  fs: xxxx  gs: xxxx
  255.      Pid: xx, process nr: xx
  256.      xx xx xx xx xx xx xx xx xx xx

  257.    or similar kernel debugging information on your screen or in your
  258.    system log, please duplicate it *exactly*.  The dump may look
  259.    incomprehensible to you, but it does contain information that may
  260.    help debugging the problem.  The text above the dump is also
  261.    important: it tells something about why the kernel dumped code (in
  262.    the above example, it's due to a bad kernel pointer). More information
  263.    on making sense of the dump is in Documentation/oops-tracing.txt

  264. - If you compiled the kernel with CONFIG_KALLSYMS you can send the dump
  265.    as is, otherwise you will have to use the "ksymoops" program to make
  266.    sense of the dump (but compiling with CONFIG_KALLSYMS is usually preferred).
  267.    This utility can be downloaded from
  268.    ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops/ .
  269.    Alternatively, you can do the dump lookup by hand:

  270. - In debugging dumps like the above, it helps enormously if you can
  271.    look up what the EIP value means.  The hex value as such doesn't help
  272.    me or anybody else very much: it will depend on your particular
  273.    kernel setup.  What you should do is take the hex value from the EIP
  274.    line (ignore the "0010:"), and look it up in the kernel namelist to
  275.    see which kernel function contains the offending address.

  276.    To find out the kernel function name, you'll need to find the system
  277.    binary associated with the kernel that exhibited the symptom.  This is
  278.    the file 'linux/vmlinux'.  To extract the namelist and match it against
  279.    the EIP from the kernel crash, do:

  280.      nm vmlinux | sort | less

  281.    This will give you a list of kernel addresses sorted in ascending
  282.    order, from which it is simple to find the function that contains the
  283.    offending address.  Note that the address given by the kernel
  284.    debugging messages will not necessarily match exactly with the
  285.    function addresses (in fact, that is very unlikely), so you can't
  286.    just 'grep' the list: the list will, however, give you the starting
  287.    point of each kernel function, so by looking for the function that
  288.    has a starting address lower than the one you are searching for but
  289.    is followed by a function with a higher address you will find the one
  290.    you want.  In fact, it may be a good idea to include a bit of
  291.    "context" in your problem report, giving a few lines around the
  292.    interesting one.

  293.    If you for some reason cannot do the above (you have a pre-compiled
  294.    kernel image or similar), telling me as much about your setup as
  295.    possible will help.  Please read the REPORTING-BUGS document for details.

  296. - Alternatively, you can use gdb on a running kernel. (read-only; i.e. you
  297.    cannot change values or set break points.) To do this, first compile the
  298.    kernel with -g; edit arch/i386/Makefile appropriately, then do a "make
  299.    clean". You'll also need to enable CONFIG_PROC_FS (via "make config").

  300.    After you've rebooted with the new kernel, do "gdb vmlinux /proc/kcore".
  301.    You can now use all the usual gdb commands. The command to look up the
  302.    point where your system crashed is "l *0xXXXXXXXX". (Replace the XXXes
  303.    with the EIP value.)

  304.    gdb'ing a non-running kernel currently fails because gdb (wrongly)
  305.    disregards the starting offset for which the kernel is compiled.
复制代码


链接:https://github.com/tnishinaga/linux_stm32f7

3

主题

39

帖子

567

积分

高级会员

Rank: 4

积分
567
板凳
发表于 2016-10-8 14:26:45 | 只看该作者
没有明白这个是什么用的???

134

主题

405

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
11808
5#
发表于 2016-10-10 11:07:37 | 只看该作者
注册成为机智云开发者,手机加虚拟设备快速开发
github的作者可能是日本的呢~~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

加入Q群 返回顶部

版权与免责声明 © 2006-2024 Gizwits IoT Technology Co., Ltd. ( 粤ICP备11090211号 )

快速回复 返回顶部 返回列表