Sunday, 2 September 2012

Ordered a Pi from which shipped immediately (for £37.98 with case + shipping + vat). Lime green case. Oh, yes.

While waiting for the Pi to arrive, I was reading and was itching to get started working through the assembly language exercises, so I wondered if there was a Pi emulator. Of course there is, this is the Internet, baby. However, note that for the OS on ARM tutorial above, although you will be able to assemble, link and run the exercises on a Pi emulator, none of the hardware (e.g. LEDs) on the Raspberry Pi are emulated, so you won't be able to 'see' the fruits of your labour (or even confirm your code is running correctly) until you run it on a real Pi. So for these exercises, the author expects you to be editing and assembling locally via a toolchain available for mac/linux/windows on his download page.

For the learning process (see below) of writing, assembling, linking and running and debugging ARM programs, the emulator is perfect: for emulator installation instructions.

Note the:
         apt-get install lxde xorg python geany

command fails until you first do:
         apt-get update 

This'll get you an emulated debian-ARM vm running in an emulated debian-raspberry pi vm in virtualbox. Next, give yourself root rights:

         su -
         Password: password

will bring up an editor to let you add your new user to the sudoers list. add a row:
         username ALL=(ALL) ALL

where username is the name you've added. Then:
         apt-get install gcc gdb

will add gcc (and gdb) for your ARM vm.

You may need to reconfigure the keyboard mappings for your emulator:
         apt-get install console-data

This means you can now write ARM assembly, use /usr/bin/as to assemble it & /usr/bin/ld to link it. If you want to link against the linux system calls / standard c libraries, you can assemble and link using gcc.

In addition to the OS on ARM tutorial above, I found the following two sites very useful for getting to grips with ARM assembly: steps you through some simple to increasingly complex examples. Did you ever think you'd understand bubblesort in assembler? is an old but still very relevant book on programming ARM with very useful sections on the ARM instruction set and all the options and variants and twizzles and doodads that you'll see in example code in the above links.

No comments:

Post a Comment