SDK记录
MSS文件
MSS文件用来表征操作系统(OS)、库(library)、驱动(driver)、处理器(processor)的信息,在ISE的SDK和Vivado的SDK中都有应用。用户可以通过修改MSS中的选项,手动对库或驱动的选项进行修改。
参考 ug1138-generating-basic-software-platforms
Global Parameters
Instance-Specific Parameters
范例
parameter VERSION = 2.1.0
BEGIN OS
parameter PROC_INSTANCE = my_microblaze
parameter OS_NAME = standalone
parameter OS_VER = 1.0
parameter STDIN = my_uartlite_1
parameter STDOUT = my_uartlite_1
END
BEGIN PROCESSOR
parameter HW_INSTANCE = my_microblaze
parameter DRIVER_NAME = cpu
parameter DRIVER_VER = 1.0
parameter XMDSTUB_PERIPHERAL = my_jtag
END
BEGIN DRIVER
parameter HW_INSTANCE = my_intc
parameter DRIVER_NAME = intc
parameter DRIVER_VER = 1.0
END
BEGIN DRIVER
parameter HW_INSTANCE = my_uartlite_1
parameter DRIVER_VER = 1.0
parameter DRIVER_NAME = uartlite
END
BEGIN DRIVER
parameter HW_INSTANCE = my_uartlite_2
parameter DRIVER_VER = 1.0
parameter DRIVER_NAME = uartlite
END
BEGIN DRIVER
parameter HW_INSTANCE = my_timebase_wdt
parameter DRIVER_VER = 1.0
parameter DRIVER_NAME = timebase_wdt
END
BEGIN LIBRARY
parameter LIBRARY_NAME = XilMfs
parameter LIBRARY_VER = 1.0
parameter NUMBYTES = 100000
parameter BASE_ADDRESS = 0x80f00000
END
BEGIN DRIVER
parameter HW_INSTANCE = my_jtag
parameter DRIVER_NAME = uartlite
parameter DRIVER_VER = 1.0
END
MLD文件
ug1138 Generating Basic Software Platforms
简介
每个 OS 和Library都有一个 MLD 文件和相应的 Tcl 文件,其中,
- MLD文件包含一些选项,用于Library、OS的设置
- Tcl文件根据MLD 文件来实现定制
范例
SDK中报错“undefined reference to sqrt”的解决方法
在SDK程序中,使用了math.h中声明的sqrt、log10等函数。由于math.h不包括sqrt等函数的定义,因此在程序编译过程中出现了如下的错误,
解决方法如下,在gcc linker中添加-lm选项即可
通过XML文件导入工程的include路径
方法
在Xilinx SDK软件中,当工程中的代码层次较多时,如下图,手动添加工程的include路径比较繁琐,
可以通过编辑xml文件的方式,将include路径导入到SDK中,
<?xml version="1.0" encoding="UTF-8"?>
<cdtprojectproperties>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths">
<language name="s">
</language>
<language name="c,S">
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Kernel/include</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Kernel/portable</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Kernel/</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Plus_TCP/include</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Plus_TCP/portable/Compiler/GCC</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Plus_TCP/portable/NetworkInterface/include</includepath>
<includepath>../test/src/FreeRTOS_Relative/FreeRTOS_Plus_TCP/portable/NetworkInterface/Zynq</includepath>
<includepath>../test/src/USER</includepath>
</language>
<language name="Object File">
</language>
<language name="ld">
</language>
</section>
</cdtprojectproperties>
说明
使用导入的方式批量设置include路径时,有时会出现下述错误,
对比了一下出错前后的工程设置,发现在导入之后,C/C++ Build Setting中的设置发生了变化,下述篮框中的设置消失了,再手动添加也无济于事,
58295 - 14.7 SDK - An error occurs when attempting to add a user library to the build
上述链接中提到,当在C/C++ General中设置路径时,可能会导致makefile文件corrupting,
由于SDK中makefile一般是工程自动管理的,因此最好还是手动逐一添加include路径吧(/ □ )
其他
有时,在SDK中添加了include路径后,编译时依然会报找不到路径的错误;此时,一种可能的原因是include path没有全部添加。要注意,如果A文件夹下有A01、A02、A03几个文件夹,即使A文件夹下没有h文件,依然需要将A文件夹添加到路径中,而不能仅仅添加A01、A02、A03这几个子文件夹。
设置编译选项
设置某些文件/文件夹不编译
单独设置文件的编译选项
SDK允许不同的文件设置不同的编译选项,可以分别设置文件是否优化、是否保留debug信息等
向存储区中导入/导出数据
通过GUI操作
使用命令行操作
产生C代码的MAP文件
XILINX官方给出的方法是
In XPS:
- Right-click the software application project and select “Set Compiler Options”.
- Click the Paths and Options tab.
- In the Other Compiler Options to Append, add -Wl,-Map -Wl,“C:<fullpath><name>.map”
- Click OK.
In SDK: - Right-click the software application project and select Properties.
- Select the C/C++ Build in the left pane.
- With the Tools tab brought forward, select Miscellaneous under Linker.
- In the Linker Flags, add -Wl,-Map -Wl,“C:<fullpath><name>.map”
- Click OK.
The -Map keyword is case sensitive. The target file name must be enclosed in quotation marks.
照做之后会提示下述错误
之后如下图修改链接选项
提示如下错误
于是我自己在相应路径下先建了一个同名空文件,生成map文件成功
生成srec文件
mb-objcopy -O srec app.elf app.srec
在Xilinx SDK 工程的BSP文件中进行断点调试
参考69084 - SDK: Stepping into a BSP function causes the Debug pointer to jump to disassembly
Xilinx工具对elf文件的转换
在Xilinx中,利用data2mem工具可以将elf文件转换为mem文件;利用mb-objcopy工具可以将elf文件转换成srec文件
data2mem -bd test.elf -d -o m test.mem
mb-objcopy -O srec tesl.elf test.srec
打开相应的文件,比对可知,srec的数据区中的数据和mem文件中的数据是相同的
移除代码中未使用的函数、变量
参考以下方法
总结起来,就是,编译阶段设置 -fdata-sections -ffunction-sections标志,链接阶段设置
-Wl,–gc-sections标志,实测如下,
查看宏展开的处理情况
在SDK中编译处理时,保留中间文件,就能在中间文件中查看宏展开后的处理情况,gcc的-save-temps标志能够达到这个效果。
清除最近打开记录
Vitis记录
改变主题颜色
禁止某个文件编译
更新platform
为了文件夹路径改变后不用重新导入,需要对platform进行更新,