AnsweredAssumed Answered

How to load .data and .bss from hex file into RAM

Question asked by Michael Cooper-Stachowsky on Feb 9, 2017
Latest reply on Feb 9, 2017 by Alice_Yang

I'm writing a loader program that will take a hex file and load it into RAM. I have successfully loaded simple programs that do not have any global data, but I'm limited in what I can do.  I can generate a hex file with the global data, but I'm afraid I don't understand what to do from here.  I've written a simple linker script to put .data and .bss right after .text, and I'm trying to just load it all into memory and jump to my start symbol, but the global data does not get correctly loaded in the application, and I don't know why.  

 

I'm not clear on the dissassembly, and what it's telling me, so I can't really tell why it isn't working.  I'm working with a MKL26Z64VFT4, and the application I'm developing is being run by a simple OS I'm developing, so the app does not contain any setup code.  The dissassembly is below. If anyone could provide me with some way to get started in understanding what is going wrong, that would be great.  The global data is shown at address 60, and it is correctly there (20001780 is the correct constant value).

 

Disassembly of section .sec1:

00000000 <.sec1>:
0: b084b580 addlt fp, r4, r0, lsl #11
4: 4a08af00 bmi 0x22bc0c
8: 4b08447a blmi 0x2111f8
c: 681b58d3 ldmdavs fp, {r0, r1, r4, r6, r7, fp, ip, lr}
10: 60fb681b rscsvs r6, fp, fp, lsl r8
14: 68b9687a ldmvs r9!, {r1, r3, r4, r5, r6, fp, sp, lr}
18: 208068fb strdcs r6, [r0], fp
1c: f81ef000 ; <UNDEFINED> instruction: 0xf81ef000
20: f0002001 ; <UNDEFINED> instruction: 0xf0002001
24: 46c0f805 strbmi pc, [r0], r5, lsl #16 ; <UNPREDICTABLE>
28: 00010054 andeq r0, r1, r4, asr r0
2c: 0000000c andeq r0, r0, ip
30: b084b580 addlt fp, r4, r0, lsl #11
34: 6078af00 rsbsvs sl, r8, r0, lsl #30
38: 447a4a06 ldrbtmi r4, [sl], #-2566 ; 0xfffff5fa
3c: 58d34b06 ldmpl r3, {r1, r2, r8, r9, fp, lr}^
40: 681b681b ldmdavs fp, {r0, r1, r3, r4, fp, sp, lr}
44: 1d3a60fb ldcne 0, cr6, [sl, #-1004]! ; 0xfffffc14
48: 68fb1d39 ldmvs fp!, {r0, r3, r4, r5, r8, sl, fp, ip}^
4c: f0002002 ; <UNDEFINED> instruction: 0xf0002002
50: e7fef805 ldrb pc, [lr, r5, lsl #16]! ; <UNPREDICTABLE>
54: 00010022 andeq r0, r1, r2, lsr #32
58: 0000000c andeq r0, r0, ip
5c: 46c04718 ; <UNDEFINED> instruction: 0x46c04718
60: 20001780 andcs r1, r0, r0, lsl #15
...
70: 00018070 andeq r8, r1, r0, ror r0

 

 

 

MKL26Z64VFT4

Outcomes