3.1 linux-4.9.2源码获取
为什么选择4.9.2移植呢?
因为太新的linux源码yaffs文件系统跟不上,编译过程会导致大量错误无法使用,所以选择比较新的源码就可以了。具体的说明到移植yaffs文件系统时再说。
我们的工作目录定在/root下面,进入到目录
root@ubuntu:/home/ubuntu# cd /root
(1)下载linux4.9.2源码
root@ubuntu:~# wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.2.tar.gz
(2)解压源码
root@ubuntu:~ # tar -zxvf linux-4.9.2.tar.gz
(3)修改环境变量
root@ubuntu:~# cd linux-4.9.2/
root@ubuntu:~/linux-4.9.2# vim Makefile
定位到255行,原来的内容是
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
如果是使用ubuntu指令安装的arm-linux-gnueabihf-gcc就改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-gnueabihf-
手动安装的arm-linux-gcc 4.4.3就改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
保存退出ESC :wq
3.2编译测试
设置目标板型号
root@ubuntu:~/linux-4.9.2# make mini2440_defconfig
这时会提示:
The program 'make' can befound in the following packages:
* make
* make-guile
Try: apt install 原因:没有安装make工具,安装一下 root@ubuntu:~/linux-4.9.2#apt install make 再重试,又出错 root@ubuntu:~/linux-4.9.2#make mini2440_defconfig /bin/sh: 1: gcc: not found scripts/Makefile.host:107:recipe for target 'scripts/basic/fixdep' failed make[1]: ***[scripts/basic/fixdep] Error 127 Makefile:448: recipe fortarget 'scripts_basic' failed make: *** [scripts_basic]Error 2 原因:缺少32位的库 解决方法:安装libncurses5等关键库 root@ubuntu:~/linux-4.9.2#apt install libncurses5-dev root@ubuntu:~/linux-4.9.2# apt-get install libx11-dev:i386 libreadline6-dev:i386 root@ubuntu:~/linux-4.9.2#apt-get install build-essential root@ubuntu:~/linux-4.9.2# apt-get install lib32stdc++6 root@ubuntu:~/linux-4.9.2# apt-get install lib32z1 再次运行 root@ubuntu:~/linux-4.9.2# make mini2440_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf # # configuration written to.config # OK,可以了,开始编译测试,这里使用-j8表示使用8个线程进行编译,可以大幅加快编译的速度,-j后面的数值可以根据你的虚拟机设置的实际情况进行选择,一般等于虚拟机的cpu核心数即可,我的虚拟机设置了8个CPU核心,所以-j8 root@ubuntu:~/linux-4.9.2# make -j8 又报错 /bin/sh: 1: bc: not found Kbuild:67: recipe fortarget 'include/generated/timeconst.h' failed 解决方法:安装bc root@ubuntu:~/linux-4.9.2#apt install bc 再次编译,可以运行 可以看到编译过程中CPU已经满载 3.3 为uImage创建脚本 查看zImage生成情况 root@ubuntu:~/linux-4.9.2# cd arch/arm/boot/ root@ubuntu:~/linux-4.9.2/arch/arm/boot# ls bootp compressed dts Image install.sh Makefile zImage 可以看到,生成了zImage 我们的平台使用uboot作为BootLoader,所以需要转换为uImage使用。 (1)先安装u-boot转换uimage工具 root@ubuntu:~/linux-4.9.2/arch/arm/boot# apt-get install u-boot-tools (2)再到Linux源码根目录 root@ubuntu:~/linux-4.9.2/arch/arm/boot# cd ../../.. (3)创建脚本 root@ubuntu:~/linux-4.9.2 # vim mkuImage.sh (4)粘贴如下内容 mkimage -A arm -O linux -Tkernel -C none -a 0x30008000 -e 0x30008040 -n mini2440 -d /root/linux-4.9.2/arch/arm/boot/zImage /root/tftp/uImage (5)赋予可执行权限 root@ubuntu:~/linux-4.9.2# chmod a+x mkuImage.sh (6)运行 root@ubuntu:~/linux-4.9.2# ./mkuImage.sh (7)查看,确认脚本有效 root@ubuntu:~/linux-4.9.2# ls /root/tftp/ uImage 可以看到,tftp文件夹下面已经存在了一个uImage 3.4运行测试 在本系统中,使用了uboot引导,所以要先将uboot烧写进入到nand flash中,然后打开secureCRT,设置好串口。 将开发板上电,按空格进入到uboot控制台,查看一下环境变量 [U-boot@mini2440A]#printenv bootdelay=1 baudrate=115200 ethaddr=08:00:3e:26:0a:5b gatewayip=192.168.1.1 netmask=255.255.255.0 xujun=bmp d 70000 stdin=serial ethact=dm9000 ipaddr=192.168.2.188 serverip=192.168.2.123 bootcmd=tftp 0x30008000uImage;bootm 0x30008000 bootargs=console=ttySAC0,115200n8root=/dev/nfs nfsroot=192.168.2.123:/home/ubuntu/NFS/myrootfs/rootfsip=192.168.2.188:192.168.2.123:192.168.2.1:255.255.255.0:SMDK2440A.arm9.net:eth0:offinit=/linuxrc stdin=serial stdout=serial stderr=serial Environment size:479/131068 bytes 我们的目的是上电之后,uboot直接从tftp文件夹内读取uImage,并启动内核,所以需要配置以下几点 1、设置开发板的ip(根据你的路由网段设置) [U-boot@mini2440A]# setenv ipaddr 192.168.2.188 2、设置服务器的ip(根据实际ip设置) [U-boot@mini2440A]# setenv serverip 192.168.2.104 3、设置uboot,tftp加载内核(tftp 是你的tftp文件夹名字) [U-boot@mini2440A]# setenv bootcmd 'tftp 0x30008000 uImage;bootm 0x30008000' 4、保存参数 [U-boot@mini2440A]# saveenv Saving Environment toNAND... Erasing Nand... Erasing at 0x4000000000002-- 0% complete. Writing to Nand... done 启动测试 [U-boot@mini2440A]# boot dm9000 i/o: 0x20000300, id:0x90000a46 DM9000: running in 16 bitmode MAC: 08:00:3e:26:0a:5b could not establish link Using dm9000 device TFTP from server192.168.2.104; our IP address is 192.168.2.188 Filename 'uImage'. Load address: 0x30008000 Loading: ################################################################# ################################################################# ################################################################# ########## done Bytes transferred = 3006872(2de198 hex) ## Booting kernel fromLegacy Image at 30008000 ... Image Name: mini2440 Created: 2017-09-27 7:06:46 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 3006808 Bytes = 2.9 MB Load Address: 30008000 Entry Point: 30008040 Verifying Checksum ... OK XIP Kernel Image ... OK OK Starting kernel ... Booting Linux on physicalCPU 0x0 Linux version 4.9.2(root@ubuntu) (gcc version 6.3.0 20170406 (Ubuntu/Linaro 6.3.0-12ubuntu2) ) #1Tue Sep 26 23:51:32 PDT 2017 CPU: ARM920T [41129200]revision 0 (ARMv4T), cr=c000717f CPU: VIVT data cache, VIVTinstruction cache Machine: MINI2440 Memory policy: Data cachewriteback CPU S3C2440A (id0x32440001) Built 1 zonelists in Zoneorder, mobility grouping on. Totalpages: 16256 Kernel command line:console=ttySAC0,115200n8 root=/dev/nfsnfsroot=192.168.2.123:/home/ubuntu/NFS/myrootfs/rootfsip=192.168.2.188:192.168.2.123:192.168.2.1:255.255.255.0:SMDK2440A.arm9.net:eth0:offinit=/linuxrc PID hash table entries: 256(order: -2, 1024 bytes) Dentry cache hash tableentries: 8192 (order: 3, 32768 bytes) Inode-cache hash tableentries: 4096 (order: 2, 16384 bytes) Memory: 58868K/65536Kavailable (4309K kernel code, 180K rwdata, 976K rodata, 176K init, 258K bss,6668K reserved, 0K cma-reserved) Virtual kernel memorylayout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xffc00000 - 0xfff00000 (3072kB) vmalloc : 0xc4800000 - 0xff800000 ( 944 MB) lowmem : 0xc0000000 - 0xc4000000 ( 64 MB) modules : 0xbf000000 - 0xc0000000 ( 16MB) .text : 0xc0008000 - 0xc043d660 (4310 kB) .init : 0xc0552000 - 0xc057e000 ( 176 kB) .data : 0xc057e000 - 0xc05ab320 ( 181 kB) .bss : 0xc05ab320 - 0xc05ebf00 ( 259 kB) SLUB: HWalign=32,Order=0-3, MinObjects=0, CPUs=1, Nodes=1 NR_IRQS:103 S3C2440: IRQ Support irq: clearing pendingstatus 00000003 irq: clearing pendingstatus 00000002 sched_clock: 16 bits at1012kHz, resolution 987ns, wraps every 32362962ns clocksource:samsung_clocksource_timer: mask: 0xffff max_cycles: 0xffff, max_idle_ns:28803037 ns Console: colour dummydevice 80x30 Calibrating delay loop...201.52 BogoMIPS (lpj=503808) pid_max: default: 32768minimum: 301 Mount-cache hash tableentries: 1024 (order: 0, 4096 bytes) Mountpoint-cache hash tableentries: 1024 (order: 0, 4096 bytes) CPU: Testing write buffercoherency: ok Setting up static identitymap for 0x300081e0 - 0x30008238 clocksource: jiffies: mask:0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns NET: Registered protocolfamily 16 DMA: preallocated 256 KiBpool for atomic coherent allocations cpuidle: using governorladder MINI2440: Option stringmini2440=0tb MINI2440: 't' ignored,touchscreen not compiled in MINI2440: LCD [0:240x320] 1:800x480 2:1024x768 3:320x240 S3C2440: Initialisingarchitecture usbcore: registered newinterface driver usbfs usbcore: registered newinterface driver hub usbcore: registered newdevice driver usb s3c-i2c s3c2440-i2c.0:slave address 0x10 s3c-i2c s3c2440-i2c.0: busfrequency set to 98 KHz s3c-i2c s3c2440-i2c.0:i2c-0: S3C I2C adapter Advanced Linux SoundArchitecture Driver Initialized. clocksource: Switched toclocksource samsung_clocksource_timer NET: Registered protocolfamily 2 TCP established hash tableentries: 1024 (order: 0, 4096 bytes) TCP bind hash tableentries: 1024 (order: 0, 4096 bytes) TCP: Hash tables configured(established 1024 bind 1024) UDP hash table entries: 256(order: 0, 4096 bytes) UDP-Lite hash tableentries: 256 (order: 0, 4096 bytes) NET: Registered protocolfamily 1 RPC: Registered named UNIXsocket transport module. RPC: Registered udptransport module. RPC: Registered tcptransport module. RPC: Registered tcp NFSv4.1backchannel transport module. futex hash table entries:256 (order: -1, 3072 bytes) workingset:timestamp_bits=30 max_order=14 bucket_order=0 NFS: Registering theid_resolver key type Key type id_resolverregistered Key type id_legacyregistered jffs2: version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc. romfs: ROMFS MTD (C) 2007Red Hat, Inc. io scheduler noopregistered io scheduler deadlineregistered io scheduler cfq registered(default) Console: switching tocolour frame buffer device 60x53 s3c2410-lcd s3c2410-lcd:fb0: s3c2410fb frame buffer device s3c2440-uart.0: ttySAC0 atMMIO 0x50000000 (irq = 74, base_baud = 0) is a S3C2440 console [ttySAC0] enabled
上一篇:Linux-4.9.2内核在mini2440上的移植(二)Ubuntu编译环境搭建(下)
下一篇:基于mini2440的mp3播放器
设计资源 培训 开发板 精华推荐
- LF33CDT-TR 3.3V 极低压降稳压器的典型应用
- LT1070 正向转换器的典型应用
- LT1172CSW、1.25A 驱动高压 NPN 的典型应用
- OP184ESZ 高端负载电流监控器的典型应用
- IS31LT3135-V1GRLS2-EB,基于 IS31LT3135V1 双通道的评估板。 (主/副) LED 驱动器
- 具有基本抑制功能的 LF50CDT-TR 5V 极低压降稳压器的典型应用
- #第五届立创电子设计大赛#低成本升降压型可调电源
- 2021年电赛F题-智能送药小车-国二作品
- LT1236BILS8-5 精密、低噪声、薄型密封电压基准的典型应用电路,以在励磁放大器中提供精确匹配
- 使用 ROHM Semiconductor 的 BD49K42G-TL 的参考设计