[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Targetting an embedded ARM chip?



Hmm. Maybe pass gcc the -S option and make an assembly code file?

       -S     Stop  after the stage of compilation proper; do not
              assemble.  The output is an assembler code file for
              each non-assembler input file specified.

              By default, GCC makes the assembler file name for a
              source file by replacing  the  suffix  `.c',  `.i',
              etc., with `.s'.  Use -o to select another name.

              GCC ignores any input files that don't require com-
              pilation.


Then experiment with "as" and see what it can make. I believe Ralph
will be able to help you as he has hacked on the Netwinder's firmware.
I studied some computer engineering years ago, but I'm a MechE now
and this is just too low-level for me anymore, I'm out of practice :-)
I'm going to post this to linux-arm as well as debian-arm because there
isn't a whole lot of traffic on debian-arm and I know Ralph reads
linux-arm.

Michael D. Crawford wrote:
> Doug,
>
Thanks for your help.

I'm afraid it's not linux, it's a custom embedded application that's hardwired to drive an I/O chip.

Address 0 in the flash rom starts with a little assembly code to set up the stack and enable interrupts, and then it jumps into a loop where each time through it services some I/O requests.

It's nothing like Linux, a Linux kernel wouldn't even fit in the available amount of flash!

So maybe I would need to port gcc to the executable format, but I'd be surprised if someone hadn't already done that.

Basically the contents of the flash is a bunch of raw machine code. Often, though, the images that an upload utility writes contain some extra information like where in the flash to upload it to.

Mike


[ Previous Correspondence ]

Hi. I have had some experience building cross-gcc compilers, and the
gist of it is using the autotools "configure" program. Now, before
you go any further, I need to confirm that you app is running arm-linux
right? (Not CE). If so, then you will be booting an arm linux kernel
and will be using the ELF binary file format. If you are trying to build
for WinCE then we can't help you here.

The key to making it all work, then, is your cross-compiling binutils
which will give you a cross-linker. This is always the first step in
making a cross-gcc setup. I won't tell you its easy, because it just
isn't, there are a lot of things that can go wrong and you need to
have compatible sources for a lot of different packages.

Here is a guide by Jeff Bailey for building an X86->Hurd cross compiler.
The steps for arm will be similar except your target will be something
like "arm4vl-unknown-linux-gnu" and you won't need MIG, gnumach, or Hurd.

http://www.freesoftware.fsf.org/thug/cross.html

The secret to success is the configure command line. Typically you
will use something like:

$ ./configure --host=i386-pc-linux-gnu --target=arm4vl-unknown-linux-gnu

When you "$make install" the cross compiler files will be put into
/usr/lib/gcc-lib/arm4vl-linux and gcc will know to look there for
headers, binaries, libs, etc.

You mention flash format, I hope you aren't writing a bootloader or
something because for that I have no idea what format to recommend,
and you might have to write the first hunk of it in raw machine
language. That is out of my area of expertise, although Ralph might
be able to give you some tips.




Michael D. Crawford wrote:
I'm thinking of maybe using gcc to compile the code for this embedded
ARM device I'm working with.

I expect to be getting a netwinder soon from one of the list members
here, and so wouldn't even have to cross-compile.  But what I would need
to do is make an executable that's in the format for uploading to a
flash rom.

I have a windows-based development system the vendor supplied me with,
it includes a flash upload utility.  I'm not sure what it wants for its
format, maybe just a file of raw code, but I'm sure the vendor would
tell me if I asked (it might already be in the doc I have).

I know some people use gcc set up as a cross-compiler for various kinds
of embedded work.  My question is how to link the code into the right
executable format.  Does anyone here know where I can find information
about that?

I know the GNU ld can be customized with some manner of script, so maybe
I can do it with the standard ld.  Or maybe there is a special GNU
linker for embedded work.

There is a small quantity of assembly code involved but it's short
enough that it wouldn't be hard to hand-translate it into gas' idea of
assembly syntax.

Thanks for any tips you can give me,

Mike




Reply to: