⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 Boot code for ADM5120 with serial console for Edimax router.
💻
字号:
#=====================================================================# Copyright 2006 HH, All Rights Reserved.# admboot bootloader make file#=====================================================================#---------------------------  Build Tools  -----------------------------------------# The /opt/MIPS-SDE/bin/... tools are more modern than the Edimax versions# usually found in /export/tools/...  The SDE compiler supports the use# of the -march and -mtune MIPS variants and deprecates the -mcpu option.# If you use a toolchain that does not support the -march and -mtune MIPS# variables you will have to play around with -mcpu and/or other compilation# flags in order to successfully build the bootloaders.#CROSS_TOOLS = /export/tools/bin/mipsel-linux#CROSS_TOOLS = /opt/toolchains/uclibc-crosstools-2.0.0/bin/mipsel-uclibcCROSS_TOOLS = /opt/MIPS-SDE/bin/sdeAS = $(CROSS_TOOLS)-asCC = $(CROSS_TOOLS)-gccLD = $(CROSS_TOOLS)-ldAR = $(CROSS_TOOLS)-arOBJCOPY  = $(CROSS_TOOLS)-objcopyOBJ_DUMP = $(CROSS_TOOLS)-objdumpRM = rmMV = mvCP = cpNATIVE_CC = gccNATIVE_CC_FLAGS = -Os -WcommentENDIAN_FLAG = -ELCC_FLAG = $(ENDIAN_FLAG) -Os -DFLASH_4M -DNOR_FLASH -WcommentCPU_FLAG = -mips32 -march=4kc -mtune=4kcLD_FLAG = -X -NAR_CMD = crusOBJDIR = ./buildBINDIR = ./binSCRIPTDIR = ./scriptsSRCDIR = ./srcMODSRCDIR = ./srcmodLIBSRCDIR = ./srcssUTILSDIR = ./utilsINCLUDEDIR = -I. -I./includePLUGINDIR = ./pluginsLIBPATH := -L./libLIBS := -lc -lz# Target-specific variable settingsss_boot   : SS_FLAG := -DSECSECTORss_loader : SS_FLAG := -DMODIFIEDSRCss_loader : SS_FLAG += -DSECSECTORss_loader : SS_FLAG += -DNOTIMEOUTss_loader : LIBPATH += -L$(LIBSRCDIR)ss_loader : LIBS += -lloaderadmcsys_main : SS_FLAG := -DMODIFIEDSRCadmcsys_main : SS_FLAG += -DNOTIMEOUTadmcsys_main : LIBPATH += -L$(LIBSRCDIR)admcsys_main : LIBS += -lloaderLOADERLIB = $(LIBSRCDIR)/libloader.aWRAPUTIL = $(UTILSDIR)/wrapcsysFSIZUTIL = $(UTILSDIR)/chkfsizeVARUTIL = $(UTILSDIR)/varutilinclude $(LIBSRCDIR)/libloader.mk		# sets SS_LIBSRC to names of library source filesinclude $(MODSRCDIR)/ss_loader.mk		# sets SS_LDRSRC to names of SS boot loader source files (and SS_LDRINITSRC)include $(SRCDIR)/adm_loader.mk			# sets ADM_LDRSRC to names of adm boot loader source files (and ADM_LDRINITSRC)include $(MODSRCDIR)/admcsys_main.mk	# sets ADMCSYS_MAINSRC to names of adm csys source files (and ADMCSYS_LDRINITSRC)#--------------------  PHONY targets and default target ----------------------------.PHONY : all.PHONY : cleanall clean dummy.PHONY : utils wrapper chkfsize.PHONY : ss ss_boot ss_loader ss_lib.PHONY : admboot adm_boot adm_loader.PHONY : admcsys admcsys_boot admcsys_main.PHONY : ss_xfer admboot_xfer admcsys_xferall : ss#---------  Wrapper Utility, File Size Utility and Constant Variable Check Utility  --------utils : wrapper chkfsize varutilwrapper : $(WRAPUTIL)chkfsize : $(FSIZUTIL)varutil : $(VARUTIL)$(WRAPUTIL) : $(UTILSDIR)/wrapcsys.c	$(NATIVE_CC) $(NATIVE_CC_FLAGS) -o $@ $<$(FSIZUTIL) : $(UTILSDIR)/chkfsize.c	$(NATIVE_CC) $(NATIVE_CC_FLAGS) -o $@ $<$(VARUTIL) : $(UTILSDIR)/varutil.c include/memdev.h include/hw5120cfg.h include/adm5120.h	$(NATIVE_CC) -Iinclude -DFLASH_4M -DNOR_FLASH $(NATIVE_CC_FLAGS) -o $@ $<#===================================================================================#-----------------------  Security Sector Boot Loader  -----------------------------#===================================================================================# The main target here is "ss".  The targets "ss_boot" and "ss_loader" are# sub-targets and should only be built manually if there's a problem or error when# building "ss".## "ss" primary output file is "$(BINDIR)/ss_64k.bin".  This file is sized to be# exactly the same size as the Security Sector on the MX29LV320 flash chip (64K).# It is a pure binary image that is not wrapped in a CSYS header.  The current# state of the code allows upgrading the 64 KByte Security Sector only via Xmodem# transfer over a serial cable.  There is no reason why this couldn't be done using# a TFTP transfer, but the code currently does not support it.ss : ss_boot ss_loader	cat $(BINDIR)/ss_boot_4k.bin $(BINDIR)/ss_loader_60k.bin > $(BINDIR)/ss_64k.tmp	$(FSIZUTIL) $(BINDIR)/ss_64k.tmp 0x10000	$(OBJCOPY) -F binary -B mips --pad-to 0x10000 $(BINDIR)/ss_64k.tmp $(BINDIR)/ss_64k.bin	@rm -f $(BINDIR)/ss_64k.tmpss_xfer :	smbclient //m5/dx -U xfer%xfer -c "put $(BINDIR)/ss_64k.bin ss_64k.bin"#-----------------------------  SS Boot Startup  -----------------------------------SS_BOOT_OBJ = $(OBJDIR)/nor_bootinit_ss.o$(SS_BOOT_OBJ) : $(SRCDIR)/nor_bootinit.S	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@ss_boot : $(SS_BOOT_OBJ)	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf \		$(SS_BOOT_OBJ) \		-e romreset_except \		-Ttext 0x9FC00000	$(OBJCOPY) -O binary $(BINDIR)/$@.elf  $(BINDIR)/$@.bin	$(OBJCOPY) -F binary -B mips --pad-to 0x1000 $(BINDIR)/$@.bin $(BINDIR)/$@_4k.bin#--------------------------  SS Loader Initialization ------------------------------SS_LDRINITOBJ = $(patsubst %.S,$(OBJDIR)/%_ss.o,$(filter %.S,$(SS_LDRINITSRC)))# All source is obtained from the MODSRCDIR directory EXCEPT for nor_ldrinit.S# which is obtained from the SRCDIR directory.  This is because the version# in SRCDIR contains full boot-from-flash initialization code, whereas the# version in MODSRCDIR assumes most of the memory chip initializations have# been done already (it's mainly geared towards running only in RAM).$(SS_LDRINITOBJ) : $(SRCDIR)/$(SS_LDRINITSRC)	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@$(OBJDIR)/%_ss.o : $(MODSRCDIR)/%.S	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<$(OBJDIR)/%_ss.o : $(MODSRCDIR)/%.c	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<ss_loader : $(patsubst %.c,$(OBJDIR)/%_ss.o,$(filter %.c,$(SS_LDRSRC))) \		$(patsubst %.S,$(OBJDIR)/%_ss.o,$(filter %.S,$(SS_LDRSRC))) \		$(SS_LDRINITOBJ) $(LOADERLIB) chkfsize	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) $(LIBPATH) \		$(SS_LDRINITOBJ) \		$(patsubst %.S,$(OBJDIR)/%_ss.o,$(filter %.S,$(SS_LDRSRC))) \		$(patsubst %.c,$(OBJDIR)/%_ss.o,$(filter %.c,$(SS_LDRSRC))) \		-e _ldrinit \		-Ttext 0x80400000 \		-nostdlib \		$(LIBS) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf	$(OBJCOPY) -O binary $(BINDIR)/$@.elf $(BINDIR)/$@.bin	$(FSIZUTIL) $(BINDIR)/$@.bin 0xF000	$(OBJCOPY) -F binary -B mips --pad-to 0xF000 $(BINDIR)/$@.bin $(BINDIR)/$@_60k.bin#--------------------------  Security Sector Library -------------------------------$(LIBSRCDIR)/%.o : $(LIBSRCDIR)/%.c	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<$(LOADERLIB) : $(patsubst %.c,$(LIBSRCDIR)/%.o,$(filter %.c,$(SS_LIBSRC)))	$(AR) $(AR_CMD) $@ $?ss_lib : $(LOADERLIB)#===================================================================================#----------------------------------  admboot  --------------------------------------#===================================================================================# The main target here is "admboot".  The targets "adm_boot" and "adm_loader" are# sub-targets and should only be built manually if there's a problem or error when# building "admboot".## "admboot" primary output file is "$(BINDIR)/admboot.bin".  This file is not# constrained to any size limitation.  If you want to use it as your primary# bootloader then you must ensure that its size is no larger than the available# space on your flash chip for the bootloader.  Some Edimax-like devices have a# limit of 32 KBytes.  Others allow for 64 KBytes.  This is a pure binary# image that is not wrapped in a CSYS wrapper.  This file can be transferred to# a device using any method it supports for updating its bootloader.## WARNING: This is the only output target I have not personally tested.# Be VERY CAREFUL if you decide to build "admtoot" and download "admboot.bin"# to your Edimax-like device as the primary bootloader. Remember: targets "ss"# and "admcsys" have been tested.  "admboot" has NOT been tested.admboot : adm_boot adm_loader	cat $(BINDIR)/adm_boot_4k.bin $(BINDIR)/adm_loader.bin > $(BINDIR)/admboot.binadmboot_xfer :	smbclient //m5/dx -U xfer%xfer -c "put $(BINDIR)/admboot_64k.bin admboot_64k.bin"#----------------------------- ADM Boot Startup  -----------------------------------ADM_BOOT_OBJ = $(OBJDIR)/nor_bootinit_adm.o$(ADM_BOOT_OBJ) : $(SRCDIR)/nor_bootinit.S	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@adm_boot : $(ADM_BOOT_OBJ)	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf \		$(ADM_BOOT_OBJ) \		-e romreset_except \		-Ttext 0x9FC00000	$(OBJCOPY) -O binary $(BINDIR)/$@.elf  $(BINDIR)/$@.bin	$(OBJCOPY) -F binary -B mips --pad-to 0x1000 $(BINDIR)/$@.bin $(BINDIR)/$@_4k.bin#-------------------------  ADM Loader Initialization ------------------------------ADM_LDRINITOBJ = $(patsubst %.S,$(OBJDIR)/%_adm.o,$(filter %.S,$(ADM_LDRINITSRC)))$(ADM_LDRINITOBJ) : $(SRCDIR)/$(ADM_LDRINITSRC)	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@$(OBJDIR)/%_adm.o : $(SRCDIR)/%.S	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<$(OBJDIR)/%_adm.o : $(SRCDIR)/%.c	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<adm_loader : $(patsubst %.c,$(OBJDIR)/%_adm.o,$(filter %.c,$(ADM_LDRSRC))) \		$(patsubst %.S,$(OBJDIR)/%_adm.o,$(filter %.S,$(ADM_LDRSRC))) \		$(ADM_LDRINITOBJ)	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) $(LIBPATH) \		$(ADM_LDRINITOBJ) \		$(patsubst %.S,$(OBJDIR)/%_adm.o,$(filter %.S,$(ADM_LDRSRC))) \		$(patsubst %.c,$(OBJDIR)/%_adm.o,$(filter %.c,$(ADM_LDRSRC))) \		-e _ldrinit \		-Ttext 0x80400000 \		-nostdlib \		$(LIBS) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf	$(OBJCOPY) -O binary $(BINDIR)/$@.elf $(BINDIR)/$@.bin#===================================================================================#-----------------------------  admboot CSYS  --------------------------------------#===================================================================================# The main target here is "admcsys".  The targets "admcsys_boot" and "admcsys_main"# are sub-targets and should only be built manually if there's a problem or error# when building "admcsys".## "admcsys" primary output file is "$(BINDIR)/admcsys_fw.bin".  This file's format# is compatible with regular Edimax-type device firmware files.  It can be# downloaded to the device in any of the usual ways: xmodem, tftp or through the# device's built-in web management interface for upgrading the firmware.admcsys : admcsys_boot admcsys_main	cat $(BINDIR)/admcsys_boot_4k.bin $(BINDIR)/admcsys_main.bin > $(BINDIR)/admcsys.bin	gzip -9 $(BINDIR)/admcsys.bin	$(WRAPUTIL) $(BINDIR)/admcsys.bin.gz $(BINDIR)/admcsys_fw.binadmcsys_xfer :	smbclient //m5/dx -U xfer%xfer -c "put $(BINDIR)/admcsys_fw.bin admcsys_fw.bin"#-------------------------  admboot CSYS Startup  ----------------------------------CSYS_BOOT_OBJ = $(OBJDIR)/nor_bootmod_csys.o# The modified boot code is used bacause we want to start executing# without doing a lot of low-level memory chip setup.  Set the# start address to where the bootloader normally expects to find# the Linux entry point.$(CSYS_BOOT_OBJ) : $(MODSRCDIR)/nor_bootmod.S	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@admcsys_boot : $(CSYS_BOOT_OBJ)	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf \		$(CSYS_BOOT_OBJ) \		-e _modinit \		-Ttext 0x80002000	$(OBJCOPY) -O binary $(BINDIR)/$@.elf  $(BINDIR)/$@.bin	$(OBJCOPY) -F binary -B mips --pad-to 0x1000 $(BINDIR)/$@.bin $(BINDIR)/$@_4k.bin#-------------------------  admboot CSYS main loader  ------------------------------ADMCSYS_LDRINITOBJ = $(patsubst %.S,$(OBJDIR)/%_csys.o,$(filter %.S,$(ADMCSYS_LDRINITSRC)))$(ADMCSYS_LDRINITOBJ) : $(MODSRCDIR)/$(ADMCSYS_LDRINITSRC)	$(CC) $(CC_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -c $< -o $@$(OBJDIR)/%_csys.o : $(MODSRCDIR)/%.S	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<$(OBJDIR)/%_csys.o : $(MODSRCDIR)/%.c	$(CC) $(CC_FLAG) $(SS_FLAG) $(CPU_FLAG) $(INCLUDEDIR) -o $@ -c $<admcsys_main : $(ADMCSYS_LDRINITOBJ) \		$(patsubst %.c,$(OBJDIR)/%_csys.o,$(filter %.c,$(ADMCSYS_MAINSRC))) \		$(patsubst %.S,$(OBJDIR)/%_csys.o,$(filter %.S,$(ADMCSYS_MAINSRC)))	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) $(LIBPATH) \		$(ADMCSYS_LDRINITOBJ) \		$(patsubst %.S,$(OBJDIR)/%_csys.o,$(filter %.S,$(ADMCSYS_MAINSRC))) \		$(patsubst %.c,$(OBJDIR)/%_csys.o,$(filter %.c,$(ADMCSYS_MAINSRC))) \		-e _ldrinit \		-Ttext 0x80003000 \		-nostdlib \		$(LIBS) \		-Map $(BINDIR)/$@.map \		-o $(BINDIR)/$@.elf	$(OBJCOPY) -O binary $(BINDIR)/$@.elf $(BINDIR)/$@.bin#===================================================================================#-------------------------------  Clean Rules  -------------------------------------#===================================================================================clean :	@$(RM) -f $(LIBSRCDIR)/*.[oa]	@$(RM) -f $(OBJDIR)/*.o	@$(RM) -f $(BINDIR)/*.elf $(BINDIR)/*.img $(BINDIR)/*.bin $(BINDIR)/*.map	@$(RM) -f $(BINDIR)/*.gz	@$(RM) -f $(PLUGINS)/*.map	@$(RM) -f $(PLUGINS)/*.o#===================================================================================#-----------------------------------  Finis  ---------------------------------------#===================================================================================#===================================================================================#-------------------------------  Plugins  -----------------------------------------#===================================================================================.PHONY : marquismarquis : marquis.csys$(PLUGINDIR)/%.o : $(PLUGINDIR)/%.c	$(CC) -EL -Os -Wcomment -mips32 -march=4kc -mtune=4kc -ffreestanding $(INCLUDEDIR) -o $@ -c $<$(PLUGINDIR)/%.o : $(PLUGINDIR)/%.S	$(CC) -EL -Os -Wcomment -mips32 -march=4kc -mtune=4kc $(INCLUDEDIR) -o $@ -c $<include $(PLUGINDIR)/marquis.mkmarquis.csys : wrapper ss_lib \		$(patsubst %.c,$(PLUGINDIR)/%.o,$(filter %.c,$(PLUGIN_MQ))) \		$(patsubst %.S,$(PLUGINDIR)/%.o,$(filter %.S,$(PLUGIN_MQ)))	$(LD) $(ENDIAN_FLAG) $(LD_FLAG) \		-L$(LIBSRCDIR) \		-o $(PLUGINDIR)/$@.tmp \		$(patsubst %.S,$(PLUGINDIR)/%.o,$(filter %.S,$(PLUGIN_MQ))) \		$(patsubst %.c,$(PLUGINDIR)/%.o,$(filter %.c,$(PLUGIN_MQ))) \		-lloader \		-e _main -nostdlib -Ttext 0x80002000 \		-Map $(PLUGINDIR)/$@.map	$(OBJCOPY) -O binary $(PLUGINDIR)/$@.tmp  $(PLUGINDIR)/$@.bin	@$(RM) $(PLUGINDIR)/$@.tmp	gzip -9 $(PLUGINDIR)/$@.bin	$(WRAPUTIL) $(PLUGINDIR)/$@.bin.gz /opt/ris/$@ 0x80002000	@$(RM) $(PLUGINDIR)/$@.bin.gz

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -