Linux内核移植开发手册
gec-6818 嵌入式linux开发指导手册

gec-6818 嵌入式linux开发指导手册嵌入式Linux开发指导手册是针对GEC-6818嵌入式开发板的用户提供的一份使用手册,旨在帮助开发者了解如何在GEC-6818上进行嵌入式Linux开发,并提供一些开发过程中可能遇到的问题和解决方案。
本文将从以下几个方面进行介绍和指导。
一、GEC-6818简介GEC-6818是一款基于ARM架构的嵌入式开发板,搭载了Cortex-A53四核处理器,主频高达 1.3GHz,拥有丰富的外设接口和扩展能力,适合用于嵌入式Linux系统的开发和应用。
本章将介绍GEC-6818的主要硬件组成和接口定义,以便开发者能够快速上手使用。
二、嵌入式Linux系统搭建本章将介绍如何搭建嵌入式Linux系统,并详细介绍了系统的编译和安装过程。
主要内容包括交叉编译工具链的安装、内核的编译和配置、文件系统的构建和配置等。
同时,还会提供一些常见的问题和解决方案,帮助开发者尽快搭建起自己的开发环境。
三、设备驱动开发设备驱动是嵌入式Linux开发中一个重要的环节,本章将介绍设备驱动的基本概念和开发过程。
主要内容包括字符设备驱动、块设备驱动、网络设备驱动等。
同时,还会提供一些实例代码和开发技巧,帮助开发者更好地理解和掌握设备驱动的开发。
四、应用程序开发应用程序开发是嵌入式Linux开发中的另一个重要环节,本章将介绍如何在GEC-6818上进行应用程序的开发。
主要内容包括交叉编译环境的搭建、编写Makefile文件、调试应用程序等。
同时,还会提供一些常见的应用程序开发技巧和调试方法,帮助开发者快速进行应用程序开发。
五、远程调试和调优远程调试和调优是嵌入式Linux开发中的重要环节之一,本章将介绍如何在GEC-6818上进行远程调试和调优。
主要内容包括通过串口进行调试、使用GDB进行调试、使用sysbench进行性能测试等。
同时,还会提供一些常见的调试和调优技巧,帮助开发者尽快定位和解决问题。
RK3128开发板Linux开发手册

如何恢复正常启动 ......................................................................................................... 14 第三章 Ubuntu Server 使用 ............................................................................................... 15 3.1 网络 .................................................................................................................................. 15 3.1.1 以太网 ................................................................................................................... 15 3.1.2 静态 IP ................................................................................................................. 16 3.1.3 WiFi ...................................................................................................................... 17 3.2 安装服务器软件包 .......................................................................................................... 18 3.2.1 列出任务 ............................................................................................................... 18 3.2.2 列出需要安装的软件包 ....................................................................................... 19 3.2.3 安装服务器任务 ................................................................................................... 19 3.3 密码 .................................................................................................................................. 20 3.3.1 系统....................................................................................................................... 20 MySQL ........................................................................................................................... 20 3.4 测试 .................................................................................................................................. 20 第四章 双系统启动的设计和实现 ....................................................................................... 21 4.1 前言 .................................................................................................................................. 21 4.2 安卓系统的启动流程 ...................................................................................................... 21 4.3 双启动系统的设计 .......................................................................................................... 22 4.4 双启动系统的实现 .......................................................................................................... 23 4.4.1 分区....................................................................................................................... 23 4.1.2 misc 分区的格式 ................................................................................................ 27 4.4.3 保留安卓急救系统 ............................................................................................... 29
君正 Linux 2.4 开发手册

君正Linux 2.4开发手册Revision: 1.2Date: Jan. 2008君正Linux 2.4开发手册Copyright © Ingenic Semiconductor Co. Ltd 2006. All rights reserved.Release historyDate Revision ChangeJan. 2008 1.2 Add description to section overviewNov. 2007 1.1 Modify NAND flash filesystem descriptionAdd mplayer demo descriptionAdd guide to start the TFTP and NFS serversMay. 2007 1.0 First releaseDisclaimerThis documentation is provided for use with Ingenic products. No license to Ingenic property rights is granted. Ingenic assumes no liability, provides no warranty either expressed or implied relating to the usage, or intellectual property right infringement except as provided for by Ingenic Terms and Conditions of Sale.Ingenic products are not designed for and should not be used in any medical or life sustaining or supporting equipment.All information in this document should be treated as preliminary. Ingenic may make changes to this document without notice. Anyone relying on this documentation should contact Ingenic for the current documentation and errata.北京君正集成电路有限公司北京市海淀区上地东路1号盈创动力E座801CTel: 86-10-58851002Fax: 86-10-58851005Http: //内容内容1概述 (1)2开发环境 (3)2.1安装交叉编译工具链 (3)2.2启动TFTP和NFS服务 (4)3Linux内核和驱动 (5)3.1Linux的目录结构 (5)3.2配置和编译Linux (6)3.3Linux配置选项 (7)4Linux根文件系统 (13)4.1根文件系统的内容 (13)4.2制作根文件系统 (13)4.2.1配置和编译BusyBox (13)5测试Linux内核和驱动 (16)5.1运行Linux内核 (16)5.2测试Linux设备驱动 (16)6NAND Flash文件系统 (19)6.1NAND Flash文件系统类型 (19)6.2MTD分区 (19)6.3创建NAND Flash文件系统 (20)7Linux电源管理 (22)7.1动态电源管理 (22)7.2系统睡眠和唤醒 (24)概述1 概述本文将向读者详细介绍基于君正处理器平台进行Linux 2.4内核开发的过程和方法,引导开发人员快速进行Linux开发,包括建立交叉编译环境、引导程序和Linux内核的配置和编译、设备驱动的测试和使用、根文件系统等等。
Tina Linux 系统软件 开发指南说明书

Tina Linux系统软件开发指南版本号:1.5发布日期:2021.04.17版本号日期制/修订人内容描述0.12019.02.20AWA1225创建1.02019.02.27AWA1225正式发布1.12019.06.16AWA1046补充软件包安装,烧录工具及分区说明1.22019.06.19AWA1046更新文档说明和目录结构说明,补充细节1.32020.12.31AWA1610增加arisc代码编译描述1.42021.02.06AWA1610arisc代码编译策略变更1.52021.04.17AWA0985完善部分章节描述1概述11.1编写目的 (1)1.2适用范围 (1)1.3相关人员 (1)2Tina系统资料22.1概述 (2)2.2文档列表 (2)3Tina系统概述33.1概述 (3)3.2系统框图 (3)3.3开发流程 (4)4Tina开发环境64.1概述 (6)4.2编译环境搭建 (6)4.2.1开发主机配置 (6)4.2.2软件包配置 (6)5Tina系统获取85.1概述 (8)5.2SDK获取 (8)5.3SDK结构 (8)5.3.1build目录 (8)5.3.2config目录 (9)5.3.3devices目录 (9)5.3.4docs目录 (10)5.3.5lichee目录 (10)5.3.6package目录 (10)5.3.7prebuilt目录 (11)5.3.8scripts目录 (11)5.3.9target目录 (11)5.3.10toolchain目录 (12)5.3.11tools目录 (12)5.3.12out目录 (12)5.4SDK更新 (13)5.5问题反馈 (13)6Tina编译打包156.1概述 (15)6.2编译系统 (15)6.3编译boot (15)6.4编译内核 (15)6.5编译arisc (16)6.6重编应用 (17)6.6.1方法一 (17)6.6.2方法二 (17)6.7其他命令 (18)7Tina系统烧写197.1概述 (19)7.2烧录工具 (19)7.3进入烧录模式 (19)8Tina uboot定制开发218.1概述 (21)8.2代码路径 (21)8.3uboot功能 (21)8.4uboot配置 (22)8.4.1defconfig方式 (22)8.4.1.1defconfig配置步骤 (22)8.4.1.2defconfig配置宏介绍 (22)8.4.2menuconfig方式 (23)8.5uboot编译 (24)8.5.1方法一 (24)8.5.2方法二 (25)8.6uboot的配置 (25)8.6.1sys_config配置 (25)8.6.1.1sys_config.fex结构介绍 (25)8.6.1.2sys_config.fex配置实例 (25)8.6.1.3sys_config.fex解析流程 (26)8.6.2环境变量配置 (26)8.6.2.1环境变量作用 (27)8.6.2.2环境变量配置示例介绍 (27)8.6.3sys_partition.fex分区配置 (28)8.6.3.1sys_partition.fex分区配置介绍 (28)9Tina kernel定制开发299.1概述 (29)9.2代码路径 (29)9.3模块开发文档 (29)9.4内核配置 (29)10Tina系统定制开发3110.1应用移植 (31)10.1.1Makefile范例 (31)10.1.2自启动设置 (33)10.1.2.1调用自启动脚本 (33)10.1.2.2sysV格式脚本 (33)10.1.2.3procd格式脚本 (34)10.2应用调试 (35)10.3应用编译 (36)10.4应用安装 (36)10.5分区与挂载 (37)3-1Tina Linux系统框图 (3)3-2Tina Linux系统开发流程 (4)8-1defconfig配置图 (22)8-2defconfig基本宏定义介绍图 (23)8-3menuconfig配置菜单图 (24)8-4sysconfig.fex基本结构图 (25)8-5platform配置图 (26)8-6target配置图 (26)8-7uart_para配置图 (26)8-8uboot启动调用环境变量方式图 (27)8-9kernel cmdline图 (28)9-1TinaLinux内核配置菜单 (30)10-1应用配置主界面 (35)10-2软件包所在界面 (36)1.1编写目的本文档作为Allwinner Tina Linux系统平台开发指南,旨在帮助软件开发工程师、技术支持工程师快速上手,熟悉Tina Linux系统的开发及调试流程。
linux 2.6 kernel移植到QEMU Mips的源代码文档.

Port Linux 2.6 Kernel to Qemu MipsAuthor: Joy Tang2009.1Version 1.02Overview•Use open source to study, no confidential information inside.•If we need deep view inside linux, we must understand what kernel do.•This doc is for build up mips for linux environment run on X86 emulator machine.I, Build Kernel•Target•Main CPU: QEMU emulate Mips•Cross Compile:mips-linux•Develop Environment: Red Hat•Notes, QEMU also support melta board, and MIPSsim. Reference web page: https:///mailarchive/git-commits-head/2008/1/29/636729/thread, from version linux 2.6.25, it remove qemu mips inside.Prepare Working•Prepare Working:•Download source code of Linux:•Annymos login •Go to the folder "/pub/linux/kernel/v2.6" inside FTP.•Get the source code:tar -jxvf linux-2.6.22.19.tar.bz2•2.6.21 will be another choice.Add Toolchain to Search Path•vi /etc/profile, add following lines•PATH="$PATH:/opt/hardhat/devkit/mips/lexra_fp_b e/bin"•PATH="$PATH:/opt/hardhat/devkit/mips/lexra_fp_b e/target/bin"•PATH="$PATH:/opt/build_mips_nofpu/mips-uClibc-linux/usr/bin“•…Change Makefile•vi Makefile, search SUBARCH•Change toSUBARCH := mips•Find CROSS_COMPILE, change toCROSS_COMPILE ?= mips-linux-•vi arch/mips/Makefile, search cflags-y:=, if it is cflags-y:= mips1, change it to cflags-y:=•The change base on user itself environment.Start to Build, Step1•Make config or make menuconfig or make xconfig •Change CPU to QEMU•Add support for “Initial RAM filesystem and RAM disk”. (Initial RAM filesystem and RAM disk (initramfs/initrd) support (BLK_DEV_INITRD) [N/y/?] n change to Y)•Change many other settings, such as MAP_RAM, MTD support, MTD_PLATRAM•Attach .config file for reference. (end of this doc)•File system analyses•In company file system, there are 4 mtds, •1, busybox=> mtd1•2, kernel=>mtd2•3, workdir=>mtd3•4, jffs etc folder=> mtd4•This step will mount all this 4 files.•Change source:go to drivers/mtd/maps.•Run cp cfi_flagadm.c qemuflash.c•Change linux/drivers/mtd/maps/Kconfig, find config MTD_CDB89712, after it, addconfig MTD_QEMU_EMUFLASHtristate"gggggg qemu emu flash”•Also change Makefile under linux/drivers/mtd/maps/ Find obj-$(CONFIG_MTD_CDB89712)+= cdb89712.o, after it, addobj-$(CONFIG_MTD_QEMU_EMUFLASH)+= qemuflash.o•See attach (makefile& kconfig, end of this doc)•For the file, qemuflash.c, there is some comments:•mtd0,mtd1, mtd2 is not used. Mtd3 is for workdir, mtd4 is for jffs etc folder.•Here is attach. (end of this doc)•Go to folder \fs\jffs2, open earse.c, line 350, function jffs2_block_check_erase, add a qemu patch#ifdef CONFIG_QEMU#elseprintk(KERN_WARNING"Newly-erased block ……#endif•Goto root folder, run make config, press enter until it quit. This is for correct errors in the file “.config”•Run build commandmake all•Run commandcp -f ./vmlinux/opt/emularor/qemu/mips/myimages2…After that, kernel elf file will be send to qemu folderII, Build Qemu•Download qemu packet on web/qemu/download.html•Get the file /qemu/qemu-0.9.1.tar.gz •Uncompress it. In order to save time, inside file config-host.mak: change TARGET_DIRS to mips-softmmu.•Open root folder\vl.c•Add following lineschar g_mtdFileName_etcSave[1024];char g_mtdFileName_workdir[1024];•At beginning of main function, addmemset(g_mtdFileName_etcSave, 0, 1024);memset(g_mtdFileName_workdir, 0, 1024);At the end of function drive_init, add following lines if (type == IF_PFLASH && g_mtdFileName_etcSave[0] == 0){//mtd will load to bios mem, save file name firstsprintf(g_mtdFileName_etcSave, "%s", file);}if (type == IF_MTD && g_mtdFileName_workdir[0] == 0){//mtd will load to bios mem, save file name firstsprintf(g_mtdFileName_workdir, "%s", file);}•Go to “hw”folder, open mips_r4k.c, add following lines •extern char g_mtdFileName_etcSave[1024]; //2M •extern char g_mtdFileName_workdir[1024]; //30M•#define START_ADDR_ETC_SAVE 0x1fc00000•#define SIZE_ETCSAVE 0x00200000•#define START_ADDR_WORKDIR 0x1fe00000•At the end of function, mips_r4k_init, add following lines, add processing of g_mtdFileName_etcSave andg_mtdFileName_workdir.Build QEMU Step 3(continue) if (g_mtdFileName_etcSave[0]){bios_offset= ram_size+ vga_ram_size;bios_size= load_image(g_mtdFileName_etcSave, phys_ram_base+ bios_offset);if ((bios_size> 0) && (bios_size<= BIOS_SIZE))cpu_register_physical_memory(START_ADDR_ETC_SAVE,BIOS_SIZE, bios_offset| IO_MEM_ROM);else/* not fatal */ fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",buf);}if (g_mtdFileName_workdir[0]){bios_offset= ram_size+ vga_ram_size+ SIZE_ETCSAVE;bios_size= load_image(g_mtdFileName_workdir, phys_ram_base+ bios_offset);if ((bios_size> 0) && (bios_size<= BIOS_SIZE))cpu_register_physical_memory(START_ADDR_WORKDIR,BIOS_SIZE, bios_offset| IO_MEM_ROM);else/* not fatal */fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",buf);}Attach mips_r4k.c, end of this doc•Open root folder sysemu.h, change 4m to 32m#define MAX_BIOS_SIZE (32 * 1024 * 1024)…#elif defined(TARGET_MIPS)#define BIOS_SIZE (32 * 1024 * 1024) //we want use bios ram to be mtd area #endif•Here is attach file for it. (end of this doc)•Run following command: ./configuremakemake installIII, Build busybox •Find web /downloads/, choose/downloads/busybox-1.6.1.tar.bz2•Uncompress it.•Change make file, like the build kernel,•vi Makefile, search SUBARCH•Change toSUBARCH := mips•Find CROSS_COMPILE, change toCROSS_COMPILE ?= mips-linux-Build busybox Step2•make xconfig•Change settings for it, make sure the mount & fdisk is inside.•make\n•make install\n•cd./_install\n•rm dev -rf\n•cp /opt/source/flashmaster_prxxx_fe-1.0.linux-2.6-2/res/1.0/rootfs.mips_nofpu/dev/ ./dev -rf\n•cd-\n•cp -f --reply=yes /opt/source/flashmaster_prxxx_fe-1.0.linux-2.6-2/res/1.0/rootfs.mips_nofpu/sbin/portmap ./_install/sbin\n•../flashmaster_prxxx_fe-1.0.linux-2.6-2/bin/mkcramfs -Nb_install/ a.mtd\n •cp -f --reply=yes a.mtd../emulator/qemu/mips/\nIV,MTD files, step 1•There are 4 MTD files in real system, now we design each to a file,•A, MTD1, it will be busy-box => -initrd“filename”•B, MTD2, it will be kernel=>-kernel “filename”•C, MTD3, it will be workdir=>-mtdblock“filename”•D, MTD4, it will jffs2 format etc/save=>-pflash“filename”•MTD files Step 2•For 1st, busybox, run following command to create it cd/opt/…/flashmaster_prxxx_fe-1.0.linux-2.6-2/res/1.0 mkdir rootfs.mips_nofpu/dev/netmknod rootfs.mips_nofpu/dev/net /tun c 10 200chmod0666 rootfs.mips_nofpu/dev/net /tun../../bin/mkcramfs -Nb rootfs.mips_nofpu a.mtd•or directly use exist one “mtd1.img”.•For 2nd, use build kernel file “vmlinux”•For 3rd, use workdir•For 4th, run following command../../bin/mkfs.jffs2 -o etcsave.mtd-d ./etc -e 65535 -p ff -bComments of MTD•For 1st, parameter –initrd use it as ram-disk. It will loaded to ram of qemu memory space.•For 2nd, parameter –kernel use same concept of 1st.•For 3rd, it emulate a flash, it start address will be 2M, 0x1fc00000 + 0x00200000, size 30M, 0x01E00000•For 4th, its start address will be 0M0x1fc00000 + 0x0000000, size 2MV, Create script fileto run kernel •Its contentsinitarg="init=/linuxrc root=/dev/hda root2=/dev/hd18" mtdparameter="-mtdblock./boot/workdir.mtd“pflashparameter="-pflash./boot/etcsave.mtd“time \${qemupath}qemu-system-mips\-kernel ./myimages2/vmlinux \-initrd a.mtd\-append "console=ttyS0 $initarg" \-nographic\-m 128 \$pflashparameter\$mtdparameter\-net nic,vlan=1 -net user,vlan=1Comments for the script file•-nographic can be removed. If it is exist, qemu emulator will not show command console, we can use secure-crt’s SSH2 account to do this.•If it is not exist, we must run under x window in linuxAdd function for readphysical memory in QEMU •Add a function in monitor.c, do_phymemory_save •Detail is in attachment monitor.cFor run qemu command•Use graphic, ctrl+alt+2•Run command•Here is help:•help|? [cmd] --show the help•commit device|all--commit changes to the disk images (if -snapshot is used) or backing files •info subcommand --show various information about the system state•q|quit--quit the emulator•eject [-f] device --eject a removable medium (use -f to force it)•change device filename --change a removable medium•screendump filename --save screen into PPM image 'filename'•logfile filename --output logs to 'filename'•log item1[,...] --activate logging of the specified items to '/tmp/qemu.log'•savevm tag|id--save a VM snapshot. If no tag or id are provided, a new snapshot is created •loadvm tag|id--restore a VM snapshot from its tag or id•delvm tag|id--delete a VM snapshot from its tag or id•stop --stop emulation•c|cont--resume emulation•gdbserver[port] --start gdbserver session (default port=1234)•x /fmt addr--virtual memory dump starting at 'addr'•xp/fmt addr--physical memory dump starting at 'addr'•p|print/fmt expr--print expression value (use $reg for CPU register access)•i /fmt addr--I/O port read•sendkey keys --send keys to the VM (e.g. 'sendkey ctrl-alt-f1')•system_reset--reset the system•system_powerdown--send system power down event•sum addr size --compute the checksum of a memory region•usb_add device --add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')•usb_del device --remove USB device 'bus.addr'•cpu index --set the default CPU•mouse_move dx dy[dz] --send mouse move events•mouse_button state --change mouse button state (1=L, 2=M, 4=R)•mouse_set index --set which mouse device receives events •wavcapture path [frequency bits channels] --capture audio to a wave file (default frequency=44100 bits=16 channels=2)•stopcapture capture index --stop capture•memsave addr size file --save to disk virtual memory dump starting at 'addr' of size 'size'•pmemsave addr size file --save to physical memory memory dump starting at 'addr' of size 'size'VI,Study on mount cd iso,harddiskand share files•1)For mount hda and cdrom correctly, we need open following kernel options:•A, ATA IDE support option.•B, VFS support•C, CDROM ISO9660 file system support•(“make xconfig”to find&open it. Recompile and build kernel again)•2)Go to /dev folder inside root file system prepare folder, run following command:•mknod hdc b 22 0•3)inside run-qemu script file, add•-cdrom./cd.ISO-hda linux.img.•(cd.ISO can be any cdrom iso file, linux.img copy fromhttp://lassauge.free.fr/qemu/release/Qemu-0.9.1-windows.zip. ./share is a folder for share between qemu and host x86 linux system)•4)After all file prepared, in qemu kernel, test this:•mount /dev/hda/tmp3 => hda will be linux.img’s data•mount /dev/hdc/tmp4 => hdc will be cdrom’s dataMount(continued)Now I want to share data with vmware. Here is steps to share data with vmware:1, inside vmware, create a IDE harddisk disk, select persistent and independent. Minimum size is 0.1GB, (100MB). Suppose it use hdd inside vmware, its file name is “vmware-qemu-flat.vmdk”. When generate it, choose a special folder for it. It is for share purpose.2, let the share folder inside a folder /mnt/hgfs. (The other topic, vmware tools.)3, inside vmware, run command: fdisk/dev/hdd. Use “n”command to create a new partition.4, inside vmware, run mkfs/dev/hdd. Then vmdk file is formatted. Copy new vmdk file to qemu’s folder, suppose it is “./share”. Make sure don’t format other partition inside vmware. ☺5, add parameter in run qemu-mips-system script: -hda/mnt/hgfs/share-qemu/vmware-qemu-flat.vmdk. Start the qemu-mips-system. Use this command in vm: mount /dev/hda/tmp3.6, With upper steps, the vmdk file can be share between qemu and vmware. It will be useful to share files.7, Before transfer the vmdk files between vmware and qemu, pls run “sync”. It is for write buffer’s data. “sync”may not enough. Maybe need “poweroff”VII. GDB for debug kernel•Step1, need re-build kernel. Run “make xconfig”, open many options in “kernel hacking”, such as “compile kernel with debug info”etc.After compile, we can find kernel image size change from about 4m to about 20m. This is normal.•Step2,use X window linux, in command script, remove –nographic, add a paramter–S, it is for stop kernel and wait for gdb command.•Step3, after qemu window start, you will see black screen but press Ctrl-Alt-3 to see bash prompt. Press Ctrl-Alt-2, go to qemu command window, press “gdbserver”, at this time, qemu will start to listen port 1234.•Step4, start another linux terminal, run “mips-linux-gdb vmlinux”, in gdb, run command “(gdb)target remote localhost:1234”, you will find gdb can trace kernel now.VIII network1, host preparation in linux •From /progDownload/tunctl-Download-41592.html download tunctl-1.5.tar.gz•Comment 2 lines,•#docbook2man $(PACKAGE).sgml•#install $(MAN) $(DESTDIR)$(MAN_DIR)•make•make install•Find if host linux kernel have “tun.ko”•[root@...~]# find /lib -name "tun.ko"•/lib/modules/2.6.9-22.EL/kernel/drivers/net/tun.konetwork•Goto guest kernel folder, run “make xconfig”•Find “network device support”=> “other ISA cards”=>”ne2000/ne1000 support”, open it.•Re-compile your guest kernel after the change.network•-----------------------------------------"create /usr/local/sbin/tap.sh file (e1000g0 is network card label, this file is at host) -----------------------------------------#!/bin/sh•IF=e1000g0•TAP=tap0•case "$1" in•"start")•sudo tunctl-t $TAP•ifconfig$TAP plumb•brdgadm-a $IF•brdgadm-a $TAP•;;•"stop")•#brdgadm-d $IF•#brdgadm-d $TAP•ifconfig$TAP unplumb•sudo tunctl-d $TAP•;;•esac•exit 0•------------------------------------# /usr/local/sbin/tap.sh start## /usr/local/sbin/tap.sh stop------------------------------------network•After run “tap.sh start”on host of linux, we check if tun.ko is probed: “lsmod | grep tun“,•tun 9153 0•And also we check if tap0 device is power up,•ifconfig –a, we can find a new device tap0 is power on.•We can run following command in host linux:“ifconfig tap0 192.168.200.1“.•Create a file, vi /etc/qemu-ifup#!/bin/shifconfig$1 192.168.200.10Network2, guest•Add following string to qemu-run script:•-net nic,vlan=1,macaddr=00:aa:00:00:01:01 -net tap,vlan=1,ifname=tap0•Startup qemu-system-mips by the added script file.•In guest linux shell, run:•ifconfig eth0 192.168.200.11•ping -c 4 192.168.200.1 to check if network is ok.Network error•I meet this error:•# ping -c 3 192.168.200.10•PING 192.168.200.10 (192.168.200.10): 56 data bytes•NETDEV WATCHDOG: eth0: transmit timed out•NETDEV WATCHDOG: eth0: transmit timed out•---192.168.200.10 ping statistics ---• 4 packets transmitted, 0 packets received, 100% packet loss•After I change this file, arch/mips/kernel/i8259.c , I solve the issue on guest linux2.6.21.•add .disable = disable_8259A_irq,on line 39•[root@localhost linux-2.6.21.7]#diff ./arch/mips/kernel/i8259.c ./arch/mips/kernel/i8259_test.c•39d38•< .disable = disable_8259A_irq•Reference web for the patch:•/mm-commits@/msg24505.html or •/Mailing-Lists/Kernel/2007-07/msg12733.html3, Network prepare inhost Windows XP host system•1, go to /BBS/thread-3209-1-1.html, download tapnic.rar.•After click “addtap.bat”, a new driver for virtual XP network is generated. Please rename it to tap0.•Reference web http://www.h7.dion.ne.jp/~qemu-win/TapWin32-en.html.XP windows hostprepare for network •Force IP address of tap0:Windows XPprepare•Run this command for windows XP:•qemu-system-mips.exe-L . -m 192 -kernel .\myimages2\vmlinux -initrd a.mtd-append "console=ttyS0 init=/linuxrc root=/dev/hda pci=noapicisa=noapic" -M mips-cdrom./cd.ISO-hda./share/vmware-qemu-flat.vmdk-net nic,vlan=1,macaddr=00:aa:00:00:01:01 -net tap,vlan=1,ifname=tap0,vlan=1,ifname=tap0•Guest OS preparation same as upper mentioned hostlinux+guest linux.Rootfs changefor the network•In order to mount nfs server on host linux or windows host, I add nfs support in guest kernel option, but still cannot mount nfs folder.•Later I add follow lines in rc.sysinit and solve the unable mount issue.ifconfig lo 127.0.0.1netmask255.0.0.0 broadcast 127.255.255.255 portmapmount -t ramfs ramfs/tmp-o maxsize=4000More Host Preparationfor Network•1, windows, for NFS work, need install cygwin, make sure NFS module is installed. We need edit “C:\cygwin\etc\hosts”and “C:\cygwin\etc\exports”for NFS setting•2, Linux, make sure NFS work. It is at “start menu”=>”system setting”=> “server setting”=> “nfs setting”Malta board(Mips24k)& Graphics study•MTD_PHYSMAP need to be closed.•Because Malta board has graphics card support, now I start to study malta board.•1) get svn code from internet:•svn co svn:///qemu/trunk•2)don’t change anything on qemu code like before because there is a crash on change code and I find workdir also can be mounted on /dev/hdc. Also don’t need to change guest kernel code, it can be optional.•3)copy malta/.config to guest kernel folder. Build guest kernel with 2 commands: make config, make allMalta (continue)•4, create a script file, my-run-qemu without graphic support(in attachment, /malta/script) and another script file, graphics-qemu with graphic support. •run the graphic script file. For malta board, we don’t need change arch/mips/kernel/i8259.c like the fake qemu board.•Under guest linux, run “mount /dev/hdc/tmp3”to check if workdir is mounted on /tmp3.Some capture imageon malta platform•Graphic display after press “ctrl+alt+1”•After run some command, network mount is working.Futher topic & summerize•There are still 1 important topics Emulate every device inside Mips chip.•That’s all•Because pdf file don’t support *.rar file asas attachment, pls rename the txt to rar.。
Linux2.6内核移植系列教程

Linux2.6内核移植系列教程第一:Linux 2.6内核在S3C2440平台上移植此教程适合2.6.38之前的版本,其中2.6.35之前使用同一yaffs补丁包,2.6.36--2.6.28 yaffs文件系统有所改变,2.6.39之后的暂时不支持,源码下载请到:/1.解压linux-2.6.34.tar.bz2源码包#tar jxvf linux-2.6.34.tar.bz22.修改linux-2.6.34/Makefile文件,在makefile中找到以下两条信息并做修改ARCH ? =armCROSS_COMPILE?=/usr/local/arm/4.3.2/bin/arm-linux-注意:交叉编译器的环境变量也需要改为4.3.2#export PATH=/usr/local/arm/4.3.2/bin/:$PATH其中ARCH变量用来决定:配置、编译时读取Linux源码arch目录下哪个体系结构的文件PATH 用来决定交叉编译器版本3.修改机器类型ID号Linux源码中支持多种平台的配置信息,内核会根据bootloader传进来的mach-types决定那份平台的代码起作用,本人手里的板子是仿照三星公司官方给出的demo板改版而来,所以采用arch/arm/mach-s3c2440/mach-smdk2440.c此配置文件,打开此文件,翻到最后,有以下信息:MACHINE_START(S3C2440, "SMDK2440")/* Maintainer: Ben Dooks <ben@> */.phys_io= S3C2410_PA_UART,.io_pg_offst= (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,.boot_params= S3C2410_SDRAM_PA + 0x100,.init_irq= s3c24xx_init_irq,.map_io= smdk2440_map_io,.init_machine= smdk2440_machine_init,.timer= &s3c24xx_timer,MACHINE_ENDMACHINE_START(S3C2440, "SMDK2440")决定了此板子的mach-types,可以在以下文件中找到S3C2440对应的具体数字,"arch/arm/tools/mach-types"文件查找S3C2440,362,这里刚好与我们的bootloader相同,所以不用做修改,直接保存退出即可,如果不同则根据bootloader的内容修改此文件,或根据此文件修改boorloader的内容(在vivi中可通过param show查看,u-boot在Y:\test\u-boot_src\u-boot_edu-2010.06\board\samsung\unsp2440\unsp2440.c文件:gd->bd->bi_arch_number = MACH_TYPE_S3C2440;中决定)。
第4章 Linux内核裁剪与移植 Linux系统移植(第2版) 教学课件

4.1 Linux内核结构 4.2 内核配置选项 4.3 内核裁剪及编译 4.4 内 核 升 级
4.1.2 内核源码目录介绍
Linux内核代码以源码树的形式存放,如 果在安装系统的时候已经安装了源码树, 其源码树就在/usr/src/linux下。
1.arch目录
禁用随机heap(heap堆是一个应用层的概念,即堆对CPU是不可见的,它 的实现方式有多种,可以由OS实现,也可以由运行库实现,也可以在一个 栈中来实现一个堆)
Choose SLAB allocator Profiling support Kprobes
选择内存分配管理器,建议选择 支持系统评测,建议不选 探测工具,开发人员可以选择,建议不选
5.init目录
init子目录包含核心的初始化代码(注意, 不是系统的引导代码)。它包含两个文件 main.c和version.c,这是研究核心如何工 作的一个非常好的起点。
6.ipc目录
ipc子目录包含核心进程间的通信代码。 Linux下进程间通信机制主要包括管道、 信号、消息队列、共享内存、信号量、套 接口。
Physical 选择XIP后,内核存放的物理地址
Kexec system call
Kexec系统调用
4.2.4 网络协议支持相关选项
菜单选项(Networking Support)的子菜 单中包含一些网络协议支持的选项。
选项名 Networking options Amateur Radio support
arch子目录包括了所有和体系结构相关的 核心代码。它的每一个子目录都代表一种 支持的体系结构,例如arm子目录是关于 ARM平台下各种芯片兼容的代码。
文档:、linux-308内核I2C触摸屏移植

Linux3.0.8平台搭建移植文档——I2C触摸屏移植1.I2C子系统goodix电容屏采用I2C接口与处理器连接,我们要首先确保linux内核拥有对I2C子系统的支持,下面我们从子系统的配置和电容屏驱动两个方面进行移植修改1)配置I2C子系统支持#make menuconfigDevice Drivers ---><*> I2C support --->[*] Enable compatibility bits for old user-space (NEW)<*> I2C device interface< > I2C bus multiplexing support (NEW)[*] Autoselect pertinent helper modules (NEW)I2C Hardware Bus support --->进入I2C Hardware Bus support选项,选中以下内容:*** I2C system bus drivers (mostly embedded / system-on-chip) ***< > Synopsys DesignWare (NEW)<*> GPIO-based bitbanging I2C< > OpenCores I2C Controller (NEW)< > PCA9564/PCA9665 as platform device (NEW)<*> S3C2410 I2C Driver< > Simtec Generic I2C interface (NEW)...2.GOODIX电容屏移植1)添加goodix电容屏驱动将“goodix_touch.c”文件copy到drivers/input/touchscreen/目录下,并将"goodix_touch.h"、"goodix_queue.h"文件copy到include/linux/目录下,并修改Kconfig文件及Makefile文件支持触摸屏驱动的配置和编译#vi driver/input/touchscreen/Kconfig在config TOUCHSCREEN_TPS6507X选项的后面添加以下内容:config TOUCHSCREEN_GOODIXtristate "GOODIX based touchscreen"depends on I2ChelpIt is a android driver to support Gooidx's touchscreen whose nameis guitar on s5pv210 platform. The touchscreen can support multi-touch not more than two fingers.Say Y here to enable the driver for the touchscreen on theS5V SMDK board.If unsure, say N.To compile this driver as a module, choose M here:the module will be called goodix_touch.ko.#vi driver/input/touchscreen/Makefile在文件最后添加如下内容:obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix_touch.o2)添加i2c_board_info资源(电容屏)#vi arch/arm/mach-s5pv210/mach-smdkv210.c在smdkv210_i2c_devs0结构体数组定义中添加以下内容:...{ I2C_BOARD_INFO("24c08", 0x50), }, /* Samsung S524AD0XD1 */ { I2C_BOARD_INFO("wm8580", 0x1b), },{I2C_BOARD_INFO("Goodix-TS", 0x55),.irq = IRQ_EINT(4),},...3)配置电容屏选项#make menuconfigDevice Drivers --->Input device support --->...[*] Touchscreens ---><*> GOODIX based touchscreen4)make将在arch/arm/boot/下生成编译好的可执行程序zImage下载到开发板即可,执行命令“cat /dev/input/event0”,然后用手触摸屏幕会在终端看到输出打印的乱码信息,表示移植成功,如果没有打印信息或没有“/dev/input/event0”这个设备说明移植失败。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
江苏中科龙梦科技有限公司Linux内核移植开发手册修 订 记 录项 次 修订日期 版 本修订內容修订者审 核1 2009‐02‐04 0.1 初版发行陶宏亮,胡洪兵2 2009‐11‐20 0.2 删除一些多余文字陶宏亮,胡洪兵DISCLAIMERTHIS DOCUMENTATION IS PROVIDED FOR USE WITH LEMOTE PRODUCTS. NO LICENSE TO LEMOTE PROPERTY RIGHTS IS GRANTED. LEMOTE ASSUMES NO LIABILITY, PROVIDES NO WARRANTY EITHER EXPRESSED OR IMPLIED RELATING TO THE USAGE, OR INTELLECTUAL PROPERTY RIGHT INFRINGEMENT EXCEPT AS PROVIDED FOR BY LEMOTE TERMS AND CONDITIONS OF SALE.LEMOTE PRODUCTS ARE NOT DESIGNED FOR AND SHOULD NOT BE USED IN ANY MEDICAL OR LIFE SUSTAINING OR SUPPORTING EQUIPMENT.ALL INFORMATION IN THIS DOCUMENT SHOULD BE TREATED AS PRELIMINARY. LEMOTE MAY MAKE CHANGES TO THIS DOCUMENT WITHOUT NOTICE. ANYONE RELYING ON THIS DOCUMENTATION SHOULD CONTACT LEMOTE FOR THE CURRENT DOCUMENTATION AND ERRATA.JIANGSU LEMOTE TECHNOLOGY CORPORATION LIMITEDMENGLAN INDUSTRIAL PARK,YUSHAN,CHANGSHU CITY,JIANGSU PROVINCE,CHINATel: 0512‐52308661Fax: 0512‐52308688Http: //目 录1. Linux内核移植开发手册 (4)1.1 内核源码访问途径 (4)1.2 内核的编译环境及其配置 (4)1.2.1本地编译 (4)1.2.2 交叉编译 (4)1.2.3 内核配置 (5)1.3 如何编译内核和内核模块 (5)1.3.1 编译内核 (5)1.3.2 编译内核模块 (6)1.4 龙芯平台代码移植框架 (6)1.4.1 创建文件结构框架 (6)1.4.2 Loongson2f cpu 支持 (7)1.4.3 特定平台的支持 (7)1.4.4 PCI子系统 (8)1.5 龙芯平台代码描述 (8)1.5.1中断 (8)1.5.2 PMON内核读写模块 (13)1.6 龙芯优化补丁描述 (15)1.6.1 Uncache accelerate (15)1.6.2 CS5536 Audio DMA (优化补丁) (16)1. Linux内核移植开发手册1.1 内核源码访问途径如果系统自带了内核源码,你可以在/usr/src/目录下找到它,一般会以压缩文件呈现。
如 linux‐source‐x.x.xx‐tar.bz2(其中x.x.xx标示了内核版本号)。
在其所在目录下,通过: tar ‐xvf linux‐source‐x.x.xx‐tar.bz2命令来解压此压缩包,阅读,学习。
在内核源码根目录下的arch/mips/lemote/子目录中, 包含龙芯平台相关的大部分代码。
如果你没有龙芯电脑,你可以通过网站浏览到Linux内核源码,网址是:/code/linux_loongson它是由git管理的龙芯相关项目开发的一个子项目,在这里,你可以跟踪此项目的每一次改动克隆到本地,创建分支,做你自己开发,使用:git‐clone git:///linux_loongson当然,前提是你的电脑里已经安装了git工具.关于git的介绍和使用,你同样可以在这个开 发网站的热门文章里找到,也可以访问以下链接:/drupal/node/211.2 内核的编译环境及其配置1.2.1本地编译在建立编译环境前,建议您在/etc/apt/sources.list中加入龙芯官方源deb /debian‐loongson loongson contrib main non‐freedeb /debian testing contrib main non‐free并使用 apt‐get update 更新以启用源。
安装gcc:apt‐get install gcc更新/usr/bin/下的as文件:下载地址:/files/toolchain/kernel/asmv /usr/bin/as /usr/bin/as‐bak /*备份以前的as*/cp as /usr/bin/ /*拷贝到下载的as,到指定目录*/1.2.2 交叉编译相对于本地编译, 交叉编译是一种更简单,快捷的编译方法,你只需要一套额外的交叉编译工具就可以在速度更快的pc平台甚至服务器上编译龙芯平台可执行的程序,内核。
需要下载交叉编译工具:gcc‐3.4.6‐newbin.ls2f.tar.gz下载地址: /debian‐loongson/code/解压,一般放到/opt目录下,:tar ‐xzf gcc‐3.4.6‐newbin.ls2f.tar.gz ‐C /opt然后在环境变量中制定其路径:export PATH=/opt/gcc‐3.4.6‐newbin/bin:$PATH或者写入~/.bashrc中,便于多次使用:export PATH=/opt/gcc‐3.4.6‐newbin/bin:$PATH设置可执行权限chmod +x /opt/gcc‐3.4.6‐newbin/bin ‐R现在就可以在主机上编译龙芯平台可运行的内核了。
1.2.3 内核配置在内核源码根目录输入: make menuconfig 会打开内核配置的图形界面。
进行内核的配置, 当然对于龙芯平台不熟悉的人,从开头逐项进行内核配置是困难,迷惑的.我们提供了默认配置,你只需要在此基础上修改你所需要变更的选项。
在源码根目录下: cp arch/mips/config/ls2f_xxxx_defconfig .config(其中xxxx,为分支平台标记)注: 目前在arch/mips/config/目录下,有3个龙芯平台的配置文件fulong_defconfig 为福珑2E mini PC的默认配置文件ls2f_fulong_defconfig 为福珑2F mini PC 的默认配置文件ls2f_notebook_defconfig 为福珑 2F 笔记本的默认配置文件然后再进行 make menuconfig你会看到默认配置已经写到配置界面中去了,它本身已经是一个附带多种功能和支持的可运行的内核配置,你可以在其上添加你想要的,去掉你不喜欢的。
当然,你得清楚你在做什么。
1.3 如何编译内核和内核模块1.3.1 编译内核本地编译情况下,在内核源码根目录下,输入Make来完成内核的编译。
交叉编译情况下, 进入内核源码树根目录下,输入:make ARCH=mips CROSS_COMPILE=mipsel‐linux‐如果你说,你总是会反复编译,调试内核.这样的一条冗长繁琐的命令令你烦恼.人们总喜欢那些一劳永逸的办法, 好吧,修改你内核根目录下的makefile文件:给ARCH变量赋值: ARCH ?= mips给CROSS_COMPILE 变量赋值CROSS_COOMPILE ?= mipsel‐linux‐1.3.2 编译内核模块在make 完以后,实际上配置内核时所选的模块已经都编译好了,只是分别放在其源码所在的位置。
我们只需要把他们安装到文件系统/lib/modules/中去,或者任意指定的目录。
如果想单独编译模块,那么:make modules /*编译内核模块*/make modules_install /*把编译好的模块安装到/lib/modules/下面*/or make modules_install INSTALL_MOD_PATH=dir /*安装到dir目录下*/当然,还有一种情况,你只是想编译单一模块,来添加个别功能. 比如你获得了一个硬公司提供的更好的,更新的网卡,或者显卡驱动.你想做尽量小的 改动,就使用它们,你需要: 进入你想编译的模块所在目录,执行:make ‐C /usr/src/linux‐x.x.xx/ M=`pwd` modules意思是说,先改变目录到你的内核源码树所在位置,编译此内核的模块cp *.ko /lib/modules/`name ‐r`/driver/然后把编译好的模块拷贝到系统模块的默认位置depmod ‐a生成modules.dep 文件和 映射文件modprobe name.ko然后,你就可以用modprobe把模块插入当前运行的内核,使用它1.4 龙芯平台代码移植框架代码移植需要注意的是平台相关中断的管理以及时钟的初始化,除此还需注意文件的结构以及相关配置文件(即Makefile,Kconfig)的修改。
以Fuloong2f 代码为例讲解(具体代码参考git仓库)。
先简单的介绍一下kernel的执行流程:在龙芯平台上通过pmon 将内核文件载入内存,开始运行,在内核开始处将bbs段进行清零处理,建立栈空间。
完成后跳转到 start_kernel(),在start_kernel() 里面完成 arch_setup(), trap_init(), init_IRQ(), time_init(),init_mem(),init_ console()等等的初始化,rest_int() 启动init kerner线程 运行用户空间的/sbin/init进程等。
1.4.1 创建文件结构框架arch/mips 下面有许多的目录,每个目录对应一块板子。
在该目录下我们创建 arch/mips/lemote/ 将其命名为公司的名字只是为了我们方便管理平台相关的代码。
Loongson主要用于桌面不像其他的SOC ,这样可以尽可能多的共享一些代码。
在下面定义了arch/mips/lemote/lm2e 以及 arch/mips/lemote/lm2f 分别对应于2e以及2f cpu,2f用于yeloong 以及fuloong 为了分别再定义了arch/mipse/lemote/lm2f/lmbox/ 以及 arch/mips/lemote/lm2f/lmbook/。