Help Compiling ML Unified

Started by menoc, April 26, 2013, 04:42:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

menoc

Can anyone help me with configuring the make file for compiling ML unified? I'm running Yagarto 4.7.2 on a Macbook Pro running OSX 10.8.3. Using MacHg 0.9.25 - Mercurial SCM 1.9.2. The result is a 61KB autoexec.bin file.

Here is my make file configuration and the output of make command in terminal.

Make File:


ARM_PATH=~/yagarto/yagarto-4.7.2/bin
CC=$(ARM_PATH)/arm-none-eabi-gcc-4.7.2
OBJCOPY=$(ARM_PATH)/arm-none-eabi-objcopy
AR=$(ARM_PATH)/arm-none-eabi-ar
RANLIB=$(ARM_PATH)/arm-none-eabi-ranlib
LD=$(CC)
HOST_CC=gcc
HOST_CFLAGS=-g -O3 -W -Wall
VERSION=0.1.9

all: magiclantern.fir


CONFIG_PYMITE = n
CONFIG_RELOC = n
CONFIG_TIMECODE = n
CONFIG_LUA = n

# 5D memory map
# RESTARTSTART is selected to be just above the end of the bss
#
ROMBASEADDR = 0xFF810000
RESTARTSTART = 0x00050000

# Firmware file IDs
FIRMWARE_ID_5D = 0x80000218
FIRMWARE_ID_7D = 0x80000250
FIRMWARE_ID = $(FIRMWARE_ID_5D)

# PyMite scripting paths
PYMITE_PATH = $(HOME)/build/pymite-08
PYMITE_LIB = $(PYMITE_PATH)/src/vm/libpmvm_dryos.a
PYMITE_CFLAGS = \
-I$(PYMITE_PATH)/src/vm \
-I$(PYMITE_PATH)/src/platform/dryos \

# Lua includes and libraries
LUA_PATH = ./lua
LUA_LIB = $(LUA_PATH)/liblua.a
LUA_CFLAGS = -I$(LUA_PATH)

ifeq ($(CONFIG_LUA),y)
include $(LUA_PATH)/Makefile
endif

CF_CARD="/Volumes/EOS_DIGITAL"

#
# Install a normal firmware file to the CF card.
#
install: magiclantern.fir magiclantern.cfg cropmarks.bmp autoexec.bin test.pym
cp $^ $(CF_CARD)
hdiutil unmount $(CF_CARD)

zip: magiclantern-$(VERSION).zip

# zip.txt must be the first item on the list!
magiclantern-$(VERSION).zip: \
zip.txt \
magiclantern.fir \
magiclantern.cfg \
cropmarks.bmp \
autoexec.bin \
README \

-rm $@
zip -z $@ < $^


FLAGS=\
-Wp,-MMD,$(dir $@).$(notdir $@).d \
-Wp,-MT,$@ \
-nostdlib \
-fomit-frame-pointer \
-fno-strict-aliasing \
-DCONFIG_MAGICLANTERN=1 \
-DRESTARTSTART=$(RESTARTSTART) \
-DROMBASEADDR=$(ROMBASEADDR) \
-DVERSION=\"$(VERSION)\" \


CFLAGS=\
$(FLAGS) \
-g \
-O3 \
-Wall \
-W \
-Wno-unused-parameter \
-mlong-calls \
-D__ARM__ \

ifeq ($(CONFIG_PYMITE),y)
CFLAGS += $(PYMITE_CFLAGS)
endif

ifeq ($(CONFIG_LUA),y)
CFLAGS += $(LUA_CFLAGS)
endif

NOT_USED_FLAGS=\
-msoft-float \

AFLAGS=\
$(FLAGS) \


%.s: %.c
$(call build,CC -S,$(CC) $(CFLAGS) -S -o $@ $<)
%.o: %.c
$(call build,CC,$(CC) $(CFLAGS) -c -o $@ $<)
%.i: %.c
$(call build,CPP,$(CC) $(CFLAGS) -E -c -o $@ $<)
%: %.c
$(call build,LD,$(CC) $(CFLAGS) -o $@ $<)
%.o: %.S
$(call build,AS,$(CC) $(AFLAGS) -c -o $@ $<)
%.bin: %
$(call build,OBJCOPY,$(OBJCOPY) -O binary $< $@)

dumper: dumper_entry.o dumper.o
$(call build,LD,$(LD) \
-o $@ \
-nostdlib \
-e _start \
$^ \
)

test: test.o
$(call build,LD,$(LD) \
-o $@ \
-nostdlib \
-mthumb-interwork \
-march=armv5te \
-e _start \
$^ \
)

dumper_entry.o: flasher-stubs.S

reboot.o: reboot.c magiclantern.bin

