1# 2# Makefile for compressed self-booting CFE on Broadcom BCM947XX boards 3# 4# Copyright (C) 2012, Broadcom Corporation 5# All Rights Reserved. 6# 7# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; 8# the contents of this file may not be disclosed to third parties, copied 9# or duplicated in any form, in whole or in part, without the prior 10# written permission of Broadcom Corporation. 11# 12# $Id: Makefile 367718 2012-11-09 03:57:10Z $ 13# 14 15CROSS_COMPILE := $(TOOLPREFIX) 16CC := $(GCC) 17LD := $(GLD) 18LOADADDR := $(CFG_TEXT_START) 19 20# The self-decompresor uses the minimal OSL, get rid of _CFE_ and vxworks 21CFLAGS := $(subst -D_CFE_,,$(CFLAGS)) -fdata-sections 22CFLAGS += -D_CFEZ_ -D_MINOSL_ -DBCMBUSTYPE=SI_BUS -Uvxworks -U__vxworks 23 24# Default mips 25ifeq ($(ARCH),) 26ARCH := mips 27endif 28 29OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S 30OBJCOPYSREC := $(CROSS_COMPILE)objcopy -O srec -R .reginfo -R .note -R .comment -R .mdebug -S 31 32SYSTEM := ../cfe 33 34vpath %.c $(SRCBASE)/shared $(SRCBASE)/cfe/cfe/arch/arm/board/bcm947xx/src 35vpath %.S $(SRCBASE)/shared 36vpath %.lds.in $(SRCBASE)/shared $(SRCBASE)/tools/misc/lzma_src/C 37 38CFLAGS += -DLOADADDR=$(LOADADDR) 39CFLAGS += -ffunction-sections $(call check_gcc, -fvtable-gc, ) 40 41# Note: siutils.o appeared seperately on purpose to solve post reference problem of GCC 42OBJS-mips = boot.o sisdram.o siutils.o hndmips.o hndpmu.o 43OBJS-arm = bootarm.o aisdram_ca9.o siutils.o hndarm_ca9.o \ 44 pcieinit_ca9.o aiutils.o 45 46ifeq ($(strip $(CFG_SHMOO)), 1) 47OBJS-arm += aisdram-ca9.o hndsoc.o \ 48 ddr40_phy_init.o platform.o shmoo_DDR3.o tinymt32.o 49endif 50 51OBJECTS := $(OBJS-$(ARCH)) 52OBJECTS += load.o hndchipc.o min_osl.o bcmutils.o \ 53 bcmstdlib.o sromstubs.o nvramstubs.o 54 55ifeq ($(ARCH), arm) 56 ELF32_LITTLE := elf32-littlearm 57 ELF32_BIG := elf32-bigarm 58 CFLAGS += -DBCMCHIPTYPE=3 59 ifeq ($(strip $(CFG_SHMOO)), 1) 60 TEXT_START := 0xc0000000 61 CFLAGS += -DCFG_SHMOO=1 62 CFEZ_LDS_IN := cfez_arm_shmoo.lds.in 63 else 64 TEXT_START := 0x00001000 65 CFEZ_LDS_IN := cfez_arm.lds.in 66 endif 67else 68 CFEZ_LDS_IN := hndrte.lds.in 69 ELF32_LITTLE := elf32-tradlittlemips 70 ELF32_BIG := elf32-bigmips 71 72 ifeq ($(strip $(CFG_MINIMAL_SIZE)), 1) 73 ifeq ($(strip $(CFG_GMAC)), 0) 74 CFLAGS += -DBCMCHIPTYPE=0 75 OBJECTS += sbsdram.o sbutils.o 76 else 77 CFLAGS += -DBCMCHIPTYPE=1 78 OBJECTS += aisdram.o aiutils.o 79 endif 80 else 81 OBJECTS += aisdram.o aiutils.o sbsdram.o sbutils.o 82 endif 83 84 # Link at 3 MB offset in RAM 85 TEXT_START := 0x80001000 86endif 87 88ifeq ($(strip $(CFG_NFLASH)), 1) 89OBJECTS += nflash.o 90endif 91 92# Default to lzma_4k 93COMPRESS := lzma_4k e 94 95ifneq ($(findstring lzma_4k,$(COMPRESS)),) 96CFLAGS += -DUSE_LZMA -DBCMLZMA 97else 98COMPRESS := cat 99endif 100 101ifeq ($(RTAC68U), 1) 102ifeq ($(BCM470XC0), 1) 103 CFE_BIN_FILE := cfe_rt-ac68u_5003_c0.bin 104else ifeq ($(BCM470XC0), 2) 105 CFE_BIN_FILE := cfe_rt-ac68u_v2_5003_c0.bin 106else ifeq ($(PATYPE), 0) 107 CFE_BIN_FILE := cfe_rt-ac68u.bin 108else ifeq ($(PATYPE), 5023) 109 CFE_BIN_FILE := cfe_rt-ac68u_v2_5023.bin 110else ifeq ($(PATYPE), 85402) 111 CFE_BIN_FILE := cfe_rt-ac68u_v2_85402.bin 112else ifeq ($(PATYPE), 5003) 113 CFE_BIN_FILE := cfe_rt-ac68u_v2_5003.bin 114endif 115endif 116 117all: cfez.bin 118 119# Don't build dependencies, this may die if $(CC) isn't gcc 120dep: 121 122cfez.bin: cfez 123 $(OBJCOPY) $< $@ 124 $(OBJCOPYSREC) $< cfez.srec 125 126ifeq ($(DSLAC68U), 1) 127ifeq ($(JDM), 1) 128 ../../../../../ctools/nvserial -i cfez.bin -o cfe_dsl-ac68u_jdm.bin -s 00 dsl-ac68u_jdm_nvram.txt 129 cp cfe_dsl-ac68u_jdm.bin ../../../.. 130else 131 ../../../../../ctools/nvserial -i cfez.bin -o cfe_dsl-ac68u.bin -s 00 dsl-ac68u_nvram.txt 132 cp cfe_dsl-ac68u.bin ../../../.. 133endif 134endif 135 136ifeq ($(RTAC87U), 1) 137 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac87u.bin -s 00 rt-ac87u_nvram.txt 138 cp cfe_rt-ac87u.bin ../../../.. 139 @if [ "$(CFEZ_MAXSIZE)" != "" ]; then \ 140 if [ "`wc -c < cfe_rt-ac87u.bin`" -gt "$(CFEZ_MAXSIZE)" ]; then \ 141 echo "*** ERROR *** : cfe_rt-ac87u.bin bootrom image size: `wc -c < cfe_rt-ac87u.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \ 142 fi ; \ 143 fi 144else 145ifeq ($(RTAC68U), 1) 146ifeq ($(BCM470XC0), 1) 147 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u_5003_c0.bin -s 00 rt-ac68u_5003_c0_nvram.txt 148 cp cfe_rt-ac68u_5003_c0.bin ../../../.. 149else ifeq ($(BCM470XC0), 2) 150 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u_v2_5003_c0.bin -s 00 rt-ac68u_v2_5003_c0_nvram.txt 151 cp cfe_rt-ac68u_v2_5003_c0.bin ../../../.. 152else 153ifeq ($(PATYPE), 0) 154 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u.bin -s 00 rt-ac68u_nvram.txt 155 cp cfe_rt-ac68u.bin ../../../.. 156else ifeq ($(PATYPE), 5023) 157 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u_v2_5023.bin -s 00 rt-ac68u_v2_5023_nvram.txt 158 cp cfe_rt-ac68u_v2_5023.bin ../../../.. 159else ifeq ($(PATYPE), 85402) 160 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u_v2_85402.bin -s 00 rt-ac68u_v2_85402_nvram.txt 161 cp cfe_rt-ac68u_v2_85402.bin ../../../.. 162else ifeq ($(PATYPE), 5003) 163 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac68u_v2_5003.bin -s 00 rt-ac68u_v2_5003_nvram.txt 164 cp cfe_rt-ac68u_v2_5003.bin ../../../.. 165else ifeq ($(PATYPE), 47094) 166 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-ac88b.bin -s 00 rt-ac88b_nvram.txt 167 cp cfe_rt-ac88b.bin ../../../.. 168endif 169endif 170else 171ifeq ($(RTN18U), 1) 172 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rt-n18u.bin -s 00 rt-n18u_nvram.txt 173 cp cfe_rt-n18u.bin ../../../.. 174endif 175ifeq ($(BUILD_NAME), RP-AC68U) 176 ../../../../../ctools/nvserial -i cfez.bin -o cfe_rp-ac68u.bin -s 00 rp-ac68u_nvram.txt 177 cp cfe_rp-ac68u.bin ../../../.. 178endif 179endif 180endif 181 182ifeq ($(DSLAC68U), 1) 183 @if [ "$(CFEZ_MAXSIZE)" != "" ]; then \ 184 if [ "`wc -c < cfe_dsl-ac68u.bin`" -gt "$(CFEZ_MAXSIZE)" ]; then \ 185 echo "*** ERROR *** : cfe_dsl-ac68u.bin bootrom image size: `wc -c < cfe_dsl-ac68u.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \ 186 fi ; \ 187 fi 188endif 189ifeq ($(RTAC68U), 1) 190 @if [ "$(CFEZ_MAXSIZE)" != "" ]; then \ 191 if [ "`wc -c < $(CFE_BIN_FILE)`" -gt "$(CFEZ_MAXSIZE)" ]; then \ 192 echo "*** ERROR *** : cfe_rt-ac68u.bin bootrom image size: `wc -c < cfe_rt-ac68u.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \ 193 fi ; \ 194 fi 195else 196ifeq ($(RTN18U), 1) 197 @if [ "$(CFEZ_MAXSIZE)" != "" ]; then \ 198 if [ "`wc -c < cfe_rt-n18u.bin`" -gt "$(CFEZ_MAXSIZE)" ]; then \ 199 echo "*** ERROR *** : cfe_rt-n18u.bin bootrom image size: `wc -c < cfe_rt-n18u.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \ 200 fi ; \ 201 fi 202endif 203ifeq ($(BUILD_NAME), RP-AC68U) 204 @if [ "$(CFEZ_MAXSIZE)" != "" ]; then \ 205 if [ "`wc -c < cfe_rp-ac68u.bin`" -gt "$(CFEZ_MAXSIZE)" ]; then \ 206 echo "*** ERROR *** : cfe_rp-ac68u.bin bootrom image size: `wc -c < cfe_rp-ac68u.bin` exceeds limit: $(CFEZ_MAXSIZE)"; \ 207 fi ; \ 208 fi 209endif 210endif 211 212# Link the loader and the kernel binary together 213cfez: cfez.lds $(OBJECTS) piggy.o 214 $(LD) -static -Map cfez.map --gc-sections -no-warn-mismatch -T cfez.lds -o $@ $(OBJECTS) $(LDLIBS) piggy.o 215 216cfez.lds: $(CFEZ_LDS_IN) Makefile 217 sed -e s/TEXT_START/$(TEXT_START)/ \ 218 -e s/TARGET_ARCH/$(ARCH)/ < $< > $@ 219 220# Create a linkable version of the (possibly compressed) kernel binary 221piggy.o: piggz piggy.lds 222 223ifeq ($(CFG_LITTLE), 1) 224 $(LD) -no-warn-mismatch -T piggy.lds -r -o $@ -b binary piggz -b $(ELF32_LITTLE) 225else 226 $(LD) -no-warn-mismatch -T piggy.lds -r -o $@ -b binary piggz -b $(ELF32_BIG) 227endif 228 229piggy.lds: 230 @echo "SECTIONS { .data : { input_len = .; LONG(input_data_end - input_data) input_data = .; *(.data) input_data_end = .; }}" > $@ 231 232piggz: piggy 233ifneq ($(findstring lzma_4k,$(COMPRESS)),) 234 $(COMPRESS) $< $@ 235else 236 $(COMPRESS) $< > $@ 237endif 238 239piggy: $(SYSTEM) 240 $(OBJCOPY) $< $@ 241 242mrproper: clean 243 244clean: 245 rm -f cfez cfez.bin cfez.srec piggz piggy *.lds *.o *.map 246 247%.o : %.S 248 $(GCC) $(ASFLAGS) $(CFLAGS) -o $@ $< 249