avr-chat
[Top][All Lists]
Advanced

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

[avr-chat] Embedding a 'foreign' file in my object code


From: Robert von Knobloch
Subject: [avr-chat] Embedding a 'foreign' file in my object code
Date: Fri, 26 Mar 2010 15:09:16 +0100
User-agent: Thunderbird 1.5.0.14 (X11/20060911)

First to say that I am asking for help because my knowledge of make,
linker & gcc is not as good as I would like (this is sort of an apology).
Also this is a little off-topic, probably not completely avr-specific,
but the 'big boys' of gcc etc. don't undertsand why anyone would want to
locate code at a defined address.
I am writing code on a Mega644 which tests and programs small devices
made with ATTiny processors of varying types.
I have the flash segmented with linker sections and use the sections to
load routines that can be called from an lcd + buttons type gui.
This all works fine using IHEX files and a serial port to update the
routines when needed (not often - I know the flash limits).
Now I want to have a special routine which will be flashed into the
Tinys just for testing (will later be replaced with the final code).
I have written this Tiny25 routine in C and can produce a binary output
file.
What I can't do is get my makefile for the host (Mega644) to actually
incorporate this into the main_test7.hex output which has a nice hole,
just waiting for some code to fill it.
I have got the makefile to convert the uut7.bin to uut7.o OK, (using the
info from the avr-libc FAQ) but how do I get this uut7.o incorporated
into the elf file so that objcopy can do the extraction?
I would really appreciate any pointers that anyone can give me.

Many thanks,
Robert von Knobloch

Some bits of my makefile (the tabs don't quite work in mail, but they
are correct):
=====================================================================================================================
CC             = avr-gcc

CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
LDFLAGS       = -Wl,-Map,$(PRG).map \
        -Wl,--section-start=.test0=0x2600 \
        -Wl,--section-start=.text0=0x2d80 \
       and many more sections.........

OBJCOPY        = avr-objcopy
OBJDUMP        = avr-objdump

all: $(PRG).elf obj7 lst text eeprom test0 test1 test2 test3 test4 test5
test6 test7 test8 test9

$(PRG).elf: $(OBJ)
    @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
# Rule for building the test7 image

obj7: uut7.o

uut7.o : uut7.bin
    @$(OBJCOPY) -I binary -O elf32-avr --rename-section
.data=.testuut7,contents,alloc,load,readonly,data $(<) $(@)

test7:  $(PRG)_test7.hex

%_test7.hex: %.elf     
    $(OBJCOPY) -j .test7 -j .text7 -j .testparms7 --change-section-lma
.test7=0 -j testuut7 --change-section-lma .testuut7=0x600
--change-section-lma .text7=0x780 --change-section-lma .testparms7=0x880
-O ihex $< $@
=====================================================================================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]