magiclantern.lds: magiclantern.lds.S
$(call build,CPP,$(CPP) $(CFLAGS) $< | grep -v '^#' > $@)

# magiclantern.lds script MUST be first
# entry.o MUST be second
# menu.o and debug.o must come before the modules
ML_OBJS-y = \
magiclantern.lds \
entry.o \
init.o \
stubs-5d2.208.o \
version.o \
stdio.o \
config.o \
debug.o \
menu.o \
property.o \
font-med.o \
font-small.o \
gui.o \
bootflags.o \
bmp.o \
focus.o \
lens.o \
spotmeter.o \
audio.o \
zebra.o \
hotplug.o \
ptp.o \
bracket.o \

ML_OBJS-$(CONFIG_PYMITE) += \
script.o \
pymite-plat.o \
pymite-nat.o \
pymite-img.o \
$(PYMITE_LIB) \

ML_OBJS-$(CONFIG_LUA) += \
lua-glue.o \
$(LUA_LIB) \

ML_OBJS-$(CONFIG_RELOC) += \
liveview.o \
reloc.o \

ML_OBJS-$(CONFIG_TIMECODE) += \
timecode.o \

# Extract the stdio files that we need
STDIO_OBJ = \
lib_a-setjmp.o \
lib_a-strchr.o \
lib_a-strrchr.o \
lib_a-strlen.o \
lib_a-strcat.o \
lib_a-strncat.o \
lib_a-strcmp.o \
lib_a-strncmp.o \
lib_a-strncpy.o \
lib_a-strstr.o \
lib_a-strcspn.o \
lib_a-memcmp.o \
lib_a-strcoll.o \
lib_a-ctype_.o \

ARM_LIBC_A = ~/yagarto/yagarto-4.7.2/arm-none-eabi/lib/libc.a

$(STDIO_OBJ): $(ARM_LIBC_A)
$(AR) xv $? $(STDIO_OBJ)
libstdio.a: $(STDIO_OBJ)
$(AR) cr $@ $^


magiclantern: $(ML_OBJS-y) libstdio.a
$(call build,LD,$(LD) \
-o $@ \
-N \
-nostdlib \
-T \
$^ \
-lm \
-lgcc \
)

# These do not need to be run.  Since bigtext is not
# a standard program, the output files are checked in.
font-huge.in: generate-font
$(call build,'GENFONT',./$< > $@ \
'-*-helvetica-*-r-*-*-72-*-100-100-*-*-iso8859-*' \
40 66 \
)
font-large.in: generate-font
$(call build,'GENFONT',./$< > $@ \
'-*-helvetica-*-r-*-*-34-*-100-100-*-*-iso8859-*' \
19 25 \
)
font-med.in: generate-font
$(call build,'GENFONT',./$< > $@ \
'-*-helvetica-*-r-*-*-17-*-100-100-*-*-iso8859-*' \
10 16 \
)
font-small.in: generate-font
$(call build,'GENFONT',./$< > $@ \
'-*-helvetica-*-r-*-*-10-*-100-100-*-*-iso8859-*' \
6 8 \
)

font-huge.c: font-huge.in mkfont
$(call build,MKFONT,./mkfont \
< $< \
> $@ \
-width 60 \
-height 70 \
-name font_huge \
)

font-large.c: font-large.in mkfont
$(call build,MKFONT,./mkfont \
< $< \
> $@ \
-width 28 \
-height 32 \
-name font_large \
)

font-med.c: font-med.in mkfont
$(call build,MKFONT,./mkfont \
< $< \
> $@ \
-width 12 \
-height 16 \
-name font_med \
)

font-small.c: font-small.in mkfont
$(call build,MKFONT,./mkfont \
< $< \
> $@ \
-width 8 \
-height 12 \
-name font_small \
)

version.c: FORCE
$(call build,VERSION,( \
echo 'const char build_version[] = "$(VERSION)";' ; \
echo 'const char build_id[] = "'`hg id`'";' ; \
echo 'const char build_date[] ="'`date -u "+%Y-%m-%d %H:%M:%S"`'";' ; \
echo 'const char build_user[] = "'`whoami`@`hostname`'";' ; \
) > $@)

autoexec: reboot.o
$(call build,LD,$(LD) \
-o $@ \
-nostdlib \
-mthumb-interwork \
-march=armv5te \
-e _start \
-Ttext=0x800000 \
$^ \
)

%-stubs.S: %.map
perl -ne > $@ < $< '\
BEGIN { print "#define SYM(a,n) n=a; .global n;\n" } \
s/[\r\n]//g; \
s/^\s*0001:([0-9A-Fa-f]+)\s+([^\s]+)$$/SYM(0x\1,\2)\n/ \
and print; \
'


%.dis: %.bin
$(ARM_PATH)/arm-linux-objdump \
-b binary \
-m arm \
-D \
$< \
> $@

BASE=0xFF800000
#BASE=0
#BASE=0xFF000000

1.1.0/ROM0.elf: 1.1.0/ROM0.bin 1.1.0/ROM0.map
./remake-elf \
--base $(BASE) \
--cc $(CC) \
--relative \
-o $@ \
$^


strings: ROM0.bin
strings -t x $^

ROM0.bin: FORCE
FORCE:


#
# Fetch the firmware archive from the Canon website
# and unpack it to generate the pristine firmware image.
#
eos5d2107.exe:
wget http://web.canon.jp/imaging/eosd/firm-e/eos5dmk2/data/eos5d2107.exe
eos7d109.exe:
wget http://aux1.jp.canon.com/eosd/firm-e/eos7d/data/eos7d109.exe

5d200107.fir: eos5d2107.exe
-unzip -o $< $@
touch $@

# Extract the flasher binary file from the firmware image
# and generate an ELF from it for analysis.

ifdef FETCH_FROM_CANON
%.1.flasher.bin: %.fir dissect_fw
./dissect_fw $< . $(basename $<)
endif

flasher.elf: 5d200107.1.flasher.bin flasher.map
./remake-elf \
--cc $(CC) \
--base 0x800120 \
-o $@ \
$^

dumper.elf: 5d2_dump.fir flasher.map
./remake-elf \
--cc $(CC) \
--base 0x800000 \
-o $@ \
$^

#
# Generate a new firmware image suitable for dumping the ROM images
#
5d2_dumper.fir: dumper.bin 5d200107.1.flasher.bin
./assemble_fw \
--output $@ \
--user $< \
--offset 0x5ab8 \
--id $(FIRMWARE_ID) \

magiclantern.fir: autoexec.bin
$(call build,ASSEMBLE,./assemble_fw \
--output $@ \
--user $< \
--offset 0x120 \
--flasher empty.bin \
--id $(FIRMWARE_ID) \
--zero \
)

dummy_data_head.bin:
perl -e 'print chr(0) x 24' > $@

#ROM0.bin: 5d200107.fir

# Use the dump_toolkit files
# deprectated; use the dumper.c program instead
5d2_dump.fir:
-rm $@
cat \
5d200107.0.header.bin \
5d200107.1.flasher.bin \
dump_toolkit/repack/dummy_data_head.bin \
> $@
./patch-bin $@ < dump_toolkit/diffs/5d2_dump.diff


# Firmware manipulation tools
dissect_fw: dissect_fw.c
$(HOST_CC) $(HOST_CFLAGS) -o $@ $<


#
# Embedded Python scripting
#
SCRIPTS=\
main.py \

# $(PYMITE_PATH)/src/tools/pmImgCreator.py \

pymite-nat.c pymite-img.c: $(SCRIPTS)
$(call build,PYMITE,\
./pymite-compile \
-c \
-u \
-o pymite-img.c \
--native-file=pymite-nat.c \
$^ \
)

%.pym: %.py
$(call build,PYMITE,\
./pymite-compile \
-b \
-u \
-o $@ \
$^ \
)

# Quiet the build process
build = \
@if [ "$V" == 1 ]; then \
echo '$2'; \
else \
printf "[ %-8s ]   %s\n"  $1 $@; \
fi; \
$2


