Going low level, very low level…

So, I started with qemu to simulate an ARM board, connect to qemu with GNU Debugger, load some code into the qemu v-board…

So far, so good, I used to run this

qemu-system-arm -M versatilepb -m 256 -kernel /dev/null -s -nographic

This allowed me to skip qemu complaint about no kernel exists, and redirect to the output to the console, and the –s is to allow GDB to connect to it via port 1234…

The problem with this, when I leave it too long, the CPU automatically keeps incrementing the program counter (PC) and keeps looking through out the entire memory space looking for some code to execute, until it runs out of valid addresses, and an exception is raised, and qemu terminates with this error:

qemu: fatal: Trying to execute code outside RAM or ROM at 0x10000000 R00=00000000 R01=00000183 R02=00000100 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 R15=10000000
PSR=400001d3 -Z– A svc32

If I’m fast enough to connect GDB to qemu, then I’m OK, if not, qemu will terminate before I’m able to connect to it…

So I had that crazy thought while having a shower…

Write a small loop with the ARM assembly language (if you can call that a language), that would keep the CPU looping within a small set of commands, just keeping it busy…

    b LOOP

Running the assembler generated an ELF-format file, and until this very moment I’m not sure how to make it generate the plain binary code without the ELF headers…

So, I went to a lower level, opened a HEX editor, and wrote these:

E1 A0 00 00
E1 A0 00 00

And saved it to loop.bin, now I can start qemu with it, and it will loop forever waiting for me connect to it …

qemu-system-arm -M versatilepb -m 256 -kernel loop.bin -s –nographic

And then start GDB like so (here I’ll be using the ELF format u-boot that has been built):

arm-eabi-gdbtui versatilepb/u-boot

And at the (gdb) prompt, enter target remote, and then load my u-boot by entering load, continue, and ctrl+c the output will be similar to these screen shots:

Loading loaded

Also using insight:


For the embedded gurus out there, I’m sure this is nothing, but for me this is a very good start…

And since I found no resources talking about this, I just thought I put it online…


6 Responses

  1. i know that you always that smart guy.

  2. “So, what else, Nanotechnology, nuclear computers, storing my data centers on the moon, using the Sun as a firewall”.. Sameh Shaker thinking about the technologies that he will take some adventures in 🙂

    Keep it up Sameh, and we really appreciate the documentation, it really helps !

    • Come ooooon, the latency resulting from putting your data centers on the moon will make it totally unpractical 😀 …
      Using the sun as a firewall !!!! Are you serious !!!! the fiber cable and the silicon chips would totally melt out 😀 …
      Nanotech and nuclear computers, mmmmmm, that should be around the corner somewhere 😀

      • Sameh, please be more practical than that, the moon data center will help a lot for my nano factory existing in the other side of the moon, also the latency is not a big deal if you used the ultra microwave as you know it is 10 times faster than light. by the way using the sun as firewall is not problem we can use the same cables used to get the energy from our power plant existed 2 kilometers deep in the sun. 😀

  3. Try to add the “-S” option too, it should freeze the emulated target at start, waiting for a gdb connection:

    qemu-system-arm -M versatilepb -m 256 -kernel /dev/null -s -S -nographic

    does it work?

    • Yes, I found that out right after I created this post…
      Thanks for the tip…
      However -S doesn’t seem to work with qemu-0.12 (latest release) I’ve filed a bug for that…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: