nerozero has quit [Read error: Connection reset by peer]
nerozero has joined #openocd
slobodan has joined #openocd
Hawk777 has quit [Quit: Leaving.]
slobodan has quit [Read error: Connection reset by peer]
slobodan has joined #openocd
slobodan has quit [Read error: Connection reset by peer]
slobodan has joined #openocd
slobodan has quit [Read error: Connection reset by peer]
slobodan has joined #openocd
jn has quit []
jn has joined #openocd
jn has joined #openocd
nerozero has quit [Ping timeout: 246 seconds]
Hawk777 has joined #openocd
Deneb has joined #openocd
nerozero has joined #openocd
<dinkelhacker>
Hello, I'm trying to load an elf file to a nucleo-h755zi. The elf contains sections in flash and sections in ram. For flash everything seems to be right, however, the ram contents seem to be wrong.
<dinkelhacker>
I'm loading the elf through gdb `load elffile`.
<dinkelhacker>
I tried loading the same file with a gdb server provided by the `st-util` program.
<dinkelhacker>
This one loads the RAM content corretly. Any idea what issue I could be facing?
<antto>
i think openocd might be adding a small "helper firmware" to RAM just to make flashing faster, i wonder if this could be it
<PaulFertser>
dinkelhacker: hm, why does your elf has both flash and ram sections though?
<PaulFertser>
dinkelhacker: are you using "compare-sections" to verify?
<dinkelhacker>
Hm? Code is in Flash, data is in ram? I mean once I am booting from flash I'd need to copy stuff from flash to RAM during startup but as long as I am loading the elf directly this should be fine?
<PaulFertser>
dinkelhacker: if you're doing the regular thing then your ELF should have sections for everything and in the "program header" it should have some sections that have same load address and physical address (execute in place code) and some with different (the RAM contents). The latter is supposed to be copied by startup code, and GDB isn't trying to replicate that process.
<PaulFertser>
Or is it not a regular firmware and you have some OS on the target and that ELF is supposed to be loaded by its loader dynamically or somethitg?
<PaulFertser>
You can see what sections with what addresses you have with "readelf", and only PT_LOAD sections are used when flashing.
<dinkelhacker>
No, not an os. Why should gdb not load the section to RAM? Does it not just load the elf file as is?
slobodan has quit [Ping timeout: 248 seconds]
<dinkelhacker>
yeah the ram section is PT_LOAD aswell
<PaulFertser>
PT_LOAD sections got copied to target addresses specified. If it's meant to be in flash it's copied to flash.
nerozero has quit [Ping timeout: 260 seconds]
<PaulFertser>
Then it's expected your startup code will copy it to RAM early.
<dinkelhacker>
So I have PT_LOAD sections that target flash and ram. Why isn't it just copying also the RAM sections to RAM?
<PaulFertser>
Show your header please
<PaulFertser>
The one that lists all PT_LOAD sections.
<PaulFertser>
dinkelhacker: indeed antto is right, if you want that area to not be kept you might need "$_CHIPNAME.cpu0 configure -work-area-backup 1"
<PaulFertser>
s/not be kept/be kept/
<antto>
my nose strikes again ;P~
<dinkelhacker>
aha so basically it assumes that you don't load anything to RAM, which is why it places the flash driver there?
<PaulFertser>
dinkelhacker: I wonder if GDB loads that section before the others or after?
<antto>
(like that broken clock that's right twice a day)
<PaulFertser>
dinkelhacker: target flash helper part of the driver, yes.
<dinkelhacker>
PaulFertser: It loads it before any flash section
<PaulFertser>
dinkelhacker: ok, that explains it then.
<PaulFertser>
You need -work-area-backup 1 to ask OpenOCD to preserve it.
<dinkelhacker>
antto: impressive nose :P
<dinkelhacker>
PaulFertser: which file do I need to touch? The one of the board, right?
<PaulFertser>
dinkelhacker: I'd say either openocd.cfg of your own or just add -c '$_CHIPNAME.cpu0 configure -work-area-backup 1' to the end of your invocation command line
<dinkelhacker>
Tadaaa, it works!
<dinkelhacker>
Out of curiosity, where does it put the flash helper instead?
<dinkelhacker>
Anyhow, thanks a lot to both of you! Is there a virtual tip char I can use to buy you a coffee?
<PaulFertser>
dinkelhacker: same place it just restores original contents afterwards
<PaulFertser>
Sorry about having to ask you about all those details before telling the solution; your usecase is certainly unusual and xy problem is seen way too often to just answer questions directly right away.
<PaulFertser>
I just use paypal in case you feel like it, fercerpav@gmail.com
<PaulFertser>
But really glad to help either way, it's a joy to see people doing all kinds of interesting things using Free Software.
<dinkelhacker>
Not a problem at all. Again, thanks a lot for your efforts and the fast response. I didn't expect to solve this before going to bed :D
Deneb has quit [Quit: Leaving]
<dinkelhacker>
I'm suprised its not a common usecase. At work I do this all the time in situations where the whole image will be loaded into RAM by a bootloader. Just saves me time flashing and resetting the device all the time.
<PaulFertser>
Usually bootloaders just remap interrupt table address and pass control to the payload running directly from flash. But your usecase makes sense too of course. Especially if firmware is really big and takes long time to flash.