栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

编译并制作NXP S32G274ARDB2开发板启动镜像

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

编译并制作NXP S32G274ARDB2开发板启动镜像

所执行命令的运行环境为Ubuntu18.04

一、基于Yocto编译Linux BSP 1)安装repo工具

mkdir ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod a+x ~/bin/repo
PATH=${PATH}:~/bin

2)配置自己的Git环境变量

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
 

3)下载Yocto开发环境

mkdir fsl-auto-yocto-bsp
cd fsl-auto-yocto-bsp
python3 /home/djnakata/bin/repo init -u https://source.codeaurora.org/external/autobsps32/auto_yocto_bsp -b release/bsp30.0 --repo-url='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

python3 /home/djnakata/bin/repo sync

下载完Yocto开发环境之后,接着进行编译

4)编译
  • 建立Yocto编译环境(只需要第一次执行)

       ./sources/meta-alb/scripts/host-prepare.sh

  • 创建编译目录并指定所需要运行的平台

       source nxp-setup-alb.sh -m s32g274ardb2

  •  启动bitbake编译命令    

       bitbake fsl-image-base

    编译完毕之后,所需的目标文件存放在build_s32g274ardb2/tmp/deploy/images/s32g274ardb2下面

二、单独编译U-Boot (非Yocto,需要单独下载arm build toolchains) 1) 下载源代码

git clone https://source.codeaurora.org/external/autobsps32/u-boot
cd u-boot
git checkout -b bsp30.0-2020.04 bsp30.0-2020.04

2)编译

make CROSS_COMPILE=/path/to/your/toolchain/dir/bin/aarch64-none-linux-gnu-  s32g274ardb2
_defconfig

make CROSS_COMPILE=/path/to/your/toolchain/dir/bin/aarch64-none-linux-gnu-

三、单独编译Linux Kernel(非Yocto,需要单独下载arm build toolchains) 1) 下载源代码

git clone https://source.codeaurora.org/external/autobsps32/linux
cd linux

git checkout -b bsp30.0-5.10.41-rt bsp30.0-5.10.41-rt

2)编译

make ARCH=arm64 CROSS_COMPILE=/path/to/your/toolchain/dir/bin/aarch64-none-linux-gnu- s32gen1_defconfig

make ARCH=arm64 CROSS_COMPILE=/path/to/your/toolchain/dir/bin/aarch64-none-linux-gnu-

编译好的image位于arch/arm64/boot目录下面,dtb文件位于arch/arm64/boot/dts/freescale目录下面

四、制作Boot镜像 1. SD卡方式

1) 如果是从Yocto进行编译,编译完成的image文件fsl-image-base-s32g274ardb2.sdcard位于build_s32g274ardb2/tmp/deploy/images/s32g274ardb2

然后使用dd命令进行burn up

sudo dd if=./fsl-image-base-s32g274ardb2.sdcard of=/dev/sdd bs=1M && sync

2) 如果想手动进行拷贝,需执行如下操作:

  • SD卡将分为两个分区:一个用于放置kernel与DTB文件;一个用于放置根文件系统, 如下:

sudo fdisk /dev/sdd

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdd: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1a3401e2

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30375935, default 2048): 8192
Last sector, +sectors or +size{K,M,G,T,P} (8192-30375935, default 30375935): +255M

Created a new partition 1 of type 'Linux' and of size 255 MiB.

Command (m for help): p
Disk /dev/sdd: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1a3401e2

Device     Boot Start    End Sectors  Size Id Type
/dev/sdd1        8192 530431  522240  255M 83 Linux

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-30375935, default 2048): 530432   
Last sector, +sectors or +size{K,M,G,T,P} (530432-30375935, default 30375935): 

Created a new partition 2 of type 'Linux' and of size 14.2 GiB.

Command (m for help): p
Disk /dev/sdd: 14.5 GiB, 15552479232 bytes, 30375936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1a3401e2

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdd1         8192   530431   522240  255M 83 Linux
/dev/sdd2       530432 30375935 29845504 14.2G 83 Linux

Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 83

Changed type of partition 'Linux' to 'Linux'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
 

  • 格式化新的两个分区,如下:

   sudo mkfs.vfat -n boot /dev/sdd1

   sudo mkfs.ext3 -L rootfs /dev/sdd2

  • 拷贝Image到SD卡的相应分区中,如下:

   cd build_s32g274ardb2/tmp/deploy/images/s32g274ardb2

   sudo dd if=u-boot.s32 of=/dev/sdd conv=notrunc bs=256 count=1 seek=0

   sudo dd if=u-boot.s32 of=/dev/sdd conv=notrunc bs=512 seek=1 skip=1 (写u-boot到/dev/sdd)

   sudo mount /dev/sdd1 /media/

   sudo cp Image /media (拷贝kernel image到/dev/sdd1)

   sudo cp fsl-s32g274a-rdb2.dtb /media/fsl-s32g274a-rdb2.dtb (拷贝dtb文件到/dev/sdd1)

   sudo umount /media

   sudo mount /dev/sdd2 /media

   sudo tar xf fsl-image-base-s32g274ardb2.tar.gz -C /media  (拷贝根文件系统到/dev/sdd2)

   sudo umount /media

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/963992.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号