1
0
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
TP-Link_Archer-XR500v/EN7526G_3.18Kernel_SDK/tplink/build/tplink.mak
2024-07-22 01:58:46 -03:00

281 lines
12 KiB
Makefile
Executable File

USE_SUPPLIER_BOOT_BUILD=y
USE_SUPPLIER_KERNEL_BUILD=y
USE_TP_DEV_BUILD=y
#USE_SUPPLIER_ROOTFS_BUILD=y
# USE_SUPPLIER_IMAGE_BUILD=y
SUPPLIER = mtk
SUPPLIER_MTK = mtk
ARCH=mips
PROFILE=$(MODEL)
CUSTOM=CT
TOOLPREFIX=mips-buildroot-linux-uclibc-
TOOLROOTPATH=/opt/trendchip/mips-linux-uclibc-4.9.3/usr
#SLIB_PATH = /opt/trendchip/mips-linux-uclibc-4.9.3/usr/lib
SLIB_PATH=$(SDK_PATH)/Project/lib/mips-linux-uclibc-v4.9
KERNELPATH=$(SDK_PATH)/linux-3.18.21
KERNELVERSION=3.18.21
export CONFIG_TP_IMAGE_MTK_IPHOST=y
#ONU TYPE: 1 - SFU, 2 - HGU
export CONFIG_TP_IMAGE_ONU_TYPE=2
# get TC_CFLAGS
include $(SDK_BUILD_PATH)/$(MODEL)/$(MODEL).profile
include $(SDK_PATH)/Project/dir.mak
include $(SDK_PATH)/Project/rule.mak
export HOST=mips-linux
#CFG_CFLAGS += -mips32r2 -muclibc
export SYSROOT=/opt/trendchip/mips-linux-uclibc-4.9.3/usr/mips-buildroot-linux-uclibc/sysroot
export PATH:=$(TOOLROOTPATH)/bin:$(PATH)
export BUILD_DIR=$(SDK_PATH)
export CROSS_COMPILE=$(TOOLPREFIX)
export TARGETS_PATH
###############################################################################
supplier_env_build:supplier_pre_build
###############################################################################
.PHONY: supplier_pre_build
supplier_tools:
$(MAKE) -C $(HOSTTOOLS_DIR) BRCM_KERNEL_ROOTFS=$(BRCM_KERNEL_ROOTFS)
supplier_pre_build:
mkdir -p $(SDK_PATH)/filesystem/lib/modules
mkdir -p $(SDK_PATH)/filesystem/userfs/bin/
mkdir -p $(SDK_PATH)/filesystem/usr/bin/
cd $(SDK_PATH) && $(MAKE) PROFILE=$(MODEL) CUSTOM=$(CUSTOM) pre_build clean_fs
###############################################################################
.PHONY: supplier_menuconfig
supplier_menuconfig: kernel_path_check
@echo "profile menuconfig"
@echo "config TC_CFLAGS which used by kernel"
cp -pfT $(SDK_BUILD_PATH)/$(MODEL)/$(MODEL).profile $(PROFILE_DIR)/$(MODEL).profile
cd $(SDK_PATH) && $(MAKE) PROFILE=$(MODEL) CUSTOM=$(CUSTOM) menuconfig
cp -pfT $(PROFILE_DIR)/$(MODEL).profile $(SDK_BUILD_PATH)/$(MODEL)/$(MODEL).profile
@echo "Replace TC_CFLAGS profile Config File"
###############################################################################
supplier_boot_build:
@echo "start supplier_boot_build"
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT CONFIG_TP_IMAGE=$(CONFIG_TP_IMAGE) CONFIG_TP_DUAL_IMAGE=$(CONFIG_TP_DUAL_IMAGE) bootbase
cp -f $(SDK_PATH)/bootrom/tcboot.bin $(BOOT_TG_PATH)/boot.bin
supplier_boot_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT CONFIG_TP_IMAGE=$(CONFIG_TP_IMAGE) CONFIG_TP_DUAL_IMAGE=$(CONFIG_TP_DUAL_IMAGE) bootbase_clean
-rm -f $(BOOT_TG_PATH)/*
.PHONY:
test_boot_build:
cd $(HOSTTOOLS_DIR) && gcc -O2 -DGNU -I$(INC_BRCMDRIVER_PUB_PATH)/$(BRCM_BOARD) -I$(INC_BRCMSHARED_PUB_PATH)/$(BRCM_BOARD) -I. -o createimg createimg.c -lm
$(HOSTTOOLS_DIR)/addvtoken --chip $(BRCM_CHIP) --flashtype NOR $(BOOT_TG_PATH)/cfe$(BRCM_CHIP).bin $(BOOT_TG_PATH)/boot.bin
$(HOSTTOOLS_DIR)/createimg --endian $(BRCM_ENDIAN_FLAGS) --boardid=$(BRCM_BOARD_ID) --voiceboardid $(BRCM_VOICE_BOARD_ID) --numbermac=$(BRCM_NUM_MAC_ADDRESSES) --macaddr=00:0A:EB:13:09:69 --tp=$(BRCM_MAIN_TP_NUM) --psisize=$(BRCM_PSI_SIZE) --logsize=$(BRCM_LOG_SECTION_SIZE) --auxfsprcnt=$(BRCM_AUXFS_PERCENT) --gponsn=$(BRCM_GPON_SERIAL_NUMBER) --gponpw=$(BRCM_GPON_PASSWORD) --wholeflashfile=$(BOOT_TG_PATH)/boot.bin
###############################################################################
.PHONY: deal_kernel_config
kernel_path_check:
@if [ ! -d $(KERNELPATH) ]; \
then \
echo "KERNELPATH: $(KERNELPATH) not found, please check the KERNELPATH defination"; \
exit 1; \
else \
echo "KERNELPATH: $(KERNELPATH)"; \
fi
supplier_kernel_build: kernel_path_check deal_kernel_config
$(MAKE) -C $(KERNELPATH)
$(MAKE) -C $(KERNELPATH) linux.7z
#cd $(KERNELPATH) && $(MAKE) V=2 linux.7z
cp $(KERNELPATH)/linux.7z $(KERNEL_TG_PATH)/
cp $(KERNELPATH)/vmlinux $(KERNEL_TG_PATH)/
@if test -e $(KERNELPATH)/linux.7z; \
then echo "Compile kernel success"; \
else echo "Compile kernel error!"; exit 1; \
fi
supplier_kernel_menuconfig: kernel_path_check deal_kernel_config
@echo "kernel menuconfig"
@echo "build kernel menuconfig"
$(MAKE) -C $(KERNELPATH) menuconfig
cp -pfT $(KERNELPATH)/.config $(SDK_BUILD_PATH)/$(MODEL)/$(MODEL).kconfig
@echo "Replace Kernel Config File"
supplier_kernel_modules: kernel_path_check deal_kernel_config
$(MAKE) -C $(KERNELPATH) modules
$(MAKE) -C $(KERNELPATH) INSTALL_MOD_PATH=$(FILESYSTEM_DIR) modules_install
cd $(FILESYSTEM_DIR)/lib/modules/3.18.21/ && find . -name "*.ko" -type f |xargs $(STRIP) --strip-unneeded
@echo "install kernel header"
cd $(KERNELPATH) && make headers_install
test -d $(MODULE_TG_PATH) || mkdir -p $(MODULE_TG_PATH) && mkdir -p $(MODULE_TG_PATH)/kmdir/
cp -pR $(FILESYSTEM_DIR)/lib/modules/$(KERNELVERSION)/* $(MODULE_TG_PATH)/kmdir/
supplier_kernel_clean: kernel_path_check
@echo "supplier_kernel_clean"
$(MAKE) -C $(KERNELPATH) clean
#rm -Rf $(KERNEL_TG_PATH)/*
deal_kernel_config:
@echo "------- deal kernel config ------"
cp -pfT $(SDK_BUILD_PATH)/$(MODEL)/$(MODEL).kconfig $(KERNELPATH)/.config
cp -f $(SDK_PATH)/app_bsp/script/add_kernel_config.sh $(KERNELPATH)
chmod 777 $(KERNELPATH)/add_kernel_config.sh
cd $(KERNELPATH) && ./add_kernel_config.sh $(KERNELPATH)/.config $(KERNELPATH)/.config_add
if test -e $(KERNELPATH)/.config_add; \
then cp $(KERNELPATH)/.config_add $(KERNELPATH)/.config; rm $(KERNELPATH)/.config_add; \
fi
rm -f $(KERNELPATH)/kernel_config
cp $(KERNELPATH)/.config $(KERNELPATH)/kernel_config
@echo "------ endof deal kernel config ------"
###############################################################################
supplier_modules:
@echo "build supplier_modules"
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT modules
#cp -p $(FILESYSTEM_DIR)/lib/modules/*.ko $(MODULE_TG_PATH)/
#cp -p $(FILESYSTEM_DIR)/lib/modules/usbhost/*.ko $(MODULE_TG_PATH)/
xpon_modules:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT xpon_modules
cp -p $(FILESYSTEM_DIR)/lib/modules/*.ko $(MODULE_TG_PATH)/
drivers:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT drivers
cp -p $(FILESYSTEM_DIR)/lib/modules/*.ko $(MODULE_TG_PATH)/
wlan:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT wlan
cp -p $(FILESYSTEM_DIR)/lib/modules/*.ko $(MODULE_TG_PATH)/
supplier_modules_clean:
@echo "clean supplier_modules"
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT modules_clean
#rm -rf $(MODULE_TG_PATH)/*
###############################################################################
supplier_apps_build:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT app_bsp
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT apps
supplier_apps_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT app_bsp_clean
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT apps_clean
omci:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT omci
omci_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT omci_clean
pmmgr:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT pmmgr
pmmgr_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT pmmgr_clean
ponmgr:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT ponmgr
ponmgr_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT ponmgr_clean
cfg_manager:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT cfg_manager
cfg_manager_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT cfg_manager_clean
sdk_ebtables:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT ebtables
sdk_ebtables_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT ebtables_clean
tppontool:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT tppontool
tppontool_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT tppontool_clean
dbgmgr:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT dbgmgr
dbgmgr_clean:
cd $(SDK_PATH) && make PROFILE=$(MODEL) CUSTOM=CT dbgmgr_clean
###############################################################################
fs_supplier:
mkdir $(FS_TG_PATH)/userfs
mkdir $(FS_TG_PATH)/userfs/bin
mkdir $(FS_TG_PATH)/tmp
mkdir $(FS_TG_PATH)/etc/Wireless
mkdir $(FS_TG_PATH)/usr/etc
cp -f $(SDK_PATH)/filesystem/lib/lib*.so* $(FS_TG_PATH)/lib
cp -pf $(SDK_PATH)/filesystem/usr/bin/* $(FS_TG_PATH)/usr/bin
cp -pf $(SDK_PATH)/filesystem/userfs/bin/* $(FS_TG_PATH)/userfs/bin
chmod +x $(FS_TG_PATH)/userfs/bin/*
cp -f $(SDK_PATH)/Project/profile/CT/$(MODEL)/romfile.cfg $(FS_TG_PATH)/userfs/romfile.cfg
cp -f $(SDK_PATH)/tplink/build/$(MODEL)/$(MODEL).profile $(FS_TG_PATH)/userfs/profile.cfg
cp -f $(SDK_PATH)/Project/profile/CT/$(MODEL)/led.conf $(FS_TG_PATH)/userfs/led.conf
ifeq ($(INCLUDE_LAN_WLAN), y)
cp -f $(APP_WRIELESSTOOL_DIR)/iwpriv $(FS_TG_PATH)/usr/bin/
cp -f $(APP_WRIELESSTOOL_DIR)/libiw.so.29 $(FS_TG_PATH)/lib/
cp -f $(APP_WRIELESSTOOL_DIR)/wlNetlinkTool $(FS_TG_PATH)/usr/bin/
cp -f $(APP_WRIELESSTOOL_DIR)/ated_tp $(FS_TG_PATH)/usr/bin/
# cp -f $(SDK_PATH)/modules/private/wifi/wireless_bin/$(MODEL)/* $(FS_TG_PATH)/etc
cp -f $(SDK_PATH)/apps/public/8021X/rtdot1xd $(FS_TG_PATH)/usr/bin/rt2860apd
chmod +x $(FS_TG_PATH)/usr/bin/*
endif
cp -f $(SDK_PATH)/Project/profile/CT/$(MODEL)/7570_bob.conf $(FS_TG_PATH)/etc
###############################################################################
supplier_fs_dev:
cd $(SDK_TP_PATH)/tools && chmod +x buildDevs && ./buildDevs $(FS_TG_PATH)
supplier_fs_rootfs:
$(HOSTTOOLS_DIR)/mksquashfs $(FS_TG_PATH) $(IMG_TG_PATH)/rootfs -noappend -all-root -b 65536 -comp xz
###############################################################################
supplier_mkkernel_build:
MTD_BOOT_SIZE=$(shell printf "%d" $(BOOT_MAX_SIZE))
MTD_KERNEL_SIZE=$(shell printf "%d" $(KERNEL_MAX_SIZE))
TEST_TG_PATH=$(TARGETS_PATH)/$(MODEL)/test
supplier_image_build:
#for bootloader WEB upgrade
mkdir -p $(TEST_TG_PATH)
#only cfe file
$(HOSTTOOLS_DIR)/bcmImageBuilder $(BRCM_ENDIAN_FLAGS) --output $(TEST_TG_PATH)/cfe --chip $(BRCM_CHIP) --board $(BRCM_BOARD_ID) --blocksize $(BRCM_FLASHBLK_SIZE) --cfefile $(BOOT_TG_PATH)/cfe$(BRCM_CHIP).bin --include-cfe
# kernel with tp tag
$(TOOLS_PATH)/mkkernel3 -s $(FLASH_SIZE) -l $(BOOT_MAX_SIZE) -m $(KERNEL_MAX_SIZE) -n $(MISC_MAX_SIZE) -e $(CPU_ENDIAN_TYPE) -p $(DATAS_TG_PATH)/reduced_data_model.xml -b $(BOOT_TG_PATH)/boot.bin -k $(KERNEL_TG_PATH)/linux.7z -f $(IMG_TG_PATH)/rootfs -o temp -v $(KERNEL_TG_PATH)/vmlinux -i $(KERNEL_TG_PATH)
# do some pad
cd $(BOOT_TG_PATH) && dd if=/dev/zero of=boot.pad bs=1 count=$(MTD_BOOT_SIZE)
cd $(BOOT_TG_PATH) && cat cfe$(BRCM_CHIP).bin boot.pad | head --bytes=$(MTD_BOOT_SIZE) > pad_boot.bin
cd $(BOOT_TG_PATH) && rm -f boot.pad
cd $(KERNEL_TG_PATH) && dd if=/dev/zero of=kernel.pad bs=1 count=$(MTD_KERNEL_SIZE)
cd $(KERNEL_TG_PATH) && cat temp_tag_kernel.bin kernel.pad | head --bytes=$(MTD_KERNEL_SIZE) > pad_tag_kernel
cd $(KERNEL_TG_PATH) && rm -f kernel.pad temp_tag_kernel.bin
# cfe_kernel_rootfs file
$(HOSTTOOLS_DIR)/bcmImageBuilder $(BRCM_ENDIAN_FLAGS) --output $(TEST_TG_PATH)/kernel_rootfs --chip $(BRCM_CHIP) --board $(BRCM_BOARD_ID) --blocksize $(BRCM_FLASHBLK_SIZE) --cfefile $(BOOT_TG_PATH)/pad_boot.bin --rootfsfile $(KERNEL_TG_PATH)/pad_tag_kernel --kernelfile $(IMG_TG_PATH)/rootfs
# cfe_kernel_rootfs file
$(HOSTTOOLS_DIR)/bcmImageBuilder $(BRCM_ENDIAN_FLAGS) --output $(TEST_TG_PATH)/cfe_kernel_rootfs --chip $(BRCM_CHIP) --board $(BRCM_BOARD_ID) --blocksize $(BRCM_FLASHBLK_SIZE) --cfefile $(BOOT_TG_PATH)/pad_boot.bin --rootfsfile $(KERNEL_TG_PATH)/pad_tag_kernel --kernelfile $(IMG_TG_PATH)/rootfs --include-cfe
rm -f $(BOOT_TG_PATH)/pad_boot.bin $(KERNEL_TG_PATH)/pad_tag_kernel
###############################################################################
.PHONY: kernel_prepare driver_clean
kernel_clean: kernel_prepare
kernel_prepare:
driver_clean:
# this will be done in kernel_clean
#$(MAKE) -C $(SDK_PATH)/bcmdrivers clean