jx2410内核移植教程

jx2410内核移植教程

作为一个内核移植的新手,在内核移植的路上会遇到很多莫名其妙的问题,在这里特此写了这篇blog,希望能帮助各位有效的避开各种坑。

关于环境

这里的环境主要是网络环境和服务器。下面将以问题的形式一一讲解

首先是xshell和winscp连不上redhat的问题

这里需要将win和Redhat放在同一网段,这里可以不关闭WiFi,但是在连上开发板的时候建议关闭WiFi,不然会出来ip混乱的问题。

win+r快捷键呼出config菜单输入cmd,在黑框框中输入ipconfig查看本机ip

在这里插入图片描述
将其改为和Redhat同一个网段(为什么不是将虚拟机改为和主机同一个IP,因为等下烧内核的时候uboot里面内置的tftp服务默认ip是Redhat的IP所以建议改主机ip,所以这里还是建议关闭WiFi

之后就能ping通了[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-r7qp2jDf-1604213401880)(C:\Users\echo\AppData\Roaming\Typora\typora-user-images\1604205424940.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-W4aSDBxp-1604213401882)(C:\Users\echo\AppData\Roaming\Typora\typora-user-images\1604205456003.png)]

其次是虚拟机和主机ping不通的问题

在首次移植中我出现了虚拟机不能ping同主机,主机能ping通虚拟机的问题,这里主要涉及俩个方面,首先是虚拟机网络选项

在这里插入图片描述

在这里插入图片描述

之后是防火墙设置

然后是入墙规则(这个再关闭了防火墙以后也要更改,具体原因不知道为什么)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jlVqwYJT-1604213401888)(C:\Users\echo\AppData\Roaming\Typora\typora-user-images\1604204774674.png)]

PPT中的坑

JX2410 #tftp 30008000 zImage

在ppt中很难看出那个是i还是l,这里特意贴了出来。

好的坑都排干净了,这里进行内核打包教程。

