nxp_2|Linux系统移植

此前需要做好以下准备工作:

  1. 安装好虚拟机Ubuntu
  2. 在Ubuntu里面安装好tftp服务和nfs服务
  3. 除了开发板外,还要准备一张TF卡(就是那种小SD内存卡,当然,也需要该卡的读卡器)和一小段网线
    在这里插入图片描述

简述

个人认为,移植系统无非三步走:
uboot -> kernel内核 -> 根文件系统
我找到了一个很好的资源,已经提供了镜像文件,直接通过Ubuntu烧录到内存卡里,然后把内存卡插到板子上运行即可跑通,这样就省了很多麻烦。
安装Ubuntu过程就不展示了,这个简单大家自行解决即可。而tftp服务和nfs服务这些后续另外发文补上^^。

TF卡烧录

插入后一般会弹出提示,按照如下操作连到Ubuntu
在这里插入图片描述
之后先执行ls命令看下设备是哪个,然后再针对自己的去执行烧录命令把下载了的文件emcraft.imxrt105x-evk.img烧到内存卡里,过程如下:

wu@ubuntu:~$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdb  /dev/sdb1
wu@ubuntu:~$ dmesg | tail
[  247.592499] scsi 34:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[  247.592763] sd 34:0:0:0: Attached scsi generic sg2 type 0
[  247.598454] sd 34:0:0:0: [sdb] 60751872 512-byte logical blocks: (31.1 GB/29.0 GiB)
[  247.602478] sd 34:0:0:0: [sdb] Write Protect is off
[  247.602480] sd 34:0:0:0: [sdb] Mode Sense: 03 00 00 00
[  247.606565] sd 34:0:0:0: [sdb] No Caching mode page found
[  247.606567] sd 34:0:0:0: [sdb] Assuming drive cache: write through
[  247.628414]  sdb: sdb1
[  247.642478] sd 34:0:0:0: [sdb] Attached SCSI removable disk
[  249.617152] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
wu@ubuntu:~$ ls
busybox-1.22.1                                           linux-5.13.1
emcraft.imxrt105x-evk.img                                linux-5.13.1.tar.xz
gcc-4.6.4                                                nxp
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf      Python-3.9.1
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar  rootfs.uImage
lib                                                      sdfuse_q
linux-3.14                                               sdtool
linux-3.14-fs4412                                        sdtool.tar.xz
linux-4.4.263                                            u-boot-2013.01-fs4412
wu@ubuntu:~$ sudo dd if=emcraft.imxrt105x-evk.img of=/dev/sdb
[sudo] password for wu: 
32768+0 records in
32768+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 14.0615 s, 1.2 MB/s
wu@ubuntu:~$ sync
wu@ubuntu:~$ 

然后把卡插到开发板上面,把模式调为SD卡模式(SW7那里设为1010),打开串口工具SecureCRT,设置波特率115200,其它一样常规设置,连上后按一下复位键就可以跑起来了
记录如下:

U-Boot 2017.09-rc1-cortexm-2.5.1 (Jun 06 2018 - 19:13:13 +0300)

CPU: i.MX RT105x at 600MHz
Model: NXP i.RT1050 EVK
DRAM:  32 MiB
MMC:   FSL_SDHC: 0
reading uboot.env
Video: 480x272x24
In:    serial@40184000
Out:   serial@40184000
Err:   serial@40184000
Net:   eth0: ethernet@402D8000
reading splash-rt1050-series_24.bmp
391736 bytes read in 108 ms (3.5 MiB/s)
reading mxrt105x-evk.ini
100 bytes read in 11 ms (8.8 KiB/s)
fatexec: 'setenv ipaddr 172.17.44.111'
fatexec: 'setenv netmask 255.255.0.0'
Hit any key to stop autoboot:  0 
reading rootfs.uImage
8202978 bytes read in 1885 ms (4.1 MiB/s)
## Booting kernel from Legacy Image at 80007fc0 ...
   Image Name:   Linux-4.5.0-cortexm-2.5.1
   Image Type:   ARM Linux Multi-File Image (uncompressed)
   Data Size:    8202914 Bytes = 7.8 MiB
   Load Address: 80008000
   Entry Point:  80008001
   Contents:
      Image 0: 8193248 Bytes = 7.8 MiB
      Image 1: 9654 Bytes = 9.4 KiB
   Verifying Checksum ... OK
## Flattened Device Tree from multi component Image at 80007FC0
   Booting using the fdt at 0x807d84ec
   Loading Multi-File Image ... OK
   Loading Device Tree to 81e77000, end 81e7c5b5 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.5.0-cortexm-2.5.1 (psl@skywanderer.emcraft.com) (gcc version 4.7.4 20130508 (prerelease) (20170818-165657- build on build.emcraft by build) ) #5 Wed Jun 6 20:30:19 MSK 2018
