MPC- LS中LS1043 内核编译---1 默认版本

1.LSDK的构造

设备要求: ubuntu 14/16/18

1.1源代码

源代码获取地址:https://lsdk.github.io/
在LS1043中 ,共有五个image需要刷写:

  1. RCW: reset配置字
  2. U-boot:boot loader
  3. PPA: 优先保护程序
  4. Fman: Frame manager hardware accelerator
  5. Linux:linux image
    创建DCM_git文件夹 在/home/user 来存储:
RCW:
git clone https://source.codeaurora.org/external/qoriq/qoriq-components/rcw
cd rcw
git checkout -b integration origin/github.com.qoriq-os/integration

u-boot:
git clone https://github.com/qoriq-open-source/u-boot
  • 1
linux:
git clone https://github.com/qoriq-open-source/linux
cd u-boot
git checkout -b LSDK-17.12 LSDK-17.12

PPA:
  git clone https://github.com/NXP/qoriq-ppa-binary/blob/integration/soc-ls1043/ppa.itb
  • 1
Fsl_fman:
git clone https://github.com/NXP/qoriq-fm-ucode
  • 1

1.2ubuntu 工具链

下载gcc linaro 工具链:https://releases.linaro.org/components/toolchain/binaries/6.3-2017.05/aarch64-linux-gnu/
并保存在DCM_git目录中。

sudo apt install crossbuild-essential-arm64 gcc-aarch64-linux-gnu
export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
sudo apt install device-tree-compiler
export PATH=$PATH:/home/<user>/DCM_git/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin

1.3 添加补丁

在DCM_git文件夹中,创建三个文件夹:
dcm-linux_patches
dcm-rcw_patches
dcm-uboot_patches
CAF 下载地址:https://www.codeaurora.org/projects/nxp-dual-chip-module-automotive-gateway
在这里插入图片描述在这里插入图片描述对所有的补丁重复上述操作,
更改补丁名称:
“0001-armv8-ls1043adcm-Enable-USB-support.patch” to “0014-armv8-ls1043adcm-Enable-USB-
support.patch”.
添加补丁:

