Reputation: 1391
In my assembly startup code for ARM9 i have some lines that i don't understand and are like this:
.word 0x41676d69
.word 0,0,0,0,0
image_type:
.word 0x0000000A
sizeOfPermanentCode:
.word (__image_size)
.word 0,0
bootparameter:
.word 0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
I ve heard that number 0x41676d69 is some sort of an image magic number, but i dont know why it is used for. What about other .word elements? What are they? What do they do?
With kind regards Žiga Lausegger
Upvotes: 1
Views: 837
Reputation: 86506
From what i'm seeing, a boot image should look something like this at the beginning...
+--------------------------+
| (asm) B Start | 0x00
+--------------------------+
| Magic (0x41676d69) | 0x04
+--------------------------+
| code CRC (if type=0x0b) | 0x08
+--------------------------+
| | 0x0c
+-- --+
| |
+-- Reserved --+
| (set to 0) |
+-- --+
| |
+--------------------------+
| image type(0x0a or 0x0b) | 0x1c
+--------------------------+
| image size (incl header) | 0x20
+--------------------------+
| image version (ignored) | 0x24
+--------------------------+
| build time (ignored) | 0x28
+--------------------------+
| "boot parameter" (..?) | 0x2c
+--------------------------+
: : 0x30
. .
it gets fuzzy from here.
Looks like this is yours
to do what you want with
. .
: :
+--------------------------+
| header CRC(if type=0x0a) | 0x6c
+--------------------------+
| | 0x70
+-- --+
| |
+-- Reserved --+
| (set to 0) |
+-- --+
| |
+==========================+
| boot code starts here | 0x80
The B Start
is a jump instruction to the entry point in the boot code. Where that entry point is is mostly up to you.
The 0x41676d69
tells the boot loader that this is a bootable image. The CRCs are basically checksums (but don't ask me how they're calculated); fortunately, if the image_type is set to 10 (0x0a
), they're ignored and can be set to 0.
Far as i'm seeing, the image version and build time are ignored by the boot loader as well. They're just there for tools or whatever to make it easier to figure out versions and stuff.
The "boot parameter", i'm not too sure about. I'm seeing stuff that says "just set it to 0" -- which apparently works. :) But what it means if it's not 0, i couldn't tell you.
Upvotes: 3