CROSS_COMPILE ?= arm-none-linux-gnueabihf- #REALVIEW_MODEL := pb1176 #REALVIEW_MODEL := pb11mp #REALVIEW_MODEL := eb #REALVIEW_MODEL := eb-11mp #REALVIEW_MODEL := eb-11mp-revb #REALVIEW_MODEL := eb-a9mp #REALVIEW_MODEL := pba8 REALVIEW_MODEL := pbx-a9 realview_dir := $(CURDIR)/build-realview integrator_dir := $(CURDIR)/build-integrator versatile_dir := $(CURDIR)/build-versatile vexpress_dir := $(CURDIR)/build-vexpress dtb := $(realview_dir)/arch/arm/boot/dts/arm-realview-$(REALVIEW_MODEL).dtb output_dir := $(HOME) rootfs := $(HOME)/rootfs-$(REALVIEW_MODEL).cpio install_dir := $(realview_dir)/install config_file := $(realview_dir)/.config rootfsbase := $(shell basename $(rootfs)) makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") tftproot := /var/lib/tftpboot make_options := -f Makefile \ -j$(makethreads) -l$(makejobs) \ ARCH=arm \ CROSS_COMPILE=$(CROSS_COMPILE) \ KBUILD_OUTPUT=$(realview_dir) make_flags := CONFIG_DEBUG_SECTION_MISMATCH=y .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config - configure build dir for RealView" @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example:" @echo "make -f realview.mak config" @echo "make -f realview.mak build" .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 .PHONY: have-mkimage have-mkimage: @echo -n "Check that mkimage is available..." @which mkimage > /dev/null ; \ if [ ! $$? -eq 0 ] ; then \ echo "ERROR: mkimage not in PATH=$$PATH!" ; \ echo "This toom creates the uImage and comes from the uboot tools" ; \ echo "On Ubuntu/Debian sudo apt-get install uboot-mkimage" ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "OK" ;\ fi config-base: FORCE @mkdir -p $(realview_dir) $(MAKE) $(make_options) realview_defconfig # 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 DEVTMPFS \ --enable CGROUPS \ --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 config-initramfs: have-rootfs config-base @cp $(rootfs) $(realview_dir)/$(rootfsbase) # Configure in the initramfs $(CURDIR)/scripts/config --file $(config_file) \ --enable BLK_DEV_INITRD \ --set-str INITRAMFS_SOURCE $(rootfsbase) \ --enable RD_BZIP2 \ --enable INITRAMFS_COMPRESSION_BZIP2 config-earlydebug-pb1176: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --enable DEBUG_REALVIEW_PB1176_PORT \ --set-str CMDLINE "root=/dev/ram0 console=ttyAMA0 earlyprintk mem=128M" config-earlydebug: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --enable DEBUG_REALVIEW_STD_PORT \ --set-str CMDLINE "root=/dev/ram0 console=ttyAMA0 earlyprintk mem=128M" config-mainlined: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable TICK_ONESHOT \ --enable NO_HZ_COMMON \ --enable NO_HZ_FULL \ --enable HIGH_RES_TIMERS \ --enable PERF_EVENTS \ --enable HW_PERF_EVENTS \ --enable AUXDISPLAY \ --enable ARM_CHARLCD \ --enable LEDS_CLASS \ --enable LEDS_VERSATILE \ --enable LEDS_TRIGGERS \ --enable LEDS_TRIGGER_HEARTBEAT \ --enable LEDS_TRIGGER_CPU \ --enable MTD_CFI \ --enable MTD_GEN_PROBE \ --enable MTD_PHYSMAP \ --enable MTD_PHYSMAP_OF \ --enable MTD_ROM \ --enable MTD_AFS_PARTS \ --enable USB_SUPPORT \ --enable USB \ --enable USB_ISP1760 \ --enable USB_ISP1760_HCD \ --enable SCSI \ --enable BLK_DEV_SD \ --enable USB_STORAGE \ --enable ARCH_MULTI_V6 \ --enable ARCH_MULTI_V7 \ --enable ARCH_MULTI_V6_V7 \ --enable ARCH_REALVIEW \ --enable REALVIEW_DT \ --enable ARCH_REALVIEW_EB \ --enable REALVIEW_EB_ARM1136 \ --enable REALVIEW_EB_ARM1176 \ --enable REALVIEW_EB_A9MP \ --enable REALVIEW_EB_ARM11MP \ --enable REALVIEW_EB_ARM11MP_REVB \ --enable MACH_REALVIEW_PB11MP \ --enable MACH_REALVIEW_PB1176 \ --enable MACH_REALVIEW_PBA8 \ --enable MACH_REALVIEW_PBX \ --enable CMA \ --enable FB \ --enable DRM \ --enable DRM_PL111 \ --enable FRAMEBUFFER_CONSOLE \ --enable DRM_PANEL \ --enable DRM_PANEL_SIMPLE \ --enable DRM_BRIDGE \ --enable DRM_PANEL_BRIDGE \ --enable DRM_SIMPLE_BRIDGE \ --enable DRM_DISPLAY_CONNECTOR \ --enable LOGO \ --enable REALVIEW_DT \ --enable ARM_APPENDED_DTB \ --enable ARM_ATAG_DTB_COMPAT \ --enable LEDS_SYSCON \ --enable REGULATOR \ --enable REGULATOR_FIXED_VOLTAGE \ --enable PROC_DEVICETREE \ --enable SMP 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-initramfs config-distro config: config-base config-mainlined config-initramfs # Reconfigure a bit $(CURDIR)/scripts/config --file $(config_file) \ --enable ARM_TEST \ --enable ARM_TCM_TEST \ --enable SMP yes "" | make $(make_options) oldconfig # Under consideration # --enable LEDS_TRIGGER_ARM_CPU # --enable DMADEVICES # --enable AMBA_PL08X menuconfig: FORCE $(MAKE) $(make_options) menuconfig saveconfig: config-base config-mainlined $(MAKE) $(make_options) savedefconfig cp $(realview_dir)/defconfig arch/arm/configs/realview_defconfig build-zimage: have-crosscompiler $(MAKE) $(make_options) zImage $(make_flags) # $(MAKE) $(make_options) -j 4 modules @echo "Copy vmlinux to $(output_dir)/vmlinux..." @cp -f $(realview_dir)/vmlinux $(output_dir)/vmlinux @echo "Copy zImage to $(output_dir)/zImage..." @cp -f $(realview_dir)/arch/arm/boot/zImage $(output_dir)/zImage build-uimage: have-mkimage build-zimage grep 'CONFIG_REALVIEW_HIGH_PHYS_OFFSET=y' $(config_file) ; RET=$$? ; \ if test $${RET} = 0 ; then \ LOADADDR=0x70008000 ; \ else \ LOADADDR=0x00008000 ; \ fi ; \ mkimage \ -A arm \ -O linux \ -T kernel \ -C none \ -a $$LOADADDR \ -e $$LOADADDR \ -n "RealView board file kernel" \ -d $(output_dir)/zImage \ $(output_dir)/uImage ; \ 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 build-uimage-dt: have-mkimage build-zimage-dt grep 'CONFIG_REALVIEW_HIGH_PHYS_OFFSET=y' $(config_file) ; RET=$$? ; \ if test $${RET} = 0 ; then \ LOADADDR=0x70008000 ; \ else \ LOADADDR=0x00008000 ; \ fi ; \ mkimage \ -A arm \ -O linux \ -T kernel \ -C none \ -a $$LOADADDR \ -e $$LOADADDR \ -n "RealView Device Tree kernel" \ -d $(output_dir)/zImage \ $(output_dir)/uImage ; \ # build: build-uimage build: build-uimage-dt # Copy to output dir # If we have a TFTP boot directory if [ -w $(tftproot) ] ; then \ cp $(output_dir)/vmlinux $(tftproot) ; \ cp $(output_dir)/zImage $(tftproot) ; \ cp $(output_dir)/uImage $(tftproot) ; \ fi @echo "TFTP boot:" @echo "set bootargs mem=128M console=ttyAMA0,38400n8 root=/dev/sda1 rw rootwait rootfstype=ext4 init=/sbin/init" @echo "set serverip 192.168.1.121 ; set ipaddr 192.168.1.38 ; tftpboot 0x00007fc0 192.168.1.121:uImage ; bootm" install: FORCE @mkdir -p $(install_dir) umask 0022 && $(MAKE) $(make_options) INSTALL_MOD_STRIP=1 modules_install clean: $(MAKE) -f Makefile clean rm -f $(module_files) rm -rf build # 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: