如何向一块ARM裸板移植linux系统

合集下载

交叉编译HTOP并移植到ARM嵌入式Linux系统

交叉编译HTOP并移植到ARM嵌入式Linux系统

交叉编译HTOP并移植到ARM嵌⼊式Linux系统原创作品,允许转载,转载时请务必以超链接形式标明⽂章、作者信息和本声明,否则将追究法律责任。

最近⼀直在完善基于Busybox做的ARM Linux的根⽂件系统,由于busybox是⼀个精简的指令集组成的简单⽂件系统,其优点就是极精简,满⾜了Linux基本的启动需求,由于它⼏乎没有什么后台服务,对于追求极度裁剪的系统开发者⽽⾔是⼀个⾮常好的体验,不过,也正是由于其精简,很多我们在开发测试中使⽤的⼯具或者库也可能都没有,这对于开发者⽽⾔也增加了⼀定的移植⼯作量,笔者最近正被各种移植⼯具软件和库⽂件深深折磨着,今天主要说⼀下⼀个⽐较实⽤的⼯具HTOP的移植过程。

htop是什么 htop——⼀个可以让⽤户与之交互的进程查看器。

作为⽂本模式的应⽤程序,主要⽤于控制台或X终端中。

当前具有按树状⽅式来查看进程,⽀持颜⾊主题,可以定制等特性。

与top相⽐,htop有以下优点: 1、可以横向或纵向滚动浏览进程列表,以便看到所有的进程和完整的命令⾏。

2、在启动上,⽐ top 更快。

3、杀进程时不需要输⼊进程号。

4、htop ⽀持⿏标操作。

5、top 已经很⽼了。

htop移植  1、编译环境 Host机:ubuntu-16.10(64bit) Target: arm 交叉⼯具链:arm-linux-gnueabi-gcc ⼯具包: ncurses-5.9.7: https:///cMkkk9pDiuu7G (提取码:2488) htop-1.0.2: https:///cMkknBsW6T5kp (提取码:b16f) 2、编译前准备 下载两个压缩包,放在/home/liangwode/test⽬录下,解压缩两个压缩⽂件夹,并创建编译安装⽬录。

tar xvzf ncurses.tar.gztart xvzf htop-1.0.2.tar.gzmkdir install_ncursesmkdir install_htop 3、编译ncurses 由于htop依赖于ncurses库,因此需要先编译ncurses,进⼊ncurses⽬录,并配置交叉编译cd ncurses-5.9./configure --prefix=/home/test/install_ncurses --host=arm-linux-gnueabi --without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs --without-tests --with-shared 编译并安装ncurses库make && make install 这样在/home/test/install_ncurses⽬录下就⽣成了ncurses的库和头⽂件等⽂件bin include lib share 4、编译htop 进⼊htop⽬录,并配置htop交叉编译选项,注意需通过LDFLAGS指定ncurses库所在的⽬录并通过CPPFLAGS指定ncurses头⽂件所在的⽬录cd htop-1.0.2./configure --prefix=/home/liangwode/test/install_htop --disable-unicode --host=arm-linux-gnueabi LDFLAGS=-L/home/liangwode/test/install_ncurses/lib CPPFLAGS=-I/home/liangwode/test/install_ncurses/include/ncurses 编译并安装htopmake && make install完可成后可以在在/home/liangwode/test/install_htop⽬录下⽣成安装完⽂件。

基于嵌入式ARM9的Linux系统移植的研究和实现

基于嵌入式ARM9的Linux系统移植的研究和实现

2020年第8期信息与电脑China Computer & Communication软件开发与应用基于嵌入式ARM9的Linux 系统移植的研究和实现冯宁波 周 剑(苏州长风航空电子有限公司,江苏 苏州 215151)摘 要:笔者以ARM9处理器为硬件,对嵌入式系统展开分析,并对安装到嵌入式ARM9芯片开发板上的Linux 系统移植进行研究。

Linux 系统移植步骤如下:首先初始化随机存取存储器,设置堆栈,引导加载程序移植;然后下载Linux 内核,修改Makefile 文件,设计交叉编译环境;最后依据内核启动过程,指定启动初始值,控制后台,并执行制作菜单配置命令。

关键词:嵌入式ARM9;Linux 系统;移植;内核中图分类号:TP311.54;TP316.81 文献标识码:A 文章编号:1003-9767(2020)08-078-02Research and Implementation of Linux System Migration Based on EmbeddedARM9Feng Ningbo, Zhou Jian(Suzhou Changfeng Avionics Co., Ltd., Suzhou Jiangsu 215151, China)Abstract: The author takes ARM9 processor as hardware, analyzes the embedded system, and studies the Linux systemporting installed on the embedded ARM9 chip development board. The steps of Linux system porting are as follows: first, initialize random access memory, set stack, boot loader porting; then download Linux kernel, modify makefile file, and design cross compiling environment; finally, according to the kernel startup process, specify the initial startup value, control the background, and execute thecommand of making menu configuration.Key words: embedded ARM9; Linux system; transplantation; kernel0 引言微电子技术快速发展使计算机技术支持下的嵌入式系统得到广泛应用,该系统因软硬件可裁剪、使用性能良好,受到人们青睐[1]。

arm版本linux系统的启动流程

arm版本linux系统的启动流程

arm版本linux系统的启动流程ARM架构是一种常见的处理器架构,被广泛应用于嵌入式设备和移动设备中。

在ARM版本的Linux系统中,启动流程是非常重要的,它决定了系统如何从开机到正常运行。

本文将详细介绍ARM版本Linux系统的启动流程。

一、引导加载程序(Bootloader)引导加载程序是系统启动的第一阶段,它位于系统的固化存储器中,比如ROM或Flash。

在ARM版本的Linux系统中,常用的引导加载程序有U-Boot和GRUB等。

引导加载程序的主要功能是加载内核镜像到内存中,并将控制权转交给内核。

二、内核初始化引导加载程序将内核镜像加载到内存后,控制权被转交给内核。

内核初始化是系统启动的第二阶段,它主要完成以下几个步骤:1. 设置异常向量表:ARM架构中,异常是指硬件产生的中断或故障,比如系统调用、中断请求等。

内核需要设置异常向量表,以便正确处理异常。

2. 初始化处理器:内核对处理器进行初始化,包括设置页表、启用缓存、初始化中断控制器等。

3. 启动第一个进程:内核创建第一个用户进程(一般是init进程),并将控制权转交给它。

init进程是系统中所有其他进程的父进程,负责系统的初始化工作。

三、设备树(Device Tree)设备树是ARM版本Linux系统中的一种机制,用于描述硬件设备的相关信息。

在内核初始化过程中,内核会解析设备树,并建立设备树对象,以便后续的设备驱动程序使用。

设备树描述了硬件设备的类型、地址、中断等信息,以及设备之间的连接关系。

它使得内核能够在运行时自动识别和配置硬件设备,大大提高了系统的可移植性和灵活性。

四、启动初始化(Init)启动初始化是系统启动的第三阶段,它是用户空间的第一个进程(init进程)接管系统控制权后的操作。

启动初始化主要完成以下几个任务:1. 挂载根文件系统:启动初始化会挂载根文件系统,使得用户可以访问文件系统中的文件和目录。

2. 加载系统服务:启动初始化会加载并启动系统服务,比如网络服务、日志服务、时间同步服务等。

ARM板TL_WN725N usb wifi Linux Driver 移植

ARM板TL_WN725N usb wifi Linux Driver 移植

ARM板TL_WN725N USB Wifi Driver 移植内容描述:2014-12-15,TL_WN725N USB Wifi Linux Driver 移植。

操作1:确定型号插入TP-link USB wifi,提示UT@utcooker:/data # 插入前后lsusbBus 001 Device 007: ID 0bda:8179得知idVendor=0bda, idProduct=8179,确认芯片型号为8188eu,TL-WN725N V2版本。

UT@utcooker:/data # netcfgsit0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00ip6tnl0 DOWN 0.0.0.0/0 0x00000080 00:00:00:00:00:00操作2:测试驱动1)Realtek官方暂无8188eu linux 驱动。

下载相近型号芯片驱动源码。

进入os_dep\linux\usb_intf.c 查看RTL8192C_USB_IDS无{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8187)}2)github 下载驱动rtl8188eu-master.tar (经测试,热插拔有问题)rtl8188EUS_linux_v4.1.4_6773.20130222.tar.gz(可用)RTL8188EUS_RTL8189ES_linux_v4.1.7_9024.20130916.zip(可用)操作3:修改内核以RTL8188EUS_RTL8189ES_linux_v4.1.7_9024.20130916.zip为例,移植过程如下:1)确认linux内核有以下配置:[*] Networking support --->-*-Wireless ---><*> cfg80211 - wireless configuration API[*] cfg80211 wireless extensions compatibility2)打开makefileCONFIG_PLATFORM_I386_PC = y 改为CONFIG_PLATFORM_I386_PC = nCONFIG_PLATFORM_ARM_S3C2K4 =n 改CONFIG_PLATFORM_ARM_S3C2K4 = y 配置编译链及内核源码地址ifeq ($(CONFIG_PLATFORM_ARM_S3C2K4), y)EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIANARCH := armCROSS_COMPILE := /opt/FriendlyARM/gcc-toolschain/4.5.1/bin/arm-linux-KSRC := /svn/pengdonghui/Android_maize/linux-3.5-newEndif3)make –j32后得到8188eu.ko放入开发板:adb push 8188eu.ko /data加载驱动模块:UT@utcooker:/data # insmod 8188eu.ko[18668.230000] bFWReady == _FALSE call reset 8051...[18668.260000] usbcore: registered new interface driver rtl8188eu 查看网络设备:UT@utcooker:/data # ifconfig -a…wlan0 Link encap:Ethernet HWaddr 08:57:00:98:6B:31BROADCAST MULTICAST MTU:1500 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)此时,此时能看到网络接口,Android界面setting 无法打开wifi。

简述内核移植的具体步骤

简述内核移植的具体步骤

简述内核移植的具体步骤嘿,朋友们!今天咱就来唠唠内核移植这档子事儿。

啥是内核移植呢?就好比你有个超级棒的灵魂,想给它换个新身体,让它在新环境里继续大展拳脚。

首先呢,你得把原来的内核好好研究研究,就像了解一个老朋友一样,知道它的脾气、喜好。

这可不能马虎,不然咋知道该怎么给它挪窝呀!然后呢,选好新的目标环境,这就跟给灵魂找新家似的,得合适才行。

你可不能随随便便找个地儿就塞进去,那可不行。

接下来,就是最关键的一步啦!要把内核的代码啊、数据啊啥的,小心翼翼地搬到新环境里。

这可不像搬个桌子椅子那么简单,这得精细着来,不能有一点差错。

就好像给一个精致的瓷器搬家,轻不得重不得。

搬完了还不算完事儿,还得调试调试。

这就好比新搬了家得看看水电通不通,家具摆得合不合适。

要是有啥问题,赶紧解决,可不能留隐患。

在这过程中,你可得有耐心啊!别嫌麻烦,就跟盖房子似的,一砖一瓦都得认真对待。

你想想,要是房子盖得不结实,那能住得安心吗?而且啊,这可不是一个人能搞定的事儿,得团队合作。

大家齐心协力,各显神通,才能把这事儿干得漂亮。

这就跟一场足球比赛似的,每个人都有自己的位置和任务,只有配合好了,才能赢下比赛。

有时候可能会遇到难题,别着急,别慌张。

想想办法,多试试几种途径,说不定就柳暗花明又一村了呢!总之呢,内核移植可不是个简单的活儿,但只要咱认真对待,一步一个脚印,就一定能成功。

这就像爬山,虽然过程辛苦,但当你站在山顶俯瞰美景的时候,你就会觉得一切都值得啦!所以,加油吧,朋友们!让我们一起征服内核移植这座大山!。

在Linux操作系统上进行数据库迁移

在Linux操作系统上进行数据库迁移

在Linux操作系统上进行数据库迁移数据库迁移是将现有的数据库从一个系统或环境迁移到另一个系统或环境的过程。

针对Linux操作系统上的数据库迁移,本文将为您介绍一种常用的方法,以保证迁移过程顺利进行。

一、准备工作在进行数据库迁移前,首先需要完成以下准备工作:1. 安装目标环境:在Linux操作系统上安装并配置好目标数据库,确保其版本与原数据库一致。

2. 备份源数据库:使用适当的备份工具对源数据库进行备份,以防止数据丢失。

3. 确保网络连接:确保源数据库和目标数据库之间的网络连接畅通。

二、迁移步骤下面是在Linux操作系统上进行数据库迁移的步骤:1. 导出源数据库使用源数据库管理系统提供的工具,如mysqldump、pg_dump等,导出源数据库的数据和结构。

命令示例:```$ mysqldump -u username -p password database_name >database_dump.sql```2. 将导出文件传输至目标服务器使用文件传输工具,如scp、rsync等,将导出的数据库文件(database_dump.sql)传输至目标服务器。

命令示例:```$ scp database_dump.sql username@target_server:/path/to/directory ```3. 导入数据库至目标服务器在目标服务器上,使用目标数据库管理系统提供的工具,如mysql、psql等,导入数据库文件。

命令示例:```$ mysql -u username -p password database_name </path/to/directory/database_dump.sql```4. 数据库配置调整在目标服务器上,根据实际需求对数据库进行配置调整,包括用户权限、表空间设置等。

5. 迁移测试在目标服务器上,执行一些简单的数据库操作,如查询、插入、更新等,验证数据库迁移是否成功。

linux系统迁移流程

linux系统迁移流程

linux系统迁移流程
1. 收集系统信息
在迁移系统之前,首先要收集系统信息。

包括:
(1)硬件清单和设置,如处理器、存储介质、网络,硬件间的互连接细节,如接口卡以及相应的号码;
(2)系统软件,包括操作系统、基础软件,如语言运行时环境、软件编译器及其他基础设施;
(3)应用软件的详细信息,包括应用软件版本号、功能、安装方式以及与其他应用软件的交互细节;
(4)系统的当前状态,包括系统上的数据、目前的登录用户状态等。

2. 迁移方案开发
具体的迁移方案开发,可以采用系统流程文档的方式,或是绘制流程图的方式,都可以,通常如果迁移系统较复杂,则可以采用流程文档的方式,而在系统迁移的过程中,建议收集系统中的相关信息。

3. 确定迁移期程
确定系统的实际迁移期程。

考虑到系统安装、运行及应用软件的部署时间,需要把握好每个步骤的时间顺序,加以安排。

在确定迁移期程时,要注意系统稳定性,故障开发时间以及整体工期质量。

4. 准备移植软件
在确定迁移期程以后,再根据迁移期程以及系统收集的信息,准备移植软件。

准备移植软件时,要考虑两点:一是要选择正确的操作系统和应用软件;二是对于操作系统的软件语言的的移植,要确保系统的功能没有受影响。

5. 测试系统
完成系统移植后,就要进行系统测试,测试的内容有:操作系统的安装,检查系统性能以及软件数据与原系统及恢复数据的正确性。

6. 文档处理
最后,在系统迁移流程完成以后,要编写系统的相关安装文档,记录迁移过程中可能的偏差,并且要收集相应的历史记录,以便进行完善。

嵌入式Linux在ARM上的移植

