Closed oltdaniel closed 2 years ago
I've compiled it now with debugging enabled and tested it in the same way as described above and have the full logging output here.
After digging around a bit more and run Bloom directly in debug mode to set some breakpoints I pulled out the raw GDB console and played around with the x
command to read some memory manually. It turns out, there is some "currently random pattern" when GDB throws an Cannot access memory at address
error. Following commands work/don't work with my currently flashed ELF and the Atmega644.
If someone has new theories what else I should test to maybe find the source of this issue, feel free to comment.
I've compared the generated svd file with one from an rp2040
ARM Processor and compared the two. Looks like, as we address the full address space here, the SVD file needs to take care of the 0x800000
offset. So these errors I guess make sense. Additionally I checked the read memory command values which determine the address as flash which would be correct considering the 0x800000
offset is missing. Will test this later and see if the features is then fully working.
Update: Can confirm, the tool just converted it in the wrong way and inserted a bunch of baseAddress
items and no offsets at any point. If these are manually changed, they read the correct values and everything works as expected.
Hi @oltdaniel
Thanks for reporting this.
Hmm, I don't think the problem is the addresses in the SVD. The ORing of 0x800000 to SRAM/register addresses is specific to GDB. GDB does this to encode the memory type in a memory address.
I think I see the problem here: You're using the GDB that is bundled with CLion. Although that GDB supports multiple architectures, it does not support the AVR architecture:
You need to install avr-gdb. This is a GDB that is configured (at compile time) to be used with the AVR architecture. Oh, and be sure to install a fairly new version. You can download a .deb from https://packages.debian.org/sid/gdb-avr. Install that package and then point CLion to your avr-gdb executable:
Give that a go and let me know how it goes. TBH, I've not used SVD files in CLion, so it's possible that you need to do both (use avr-gdb and convert the address in the SVD). That would be a shame if it's the case - the addresses in the SVD file should not have to accommodate GDB specific functionality. Let's hope you only have to use avr-gdb to resolve the issue.
I will reopen this issue to allow you to post an update. Feel free to close afterwards.
Thanks!
In this case related to this specific feature set required to show and set a breakpoint, there is no difference between using the multiarch or actual gdb client (had been tested by us before, even though the avr gdb is in this case definitely recommended). The address issue is the main thing that went wrong with the following indicators, that can be verified with the Insight Window Data:
0x800100
as the address. 0x800000
as the offset to the SRAM itself, 0x100
for the offset of internal registers and stuff.baseaddress
of the CPU
peripheral by adding the 0x800000
offset, the data will be also correct within the CLion Peripheral view.This means, fixing the baseaddress
within the generated SVD file fixed all the issues. Still thanks for checking in to solve this. Awesome work you've done here.
EDIT I'll be able to post comments independent of the close or open state of this issue.
Also, just FYI, there is a known issue with configuring Bloom to run as an 'Embedded GDB Server' - CLion doesn't allow it enough time to shutdown. In fact, it's currently unclear how CLion is shutting Bloom down. Not allowing Bloom to shutdown properly may result in subsequent startup failures.
I created a ticket regarding this issue with the CLion team, a few weeks back: https://youtrack.jetbrains.com/issue/CPP-28843
Hopefully they will improve the server termination routine at some point. 👍🏽
Ah ok. With the Atmel ICE 3 we had luck so far, with no startup issues (at least in this configuration). Let's hope Jetbrains will at least give some insight and maybe close it with a sensible timeout (the only thing required and the easiest solution).
And lets hope Jetbrains is better at solving this kind of stuff than Microchip...
In the planned use case for Bloom in our production ("education") environment, we would like to focus on the CLion internal Debugging functionality. We got it working after 1-2 hours of trying with the following steps and most of the stuff works, but we end up with some read memory errors.
As this is something I think that would nicely fit into the wiki later, I will document everything right away.
Setting up
Embedded GDB Server
in CLionStarting a Debug session
Now a quick explanation, why you would choose
Embedded GDB Server
overRemote Debug
. If you choose Remote Debug, CLion disables some embedded device features, like Peripherals. If we have these features, we can simply load an SVD File (yes an ARM targeted format, but the community has some tricks up its sleeve).Loading an SVD File
We are happily greeted with the option to choose an SVD file here. However, in the AVR universe we only have
.atdf
files which contain this sort of information. But with the help ofRahix/avr-device
we can simply convert these files and also patch some issues that may occur.If done right, we can choose the newly generated svd file and start choosing our desired peripherals to debug.
The current Bloom limit
Having the SVD loaded, we start causing some Bloom internal issues with the
Read memory
command.As there aren't enough debug informations on hand as I installed with simply over the package manager, I will need to compile it and start testing to get deeper into the issue. I will continue to work on it and come back with any new information or even fix.