marvell 开发板Ubuntu镜像制作及配置步骤

http://wiki.macchiatobin.net/tiki-index.php?page=Boot+from+removable+storage+-+Ubuntu

marvell开发板的烧写步骤比较复杂。

 

板子上没有flash,默认SD卡启动,需要将SD卡制成启动盘。

第一步制作rootfs,以Ubuntu为例:

首先下载Ubuntu镜像:

 

mcbin@buildserver:~$ mkdir ubuntu
mcbin@buildserver:~$ cd ubuntu
mcbin@buildserver:~/ubuntu$ wget http://cdimage.ubuntu.com/releases/16.04.2/release/ubuntu-16.04.2-server-arm64.iso

挂载image

 

 

mcbin@buildserver:~/ubuntu$ mkdir temp
mcbin@buildserver:~/ubuntu$ sudo mount -o loop ubuntu-16.04.2-server-arm64.iso temp/
mcbin@buildserver:~/ubuntu$ ls temp/install/
filesystem.manifest  filesystem.squashfs      hwe-initrd.gz  hwe-vmlinuz  netboot
filesystem.size      filesystem.squashfs.gpg  hwe-netboot    initrd.gz    vmlinuz
恢复(不知怎么翻译unsquash)文件系统到/rootfs
mcbin@buildserver:~/ubuntu$ sudo unsquashfs -d rootfs/ temp/install/filesystem.squashfs
mcbin@buildserver:~/ubuntu$ ls rootfs/
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

修改passwd,使得免密码登录:

 

 

mcbin@buildserver:~/ubuntu/rootfs/etc$ cat passwd
root::0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
[truncated output]

打包rootfs:

 

 

mcbin@buildserver:~/ubuntu$ sudo tar -cjvf rootfs.tar.bz2 -C rootfs/ .

 

 

 

 

第二步编译源码:

建文件夹

 

mcbin@buildserver:~$ mkdir -p kernel/4.4.8
mcbin@buildserver:~$ cd kernel/4.4.8/

下载源码:

 

 

mcbin@buildserver:~/kernel/4.4.8$ git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell .

记得不要漏掉最后的点。

 

切换分支:

 

mcbin@buildserver:~/kernel/4.4.8$ git checkout linux-4.4.8-armada-17.02-macchiatobin
Checking out files: 100% (44078/44078), done.
Branch linux-4.4.8-armada-17.02-macchiatobin set up to track remote branch linux-4.4.8-armada-17.02-macchiatobin from origin.
Switched to a new branch 'linux-4.4.8-armada-17.02-macchiatobin'

设置环境变量:

 

 

mcbin@buildserver:~/kernel/4.4.8$ export ARCH=arm64
mcbin@buildserver:~/kernel/4.4.8$ export CROSS_COMPILE=aarch64-linux-gnu-

创建config文件,确保你的系统中有arm的交叉编译器,没有的话请安装:aarch64-Linux-gnu-gcc,最好用apt-get安装。

 

开始编译:

 

mcbin@buildserver:~/kernel/4.4.8$ make -j4

 

如果你的交叉编译器有问题会导致编译出错。

查看结果:

 

mcbin@buildserver:~/kernel/4.4.8$ ls arch/arm64/boot
dts Image Image.gz install.sh Makefile

如果有上述文件则说明编译成功。

 

将SD卡插入pc,pc须安装有Linux环境,我的是在virtualbox中安装的Ubuntu。在终端中输入:lsblk来外设,

 

 

mcbin@buildserver:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk
├─sda1   8:1    0 230.6G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0   7.9G  0 part [SWAP]
sdb      8:16   0   3.7T  0 disk
└─sdb1   8:17   0   3.7T  0 part /media/disk1
sdc      8:32   0 238.5G  0 disk
└─sdc1   8:33   0 238.5G  0 part /media/disk2
sde      8:64   1   7.4G  0 disk
└─sde1   8:65   1   7.4G  0 part

显然SD卡是sde,含有sde1一个分区。接下来格式化分区:

 

 

mcbin@buildserver:~$ sudo mkfs.ext4 /dev/sde1
mke2fs 1.42.13 (17-May-2015)
/dev/sde1 contains a vfat file system
Proceed anyway? (y,n) y
Creating filesystem with 1939456 4k blocks and 485760 inodes
(truncated output)

将格式化后的sde1挂载到/mnt

 

 

mcbin@buildserver:~$ sudo mount /dev/sde1 /mnt/

解压rootfs到SD卡,

 

 

mcbin@buildserver:~$ cd /mnt/
mcbin@buildserver:/mnt$ sudo tar -xvf ~/ubuntu/rootfs.tar.bz2

 

 

mcbin@buildserver:/mnt$ ls
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

 

将编译好的image和依赖文件放到SD卡:

 

mcbin@buildserver:/mnt$ sudo cp ~/kernel/4.4.8/arch/arm64/boot/Image boot/
mcbin@buildserver:/mnt$ sudo cp ~/kernel/4.4.8/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dtb boot/
mcbin@buildserver:/mnt$ ls boot
armada-8040-mcbin.dtb  Image

卸载SD卡:

 

 

mcbin@buildserver:/mnt$ cd
mcbin@buildserver:~$ sudo umount /mnt

最后一步,启动设置:

 

将SD卡插入marvell板子,将marvell板子连接pc,打开pc端的上位机,我用的是 mobaxterm,打开相应的串口,设置波特率115200,此时将marvell板接上电源,上位机将显示启动信息,这时必须要不停地按键使其停止在设置段。

 

Hit any key to stop autoboot:  0
Marvell>>
Marvell>>

接下来就按照说明一步步操作:

 

 

Marvell>> mmc dev 1
switch to partitions #0, OK
mmc1 is current device
Marvell>> ext4ls mmc 1:1 /
       4096 .
       4096 ..
      16384 lost+found
       4096 home
       4096 opt
       4096 srv
       4096 lib
       4096 media
       4096 etc
       4096 proc
       4096 run
       4096 bin
       4096 usr
       4096 sbin
       4096 var
       4096 sys
       4096 root
       4096 tmp
       4096 mnt
       4096 dev
       4096 boot
Marvell>> ext4ls mmc 1:1 /boot
       4096 .
       4096 ..
        12687360 Image
           33736 armada-8040-mcbin.dtb
Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-8040-mcbin.dtb
Marvell>> setenv bootmmc 'mmc dev 1; ext4load mmc 1:1 $kernel_addr $image_name;ext4load mmc 1:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk1p1 rw rootwait; booti $kernel_addr - $fdt_addr'
Marvell>> saveenv
Marvell>> setenv bootcmd 'run bootmmc'
Marvell>> saveenv
Marvell>> run bootmmc

至此设置成功:登录root即可。

 

 

localhost login: root
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.8-armada-17.02.2-g4126e30 aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~#

 

 

 

你可能感兴趣的:(linux)