Skip to content

Commit 499e6de

Browse files
committed
pofParser: added 0x13 flag notes
1 parent e8d076a commit 499e6de

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/pofParser.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ int POFParser::parse()
124124
uint32_t POFParser::parseSection(uint16_t flag, uint32_t pos, uint32_t size)
125125
{
126126
std::string content;
127+
std::string t;
128+
char mess[1024];
127129

128-
if (_verbose)
129-
printf("%d %u\n", flag, size);
130+
if (_verbose) {
131+
snprintf(mess, 1024, "Flag: %02x (%d) Size: %u", flag, flag, size);
132+
printInfo(mess);
133+
}
130134

131135
/* 0x01: software name/version */
132136
/* 0x02: full FPGAs model */
@@ -165,6 +169,30 @@ uint32_t POFParser::parseSection(uint16_t flag, uint32_t pos, uint32_t size)
165169
if (_verbose)
166170
printf("size %u %zu\n", size, _bit_data.size());
167171
break;
172+
case 0x13: // contains usercode / checksum
173+
_hdr["usercode"] = std::to_string(ARRAY2INT16((&_raw_data.data()[pos])));
174+
if (_verbose) {
175+
t = _raw_data.substr(pos, size);
176+
for (size_t i = 0; i < t.size(); i++)
177+
printf("%02x ", static_cast<uint8_t>(t[i]));
178+
printf("\n");
179+
printf("%s\n", t.c_str());
180+
181+
/* 4 x 32bits */
182+
uint32_t sec0, sec1, sec2, sec3;
183+
sec0 = (t[0] << 24) | (t[1] << 16) | (t[2] << 8) | (t[3] << 0);
184+
sec1 = (t[4] << 24) | (t[5] << 16) | (t[6] << 8) | (t[7] << 0);
185+
sec2 = (t[8] << 24) | (t[9] << 16) | (t[10] << 8) | (t[11] << 0);
186+
sec3 = ((unsigned char)t[size-4] << 24) |
187+
((unsigned char)t[size-3] << 16) |
188+
((unsigned char)t[size-2] << 8) |
189+
((unsigned char)t[size-1] << 0);
190+
printf("sec0: %08x\n", sec0);
191+
printf("sec1: %08x\n", sec1);
192+
printf("sec2: %08x\n", sec2);
193+
printf("sec3: %08x\n", sec3);
194+
}
195+
break;
168196
case 0x1a: // flash sections
169197
// 12Bytes ?
170198
// followed by flash sections separates by ';'
@@ -173,7 +201,6 @@ uint32_t POFParser::parseSection(uint16_t flag, uint32_t pos, uint32_t size)
173201
parseFlag26(flag, pos, size, content);
174202
break;
175203
default:
176-
char mess[1024];
177204
snprintf(mess, 1024, "unknown flag 0x%02x: offset %u length %u",
178205
flag, pos - 6, size);
179206
printWarn(mess);

0 commit comments

Comments
 (0)