首先用winscp将ramdisk.gz和zImage导入Redhat中,(任意文件夹,这里我导入的是/tmp/loopboot在这里插入图片描述

然后为了方便和出现不必要的错误这里我们先使用赋予所有权限

chmod 777 ramdisk.gz
chmod 777 zImage

再接着解压并挂载ramddisk.gz

gunzip ramdisk.gz
mount -o loop ramdisk /tmp/loop

然后我们进入这个目录在把导入目标文件

cd /tmp/loop
ls
[root@localhost loopboot]# mount -o loop /tmp/loop
mount: can't find /tmp/loop in /etc/fstab or /etc/mtab
[root@localhost loopboot]# ls
ramdisk  test.c  tmp  zImage
[root@localhost loopboot]# mount -o loop ramdisk /tmp/loop
[root@localhost loopboot]# cd /tmp/loop
[root@localhost loop]# ls
bin  dev  etc  lib  linuette  mnt  proc  qt  sbin  tmp  usr  var
[root@localhost loop]# 

之后我们手写目标程序

vim test.c
#include "stdio.h"
int main(){
	printf("hello world");
	return 0;
}
arm-linux-g++ test.c -o tmp

然后把tmp移到usr里面去

cp -r tmp /usr

之后退出目录卸载并打包内存盘

[root@localhost loop]# cd ..
[root@localhost tmp]# umount /tmp/loop
[root@localhost tmp]# cd /tmp/loopboot/
[root@localhost loopboot]# ls
ramdisk  test.c  tmp  zImage
[root@localhost loopboot]# gzip -v9 ramdisk 
ramdisk:	 63.7% -- replaced with ramdisk.gz
[root@localhost loopboot]# ls
ramdisk.gz  test.c  tmp  zImage
[root@localhost loopboot]# 


之后我们把ramdisk.gz和zImage放到之前设置的tftpboot目录中去

cp -r ramdisk.gz /tftpboot
cp -r zImage /tftpboot

然后对开发板进行操作

PS:先确定主机,开发板,虚拟机的ip,必须都在192.168.1.*这个网段下

打开开发板和secureCRT(波特率还是115200)

tftp 30800000 ramdisk.gz


Filename 'ramdisk.gz'.
Load address: 0x30800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ################################################
done

JX2410 # tftp 30008000 zImage
RTL8019AS Founded!
MAC : 0x8-0x0-0x3e-0x26-0xa-0x5b
MAC: 0x0:0x0:0x0:0x0:0x0:0x0 
TFTP from server 192.168.1.180; our IP address is 192.168.1.45
Filename 'zImage'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         ############################
done
Bytes transferred = 807516 (c525c hex)

然后

go 30008000

## Starting application at 0x30008000 ...
Uncompressing Linux......................................................... done, booting the kernel.
Linux version 2.4.18-rmk7-pxa1 (root@localhost.localdomain) (gcc version 2.95.3 20010315 (release)) #244 六 7月 22 16:13:27 CST 2006
CPU: ARM/CIRRUS Arm920Tsid(wb) revision 0
Machine: Samsung-SMDK2410
Warning: bad configuration page, trying to continue
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/ram0 console=ttyS0
Console: colour dummy device 80x30
Calibrating delay loop... 50.58 BogoMIPS
Memory: 64MB = 64MB total
Memory: 52300KB available (1537K code, 318K data, 72K init)
Dentry-cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode-cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
CPU clock = 202.800000 Mhz, HCLK = 101.400000 Mhz, PCLK = 50.700000 Mhz
check your kernel config.
USB Function Character Driver Interface - 0.5, (C) 2001, Extenex Corp.
usbctl: Opened for usb-char
usbctl: Started for usb-char
Starting kswapd
devfs: v1.10 (20020120) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
JFFS version 1.0, (C) 1999, 2000  Axis Communications AB
JFFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communications AB.
Samsung S3C2410X (i2c) algorithm module version 2.6.1 (20010830)
iic_s3c2410_init: Samsung S3C2410X iic adapter module version 2.6.1 (20010830)
i2c-dev.o: Registered 'Samsung S3C2410X IIC adapter' as minor 0
s3c2410_init: Initialized IIC on S3C2410X, 96kHz clock
iic_s3c2410_init: initialized iic-bus at 0xf4000000.
ttyS%d0 at I/O 0x50000000 (irq = 52) is a S3C2410
ttyS%d1 at I/O 0x50004000 (irq = 55) is a S3C2410
ttyS%d2 at I/O 0x50008000 (irq = 58) is a S3C2410
Console: switching to colour frame buffer device 80x30
s3c2410_init successful
pty: 256 Unix98 ptys configured
Prescale = 24
Loading S3C2410 Touch Screen Driver, major = 254          
S3C2410 Real Time Clock Driver v0.1
block: 128 slots per queue, batch=32
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
Last modified Nov 1, 2000 by Paul Gortmaker
NE*000 ethercard probe at 0xd0000300:8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)
 00 00 00 00 00 00
eth0: NE2000 found at 0xd0000300, using IRQ 32.
loop: loaded (max 8 devices)
UDA1341 audio driver initialized
physmap flash device: 2000000 at f00000
Number of erase regions: 1
Primary Vendor Command Set: 0001 (Intel/Sharp Extended)
Primary Algorithm Table at 0031
Alternative Vendor Command Set: 0000 (None)
No Alternate Algorithm Table
Vcc Minimum: 2.7 V
Vcc Maximum: 3.6 V
No Vpp line
Typical byte/word write timeout: 128 祍
Maximum byte/word write timeout: 2048 祍
Typical full buffer write timeout: 128 祍
Maximum full buffer write timeout: 2048 祍
Typical block erase timeout: 1024 ms
Maximum block erase timeout: 16384 ms
Chip erase not supported
Device size: 0x1000000 bytes (16 MiB)
Flash Device Interface description: 0x0002
  - supports x8 and x16 via BYTE# with asynchronous interface
Max. bytes in buffer write: 0x20
Number of Erase Block Regions: 1
  Erase Region #0: BlockSize 0x20000 bytes, 128 blocks
