0
votes

I have multiple questions regarding debugging a Raspberry pi 3 from a linux x64 host using gdb-multiarch, as well as writing bare metal programs in general. We are currently facing a problem where our code appears to not be loaded into memory. When we begin debugging in GDB we start at address 0. 3 instructions down we jump into 0x10000. If I modify my linker script to put the Raspberry pi into either address I get the same result, we jump into 0x10000 and our code isn't loaded there. Instead we get this GDB Output

We noticed also that GDB is using 32 bit register names here when we're supposed to be debugging 64 bit code.

Again a recap of what we're using: QEMU with versatile-pb machine. An aarch64 GCC cross-compiler. GDB-multiarch.

We've tried on two different hosts: Ubuntu 16.04 x64 Host running in virtualbox. Mint x64 running natively. We also tried the arm-none-eabi toolchain but were running into problems not having our code compiled as 64 bit.

Help is much appreciated! Thanks!

1

1 Answers

2
votes

You don't give your command line, but "versatile-pb" is a 32-bit only board type, so trying to run 64-bit code on it is going to misbehave in confusing ways. You need to tell QEMU to emulate a 64-bit capable board that matches what your bare-metal code is expecting to run on.

In QEMU 2.12 there will be a "raspi3" QEMU board which may be helpful for you; you'd need to try building the latest 2.12 release candidate tarball at the moment if you wanted to experiment with that (2.12 release isn't due for another couple of weeks). Otherwise you could use the "virt" board if you made sure your bare metal code was built to be able to run on that board.