Forum Discussion
Altera_Forum
Honored Contributor
12 years agoThat is the EPCS flash loader sequence.
What you should be able to do is extrace the sections from the elf file and use each one to generate an initialisation file for the relevant memory block. I generate an elf file that includes two code and two data sections that need initialising (and some sections that don't).$ objdump -h mtp2.elf
mtp2.elf: file format elf32-little
Sections:
Idx Name Size VMA LMA File off Algn
0 prot_code 00002078 00008000 00008000 000000f4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 hdlc_code 00000a50 0000c000 0000c000 0000216c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 shared_data 00002000 00014000 00014000 00002bbc 2**2
ALLOC
3 prot_data 00002b3c 00018000 00018000 00002bbc 2**4
CONTENTS, ALLOC, LOAD, DATA
4 hdlc_data 00002e08 0001c000 0001c000 000056f8 2**2
CONTENTS, ALLOC, LOAD, DATA
5 sdram 00a38000 01000000 01000000 00008500 2**15
ALLOC
6 .comment 000001ce 00000000 00000000 00008500 2**0
CONTENTS, READONLY
7 unwanted 00000000 0001c000 0001c000 000056f8 2**0
CONTENTS, ALLOC, LOAD, CODE I actually use objcopy to convert them into ppc object files, but I generate raw binary files on the way. Makefile fragment below: # Convert sections from nios2 program into readonly data areas that can
# be linked into the loading program.
# We must cd to $(OBJDIR) to avoid getting the directory path prepended
# to the symbol names objcopy adds to the created file.
# Flags for objcopy to generate the correct section type from raw data
SECT = $(notdir $(@:.o=))
FL_GEN = --rename-section .data=.rodata.$(SECT),alloc,load,readonly,data,contents
OBJ_FLAGS = -O elf32-powerpc -B powerpc
$(NIOS_SECT_OBJS): $(OBJ_DIR)/mtp2.elf
@ echo '### create $@'
$(NIOS_OBJCOPY) -O binary -j $(SECT) $^ $(@:.o=.x)
cd $(OBJ_DIR) && {
$(OBJCOPY) -I binary $(OBJ_FLAGS) $$FL_GEN $(SECT:=.x) $(SECT:=.o);
}
rm -f $(@:.o=.x) I'm not sure what format you need the M9K initialisation data in, you might not need two objcopy call, and you'll certainly need different values for OBJ_FLAGS for the second one.