Using buffer write method
mtd: Giving out device 0 to Physically mapped flash
S3C2410 flash device: 2000000 at f00000
Search for id:(89 18) interleave(2) type(2)
Search for id:(89 18) interleave(2) type(2)
Search for id:(89 18) interleave(2) type(2)
Search for id:(89 89) interleave(2) type(1)
Search for id:(89 89) interleave(2) type(1)
Search for id:(89 89) interleave(2) type(1)
Search for id:(89 00) interleave(4) type(2)
Search for id:(89 00) interleave(4) type(2)
Search for id:(89 00) interleave(4) type(2)
Search for id:(89 18) interleave(4) type(1)
Search for id:(89 18) interleave(4) type(1)
Search for id:(89 18) interleave(4) type(1)
JEDEC: Found no s3c2410 flash device device at location zero
Number of erase regions: 1
Primary Vendor Command Set: 0001 (Intel/Sharp Extended)
Primary Algorithm Table at 0031
Alternative Vendor Command Set: 0000 (None)
No Alternate Algorithm Table
Vcc Minimum: 2.7 V
Vcc Maximum: 3.6 V
No Vpp line
Typical byte/word write timeout: 128 祍
Maximum byte/word write timeout: 2048 祍
Typical full buffer write timeout: 128 祍
Maximum full buffer write timeout: 2048 祍
Typical block erase timeout: 1024 ms
Maximum block erase timeout: 16384 ms
Chip erase not supported
Device size: 0x1000000 bytes (16 MiB)
Flash Device Interface description: 0x0002
  - supports x8 and x16 via BYTE# with asynchronous interface
Max. bytes in buffer write: 0x20
Number of Erase Block Regions: 1
  Erase Region #0: BlockSize 0x20000 bytes, 128 blocks
Using buffer write method
Creating 3 MTD partitions on "s3c2410 flash device":
0x00100000-0x00180000 : "reserved for u-boot"
mtd: Giving out device 1 to reserved for u-boot
0x00a80000-0x01100000 : "jffs2(8M - 256KBytes)"
mtd: Giving out device 2 to jffs2(8M - 256KBytes)
0x01100000-0x02000000 : "reserved"
mtd: Giving out device 3 to reserved
NAND device: Manufacture ID: 0xec, Chip ID: 0x73 (Samsung KM29U128T)
mtd: Giving out device 4 to Samsung KM29U128T
bon0: 00000000-00ff8000 (00ff8000) 00000000
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.95 (c) 1998-1999 Rebel.com
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 10240K
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Mounted devfs on /dev
Freeing init memory: 72K
==> 1 
console=/dev/con鹢le
init started:  BusyBox v0.60.3 (2002.05.13-08:36+0000) multi-c醠l binary
Starting pid 9, console /dev/console: '/etc/init.d/rcS'
/etc/init.d/rcS:mount /etc as ramfs
/etc/init.d/rcS:re-create the /etc/mtab entries
/etc/init.d/rcS:mount /proc as proc
/etc/init.d/rcS:config eth0 ethernet
/etc/init.d/rcS:mount jffs2 to /mnt/jffs2
/etc/init.d/rcS:run the /mnt/jffs2/rc script
/mnt/jffs2/rc:install the usb modules
Initializing S3C2410 buffer pool for DMA workaround
SCSI subsystem driver Revision: 1.00
modprobe: modprobe: Can't open dependencies file /lib/modules/2.4.18-rmk7-pxa1/modules.dep (No such file or directory)
usb.c: registered new driver hub
usb-ohci.c: USB OHCI at membase 0xe9000000, IRQ 26
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 2 ports detected
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
/etc/init.d/rcS:reconfig the ethernet, it will overwrite the config of the ramdisk
JXARM9-2410 TOUCH SCREEN VERIFY DATA LOADPROGRAM
version 2.0
www.cvtech.com.cn
WARNNING: failed to open /mnt/jffs2/cfg.dat
/etc/init.d/rcS:mount cramfs to /mnt/cramfs
Starting calibrate touchscreen...
xres = 640, yres = 480
signal 2 caught
Waiting for enter to start '/bin/sh' (pid 68, terminal /dev/console)

Please press Enter to activate this console. 
Starting pid 68, console /dev/console: '/bin/sh'


BusyBox v0.60.3 (2002.05.13-08:36+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

然后ls

bin       etc       linuette  proc      root      tmp       var
dev       lib       mnt       qt        sbin      usr

# cd usr/
# ls
demo.mp3  local     tmp

# ./tmp 
hello wolrd

好的,这次内核移植就完成了!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值