NishanthMenon changed the topic of #openocd to: this is the place to discuss all things OpenOCD | Logs: https://libera.irclog.whitequark.org/openocd/
Heisey has quit [Quit: Client closed]
jancoow has quit [Quit: The Lounge - https://thelounge.chat]
jancoow has joined #openocd
renrelkha has quit [Quit: bye]
renrelkha has joined #openocd
Hawk777 has joined #openocd
russ has quit [Ping timeout: 272 seconds]
russ has joined #openocd
Hawk777 has quit [Quit: Leaving.]
Hawk777 has joined #openocd
gzlb has quit [Ping timeout: 264 seconds]
gzlb has joined #openocd
Hawk777 has quit [Quit: Leaving.]
Hawk777 has joined #openocd
nerozero has joined #openocd
Heisey has joined #openocd
Hawk777 has quit [Quit: Leaving.]
<Heisey> PaulFertser, thanks for the reply:
<Heisey> This is the OpenOCD output: https://pastebin.com/gsHpi2ir
<Heisey> This is the GDB output: https://pastebin.com/xDRgBeHu
<Heisey> I am not sure if CLion allows typing GDB commands interactively, but I'll find out
MGF_Fabio has joined #openocd
Haohmaru has joined #openocd
<PaulFertser> Heisey: hey
<PaulFertser> Heisey: is there a list of OpenOCD and/or GDB commands it runs?
<PaulFertser> Heisey: are are you able to run same OpenOCD binary with same config manually and try to run it with -c "init; halt; verify_image /path/to/your/elf" ?
<Heisey> I'll try it
<PaulFertser> Heisey: also, it looks like CLion uses "program" procedure to flash it on startup but it doesn't include "verify" optional argument, why?
<PaulFertser> Heisey: does "flash size = 1536 KiB" match your MCU features?
<PaulFertser> "xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc" with flashed image looks like the flash is empty, that is strange.
<Heisey> it's not programming the flash, that much I do know because I can open the flash from other tools (such as the ST programmer)
<Heisey> "flash size = 1536 KiB" does seem to match the MCU
<Heisey> when I connect to the MCU from the ST Utility I can see th flash size and its contents
<PaulFertser> Heisey: ok, are you using an elf file to flash? Can you run openocd -f /your/board.cfg -c "program /path/to/your/elf verify exit"?
<Heisey> yes
<PaulFertser> Please do and show :)
<Heisey> oh sorry
<Heisey> that was the last thing you said, let me run the other thing
<Heisey> https://pastebin.com/xsUwmGkb - here, it seems to be able to program and verify
<PaulFertser> Heisey: interesting, that verify image worked properly and values are expected, so it was flashed with this image before.
<Heisey> what I'll try now is erase the flash with the other tools and do that again
<PaulFertser> xPSR: 0x21000000 pc: 0x0800186a msp: 0x2004ff74 <-- see it's right address of reset vector and stack pointer somewhere at the end of RAM
<PaulFertser> Heisey: you can erase with OpenOCD too.
<PaulFertser> Heisey: -c "init; flash erase_sector 0 0 last; shutdown"
<Heisey> yeah okay, so it does seem to be able to erase and program
<PaulFertser> Heisey: so let's check the commands that CLion gives it.
<Heisey> I wonder if I need some hackery to do that
<PaulFertser> Heisey: unlikely, it should be in some config
<Heisey> where should I look in your opinion? I could also talk to the JetBrains people to ask them
<PaulFertser> Heisey: btw, https://resources.jetbrains.com/help/img/idea/2023.3/cl_embed_openocdconfig.png shows "reset init" selected, but reset init is only appropriate before flashing, and after flashing it should do "reset halt" to have a fully clean state. "reset init" is a special thing to prepare for maximum speed reliable flashing and shouldn't be used prior to debug.
<PaulFertser> Heisey: yes, worth discussing that with them, as that's a commercial product and you should have support. I suggest you mention the "reset init" thing too.
<PaulFertser> The question is how exactly they implemented download there and why it's not verifying.
<Heisey> yeah I changed it to reset halt via the UI
<Heisey> let me show you
<PaulFertser> Heisey: btw, not sure if you're familiar with a concept of hack space, so just mentioning in case you're not: there's a place TAMI it Tel Aviv where you can often meet nice people and use some nice tools for your hobby projects.
<Heisey> nice, pretty cool
<Heisey> I haven't used IRC for programming stuff in over a decade... this is bringing me back :)
<Heisey> using pastebin, image pasting and all that
<PaulFertser> Heisey: usually there's a way to specify some init commands for GDB. So you can have CLion just start OpenOCD without flashing, and to the list of GDB commands add "load" (it flashes current elf to target) and "compare-sections".
<Heisey> I can also try a plugin that supports OpenOCD instead of using their built-in support
<PaulFertser> There must be some way in CLion to configure that, probably just not in GUI.
<PaulFertser> The plugin has source available https://github.com/elmot/clion-embedded-arm
<Heisey> it looks pretty old... I am guessing they took this plugin and made it a part of the IDE since then?
<Heisey> they're calling their plugin "Embedded Development Support" now
<PaulFertser> Yes they did
<PaulFertser> Probably didn't change the flashing part though.
<PaulFertser> Heisey: I see it generates an additional UPLOAD target in the CMake file.
<PaulFertser> Heisey: so you should be able to just manually edit CMakeLists instead
<PaulFertser> (instead of using that GUI dialogue)
<PaulFertser> We really need to get in contact with JetBrains to explain them the deal about this "reset init" thing.
<PaulFertser> It's breaking assumptions.
<PaulFertser> And that "program" should better receive "verify" optional argument there.
<Heisey> yeah I'll try to talk to them... they actually have a Discord server for stuff, but it's probably better to open a ticket on their site
<Heisey> trying to do stuff directly from OpenOCD should have been my first goto... I banged the head against the wall for hours yesterday :)
<PaulFertser> Heisey: you disappeared suddenly after asking though
<PaulFertser> Try to see if editing CMakeLists in your project allows you to add verify there.
<PaulFertser> And in general, it shouldn't be using "program" or reset or anything like that manually. It has "monitor" commands which means it's all going through GDB already. And gdb has native "load" command which properly flashes the target if the elf maps to flash and uploads to RAM if it maps elsewhere. No need to reset, no need to specify anything, just simple "load".
<Heisey> oh you think they're doing that? having GDB do all these bits?
<Heisey> I had this IRC session open at the work computer and left
<Heisey> I'd suggest to also have a Discord server, but I know that people are allergic to the idea :)
<PaulFertser> D is actively abuses free software developers, it's an anti-user service.
<PaulFertser> Yes, I see "monitor" commands in their template.
<PaulFertser> That's a way to send to OpenOCD directly via GDB. But GDB knows how to flash with any GDB server, it's just "load".
<Heisey> so it's possible that it's their bundled GDB that's causing issues?
<PaulFertser> Heisey: unlikely. I'm yet to understand what's actually happening without seeing the commands it runs.
<PaulFertser> Heisey: but if editing our project file CMakeLists.txt manually works then we can do it.
<PaulFertser> You can add "monitor log_level 2" before the flashing command and we'll see much more.
<Haohmaru> how about.. replace openocd with a proxy script that relays the commands but also prints them somewhere
<Heisey> I don't see any mention of OpenOCD or GDB commands in the CMakeLists file
<Heisey> well I don't need to use a script for seeing the interaction between the processes... I could use something like Process Monitor
<Haohmaru> well, i'm no h4x0r, that's as much as i could think of
<Heisey> not technically hacking :)
<PaulFertser> Heisey: hm, can you try to grep through whole project directory for "UPLOAD" ?
<PaulFertser> Eh, probably it's not in cmake file after all and just hardcoded in plugin source :/
<PaulFertser> Yes, sorry, I see it now.
<PaulFertser> Well, this plugin isn't that great apparently.
<PaulFertser> You can just run OpenOCD manually and have CLion configured as with any other GDB server for remote debugging.
<PaulFertser> There you surely can add custom GDB commands.
<Heisey> the plugin worked though and is easy to set up and replicate, which is the frustrating part... but if I understand you correctly, you're suggesting to run OpenOCD & GDB directly (presumably from CLion) and then attach to it as a GDB target?
<PaulFertser> I suggest to run OpenOCD manually in another terminal and ask CLion to run GDB for you.
<PaulFertser> And just specify "extended-remote :3333" for the GDB target.
<PaulFertser> The plugin needs some fixes but it's hard to tell what exactly is wrong with it because it's so inflexible and doesn't allow to raise debugging level or some such.
shibboleth has joined #openocd
slobodan_ has joined #openocd
<Heisey> PaulFertser, okay so I managed to get it to work by using the ST Link's GDB server (effectively what the ST Cube IDE is using) and figuring out what the ST IDE tells GDB to do and applying it from CLion
<PaulFertser> Heisey: but not OpenOCD proper?
<Heisey> set *(int *)0xE000EDFC=*(int *)0xE000EDFC|0x7F0
<Heisey> I am still not sure what this does
<Heisey> not yet
<PaulFertser> This thing is some tricky thing for RAM boot, shouldn't be relevant.
<PaulFertser> Probably no, I need to check.
<Heisey> it used to have a "monitor reset" command in CLion by default
<Heisey> let me try getting rid of that set
shibboleth has quit [Quit: shibboleth]
<Heisey> I think the monitor reset is what messed things up
<PaulFertser> Yes, that's some internal register for proper debug, OpenOCD sets it automatically when appropriate.
<Heisey> so it's resetting that ruins it for me
<PaulFertser> "monitor reset" is "reset run" so it lets the target run the flashed code. Unlikely you want to have it in debug session, you want "monitor reset halt".
<Heisey> ah
<Heisey> yeah because the flashed code isn't going to the program, but to some bootloader
<Heisey> and if the bootloader is not present then it doesn't do anything
Heisey has quit [Quit: Client closed]
Heisey has joined #openocd
<Heisey> damn did I speak to the ether?
<Heisey> [2:31:34 PM] <PaulFertser> "monitor reset" is "reset run" so it lets the target run the flashed code. Unlikely you want to have it in debug session, you want "monitor reset halt".
<Heisey> [2:31:52 PM] <Heisey> ah
<Heisey> [2:32:14 PM] <Heisey> yeah because the flashed code isn't going to the program, but to some bootloader
<Heisey> [2:32:26 PM] <Heisey> and if the bootloader is not present then it doesn't do anything
<PaulFertser> Heisey: no it was all here
<Heisey> I'll take a break from this because I actually have to get some work done
<PaulFertser> Heisey: bootloader where, in ROM?
<Heisey> no, it's in the flash also
<PaulFertser> ROM bootloader is always there.
<PaulFertser> Oh you have bootloader in flash!
<PaulFertser> And your elf has no bootloader, right?
<PaulFertser> And probably CLion invocation erases the bootloader somehow?
<PaulFertser> That would kinda explain the behaviour.
crabbedhaloablut has quit []
<Heisey> no the CLion invocation shouldn't erase the bootloader, but even if it did it shouldn't be a problem as long as I'm not using the device in production
<Heisey> but it doesn't start the program for some odd reason
<Heisey> either way it works with CLion + the ST gdbserver for now, but it's frustrating that I can't get it to work with OpenOCD yet
<Heisey> I'll research this when I have more time... I really have to improve my knowledge on debuggers somehow
crabbedhaloablut has joined #openocd
<Heisey> maybe I can convince JetBrains to put their Embedded Support Plugin on an open repository so I can maybe play around with it myself
<Heisey> what was that group in Tel-Aviv you mentioned earlier? I am curious
<Heisey> cool cool
<Heisey> thanks a lot for all the help
<Heisey> I'll look into getting JetBrains to fix those OpenOCD issues
<PaulFertser> Heisey: feel free to ping me when you get more info. It's really hard to tell without seeing what's going on. Probably later when you have more time you can use ProcessMonitor to capture full invocation command line and reproduce it without clion.
Heisey has quit [Quit: Client closed]
Heisey has joined #openocd
dreamcat4 has quit [Quit: Connection closed for inactivity]
Deneb has joined #openocd
Deneb has quit [Remote host closed the connection]
Kerr has quit [Ping timeout: 255 seconds]
Haohmaru has quit [Quit: saionara]
shibboleth has joined #openocd
MGF_Fabio has quit [Ping timeout: 255 seconds]
bvernoux has joined #openocd
bero has quit [Read error: Connection reset by peer]
shibboleth has quit [Quit: shibboleth]
nerozero has quit [Ping timeout: 272 seconds]
Heisey has quit [Quit: Client closed]
slobodan_ has quit [Remote host closed the connection]
slobodan_ has joined #openocd
bvernoux has quit [Quit: Leaving]
slobodan_ has quit [Read error: Connection reset by peer]
slobodan has joined #openocd
slobodan_ has joined #openocd
slobodan has quit [Read error: Connection reset by peer]