编译全志H3的linux源码

说明

 由于需要用到全志的芯片的orangepi_zero的开源板子做项目,需要定制linux系统,对系统添加内置程序,修改镜像大小和ubuntu系统版本。需要对源码编译生成ubuntu系统镜像。

使用编译环境

编译内核使用的是docke容器,比较方便。封装打包内核生成镜像使用实体机ubuntu16.04 64位。因为打包镜像在docker内运行会出错。

docker地址

docker pull registry.cn-shenzhen.aliyuncs.com/qusir/orangepi_zero:0.2

源码地址

https://github.com/QUSIR/orangepi_h2_linux

依赖项安装

设置dtc编译uboot

运行容器

docker run -it -v /home/orangepi_h2_linux:/data registry.cn-shenzhen.aliyuncs.com/qusir/orangepi_zero:0.2 bash

说明:将orangepi_h2_linux源码目录映射到容器的data文件夹

编译dtc

dtc下载地址 链接:https://pan.baidu.com/s/1sndX30T 密码:c2mw

7z x dtc.7z
cd dtc
make 

设置dtc环境变量

export PATH=/data/dtc/:$PATH

设置交叉编译器环境变量

export PATH="$PWD/brandy/gcc-linaro/bin":"$PATH"

编译过程

编译uboot

make CROSS_COMPILE=arm-linux-gnueabi- orangepi_zero_defconfig

编译内核

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sun8iw7p1smp_linux_defconfig
make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage modules

编译文件生成文件拷贝

cp -rf ./linux-3.4/output/lib/* ./build/lib
cp -rf ./linux-3.4/arch/arm/boot/uImage ./build/uImage 
cp -rf ./u-boot-2016.7/u-boot-sunxi-with-spl.bin ./build/uboot 
cp -rf ./build/lib/* ../OrangePi-BuildLinux/orange/lib/
cp -rf ./build/uImage ../OrangePi-BuildLinux/orange/ 
cp -rf ./build/uboot/u-boot-sunxi-with-spl.bin ../OrangePi-BuildLinux/orange/
cp -rf ./build/uboot/boot.scr ../OrangePi-BuildLinux/orange/

依赖项安装

实体机上

apt-get install debootstrap qemu-user-static chroot

生成镜像

./create_image
./image_from_dir linux-trusty orangepi ext4 zero

说明:linux-trust为执行create_imge所生成系统目录,orangepi为生成镜像名称。

镜像定制说明

修改 params.sh文件

# =====================================================
# ==== P A R A M E T E R S ============================
# =====================================================


# *****************************************************
# Set to "yes" to create realy minimal image          *
# *****************************************************
ONLY_BASE="no"


# *****************************************************
# Set hostname, user to be created                    *
# and root and user passwords                         *
# *****************************************************
HOSTNAME="OrangePizero"  #主机名称
USER="orangepi"          #用户名
ROOTPASS="orangepi"      #root密码
USERPASS="orangepi"      #orangepi密码


# *****************************************************
# Set timezone, for default (HOST'S) set _timezone="" *
# *****************************************************
_timezone="Etc/UTC"
#_timezone=""


# *****************************************************
# SET IF YOU WANT TO INSTALL SPECIFIC LANGUAGE,       *
# COMMENT FOR DEFAULT (HOST) settings                 *
# *****************************************************
LANGUAGE="en"
LANG="en_US.UTF-8"


# *****************************************************
# Set the base name of your image.                    *
# Distro name is automaticaty appended, and the image *
# will be "image_name-distro.img"                     *
# --------------------------------------------------- *
# IF image_name="", image file won't be created,      *
# instalation will be created in local directories    *
# linux-$distro & boot-$distro                        *
# YOU CAN CREATE THE IMAGE LATER RUNNING:             *
# sudo ./image_from_dir <directory> <DEVICE|IMAGE>    *
# === IT IS THE RECOMMENDED WAY OF IMAGE CREATION === *
# --------------------------------------------------- *
# IF image_name is BLOCK DEVICE (/dev/sdXn)           *
# LINUX filesystem will be created directly on it     *
# Partition must exist !                              *
# IF _format="" partition will NOT be formated        *
# otherwyse it will be formated with specified format *
# *****************************************************
image_name=""
#image_name="minimal"
#image_name="/dev/sdg"


# *****************************************************
# Filesystem type for linux partition                 *
# If btrfs is selectet, partition will be mounted     *
# "compressed" option, you can save some sdcard space *
# --------------------------------------------------- *
# Used when creating the system directly on SDCard or *
# SDCard image file and in "image_from_dir" script    *
# *****************************************************
_format="ext4"  #文件系统
#_format="btrfs"


# *****************************************************
# SD Card partitions sizes in MB (1024 * 1024 bytes)  *
# --------------------------------------------------- *
# If creating on physical sdcard (not image) you can  *
# set "linuxsize=0" to use maximum sdcard size        *
# --------------------------------------------------- *
# When creating the image with "image_from_dir" script*
# "linuxsize" is calculated from directory size       *
# *****************************************************
fatsize=64
linuxsize=800  #生成镜像大小


# *****************************************************
#   Select ubuntu/debian distribution and repository  *
#     === SELECT ONLY ONE distro AND ONE repo ===     *
# *****************************************************

# === Ubuntu ===
#distro="precise"
#distro="xenial"
distro="trusty"  #ubuntu版本
#distro="utopic"
#distro="vivid"
#distro="wily"
#repo="http://ports.ubuntu.com/ubuntu-ports"

repo="http://mirrors.ustc.edu.cn/ubuntu-ports"  #ubuntu镜像源

# === Debian ===
#distro="wheezy"
#distro="jessie"
#repo="http://ftp.hr.debian.org/debian"
#raspbian="no"

# === Raspbian ===
#distro="wheezy"
#distro="jessie"
#repo="http://archive.raspbian.org/raspbian"
#raspbian="yes"

# ******************************************************
# If creating the image, you can xz compress the image *
# after creation and make the md5sum file              *
# to do that automatically, set  _compress="yes"       *
# ******************************************************
_compress="no"


# =====================================================
# IF YOU WANT TO HAVE BOOT FILES ON EXT4 PARTITION    =
# AND NOT ON SEPARATE FAT16 PARTITION                 =
# set  _boot_on_ext4="yes"  and                       =
# FAT partitin won't be created                       =
# --------------------------------------------------- =
# DO NOT CHANGE FOR NOW !                             =
# =====================================================
_boot_on_ext4="no"


# ^^^^ P A R A M E T E R S ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

转载于:https://www.cnblogs.com/QUSIR/p/8400069.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
全志H3是一款基于ARM架构的处理器,它广泛应用于嵌入式系统和物联网设备中。要进行H3的Linux移植,可以按照以下步骤进行操作: 1. 准备开发环境:首先需要搭建好交叉编译环境,包括安装交叉编译工具链和相关的开发工具。 2. 获取内核源码:从全志官方或其他可靠的渠道获取H3的内核源码。 3. 配置内核:根据具体的硬件平台和需求,对内核进行配置。可以使用全志提供的配置文件作为基础,如引用[3]中的env.cfg文件。根据实际情况,可以修改配置文件中的参数,如设置启动参数、分区大小等。引用[1]和[2]中的内容提供了一些具体的配置示例。 4. 编译内核:使用交叉编译工具链编译内核源码,生成可执行的内核镜像文件。 5. 烧录内核:将编译生成的内核镜像文件烧录到目标设备的存储介质中,如SD卡或闪存。 6. 配置启动参数:根据具体的启动方式,配置引导加载程序(如U-Boot)的启动参数,以正确加载和启动内核。 7. 测试和调试:将烧录好的设备连接到目标设备上,进行测试和调试,确保系统正常启动并能够运行所需的应用程序。 需要注意的是,以上步骤只是一个大致的指导,具体的移植过程可能因硬件平台和需求的不同而有所差异。在实际操作中,可能还需要进行一些额外的配置和调整。建议参考全志官方提供的文档和社区中的讨论,以获取更详细和准确的移植教程。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值