clean:
-$(RM) \
*.o \
*.a \
.*.d \
font-*.c \
magiclantern.lds \
$(LUA_PATH)/*.o \
$(LUA_PATH)/.*.d \

-include .*.d



Make output:

1671-712-MBP:Magic-Lantern-Unified lanadministrator$ make clean
rm -f \
*.o \
*.a \
.*.d \
font-*.c \
magiclantern.lds \
./lua/*.o \
./lua/.*.d \

1671-712-MBP:Magic-Lantern-Unified lanadministrator$ make
[ CPP      ]   magiclantern.lds
[ AS       ]   entry.o
[ CC       ]   init.o
[ AS       ]   stubs-5d2.208.o
[ VERSION  ]   version.c
/bin/sh: hg: command not found
[ CC       ]   version.o
[ CC       ]   stdio.o
stdio.c: In function 'realloc':
stdio.c:277:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
[ CC       ]   config.o
[ CC       ]   debug.o
debug.c: In function 'call_setprintmovielog':
debug.c:169:2: warning: format '%d' expects argument of type 'int', but argument 7 has type 'int32_t' [-Wformat]
debug.c:187:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' [-Wformat]
debug.c:187:2: warning: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' [-Wformat]
debug.c:196:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' [-Wformat]
debug.c:196:2: warning: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' [-Wformat]
debug.c:196:2: warning: format '%d' expects argument of type 'int', but argument 7 has type 'int32_t' [-Wformat]
debug.c:196:2: warning: format '%d' expects argument of type 'int', but argument 8 has type 'int32_t' [-Wformat]
debug.c:196:2: warning: format '%d' expects argument of type 'int', but argument 9 has type 'int32_t' [-Wformat]
debug.c:201:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' [-Wformat]
debug.c:201:2: warning: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' [-Wformat]
debug.c:206:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' [-Wformat]
debug.c:206:2: warning: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' [-Wformat]
debug.c:159:13: warning: unused variable 'div' [-Wunused-variable]
debug.c:158:9: warning: unused variable 'mvrSetQScale' [-Wunused-variable]
debug.c:157:9: warning: unused variable 'mvrFixQScale' [-Wunused-variable]
debug.c:156:9: warning: unused variable 'mvrSetBitRate' [-Wunused-variable]
debug.c:155:10: warning: unused variable 'bps' [-Wunused-variable]
debug.c: In function 'efic_temp_display':
debug.c:249:2: warning: format '%d' expects argument of type 'int', but argument 5 has type 'uint32_t' [-Wformat]
debug.c: At top level:
debug.c:351:3: warning: initialization from incompatible pointer type [enabled by default]
debug.c:351:3: warning: (near initialization for 'debug_menus[4].select') [enabled by default]
debug.c: In function 'debug_property_handler':
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'long unsigned int' [-Wformat]
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 8 has type 'long unsigned int' [-Wformat]
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 9 has type 'long unsigned int' [-Wformat]
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 10 has type 'long unsigned int' [-Wformat]
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 11 has type 'long unsigned int' [-Wformat]
debug.c:433:2: warning: format '%x' expects argument of type 'unsigned int', but argument 12 has type 'long unsigned int' [-Wformat]
debug.c: At top level:
debug.c:606:1: warning: initialization from incompatible pointer type [enabled by default]
debug.c:606:1: warning: (near initialization for 'task_create_movie_start.entry') [enabled by default]
[ CC       ]   menu.o
menu.c: In function 'menu_handler':
menu.c:516:2: warning: case value '1' not in enumerated type 'gui_event_t' [-Wswitch]
menu.c:520:2: warning: case value '268435590' not in enumerated type 'gui_event_t' [-Wswitch]
[ CC       ]   property.o
[ MKFONT   ]   font-med.c
[ CC       ]   font-med.o
[ MKFONT   ]   font-small.c
[ CC       ]   font-small.o
[ CC       ]   gui.o
[ CC       ]   bootflags.o
[ CC       ]   bmp.o
[ CC       ]   focus.o
[ CC       ]   lens.o
[ CC       ]   spotmeter.o
[ CC       ]   audio.o
[ CC       ]   zebra.o
[ CC       ]   hotplug.o
[ CC       ]   ptp.o
[ CC       ]   bracket.o
~/yagarto/yagarto-4.7.2/bin/arm-none-eabi-ar xv /Users/lanadministrator/yagarto/yagarto-4.7.2/arm-none-eabi/lib/libc.a lib_a-setjmp.o lib_a-strchr.o lib_a-strrchr.o lib_a-strlen.o lib_a-strcat.o lib_a-strncat.o lib_a-strcmp.o lib_a-strncmp.o lib_a-strncpy.o lib_a-strstr.o lib_a-strcspn.o lib_a-memcmp.o lib_a-strcoll.o lib_a-ctype_.o
x - lib_a-setjmp.o
x - lib_a-strchr.o
x - lib_a-strrchr.o
x - lib_a-strlen.o
x - lib_a-strcat.o
x - lib_a-strncat.o
x - lib_a-strcmp.o
x - lib_a-strncmp.o
x - lib_a-strncpy.o
x - lib_a-strstr.o
x - lib_a-strcspn.o
x - lib_a-memcmp.o
x - lib_a-strcoll.o
x - lib_a-ctype_.o
~/yagarto/yagarto-4.7.2/bin/arm-none-eabi-ar cr libstdio.a lib_a-setjmp.o lib_a-strchr.o lib_a-strrchr.o lib_a-strlen.o lib_a-strcat.o lib_a-strncat.o lib_a-strcmp.o lib_a-strncmp.o lib_a-strncpy.o lib_a-strstr.o lib_a-strcspn.o lib_a-memcmp.o lib_a-strcoll.o lib_a-ctype_.o
[ LD       ]   magiclantern
[ OBJCOPY  ]   magiclantern.bin
[ CC       ]   reboot.o
[ LD       ]   autoexec
[ OBJCOPY  ]   autoexec.bin
[ ASSEMBLE ]   magiclantern.fir
magiclantern.fir: New CRC: ffffffffffb69d36 OLD b7932bae
1671-712-MBP:Magic-Lantern-Unified lanadministrator$


menoc

Maybe someone has an OSX setup with a working compiler that I could use the make file as a working sample? Anybody care to post a working ML unified make file?