CPU: ARMv7-M [411fc271] revision 1 (ARMv7M), cr=00000000
CPU: WBA data cache, WBA instruction cache
Machine model: NXP IMXRT1050 board
debug: ignoring loglevel setting.
On node 0 totalpages: 8192
free_area_init_node: node 0, pgdat 807d7e18, node_mem_map 81ec0000
  Normal zone: 64 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 8192 pages, LIFO batch:0
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0 
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 8128
Kernel command line: console=ttyLP0,115200 consoleblank=0 ignore_loglevel ip=172.17.44.111:172.17.0.1::255.255.0.0::eth0:off
PID hash table entries: 128 (order: -3, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 23284K/32768K available (2587K kernel code, 121K rwdata, 408K rodata, 4884K init, 96K bss, 9484K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0x00000000 - 0x00001000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0x00000000 - 0xffffffff   (4095 MB)
    lowmem  : 0x80000000 - 0x82000000   (  32 MB)
      .text : 0x80008000 - 0x802f4ed4   (2996 kB)
      .init : 0x802f5000 - 0x807ba000   (4884 kB)
      .data : 0x807ba000 - 0x807d84e0   ( 122 kB)
       .bss : 0x807d84e0 - 0x807f075c   (  97 kB)
NR_IRQS:16 nr_irqs:16 16
sched_clock: 32 bits at 75MHz, resolution 13ns, wraps every 28633115129ns
clocksource: vf-pit: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 25483472618 ns
Calibrating delay loop... 1196.85 BogoMIPS (lpj=5984256)
pid_max: default: 4096 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
imxrt105x-pinctrl 401f8000.iomuxc: initialized IMX pinctrl driver
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Bluetooth: Core ver 2.21
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: L2CAP socket layer initialized
Bluetooth: SCO socket layer initialized
clocksource: Switched to clocksource vf-pit
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: 16 (order: -5, 192 bytes)
fuse init (API version 7.24)
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
io scheduler noop registered
io scheduler cfq registered (default)
mxsfb 402b8000.lcdif: initialized
40184000.serial: ttyLP0 at MMIO 0x40184000 (irq = 44, base_baud = 375000) is a FSL_LPUART
console [ttyLP0] enabled
Serial: VF610 driver
libphy: fec_enet_mii_bus: probed
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP Deflate Compression module registered
usbcore: registered new interface driver rt2800usb
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-mxc: Freescale On-Chip EHCI Host driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver uas
usbcore: registered new interface driver usb-storage
ci_hdrc ci_hdrc.1: EHCI Host Controller
ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
g_serial gadget: Gadget Serial v2.4
g_serial gadget: g_serial ready
i2c /dev entries driver
ft5x0x_ts 0-0038: resolution: 479x271
ft5x0x_ts 0-0038: Operating withoug nReset pin (-2)
input: ft5x0x_ts as /devices/virtual/input/input0
ft5x0x_ts 0-0038: fft5x0x_i2c_Read: i2c read error.
[FTS] Firmware version = 0x3e
ft5x0x_ts 0-0038: fft5x0x_i2c_Read: i2c read error.
[FTS] report rate is 620Hz.
ft5x0x_ts 0-0038: fft5x0x_i2c_Read: i2c read error.
[FTS] touch threshold is 248.
i2c i2c-0: LPI2C adapter registered
usbcore: registered new interface driver btusb
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
sdhci-esdhc-imx 402c0000.esdhc: could not get default state
/soc/aips-bus@40000000/esdhc@402c0000: voltage-ranges unspecified
mmc0: SDHCI controller on 402c0000.esdhc [402c0000.esdhc] using DMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
NET: Registered protocol family 17
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM ver 1.11
input: gpio-keys as /devices/platform/gpio-keys/input/input1
Freeing unused kernel memory: 4884K (802f5000 - 807ba000)
init started: BusyBox v1.24.2 (2018-06-06 19:15:39 MSK)
mmc0: host does not support reading read-only switch, assuming write-enable
mmc0: new high speed SDHC card at address 0001
mmcblk0: mmc0:0001 SD32G 29.0 GiB 
 mmcblk0: p1
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
random: dropbear urandom read with 5 bits of entropy available
/ # Micrel KSZ8081 or KSZ8091 402d8000.etherne:02: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=402d8000.etherne:02, irq=-1)

/ # 
/ # ls
bin        etc        lib        root       tmp
crankdemo  httpd      mnt        sbin       usr
dev        init       proc       sys        var
/ # 

在这里插入图片描述

根文件系统实现同步

现在是要实现网络文件系统,通过网线传输文件数据,那么就要让开发板、电脑、虚拟机Ubuntu三端都在同一个网段上面,然后通过设置开发板服务对象地址(serverip)为虚拟机的地址就可以实现了。以192.168.137.xxx为例:
开发板端(ipaddr)设为192.168.137.200
电脑端(以太网的IP)设为192.168.137.137
虚拟机(Ubuntu的IP)设为192.168.137.100
先是在开发板ping 192.168.137.137看能不能连通电脑,然后通过虚拟机ping 192.168.137.137验证是否连通电脑,都验证成功连通的话,最后通过设置开发板的serverip=192.168.137.100就可以实现同步了

设置电脑IP

在这里插入图片描述

设置Ubuntu的IP

虚拟机网络配置成桥接模式,自定义地址,后续会发文补上。
设置之后,验证成功连通电脑,执行ifconfig命令可以查看虚拟机自己的IP
在这里插入图片描述

设置开发板的IP

常规操作

首先在启动信息里查看,板子的网络地址ipaddr是172.17.44.111,如下所示
在这里插入图片描述
发现,很明显跟电脑的IP地址网段不同,所以把板子的设置成前面所约定的192.168.137.200就可以了。在板子启动后进入boot模式下设置(复位后马上按回车,不然就自动跑内核去了)
在这里插入图片描述
眼尖的话就会发现,serverip172.17.0.1也不符合,所以也要进行设置
在这里插入图片描述
结果发现验证开发板是否连通电脑时出错

/ # ping 192.168.137.137
PING 192.168.137.137 (192.168.137.137): 56 data bytes
ping: sendto: Network is unreachable
/ # ping 192.168.137.137
PING 192.168.137.137 (192.168.137.137): 56 data bytes
ping: sendto: Network is unreachable
/ # 

在这里插入图片描述
查找原因时发现,每次保存后重启就自动设置回原样,原来是那个mxrt105x-evk.ini 文件在搞鬼,每次都强制初始化。那,怎么办呢?

解决方案

去Ubuntu重新改动内存卡文件信息,过程如下:

wu@ubuntu:~$ ls /dev/sd*
/dev/sda  /dev/sda1
wu@ubuntu:~$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdb  /dev/sdb1
wu@ubuntu:~$ dmesg | tail
[ 3473.511105] scsi 33:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[ 3473.513808] sd 33:0:0:0: Attached scsi generic sg2 type 0
[ 3473.642864] sd 33:0:0:0: [sdb] 60751872 512-byte logical blocks: (31.1 GB/29.0 GiB)
[ 3473.647062] sd 33:0:0:0: [sdb] Write Protect is off
[ 3473.647063] sd 33:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 3473.650757] sd 33:0:0:0: [sdb] No Caching mode page found
[ 3473.650759] sd 33:0:0:0: [sdb] Assuming drive cache: write through
[ 3473.674735]  sdb: sdb1
[ 3473.690687] sd 33:0:0:0: [sdb] Attached SCSI removable disk
[ 3474.357856] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
wu@ubuntu:~$ sudo mount /dev/sdb1 /mnt
[sudo] password for wu: 
wu@ubuntu:~$ vi /mnt/mxrt105x-evk.ini 
wu@ubuntu:~$ sudo umount /mnt
wu@ubuntu:~$ sync
wu@ubuntu:~$ 

vi编辑文件
(改之前)
在这里插入图片描述
(改之后)
在这里插入图片描述
最终开发板成功连通电脑
在这里插入图片描述

文件同步共享

和虚拟机跟电脑共享文件一样,现在是虚拟机和开发板之间进行文件共享(前提是tftp服务和nfs服务都就位)
(开发板端)过程如下:

/ # ping 192.168.137.100
PING 192.168.137.100 (192.168.137.100): 56 data bytes
64 bytes from 192.168.137.100: seq=0 ttl=64 time=1.145 ms
64 bytes from 192.168.137.100: seq=1 ttl=64 time=0.952 ms
64 bytes from 192.168.137.100: seq=2 ttl=64 time=0.936 ms
64 bytes from 192.168.137.100: seq=3 ttl=64 time=0.701 ms
^C
--- 192.168.137.100 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.701/0.933/1.145 ms
/ # # ls /mnt/nfs/
/ # mount -o nolock,rsize=1024 192.168.137.100:/source/rootfs /mnt/nfs

成功同步共享
在这里插入图片描述
为了证明成功,在开发板端的共享目录里建个新文件夹test,然后查看虚拟机同样也建了新文件夹test!!!
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值