1.
   cd u-boot
   sudo git am ../dcm-uboot_patches/*
   The patch will be applied to u-boot.
2.
 cd  linux
 sudo git am ../dcm-linux_patches/*
 The patch will be applied to linux.
3.
  cd rcw
  sudo git am ../dcm-rcw_patches/*
  The patch will be applied to rcw.

在DCM_git文件夹中,创建两个文件夹:
dcm-linux_patches_addons
dcm-uboot_patches_addons
从CAF链接下载:
在这里插入图片描述添加补丁:

1.
   cd u-boot
   sudo git am ../dcm-uboot_patches_addons/*
   The patch will be applied to u-boot.
2.
 cd  linux
 sudo git am ../dcm-linux_patches_addons/*
 The patch will be applied to linux.

1.4 构造RCW

export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
export PATH=$PATH:/home/<user>/DCM_git/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
cd ../rcw/ls1043ardb
make
tclsh ../tools/byte_swap.tcl RR_SPPP_3560/rcw_1600_qspiboot.bin RR_SPPP_3560/rcw_1600_qspiboot_swapped.bin 8

构建成功的rcw_1600_qspiboot_swapped.bin 会生成在…/rcw/ls1043ardb/RR_SPPP_3560。

1.5构造U-boot

U-boot包括了四种形式:ddr、qspi、nand、sd
在DCM_git下创建u-boot_binary目录,在其下创建四个子文件夹: ddr、qspi、nand、sd。

cd u-boot
export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
export PATH=$PATH:/home/<user>/DCM_git/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin

1.5.1 DDR boot

make distclean && make ls1043adcm_sdcard_defconfig && make -j3
u-boot-dtb.bin  被创建在此文件夹
mv u-boot-dtb.bin ~/DCM_git/u-boot_binary/ddr/u-boot-dtb_ramboot.bin

1.5.2 QSPI NOR boot

make distclean && make ls1043adcm_defconfig && make -j3
mv u-boot-dtb.bin ~/DCM_git/u-boot_binary/qspi/u-boot-dtb_qspi.bin

1.5.3 NAND boot

make distclean && make ls1043adcm_nand_defconfig && make -j3
 mv u-boot-dtb.bin ~/DCM_git/u-boot_binary/nand/u-boot-with-spl-pbl-nand.bin

1.5.4 SD boot

make distclean && make ls1043adcm_sdcard_defconfig && make -j3
 mv u-boot-with-spl-pbl.bin ~/DCM_git/u-boot_binary/qspi/u-boot-dtb_sd.bin

1.6构建linux

下载rootfs (ramdisk版本):https://github.com/qoriq-open-source/ramdiskrfs
下载ramdisk_rootfs_arm64.ext4.gz 。
在/home/user目录下构建ramdisk_fs文件夹,

mv ramdisk_rootfs_arm64.ext4.gz ~/ramdisk_fs
  • 1

下载tcpdump arm64
link:https://packages.debian.org/stretch/tcpdump
并下载该链接下的libpcap 和libssl arm64版本
在ramdisk_fs目录下创建libpcap 、libssl文件夹,将上述下载内容拷贝到对应的文件夹

cd libpcap
dpkg -x libpcap0.8_1.8.1-3_arm64.deb .
cd ../libssl
dpkg -x libssl1.0.2_1.0.2t-1~deb9u1_arm64.deb .
cd ..
dpkg -x tcpdump_4.9.2-1_deb8u1_arm64.deb .
sudo mkdir TEMP
sudo gunzip ramdisk_rootfs_arm64.ext4.gz
sudo mount ramdisk_rootfs_arm64.ext4 TEMP/
sudo cp usr/sbin/tcpdump TEMP/sbin/
sudo cp libpcap/usr/lib/aarch64-linux-gnu/libpcap.so.0.8 TEMP/usr/lib64
sudo cp libpcap/usr/lib/aarch64-linux-gnu/libpcap.so.1.8.1 TEMP/usr/lib64
sudo cp libssl/usr/lib/aarch64-linux-gnu/libcrypto.so.1.0.2 TEMP/usr/lib64
sudo cp libssl/usr/lib/aarch64-linux-gnu/libssl.so.1.0.2 TEMP/usr/lib64
sudo umount TEMP/
sudo gzip -9 ramdisk_rootfs_arm64.ext4
cp ramdisk_rootfs_arm64.ext4.gz ~/DCM_git/linux
mv ramdisk_rootfs_arm64.ext4.gz fsl-image-core-ls1043ardb.ext2.gz
 export CROSS_COMPILE=aarch64-linux-gnu-
 export ARCH=arm64
 export PATH=$PATH:/home/<user>/DCM_git/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
 make defconfig
 make lsdk.config
 make -j6
 ../u-boot/tools/mkimage -f kernel-ls1043a-rdb.its kernel-ls1043a-rdb.itb

kernel-ls1043a-rdb.itb创建成功。
若在上述内核编译过程中遇到权限不足 或缺少头文件等问题:

chmod 777 linux/* -R 
  • 1

1.7 通过SD卡启动系统

(使用sd boot的前提是开发板上驱动电阻的形式为sd boot形式)
先通过sudo fdisk -l 查看sd卡在主机上所获取的设备号,假设为/dev/sde,则:

export DEVSD=/dev/sde
sudo fdisk ${DEVSD}
Press “d”. (Repeat unitl all the partitions are deleted)
Press “n”. This creates a new partition.
Press “p”. This creates a primary partition.
Press “1. The first partition.
Press enter. This will create a partition that starts at offset 2048.
Press “t”. To set partition type.
Press “1” to select partition number 1. Note: If “1” is already entered in the command and
displayed, directly go to the next step.
Now type “83” to select Linux file system.
Press “w”. This writes the partition table and fdisk exits
This newly created partition need to be formatted to be usable. Firstly, remove and put SD Card
back into its slot, then run the following commands to format the partition:
sudo mkfs.ext3 -L rootfs ${DEVSD}1

将所有的binary拷贝到sd卡:

1. U-boot: u-boot: u-boot-with-spl-pbl_sd.bin(image build as in section SD Boot)
sudo dd if=u-boot-with-spl-pbl_sd.bin of=/dev/ sde bs=512 seek=8
2. PPA: ppa.itb
sudo dd if=ppa.itb of=/dev/sde bs=512 seek=8192
3. Fman: fsl_fman_ucode_ls1043_r1.1_106_4_18.bin
sudo dd if=fsl_fman_ucode_ls1043_r1.1_106_4_18.bin of=/dev/sde bs=512 seek=18432
4. Linux: kernel-ls1043a-rdb.itb
sudo dd if=kernel-ls1043a-rdb.itb of=/dev/sde bs=512 seek=32768

将sd卡插入开发板即可。

1.8 在ubuntu主机上安装串口驱动

FTDI驱动: https://blog.youkuaiyun.com/Davidietop/article/details/86520281
检查是否安装成功:

lsmod | grep usbserial
  • 1

查找设备列表:

dmesg
  • 1

串口工具:minicom 、设置端口为USB-serial的名字,设置波特率为115200。

<think>好的,用户现在的问题是在RHEL 6.4系统上,已经配置了阿里云的CentOS-Vault适配源,现在需要在保留原有GCC 4.4.7的情况下安装GCC 5.3,并能够随时切换两个版本。首先,我需要考虑如何在较旧的系统上安装较新版本的GCC,同时不影响原有版本。 首先想到的是,RHEL 6.4的默认仓库可能没有GCC 5.3,所以需要寻找第三方仓库或者源码编译。用户已经配置了阿里云的CentOS-Vault和EPEL源,可能EPEL仓库中有较新的GCC版本吗?不过通常EPEL可能不会提供GCC 5.3,因为CentOS 6的软件包相对较旧。可能需要使用其他方法,比如使用DevToolset或者SCL(Software Collections),但RHEL 6可能不支持SCL,或者需要额外的仓库。 DevToolset是Red Hat提供的开发工具集,允许用户安装较新的编译器而不影响系统默认版本。例如,DevToolset-3提供GCC 4.9,DevToolset-6有GCC 6.3,但用户需要GCC 5.3。这时候可能需要查看可用的DevToolset版本是否包含GCC 5.3,或者是否可以通过其他途径获取。 另一个方法是手动编译GCC 5.3,然后安装到自定义路径,这样不会覆盖系统默认的GCC。用户可以通过环境变量切换PATH来使用不同版本的GCC。但是手动编译可能需要处理依赖问题,比如GMP、MPFR、MPC等库的版本是否兼容,这可能会比较麻烦。 或者,是否有第三方仓库提供预编译的GCC 5.3?比如City Fan的仓库或者其他社区维护的源。需要确认这些仓库是否支持RHEL 6.4,并且是否与现有系统兼容。 接下来考虑用户的需求是随时切换两个版本,所以需要一种版本管理的方法。常用的方法有使用alternatives系统,或者通过环境变量设置PATH和LD_LIBRARY_PATH。例如,使用update-alternatives命令来配置多个GCC版本,或者编写脚本来切换环境变量。 如果用户使用DevToolset,可能需要通过scl enable来激活环境,但RHEL 6可能需要安装scl-utils,并且需要确认DevToolset是否支持。例如,DevToolset-4可能包含GCC 5.3,但需要确认该版本是否适用于RHEL 6。 此外,用户可能需要安装相关的依赖库,比如libstdc++等,以确保GCC 5.3能正常工作。如果手动编译安装,可能需要指定安装路径为/opt/gcc-5.3,这样不会与系统默认路径冲突。 在步骤上,可能需要先检查EPEL或其他仓库是否有可用的GCC 5.3包。如果没有,则考虑使用DevToolset或手动编译。然后配置alternatives或环境脚本来切换版本。同时需要注意,安装新版本的GCC可能会需要更新binutils或其他开发工具,需要处理依赖关系。 最后,验证安装后的GCC版本是否正确,以及切换是否有效。确保在切换后编译程序时使用的是正确的库路径,避免链接错误。</think>以下是为RHEL 6.4系统实现GCC 4.4.7与GCC 5.3共存并自由切换的完整方案: --- ### **方案选择:使用第三方预编译包(推荐)** #### 1. 安装SCL工具链 ```bash # 添加SCL仓库 sudo yum install -y centos-release-scl-rh # 安装开发工具集 sudo yum install -y devtoolset-4-gcc devtoolset-4-gcc-c++ ``` #### 2. 查看已安装版本 ```bash # 原始GCC版本默认路径) $ gcc --version gcc (GCC) 4.4.7 20120313... # SCL安装的GCC版本(隔离路径) $ scl enable devtoolset-4 "gcc --version" gcc (GCC) 5.3.1 20160406... ``` --- ### **手动切换方法** #### 临时切换(单次会话有效) ```bash scl enable devtoolset-4 'bash' # 启动带GCC5环境的新shell exit # 退出后恢复原环境 ``` #### 永久切换(用户级配置) ```bash # 编辑用户配置文件 echo 'source scl_source enable devtoolset-4' >> ~/.bashrc source ~/.bashrc ``` --- ### **方案二:源码编译安装(高级用户)** #### 1. 准备编译环境 ```bash sudo yum install -y gmp-devel mpfr-devel libmpc-devel wget mkdir ~/gcc-build && cd ~/gcc-build ``` #### 2. 下载并编译GCC5.3 ```bash wget https://ftp.gnu.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz tar xzf gcc-5.3.0.tar.gz mkdir build && cd build ../gcc-5.3.0/configure --prefix=/opt/gcc-5.3 --disable-multilib make -j$(nproc) && sudo make install ``` #### 3. 创建切换脚本 ```bash # /etc/profile.d/gcc-select.sh export PATH=/opt/gcc-5.3/bin:$PATH export LD_LIBRARY_PATH=/opt/gcc-5.3/lib64:$LD_LIBRARY_PATH ``` #### 4. 使用方式 ```bash source /etc/profile.d/gcc-select.sh # 启用GCC5.3 unset PATH LD_LIBRARY_PATH # 恢复系统GCC ``` --- ### **版本验证命令** ```bash # 查看当前生效版本 which gcc && gcc --version # 查看所有可用版本 ls /opt/gcc-5.3/bin/gcc /usr/bin/gcc ``` --- ### **关键注意事项** 1. **依赖库隔离**:SCL方案通过`/opt/rh/devtoolset-4/root`路径隔离,不会污染系统环境 2. **ABI兼容性**:使用GCC5编译的程序需要对应动态库: ```bash # 运行时需指定库路径 export LD_LIBRARY_PATH=/opt/gcc-5.3/lib64:$LD_LIBRARY_PATH ``` 3. **内核兼容**:GCC5编译内核模块无法在RHEL6原生内核加载(需重新编译内核--- ### **版本切换原理** 通过`PATH`环境变量优先级控制: ```text 原始GCC路径:/usr/bin/gcc (4.4.7) 自定义路径:/opt/rh/devtoolset-4/root/usr/bin/gcc (5.3) ``` --- 建议优先使用SCL方案,这是Red Hat官方推荐的多版本共存实现方式,安全性和兼容性更有保障。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值