|
From: | JD |
Subject: | [Gm2] A success with a stand-alone application on the Raspberry PI - after modifying the assembler |
Date: | Thu, 6 Nov 2014 14:24:28 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
Gaius, My main interest in using gm2 is
to create stand-alone applications ("bare metal programming") on
the RPi. So here is my first, trivial, attempt:
MODULE BakingPi2;(This simple functionality comes from http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/). This module compiles and produces a binary with no problem but, unfortunately, nothing seems to happen when the RPi is booted with just this binary. Of course, there isn't much that the RPi could display to show what happened. So I looked at the assembler and noticed that it uses the stack pointer before assigning anything to it: _M2_BakingPi2_init:The stmfd instruction saves the list of registers in {} on the stack using the register sp. So I augmented the assembler using a crib from the web: _M2_BakingPi2_init:and right at the end: STACK: . = . + 0x1000 /* 4kB of stack memory */And then it all works! So, is there a way around this "feature"? Is there a gcc option? (I tried -nostdlib, but no change) Or is this a problem with binutls that neither you nor a user can alter? I tried compiling the above module on my x86 and the assembler looks very similar. It starts off with a pushl instruction. I look forward to hearing from you. Regards, John |
[Prev in Thread] | Current Thread | [Next in Thread] |