0.顶层Makefile增加交叉编译器

顶层makefile:

ARCH		?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

改为:

ARCH		?= arm64
CROSS_COMPILE ?= aarch64-linux-gnu-

1.生成.config

***_defconfig文件一般的芯片都有,找到以后,用如下命令,其实就是拷贝到顶层目录,并命名为.config,里面包含一堆配置,make时读取。

***_defconfig文件在 arch/arm64/configs/目录下

[liuwanpeng@localhost linux]$ make xilinx_zynqmp_defconfig O=./output/
#
# configuration written to .config
#

单独输出到其他文件件有助于源码进行git管理,否则乱的文件。

2.make

[liuwanpeng@localhost linux]$ make LOADADDR=0x8000

默认生成Image,若想生成uImage,需要加上uImage后缀

[liuwanpeng@localhost linux]$ make LOADADDR=0x8000 uImage
make: *** 没有规则可以创建目标“uImage”。 停止。

2.1 uImage无法生成问题

mpsoc不像ZYNQ,把make uImage集成到makefile里了,可以单独执行mkimage指令。

mkimage是uboot编译后,生成的工具,拷贝到/usr/bin里

[liuwanpeng@localhost tools]$ mkimage
Error: Missing output filename
Usage: mkimage -l image
-l ==> list image header information
mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
mkimage [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b <dtb> [-b <dtb>]] [-i <ramdisk.cpio.gz>] fit-image
<dtb> file is used with -f auto, it may occur multiple times.
-D => set all options for device tree compiler
-f => input filename for FIT source
-i => input filename for ramdisk file
Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)
mkimage -V ==> print version information and exit
Use -T to see a list of available image types

在Image所在目录执行如下命令即可:

 mkimage -n 'xlnx-linux' -A arm64 -O linux -T kernel -C none -a 0x00080000 -e 0x00080000 -d Image uImage

2.2 几种linux镜像格式

  • vmlinux 未压缩内核镜像文件,
  • zImage zImage是一般情况下默认的压缩内核映像文件,压缩vmlinux,加上一段解压启动代码得到,只能从0X0地址运行
  • uImage uImage是u-boot使用bootm命令引导的Linux压缩内核映像文件格式, 使用工具mkimage(uboot提供此工具)对普通的压缩内核映像文件(zImage)加工而得。可以由bootm命令从任意地址解压启动内核。由于bootloader一般要占用0x0地址,所以,uImage相比zImage的好处就是可以和bootloader共存。

3. dts文件

dts文件在arch/arm64/boot/dts中

make dtbs

可以生成dtb文件,整个目录都编译了

make xxx.dtb

不好用了,具体原因还未定位,估计是makefile体系的问题

可以用dtc命令编译或反编译特定的dtb文件

liuwanpeng@liuwanpeng-virtual-machine:~/work/linux/output/arch/arm64/boot/dts/xilinx$ dtc --help
Usage: dtc [options] <input file> Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
-q, --quiet
Quiet: -q suppress warnings, -qq errors, -qqq all
-I, --in-format <arg>
Input formats are:
dts - device tree source text
dtb - device tree blob
fs - /proc/device-tree style directory
-o, --out <arg>
Output file
-O, --out-format <arg>
Output formats are:
dts - device tree source text
dtb - device tree blob
asm - assembler source
-V, --out-version <arg>
Blob version to produce, defaults to 17 (for dtb and asm output)
-d, --out-dependency <arg>
Output dependency file
-R, --reserve <arg>
Make space for <number> reserve map entries (for dtb and asm output)
-S, --space <arg>
Make the blob at least <bytes> long (extra space)
-p, --pad <arg>
Add padding to the blob of <bytes> long (extra space)
-b, --boot-cpu <arg>
Set the physical boot cpu
-f, --force
Try to produce output even if the input tree has errors
-i, --include <arg>
Add a path to search for include files
-s, --sort
Sort nodes and properties before outputting (useful for comparing trees)
-H, --phandle <arg>
Valid phandle formats are:
legacy - "linux,phandle" properties only
epapr - "phandle" properties only
both - Both "linux,phandle" and "phandle" properties
-W, --warning <arg>
Enable/disable warnings (prefix with "no-")
-E, --error <arg>
Enable/disable errors (prefix with "no-")
-h, --help
Print this help and exit
-v, --version
Print version and exit

例如:

反汇编,由dtb生成dts,反之亦然

dtc -I dtb -O dts -o zynqmp-zcu102.dts zynqmp-zcu102.dtb

最新文章

  1. DM9000驱动移植在mini2440(linux2.6.29)和FS4412(linux3.14.78)上的实现(deep dive)篇一
  2. WPF 控件总结
  3. 为什么我如此热爱这样一个比赛(转自vici)
  4. mvc深入理解
  5. Spring MVC 和 Spring 总结
  6. [原创,分享]DbHelper 续
  7. Data Types
  8. 小米wifi
  9. Mybatis入门(一)之操作数据库
  10. 2018/1/21 Netty通过解码处理器和编码处理器来发送接收POJO,Zookeeper深入学习
  11. ipa企业签名
  12. session和cookie的简介
  13. C++之 自定义数据类型 枚举、结构体、共用体
  14. React Native &amp; Google &amp; Proxy
  15. HNOI2019 退役记
  16. P1325 雷达安装
  17. Sitecore CMS中更改项目的模板
  18. vue2.0过滤器
  19. c++复习:STL之容器
  20. iOS 截屏分享(包含状态栏与不包含状态栏)

热门文章

  1. C#中float, double的精度问题
  2. CentOS7.x系统根目录分区扩容
  3. 【python】Python的单例模式
  4. linux服务器上Apache配置多域名
  5. key-value数据库-Redis
  6. 吞吐量(TPS)、QPS、并发数、响应时间(RT)概念
  7. 裸板驱动总结(makefile+lds链接脚本+裸板调试)
  8. django事务处理
  9. ChatterBot之使用mongodb 03
  10. 五十个小技巧提高PHP执行效率(二)