CROSS_COMPILE ?= arm-none-eabi- build_dir := $(CURDIR)/build-bcm6846 output_dir := $(HOME) rootfs := $(HOME)/rootfs-bcm53xx-openwrt.cpio fw_tools_dir := /mnt/storage/linus/openwrt/staging_dir/host/bin config_file := $(build_dir)/.config rootfsbase := $(shell basename $(rootfs)) makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") BCM_BOARD ?= bcm6846-genexis-xg6846b dtb := $(build_dir)/arch/arm/boot/dts/broadcom/$(BCM_BOARD).dtb tftproot := /var/lib/tftpboot output_nfs := /mnt/storage/nfsroot/bcm6846 make_options := -f Makefile \ -j$(makethreads) -l$(makejobs) \ ARCH=arm \ CROSS_COMPILE=$(CROSS_COMPILE) \ KBUILD_OUTPUT=$(build_dir) make_flags := CONFIG_DEBUG_SECTION_MISMATCH=y .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config - configure for bcm53xx" @echo "make build - build the kernel and produce a zImage" .PHONY: have-rootfs have-rootfs: @if [ ! -f $(rootfs) ] ; then \ echo "ERROR: no rootfs at $(rootfs)" ; \ echo "This is needed to boot the system." ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "Rootfs available at $(rootfs)" ; \ fi @if [ ! -r $(rootfs) ] ; then \ echo "ERROR: rootfs at $(rootfs) not readable" ; \ echo "ABORTING." ; \ exit 1 ; \ fi .PHONY: have-crosscompiler have-crosscompiler: @echo -n "Check that $(CROSS_COMPILE)gcc is available..." @which $(CROSS_COMPILE)gcc > /dev/null ; \ if [ ! $$? -eq 0 ] ; then \ echo "ERROR: cross-compiler $(CROSS_COMPILE)gcc not in PATH=$$PATH!" ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "OK" ;\ fi # Config options needed to bring up rootfs on distros config-distro: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable LDM_PARTITION \ --enable MSDOS_PARTITION \ --enable EXT4_FS \ --enable EXT4_POSIX_ACL \ --enable DEVTMPFS \ --enable CGROUPS \ --enable INOTIFY_USER \ --enable SIGNALFD \ --enable TIMERFD \ --enable EPOLL \ --enable NET \ --enable SYSFS \ --disable SYSFS_DEPRECATED \ --enable PROC_FS \ --enable FHANDLE \ --enable TMPFS_XATTR \ --enable TMPFS_POSIX_ACL \ --enable CGROUP_SCHED \ --enable FAIR_GROUP_SCHED \ --enable CFS_BANDWIDTH \ --disable RT_GROUP_SCHED \ --enable SECCOMP \ --enable SECCOMP_FILTER \ --enable CHECKPOINT_RESTORE \ --enable CGROUP_FREEZER \ --enable CGROUP_DEVICE \ --enable CPUSETS \ --enable PROC_PID_CPUSET \ --enable CGROUP_CPUACCT \ --enable RESOURCE_COUNTERS \ --enable CGROUP_MEM_RES_CTLR \ --enable CGROUP_MEM_RES_CTLR_DISABLED \ --enable CGROUP_MEM_RES_CTLR_SWAP \ --enable CGROUP_SCHED \ --enable FAIR_GROUP_SCHED \ --enable BLK_CGROUP \ --enable NAMESPACES \ --enable SCHED_AUTOGROUP \ --enable FHANDLE \ --enable SWAP \ --enable AUTOFS4_FS \ --enable BSD_PROCESS_ACCT \ --enable BSD_PROCESS_ACCT_V3 \ --enable TASKSTATS \ --enable TASK_DELAY_ACCT \ --enable TASK_XACCT \ --enable TASK_IO_ACCOUNTING \ --enable BUILD_BIN2C \ --enable IKCONFIG \ --enable IKCONFIG_PROC \ --enable PAGE_COUNTER \ --enable MEMCG \ --enable MEMCG_SWAP \ --enable MEMCG_SWAP_ENABLED \ --enable MEMCG_KMEM \ --enable CGROUP_PERF \ --enable CGROUP_WRITEBACK \ --enable USER_NS \ --enable BLK_DEV_BSG \ --enable BLK_DEV_BSGLIB \ --enable BLK_DEV_INTEGRITY \ --enable NET_INGRESS \ --enable IP_ADVANCED_ROUTER \ --set-str UEVENT_HELPER_PATH "" \ --enable WANT_DEV_COREDUMP \ --enable DEV_COREDUMP \ --enable CHR_DEV_SG \ --enable KEYS \ --enable ENCRYPTED_KEYS \ --enable SECURITY \ --enable SECURITYFS \ --enable SECURITY_NETWORK \ --enable SECURITY_NETWORK_XFRM \ --enable SECURITY_PATH \ --enable INTEGRITY \ --enable CRYPTO_USER_API \ --enable CRYPTO_USER_API_HASH \ --enable CRYPTO_USER_API_SKCIPHER \ --enable CRYPTO_USER_API_AEAD \ --enable ARM_CRYPTO \ --enable CRYPTO_SHA1_ARM \ --enable CRYPTO_SHA256_ARM \ --enable CRYPTO_SHA512_ARM \ --enable CRYPTO_AES_ARM \ --enable BINARY_PRINTF \ --enable MD \ --enable BLK_DEV_DM_BUILTIN \ --enable BLK_DEV_DM \ --enable DM_CRYPT \ --enable DM_UEVENT \ --enable SCSI \ --enable USB_STORAGE config-base: FORCE @mkdir -p $(build_dir) # For multiplatform switch to this and disable earlydebug $(MAKE) $(make_options) bcm6846_defconfig config-initramfs: have-rootfs config-base # Copy and configure in the initramfs @cp $(rootfs) $(build_dir)/$(rootfsbase) $(CURDIR)/scripts/config --file $(config_file) \ --enable BLK_DEV_INITRD \ --set-str INITRAMFS_SOURCE $(rootfsbase) \ --enable RD_XZ \ --enable INITRAMFS_COMPRESSION_XZ config-ext4-rootfs: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable SCSI \ --enable USB_STORAGE \ --enable PARTITION_ADVANCED \ --enable MSDOS_PARTITION \ --enable EFI_PARTITION \ --enable EXT3_FS \ --enable EXT4_FS \ --set-str CMDLINE "root=/dev/sda1 rw" \ --enable CONFIG_CMDLINE_EXTEND config-common: config-base $(CURDIR)/scripts/config --file $(config_file) \ --set-str CMDLINE "console=ttyS0,115200" \ --enable SERIAL_OF_PLATFORM \ --enable PINCTRL_NS \ --enable BCM47XX_NVRAM \ --enable BCM47XX_SPROM \ --enable WATCHDOG \ --enable BCMA \ --enable BCMA_BLOCKIO \ --enable BCMA_DRIVER_GMAC_CMN \ --enable BCMA_DRIVER_GPIO \ --enable BCMA_DRIVER_PCI \ --disable PHY_NS2_PCIE \ --enable BCMA_HOST_SOC \ --disable BCMA_SFLASH \ --enable BCM_NET_PHYLIB \ --enable NETDEVICES \ --enable THERMAL \ --enable THERMAL_GOV_STEP_WISE \ --enable THERMAL_DEFAULT_GOV_STEP_WISE \ --enable THERMAL_OF \ --enable BCM_NS_THERMAL \ --enable BGMAC \ --enable BGMAC_BCMA \ --enable BROADCOM_PHY \ --enable CLK_BCM_NSP \ --enable SPI_BCM_QSPI \ --enable MTD \ --enable MTD_PARTITIONED_MASTER \ --enable MTD_SPI_NOR \ --enable MTD_JEDECPROBE \ --enable MTD_OF_PARTS \ --enable MTD_BCM47XX_PARTS \ --enable MTD_PARSER_TRX \ --enable MTD_NAND_CORE \ --enable MTD_RAW_NAND \ --enable MTD_NAND_BRCMNAND \ --enable NVMEM \ --enable NVMEM_BRCM_NVRAM \ --enable HW_RANDOM \ --enable HW_RANDOM_BCM2835 \ --enable NET_DSA \ --enable B53 \ --enable B53_SRAB_DRIVER \ --enable USB_SUPPORT \ --enable USB \ --enable USB_OHCI_HCD \ --enable USB_OHCI_HCD_PLATFORM \ --enable USB_EHCI_HCD \ --enable USB_EHCI_HCD_PLATFORM \ --enable USB_XHCI_HCD \ --enable USB_XHCI_PLATFORM \ --disable USB_OHCI_HCD_SSB \ --enable USB_HCD_BCMA \ --enable USB_HCD_SSB \ --disable USB_BRCMSTB \ --enable MDIO_DEVICE \ --enable MDIO_BUS \ --enable OF_MDIO \ --enable MDIO_BUS_MUX_MMIOREG \ --enable PHY_BCM_SR_USB \ --enable PHY_BCM_NS_USB2 \ --enable PHY_BCM_NS_USB3 config-earlydebug-6846: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable DEBUG_LL \ --enable DEBUG_BCMBCA \ --enable DEBUG_UNCOMPRESS \ --enable EARLY_PRINTK \ --set-str CMDLINE "console=ttyS0,115200 earlyprintk" config-kasan: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable KASAN \ --enable KASAN_OUTLINE \ --enable STACKTRACE \ --enable SLUB_DEBUG_ON \ --enable TEST_KASAN config-router: config-common @echo "Enabling D-Link BCM router configuration options" $(CURDIR)/scripts/config --file $(config_file) \ --enable NEW_LEDS \ --enable LEDS_CLASS \ --enable LEDS_GPIO \ --enable LEDS_TRIGGERS \ --enable LEDS_TRIGGER_HEARTBEAT \ --enable INPUT \ --enable KEYBOARD_GPIO \ --enable MTD_UBI \ --enable UBIFS_FS \ --enable UBIFS_FS_LZO config-xg6846b: config-common config-router @echo "Enabling XG6846B" $(CURDIR)/scripts/config --file $(config_file) \ --enable USE_OF \ --enable ARM_APPENDED_DTB \ --disable ATAGS \ --disable ARCH_BCM_5301X \ --disable ARCH_BCM_53573 \ --enable ARCH_BCMBCA \ --enable ARCH_BCMBCA_CORTEXA7 \ --disable ARCH_BCMBCA_CORTEXA9 \ --enable ARM_PSCI \ --enable ARM_PSCI_CPUIDLE \ --enable MTD_NAND_BRCMNAND_BCMBCA \ --disable SERIAL_8250 \ --enable SERIAL_BCM63XX \ --enable SERIAL_BCM63XX_CONSOLE \ --enable HW_RANDOM \ --enable HW_RANDOM_IPROC_RNG200 \ --disable HW_RANDOM_BCM2835 \ --enable HW_RANDOM_ARM_SMCCC_TRNG \ --enable WATCHDOG \ --enable BCM7038_WDT \ --enable GPIO_GENERIC_PLATFORM \ --enable KEYBOARD_GPIO_POLLED \ --enable LEDS_BCM63138 \ --enable USB_SUPPORT \ --enable USB \ --enable USB_OHCI_HCD \ --enable USB_OHCI_HCD_PLATFORM \ --enable USB_EHCI_HCD \ --enable USB_EHCI_HCD_PLATFORM \ --disable USB_OHCI_HCD_SSB \ --enable USB_HCD_BCMA \ --enable PHY_BRCM_USB \ --enable MDIO_DEVICE \ --enable MDIO_BCM_UNIMAC \ --enable NET_VENDOR_BROADCOM \ --enable ARM_AMBA \ --enable DMADEVICES \ --enable AMBA_PL08X \ --enable DMATEST # config-earlydebug-bcm5301x config-initramfs config-earlydebug-6846 config: config-common config-xg6846b config-initramfs config-earlydebug-6846 $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable DEBUG_FS yes "" | make $(make_options) oldconfig menuconfig: FORCE $(MAKE) $(make_options) menuconfig saveconfig: FORCE $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/bcm6846_defconfig # Tag on KBUILD_VERBOSE=1 to get verbose build output build-zimage: have-crosscompiler $(MAKE) $(make_options) zImage $(make_flags) @echo "Copy zImage to $(output_dir)/zImage..." @cp -f $(build_dir)/arch/arm/boot/zImage $(output_dir)/zImage build-dtbs: FORCE $(MAKE) $(make_options) dtbs $(make_flags) check-bindings: FORCE $(MAKE) $(make_options) dt_binding_check -k $(make_flags) $(MAKE) $(make_options) dtbs_check -k $(make_flags) build-zimage-dt: build-zimage build-dtbs @if [ ! -r $(dtb) ] ; then \ echo "NO DTB in $(dtb)!" ; \ exit 1 ; \ fi @echo "Catenate DTB onto zImage $(output_dir)/zImage..." cat $(dtb) >> $(output_dir)/zImage # $(fw_tools_dir)/lzma e -lc1 -lp2 -pb2 -d22 $(output_dir)/zImage $(output_dir)/zImage.lz # $(fw_tools_dir)/bcm4908kernel -i $(output_dir)/zImage.lz -o $(output_dir)/zImage.lz.brcm # $(HOME)/bin/bcm4908kernel -i $(output_dir)/zImage.lz -o $(output_dir)/zImage.lz.brcm # rm $(output_dir)/zImage.lz # mv $(output_dir)/zImage.lz.brcm $(output_dir)/zImage @echo "INFO boot with CFE like this on XG6846B:" @echo "r 192.168.1.2:zImage" @echo "loadb n 0x03000000 192.168.1.2:zImage" @echo "go 0x03000000" @if [ -w $(tftproot) ] ; then \ cp $(output_dir)/zImage $(tftproot) ; \ fi @if [ -w $(output_nfs) ]; then \ echo "Copying to NFS root..." ; \ cp -f $(output_dir)/zImage $(output_nfs) ; \ fi build: build-zimage-dt @echo "complete." TAGS: FORCE $(MAKE) $(make_options) TAGS clean: $(MAKE) -f Makefile clean rm -rf $(build_dir) # Rules without commands or prerequisites that do not match a file name # are considered to always change when make runs. This means that any rule # that depends on FORCE will always be remade also. FORCE: