MINI2440移植高版本内核

MINI2440移植高版本内核

网上大多大多都是2.6.32版本的内核,因为想要学习设备树相关的知识,所以在2440中移植4.9.2版本的内核,记录一下自己遇到的问题,搭建环境时参考了一个大佬的文章,特此感谢。
linux4.9.2内核在mini2440上的移植

内核版本:linux4.9.2
虚拟机环境:VMware Workstation15 Pro,Ubuntu20.04
编译器环境:arm-linux-gcc v4.4.3,arm-linux-gnueabihf-gcc

  1. 下载linux4.9.2源码到虚拟机并解压
  2. 根据自己的编译环境修改顶层Makefile文件第255行,也就是平台及
    当编译器环境为arm-linux-gcc时,修改为
ARCH            ?= arm
CROSS_COMPILE   ?= arm-linux-gnueabihf-

当编译器环境为arm-linux-gnueabihf-gcc时,修改为

ARCH            ?= arm
CROSS_COMPILE   ?= arm-linux-

注意:写的时候后面一定不能有空格,有空格导致解析工具链出错,make无法成功

  1. 复制平台配置文件到顶层并重命名为.config
    平台配置文件在arch/arm/configs目录下,执行cp ./.mini2440_defconfig ../../../.config

  2. make生成zImage

  Kernel: arch/arm/boot/Image is ready
  Building modules, stage 2.
  Kernel: arch/arm/boot/zImage is ready
  MODPOST 196 modules
  1. arch/arm/boot/下执行mkimage -n 'mykernel' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImage
    其中0x30008000是规定的内核的起始地址为基地址偏移0x80000x30008040应该是因为zImage多了一个64字节的信息头

自此生成了mini2440可以使用的内核

因为是要从头写平台文件,所以要多次编译内核生成uImage并复制到 tftp 目录下,很麻烦,所以写成一个脚本文件,脚本内容为:

mkimage -n 'mykernel' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage ./uImage_4_9_2         
    
cp ./uImage_4_9_2 /home/huizhe/tftp_share/uImage_4_9_2

赋予可执行权限chmod a+x mkuImage.sh

以上工作我们都是在Linux环境下操作,生成了可以在板子上运行的uImage,所以我们接下来配置环境将生成的内核跑在板子上。

  1. 配置板子ip环境
    串口工具为SecureCRT
    s3c2440.jflashuboot.bin文件通过J-Flash ARM软件烧入,连接开发板,连接串口,会显示
U-Boot 2010.03 (Oct 04 2017 - 23:09:46)

DRAM:  64 MB
Flash:  2 MB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000

****************************************************************
        U-BOOT (Ver2010.03) for FriendlyARM MINI2440 Board
        CPU:Sumsung S3C2440A,Memory:64MB,NorFlash:2MB,NandFlash:256MB
        Modified By ZhangLiang,2016-3-18
        Copyright ZHL, All Rights Reserved
******************************************************************
Hit any key to stop autoboot:  0 

printenv查看当前环境

baudrate=115200
bootargs=root=/dev/nfs nfsroot=192.168.152.123:/home/huizhe/rootfs ip=192.168.152.125 console=ttySAC0,115200
bootdelay=5
ethact=dm9000
ethaddr=00:0c:29:4d:e4:f4
mtddevname=u-boot
mtddevnum=0
mtdids=nand0=jz2440-0
mtdparts=mtdparts=jz2440-0:256k(u-boot),128k(params),2m(kernel),-(rootfs)
partition=nand0,0
filesize=2E2B50
fileaddr=30008000
gatewayip=192.168.152.1
netmask=255.255.255.0
ipaddr=192.168.152.125
serverip=192.168.152.123
bootcmd=tftp 0x30008000 uImage_4_9_2;bootm 0x30008000
stdin=serial
stdout=serial
stderr=serial

根据自己的网络环境修改ipaddrserverip,前者为自己的网络ip,后者为服务器也就是虚拟机的网络ip

