This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am trying to do a field upgrade on my TM4C1231H6PZ processor by manually downloading the binary (erasing the flash then programming the flash with the .bin data directly) rather than using a utility such as uniflash or LM Flash Programmer. However, when I compare the .bin file to the disassembled code that runs from the .bin, I notice that the .bin file is not loaded byte for byte into the microcontroller- in fact, the byte manipulation that takes place seems to vary depending on the address within the binary (data prior to address 0x26c seem to be byte swapped over 4 bytes, while data after that address seem to be byte swapped over two bytes).
The process I'm using involves placing the "upgrade loader" code into a portion of flash that is not erased or overwritten, by modifying the .cmd file- that portion of the process is working fine. I will read the .bin data from an external flash.
Two questions: is there documentation on the format of the .bin file I'm dealing with? I've searched for it without success. And my second question is if there is a problem with this approach other than getting the .bin data into the proper format?
Thanks!
Cindy
Hi Robert,
Yes, disassembled code.
The binary is generated using the post-processing step within code composer- the binaries in question can be downloaded and used successfully via LM Flash Programmer, so I'm not questioning the accuracy of the .bin files. So when I download the .bin file and look at the disassembly, then compare that with what I see in the .bin file (viewed with a hex editor), the two don't match. Each byte is there, but there is byte swapping going on.
Thanks for helping me again!
Cindy
Hi Amit,
Yes, I understand how the flash is programmed- and it IS getting programmed with the data, but not exactly how I would expect. Using the BLInternalFlashProgram() utility provided in the TIVA examples, here is some disassembly after the download, and the disassembly of code when I download directly from Code Composer. Things in the beginning track, but things go south at 0x26C, where it looks like there are some endian issues.
Thanks for you help,
Cindy
Using flash utility:
00000000: 20000200 ANDCS R0, R0, R0, LSL #4
00000004: 000007D3 LDREQD R0, [R0], -R3
00000008: 000007D9 LDREQD R0, [R0], -R9
0000000c: 000007DB LDREQD R0, [R0], -R11
00000010: 000007DD LDREQD R0, [R0], -R13
00000014: 000007DD LDREQD R0, [R0], -R13
00000018: 000007DD LDREQD R0, [R0], -R13
...
00000268: 000007DD LDREQD R0, [R0], -R13
0000026c: 4684B5F8 PKHTBMI R11, R4, R8, ASR, #11
00000270: F04F2500 SUBNV R2, PC, R0, LSL #10
00000274: 27030E01 STRCS R0, [R3, -PC, ROR R1]
00000278: F005FA0E ANDNV PC, R5, R14, LSL #20
0000027c: D00F4201 ANDLE R4, PC, R1, LSL #4
00000280: 4FC4F8DC SVCMI #12908764
Using Code Composer (correct result):
00000000: 20000200 ANDCS R0, R0, R0, LSL #4
00000004: 000007D3 LDREQD R0, [R0], -R3
00000008: 000007D9 LDREQD R0, [R0], -R9
0000000c: 000007DB LDREQD R0, [R0], -R11
00000010: 000007DD LDREQD R0, [R0], -R13
00000014: 000007DD LDREQD R0, [R0], -R13
00000018: 000007DD LDREQD R0, [R0], -R13
...
00000268: 000007DD LDREQD R0, [R0], -R13
GPIOPadConfigSet():
0000026c: B5F8 PUSH {R3, R4, R5, R6, R7, LR}
0000026e: 4684 MOV R12, R0
00000270: 2500 MOVS R5, #0
00000272: F04F0E01 MOV.W R14, #1
00000276: 2703 MOVS R7, #3
$C$DW$L$GPIOPadConfigSet$2$B, $C$L1:
00000278: FA0EF005 LSL.W R0, R14, R5
0000027c: 4201 TST R1, R0
0000027e: D00F BEQ $C$DW$L$GPIOPadConfigSet$4$B
$C$DW$L$GPIOPadConfigSet$2$E, $C$DW$L$GPIOPadConfigSet$3$B:
00000280: F8DC4FC4 LDR.W R4, [R12, #4036]
Hi Amit,
Thanks for looking over my problem, but unfortunately, all the bytes are accounted for in the working and the failing versions. Here's a longer version:
dd 07 00 00 dd 07 00 00 dd 07 00 00 f8 b5 84 46
00 25 4f f0 01 0e 03 27 0e fa 05 f0 01 42 0f d0->
Via Code Composer download:
00000260: 000007DD LDREQD R0, [R0], -R13
00000264: 000007DD LDREQD R0, [R0], -R13
00000268: 000007DD LDREQD R0, [R0], -R13
GPIOPadConfigSet():
0000026c: B5F8 PUSH {R3, R4, R5, R6, R7, LR}
0000026e: 4684 MOV R12, R0
00000270: 2500 MOVS R5, #0
00000272: F04F0E01 MOV.W R14, #1
My downloader yields:
00000268: 000007DD LDREQD R0, [R0], -R13
0000026c: 4684B5F8 PKHTBMI R11, R4, R8, ASR, #11
00000270: F04F2500 SUBNV R2, PC, R0, LSL #10
00000274: 27030E01 STRCS R0, [R3, -PC, ROR R1]
00000278: F005FA0E ANDNV PC, R5, R14, LSL #20
Note that my downloader downloads the binary byte by byte always in the same order, but the working version doesn't. Also my version is attempting to create 32-bit instructions every time, while the working version has 16-bit instructions as well.
Thanks again for your help,
Cindy
Cynthia Crutchfield said:I can move data in and out of the micro's flash and get what I would expect- a counting pattern of 00 01 02 03 04 05 06 07 ... will show up as 03 02 01 00 07 06 05 04 ... in the flash and I can read those 32-bit words out.
Of the length you are encountering problems? If not you need to do longer.
Also have you checked this using both programming methods?
Cynthia Crutchfield said:Comparison isn't straight-forward because of the way data is loaded into the flash with bytes reversed.
Sorry, no the comparison is very straightforward.
Cynthia Crutchfield said:. I'm back to my original question of why the following binary disassembles
The disassembler is a big part of your problem. It can only confuse the issue.
Robert
Cynthia Crutchfield said:It's the assembly that's having a problem.
That makes no sense at all. It's not the "assembly".
Robert
Hi Robert,
I was actually able to use code composer to do the extraction in both cases- I didn't know that was a tool. So I downloaded the code in the traditional way and then extracted the binary, and then did the download in my code and extracted that binary. Saved both files and did a linux "diff" which showed no difference.
So at this point I'm wondering if there's a problem in the way I'm trying to execute the binary, after I manually load it. I'm using:
HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
Is that appropriate?
Thanks,
Cindy