PSoC Hex Dump


PSoC4 Programming & Hex file Dump

参考文档:Infineon-CY8C4xxx_CYBLxxxx_Programming_Specifications-Programming Specifications

文档对于PSoC4通过SWD下载进行详尽的描述,此处仅整理相关笔记及分享从Hex中dump CRC值。

  1. 表一中记录Programming Values:(ID等)Acquire Chip时需要

PSoC4 Chip

  1. Hex File记录:

Hex File

  • 0x0000_0000 :开始为User Flash,程序地址

  • 0x9030_0000 :CheckSum, CRC校验,2Byte,是整个user flash 的校验。

  • 0x9040_0000 :Flash Protection(of users rows),Protection Size = FlashSize/Row Size/8,如Flash 128KB,Flash Protection为128Byte

  • 0x9050_0000 :MetaData - 12bytes,内容如下:

Offset Data Type Length in bytes
0x00 Hex file version - “2” 2 (big-endian)
0x02 Silicon ID 4 (big-endian)
0x06 Reserved 1
0x07 Reserved 1
0x08 Internal use 4

Silicon ID: 程序下载时,Acquired device与此ID相比较,必须相等才可以下载,Revision ID跳过。

byte[0] : Silicon ID Hi

byte[1] : Silicon ID Lo

byte[2] : Revision ID

byte[3] : Family ID

  • 0x9060_0000 :Chip Level protection - 1bytes

chipLevelProtection

  1. SWD下载流程

SWD program

第一步:Acquire Chip,如果对于未接XRES的MCU,并且SWD复用为IIC的4014等芯片来说,如果使用官方下载器可能没问题,如果要自制时就需要注意,尤其是power cycle的时序:

time of testMode

Power UP 后,需要在5ms~5.4mS之间访问!最小的SWD时钟频率为1.5MHz,满足400uS。

  1. Hex File:
Start Code Byte Count Address Record Type Data Check Sum
: 1 byte 2 bytes 1 byte N bytes 1 byte
  • Start code , one character — an ASCII colon ‘:’
  • Byte count , two hex digits (1 byte) — specifies the number of bytes in the data field.
  • Address, four hex digits (2 bytes) — a 16-bit address of the beginning of the memory position for the data.
  • Record type, two hex digits (00 to 05) — defines the type of the data field. The record types used in the hex file are as follows.
    • 00 – Data record, which contains data and 16-bit address.
    • 01 – End of file record, which is a file termination record and has no data. This must be the last line of the file; only one is allowed for every file.
    • 04 – Extended linear address record, which allows full 32-bit addressing. Address field is 0000. Byte count is 02 . The two data bytes represent the upper 16 bits of the 32-bit address, when combined with the lower 16-bit address of the 00 type record.
  • Data, a sequence of ‘n’ bytes of the data, represented by 2n hex digits.
  • Checksum, two hex digits (1 byte), which is the least significant byte of the two’s complement of the sum of the values of all fields except fields 1 and 6 (start code ‘:’ byte and two hex digits of the checksum).

如:PSoC Hex文件:

Hex

0x90300000地址的CRC:0xD097,可以使用notepad打开hex文件,拖到结尾直接查看crc校验。解析之:

ihexParser


文章作者: xArm
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 xArm !
评论