Hello,
Unfortunately, this is the way to read the pFlash area, not the Config area.
I apologize for any misunderstanding on this matter. However, if you have an answer for this, please let me know.
Question: What I want is a way to read the following "Config" area from C/C++ firmware code.
$ DK6Programmer.exe -V 0 -s COM4 -r Config:512 <= The Config, not pFlash
COM4: Connected at 115200
COM4: Detected JN5189 with MAC address 00:15:8D:00:05:B0:EA:86
COM4: Selected memory: Config
COM4: Reading 512 bytes from Config at 00000000
COM4: Config = a41c000000000000...snip...2c196c
Just to be sure, I tried the code you gave me, but it still reads pFlash.
const unsigned SIZ = 16;
uint8_t b0[SIZ];
{
Serial << "\r\n[psector_ReadData]";
psector_page_data_t page; /* Stored in the stack temporarily */
psector_page_state_t pg_state;
pg_state = psector_ReadData(PSECTOR_PFLASH_PART,0,0,sizeof(psector_page_data_t),&page);
if (pg_state < PAGE_STATE_DEGRADED)
{
Serial << "error at psector_ReadData()";
}
uint8_t *p = (uint8_t *)&page;
for (unsigned i = 0; i < 512; i += SIZ) {
Serial << crlf << format("%05x:", i);
for(uint8_t j = 0; j < SIZ; j++) {
Serial << format(" %02x", *p);
p++;
}
Serial.flush();
}
}
Serial << "\r\n[Flash Dump]";
for (int i = 0x9ec00; i < 0x9f000; i += SIZ) {
Serial << crlf << format("%05x:", i);
for(uint8_t j = 0; j < SIZ; j++) {
uint8_t *p = (uint8_t*)(i + j);
Serial << format(" %02x", *p);
}
Serial.flush();
}
My code is written in C++ (I think it's not the matter in this case), where Serial is handling output to UART. And the result is...
[psector_ReadData]
00000: 3a e6 2e 62 3d 35 b4 a7 00 00 00 00 08 00 00 00
00010: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00
00020: e4 04 00 00 19 e1 09 00 8f cd b5 64 01 00 00 00
00030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00
00040: 00 00 00 00 8a 03 9d b7 00 00 00 00 00 00 00 00
00050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00060: 34 12 38 26 01 c5 1b 00 d1 4a d8 03 00 8d 15 00
00070: 00 00 00 60 37 9f 7a b3 00 00 00 00 00 00 00 00
00080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000c0: 79 2b cf e0 b3 b7 60 d6 38 47 c5 49 28 53 fa 71
000d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
...
001f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[Flash Dump] Data is stored at both 9ec00 and 9ee00.
9ec00: 3a e6 2e 62 3d 35 b4 a7 00 00 00 00 08 00 00 00
9ec10: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00
9ec20: e4 04 00 00 19 e1 09 00 8f cd b5 64 01 00 00 00
9ec30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00
9ec40: 00 00 00 00 8a 03 9d b7 00 00 00 00 00 00 00 00
9ec50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
9ec60: 34 12 38 26 01 c5 1b 00 d1 4a d8 03 00 8d 15 00
...
9edf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
9ee00: 3a e6 2e 62 3d 35 b4 a7 00 00 00 00 08 00 00 00
9ee10: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 00
...
9eff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00