本人干了10多年的硬件开发,懂一些fpga和arm程序的编写和调试方法,所以通常一块新板子焊好,我都是自己独立将各个接口和芯片的驱动调通,再给软件人员开发应用程序。最近在调国产化的板子,用到了复旦微的国产zynq fmql045和七星华创的9361,进口的芯片去年自己都调过,也很顺利,但是国产化的东西,坑实在太多,甚是折磨人。
复旦微的手册都只教你怎么编译在线下载调试,烧到flash的过程只是简单介绍方法,自己学着用helloworld烧到flash是能正常运行的,也就没太在意。直到开始调试七星华创的9361,光驱动程序就大的很,经常会报ram放不下程序。开始也不知道怎么改,后来百度出来说要改icf文件,我也不懂这块啥意思,感觉和xilinx的linker.ld功能差不多,但是人家sdk是选一下程序放哪就可以了,这icf要自己网里敲,复旦微给的例程也不多,折腾好久才弄懂,下面罗列一下遇到的问题和解决办法。
裸机app很大,在线调试没问题,烧到flash里,fsbl不能正常加载app,死机不运行
====PSOC FSBL BOOTING ....... ====
====FSBL Version: 3.9 ....... ====
======= In BootStage 1 =======
====UART initialized success!!!====
BootMode Register is : 0x00000001
PS was reset by POR,Non_secure mode is set!
Cluster ID 0x3731093
Running on A7-0
Boot Initialize is done at the 25.433960 ms
======= In BootStage 2 =======
Preparing boot device initialization......
QSPI Boot Mode
Boot device initialization success......
Boot device initialization is done at the 41.232201 ms
Preparing boot header search and validate......
Multiboot register: 0x0
Image start address: 0x0
Load boot header info (offset:0x20~0x48)success!
Image ID verified success!!!
Checksum verified success!!!
Boot header validate success, this is a valid image!!!
Boot header search is done at the 69.207161 ms
Image Header Table Offset 0x8c0
Checksum verified success!!!
Checksum validate success!!!
Image Header Table Details
Boot Gen Ver: 0x1020000
Number of Partitions: 0x3
Partition Header Address: 0x270
Partition Present Device: 0x0
Boot header validate is done at the 94.422997 ms
======= In BootStage 3 =======
Partition header validate......
Checksum verified success!!!
Partition is unencrypted......
Partition is unauthenticated......
UnEncrypted data Length: 0x32d130
Data word offset: 0x32d130
Total Data word length: 0x32d130
Destination Load Address: 0xffffffff
Execution Address: 0x0
Data word offset: 0x7d00
Partition Attributes: 0x20
Partition header validate SUCCESS!!
Partition header validate is done at the 135.314316 ms
Prepare Copy Partition......
Copy Partition is done at the 142.797043 ms
Prepare downloading bitstream.....
Download the PL bitstream is done at the 1003.257935 ms
Partition Load Success
======= In BootStage 3 =======
Partition header validate......
Checksum verified success!!!
Partition is unencrypted......
Partition is unauthenticated......
UnEncrypted data Length: 0x7897
Data word offset: 0x7897
Total Data word length: 0x7897
Destination Load Address: 0x104000
Execution Address: 0x11e008
Data word offset: 0x334e30
Partition Attributes: 0x118
Partition header validate SUCCESS!!
Partition header validate is done at the 1046.936646 ms
Prepare Copy Partition......
到这就不跑了,bit正常加载,fpga也跑起来了。。
分析:默认的icf文件,将app加载到片上ocm运行,fsbl也是加载到ocm运行,导致fsbl load app的时候覆盖了fsbl 自己运行的ram空间,导致fsbl运行死机。所以要修改icf文件,将app的运行空间放到片外内存上。那么问题来了,没接触过icf文件,不知到怎么改,折腾了好久,后来弄明白了,只需要将ram定义的地址范围改到片外ddr的地址范围就可以了。
define symbol __AXI_DDR_START = 0x00100000;
define symbol __AXI_DDR_END = 0x0FFFFFFF;
define symbol __ICFEDIT_region_RAM_start__ = __AXI_DDR_START;
define symbol __ICFEDIT_region_RAM_end__ = __AXI_DDR_END;
还有一点很坑,app里要把对应的ps_init注释掉,因为fsbl已经初始化一遍了,再初始化会把load到内存的app清空,导致假死机现象。
复旦微支持的flash型号
我费了半天劲,把兆易创新的flash读写调通了,用串口把bin烧到flash里了,可是上电还是不能启动,估计是boot rom写死了只能支持特定厂家的flash,国产flash只能用复旦微的,一片1000多块,没办法。
还有就是我手上的复旦微的资料确实不全,看到网上好多人是对着复旦微给的faq调试的,肯定要轻松很多,我的解决方法几乎只有基本的手册和百度,不过自己摸索的过程中对代码的熟悉和程序的工作机制的理解都有很大提升。