修改bootargs,挂载根文件系统

  1. 配置虚拟机环境
    将虚拟机的ip修改为静态ip,怎么设置网上自己查一下,就不过多赘述了。
    安装tftp服务器并配置,将uImage放到该目录下
    安装nfs服务器并将rootfs也就是根文件系统放到这

  2. 测试,设置setenv 'bootcmd=tftp 0x30008000 uImage;bootm 0x30008000',并通过saveenv保存修改
    boot执行,打印如下信息,没进去内核应该是没有挂载适配的rootfs,内核应该是没有问题的

Bytes transferred = 2998640 (2dc170 hex)
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   mykernel
   Created:      2022-08-16   3:01:23 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2998576 Bytes =  2.9 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.9.2 (huizhe@ubuntu) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) ) #2 Tue Aug 16 10:54:01 CST 2022
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c000717f
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Memory policy: Data cache writeback
CPU S3C2440A (id 0x32440001)
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: root=/dev/nfs nfsroot=192.168.152.123:/home/huizhe/rootfs ip=192.168.152.125 console=ttySAC0,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 58892K/65536K available (4285K kernel code, 180K rwdata, 980K rodata, 172K init, 258K bss, 6644K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc04376c0   (4286 kB)
      .init : 0xc054d000 - 0xc0578000   ( 172 kB)
      .data : 0xc0578000 - 0xc05a5320   ( 181 kB)
       .bss : 0xc05a5320 - 0xc05e5c00   ( 259 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:103
S3C2440: IRQ Support
irq: clearing pending status 00000003
irq: clearing pending status 00000002
sched_clock: 16 bits at 1012kHz, resolution 987ns, wraps every 32362962ns
clocksource: samsung_clocksource_timer: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 28803037 ns
Console: colour dummy device 80x30
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x300081e0 - 0x30008238
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
MINI2440: Option string mini2440=0tb
MINI2440: 't' ignored, touchscreen not compiled in
MINI2440: LCD
 [0:240x320]
 1:800x480
 2:1024x768
 3:320x240

S3C2440: Initialising architecture
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c.0: slave address 0x10
s3c-i2c s3c2440-i2c.0: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c.0: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource samsung_clocksource_timer
NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 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 table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
futex hash table entries: 256 (order: -1, 3072 bytes)
workingset: timestamp_bits=30 max_order=14 bucket_order=0
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
s3c2410-lcd s3c2410-lcd: fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 74, base_baud = 0) is a S3C2440
console [ttySAC0] enabled
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 77, base_baud = 0) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 80, base_baud = 0) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM, writable, 16 bytes/write
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
nand: Could not find valid JEDEC parameter page; aborting
nand: device found, Manufacturer ID: 0xec, Chip ID: 0xda
nand: Samsung NAND 256MiB 3,3V 8-bit
nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
Creating 4 MTD partitions on "nand":
0x000000000000-0x000000040000 : "u-boot"
ftl_cs: FTL header not found.
0x000000040000-0x000000060000 : "u-boot-env"
ftl_cs: FTL header not found.
0x000000060000-0x000000560000 : "kernel"
ftl_cs: FTL header not found.
0x000000560000-0x000010000000 : "root"
ftl_cs: FTL header not found.
eth0: dm9000e at c4a5b300,c4a5d304 IRQ 55 MAC: 00:0c:29:4d:e4:f4 (chip)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-s3c2410: OHCI S3C2410 driver
s3c2410-ohci s3c2410-ohci: OHCI Host Controller
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
random: fast init done
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq disabled
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
hidraw: raw HID events driver (C) Jiri Kosina
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
NET: Registered protocol family 17
Key type dns_resolver registered
input: gpio-keys as /devices/platform/gpio-keys/input/input0
hctosys: unable to open rtc device (rtc0)
dm9000 dm9000 eth0: link down
dm9000 dm9000 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
     device=eth0, hwaddr=00:0c:29:4d:e4:f4, ipaddr=192.168.152.125, mask=255.255.255.0, gw=255.255.255.255
     host=192.168.152.125, domain=, nis-domain=(none)
     bootserver=255.255.255.255, rootserver=192.168.152.123, rootpath=
ALSA device list:
  No soundcards found.
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值