嵌入式Linux在ARM上的移植

指 Ln x支 持 的 文 件 系 统 , 如 步 骤 基 本 一 致 , 但 移 植 的 难 度 iu
短 产 品 的 研 发 周 期 。 这 样 的 嵌 全 开 放 的 前 提 下 , 不 同 领 域 和 Ma a e ) 标 准 Ln x内 存 管 ngr iu
入 式操 作 系 统具 有 以下特 点 : ◆ 较 好 的实 时性 ; ◆ 系统 可 靠性 高 ; 不 同 层 次 的 用 户 可 以根 据 自 己 理 支 持 虚 拟 内 存 , 程 的 代 码 、 进 的 应 用 需 要 很 容 易 地 对 内 核 进 数 据 和 堆 栈 的 总 量 可 以超 过 实 行 改 造 , 低 成 本 的 前 提 下 , 际 内存 的 大 小 。 iu 大 致 可 以 在 设 Ln x
Ln x操 作 系 统 。 嵌 入 式 Ln x iu iu
内核 系 统 组 成 。 在 内 核 代 码 完
底层 硬 件 细 节 , 程序 易 调 试 、 使
易 移植 、易 维 护 ,并且 能 够 缩
是 由很 多 体积 小 且 性 能高 的微 系 统组 成 : ◆ 内 存 管 理 ( em Or M Y
建 立开发环境
目标 平 台 介 绍
在 对芯 片第 一 次擦 写 时 ,
首 先 对 其 寄 存 器 等 进 行 初 始
化 。在 PC 机 上 W id ws环 境 no
Ln x 核 与 具 体 的 目标 平 下 , 在 ADS 软 件 环 境 下 通 过 iu 内 台 相 关 ,不 同 的 目 标 平 台 移 植 J AG 仿 真 器 在 线 调 试 将 初 始 T 化 程 序 下 载 到 芯 片 中 。 将
维普资讯
L n x是 一 个 源 代 码 免 费 公 开 的 操 作 系统 , 有 很 强 的 移 植 性 。 本 文 描 述 了将 iu Ln x移 植 到 ARM 目标 板 上 的 通 用 方 法 , 并 结 合 实 例 说 明 了如 何 建 立 交 叉 编 译 环 iu 境 ,修 改 B o L a e ,有 效 地 将 Ln x内核 及 文 件 系 统 移 植 到 目标 板 上 ,并 对 这 种 o to d r iu
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

11. How to port Linux to a raw ARM boardThis document provides a summary of the steps when porting Linux to a new ARM platform ora new processor. In this page we assume that the reader has a knowledge of C and assemblyprogramming and is familiar with ARM and operating systems concepts such as interrupt handling, system calls and memory management.Some useful information can be found in the kernel documentation section on how to configure the kernel itself. It is probably best to familiarize with Linux on x86 before if you are not familiar with embedded platforms. In addition to Linux kernel source documentation, some notes maintained by community members are available on booting and setting up Linux for ARM platforms, you can consult the following kernel document and Vincent Sander‟s documentation for additional information.Porting steps∙Install a cross-development environment.∙Setup the board and ensure that the serial port is working so we can print data through the serial port.∙Download and install the Linux kernel, most of the porting work will be done at this level.∙Add board specific code into the kernel tree.∙Build a kernel image to run on the board∙Test that early kernel printk is working∙Get the real printk working with the serial console.∙For a new board, a new board-specific directory should be added as well as support for interrupt handling, kernel timer services and mapping for memory areas.∙Ethernet drivers are usually the next drivers to focus on as they enable setup of NFS root file system to get access to user utilities and applications.∙Filesystem can be provided in different forms which are listed on LinuxFilesystemDevelopment environmentDevelopment for embedded platforms is usually done using cross-development tools. In the case of Linux, the host platform is often a Linux host computer connected to the target board using Ethernet, serial and/or ICE/JTAG.The GNU compiler is required to build the Linux kernel. There is more information on downloading and installing GNU tools is available on LinuxDevTools. Other compilers compliant with the new ABI for the ARM Architecture can also be used to compile user-space applications and some libraries.Install and build the Linux kernelDownload the latest stable release of the Linux kernel sources from and install the source in your local directory. Working from the latest kernel source base is preferred as older versions will not be supported by the community. Later kernel versions usually contain recent bug fixes and enhancements. Older kernels such as 2.4 kernels are no more actively supported.Adding board specific codeSupport code for a new board consist in processor support, board specific code including where devices are mapped etc. and device drivers. Source code for device drivers is based in the drivers/ directory and net/ directories. Board specific code should be placed into the arch/arm/ directory.The following sections will use ARM Versatile PB926EJ-S as an example and assume that the processor support code already exist. The board intialisation and definition files are located in the arch/arm/mach-versatile directory. ARM Versatile board comes in two different form factors, a compact version (Application Baseboard) and a expandable version (Platform Baseboard). This directory contains the following files:∙clock.[c,h] – Functions handling clock settings∙core.[c,h] –IRQ initialisation, definition of initial IO mappings and low-level platform initialisation∙dma.[c,h] – DMA support code and initialisation∙pci.c – PCI setup∙versatile_[ab,pb].c – board initialisation with functions such as versatile_init(), etc.The MACHINE_START() macro defined at the end of versatile_pb.c contains the base definition for this platform, using initialisation functions defined in other platform files in this directory.Header files are located in a similar directory: include/asm-arm/. In the case of versatile files are located in include/asm-arm/arch-versatile/.∙platform.h – contains register definitions for peripherals and controllers on the board∙debug-macro.S –contains definition of the “addruart” macro called by the printk() function to print data on the serial port∙irqs.h – IRQ register definitions∙system.h – contains idle() and reset() functions.∙vmalloc.h – defines constants such as VMALLOC_END.∙…Connecting it to the main build systemCreate a Kconfig file for the board in arch/arm/mach-versatile/ to link this board to the overall build system so that it can be selected when running make *config. Refer to Documentation/kbuild/kconfig-language.txt for a description of the syntax.A Makefile entry need to exist to enable the systen to recurse into the platform sub-directories.Use Makefiles from existing boards as starting points and modify as appropriate.Platform IDFinally, add your machine group and type ID. A unique identifier can be obtained by registering your machine at /developer/machines/. You could initially assign a local ID in arch/arm/tools/mach-types while developing your BSP locally and then register it to get an official ID. You must be careful when changing kernel version as new machine are regularly added and make sure this doesn‟t conflict with the ID you have chosen.This ID is used very early in the boot process to determine the platform type and pull in the correct initialisation functions. It is used by the boot loader and stored in banked registers(i.e.r1) before the bootloader hands over to the kernel.Device driversNew device driver should be added in the appropriate directories, net/ for network drivers or drivers/ for others. Makefiles and Kconfig files also need to be edited (or created) so they are linked to the rest of the system. The following book provide a good guide on how to develop new device drivers with Linux.If the board contains controllers or devices for which Linux already has support for, we only need to include these in Kconfig files and pass the correct parameters to these drivers when initialisation is done.Configure and build a kernel imageEnsure that the cross-toolchain program names are correct and accessible from your execution path (i.e. your PATH environment variable).To configure the kernel you can use some of the following command:∙make xconfig∙make menuconfig∙make gconfig∙…These commands assume that you have a cross-compiler accessible on your execution path.∙If support is set to be EXPERIMENTAL, select …Prompt for developmen t and/or incomplete code/drivers‟ under …Code maturity level options‟.∙In System Type, select VERSATILE and correct subtype if this is a family of boards.∙Select the right CPU under …CPU selection‟ (in the case of Versatile there is one CPU currently for this type of board).∙In the …Device Drivers‟ -> …Character devices‟ select the appropriate device driver (ARM_AMBA_PL011 in the case of Versatile).∙In …Boot options‟ you can also enter your CMDLINE boot parameters. This will only be used as default in case the bootloader doesn‟t provide any command line.For other options you can either use the default or select …No‟. The resulting configuration file is stored as .config in the top level directory.We can now type make dep and make to build a kernel image. If successful, the resulting image is placed in the arch/arm/boot directory. You can either build a compressed image (zImage) or a raw binary image (Image). The ELF file containing debug information (if selected in the Makefile) is called vmlinux and is at the top-level directory. When loading a kernel image onto the board using a debugger, you should use either zImage or Image files.The vmlinux image can be loaded to perform symbolic debugging.Kernel bootEarly signs of a working Linux kernel come from the output of printk(), which is routed directly to the first console. Having configured a serial console, we should be able to see some kernel messages on the serial port if it has been setup correctly. Note that often the bootmonitor from the board or the boot loader initialises the serial device, however the kernel should not necessarily rely on this.The setup of the serial console happens much later during the kernel initialisation process.Chances are your new kernel probably dies even before that which is where early printk are useful. printk() allows you to print text as early as the first line of C code. The early initialisationsteps are listed in init/main.c:start_kernel(). From this you can see that the console_init() call is done later on after we already had calls to printk().Early printk() is very useful, however the serial driver should be working to enable further debug. For Versatile platforms, the serial driver is in drivers/serial/amba-pl011.c.Debug with kgdbKGDB enables developers to debug the kernel while running and set breakpoints or do single stepping at source code level. If available, you can use two serial ports on the target, one used for KGDB communication and the other to print messages. You should use a crossover-cable (or null-modem) to connect it to your development host. Doing everything using one serial port is also possible.You should select the Remote GDB kernel debugging which is listed under Kernel hacking when you configure the kernel and then do a …make clean‟ and recompile the kernel to make sure that debugging symbols are compiled into the generated Linux image.Run the new kernel image. At this stage the kernel will be waiting for a gdb client connection. If there is a cross-over serial cable connected between the serial port on the target and the host, you can then set the appropriate baud rate and start the gdb on your host:∙stty -F /dev/ttyS0 38400∙arm-none-linux-gnueabi-gdb vmlinuxAt the gdb prompt, type: target remote /dev/ttyS0If successful, you should be talking to the kernel through KGDB.Interrupt handlingWhen porting the kernel to a new board it often hangs in the calibration step. This is normal if the interrupt code is not yet implemented in which case jiffies are never updated. Beforeadding support code for interrupt handling you need to identify interrupt controllers, all interrupt sources and how they are routed.The following steps are involved to handle interrupts:∙include/asm-arm/arch-versatile/entry-macro.S: this file contains a macro called get_irqnr defined used to determine the interrupt number when an interrupt is generated. This function is board specific.∙arch/arm/kernel/entry-armv.S: this file contains the definition of the irq_handler() which in turn calls the asm_do_IRQ() function which handles all hardware IRQs.∙arch/arm/kernel/irq.c: this file contains most of the code handling interrupts including the definition of asm_do_IRQ() as well as enabling or disabling specific interrupts numbers.Individual IRQ handlers are invoked by the __do_irq() function.A descriptor structure (see irqdesc structure in include/asm-arm/mach/irq.h) is associated witheach registered IRQ source. This structure contains pointers to functions declared by device drivers to handle individual interrupts.System time and timerLinux relies on a system timer to advance the tick count, jiffies. Without this, Linux won‟t run and will stop in calibrate_delay() during the startup process as jiffies will never be incremented.Access to a real-time clock (RTC) device is also required to obtain the calendar date and time when the kernel boots up.ARM Versatile board includes primecell SP804 which provide facilities for periodic timers. One of the timers is used to generate system ticks. This is done at the end of arch/arm/mach-versatile/core.c with the definition and initialisation of the versatile_timer structure.。

相关文档
最新文档