2015-10-01 11:25:19 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
|
|
|
#
|
|
|
|
# \brief Tool for creating an MMC image with a platform specific U-Boot setup
|
|
|
|
# \author Martin Stein
|
|
|
|
# \date 2015-09-30
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Print help text
|
|
|
|
#
|
|
|
|
help:
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) "Tool for creating an MMC image with a platform specific U-Boot setup"
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) "usage:"
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) " create_uboot <platform> [BUILD_DIR=<build-dir>]"
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) " <platform> can be:"
|
2017-01-11 11:26:19 +00:00
|
|
|
$(ECHO) " 'wand_quad'"
|
|
|
|
$(ECHO) " 'usb_armory'"
|
2015-10-01 11:25:19 +00:00
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) " The image will be located at:"
|
|
|
|
$(ECHO) " $(UBOOT_BUILD_DIR)<platform>/$(shell basename $(MMC_IMG))"
|
|
|
|
$(ECHO)
|
|
|
|
|
2017-01-11 11:26:19 +00:00
|
|
|
PLATFORMS_ARM := wand_quad usb_armory
|
2015-10-01 11:25:19 +00:00
|
|
|
PLATFORMS := $(PLATFORMS_ARM)
|
|
|
|
|
|
|
|
# get targeted platform based on the make target
|
|
|
|
PLATFORM := $(firstword $(filter $(PLATFORMS),$(MAKECMDGOALS)))
|
|
|
|
|
|
|
|
# get Genode base directory based on the known location of this tool
|
|
|
|
GENODE_DIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/..)
|
|
|
|
|
|
|
|
UBOOT_URL := https://github.com/m-stein/uboot
|
|
|
|
UBOOT_DIR := $(GENODE_DIR)/contrib/uboot
|
|
|
|
UBOOT_TAG := $(UBOOT_DIR)/.gitignore
|
|
|
|
UBOOT_BRANCH := genode_$(PLATFORM)
|
|
|
|
UBOOT_BRANCH_TAG := $(UBOOT_DIR)/$(UBOOT_BRANCH)
|
|
|
|
UBOOT_BUILD_ROOT := $(UBOOT_DIR)/build
|
|
|
|
UBOOT_BUILD_DIR := $(UBOOT_BUILD_ROOT)/$(PLATFORM)
|
|
|
|
UBOOT_BUILD_CONF := $(UBOOT_BUILD_DIR)/.config
|
|
|
|
MMC_IMG := $(UBOOT_BUILD_DIR)/mmc_img
|
|
|
|
MMC_IMG_SIZE := 8M
|
|
|
|
SHELL := bash
|
|
|
|
VERBOSE := @
|
|
|
|
ECHO := @echo -e
|
|
|
|
BRIGHT_COL := \033[01;33m
|
|
|
|
DEFAULT_COL := \033[0m
|
|
|
|
|
|
|
|
#
|
|
|
|
# Determine architecture based on the given platform
|
|
|
|
#
|
|
|
|
ifeq ($(filter-out $(PLATFORMS_ARM),$(PLATFORM)),)
|
|
|
|
ARCH := arm
|
|
|
|
endif
|
|
|
|
|
|
|
|
UBOOT_MAKE := \
|
|
|
|
$(VERBOSE)make ARCH=$(ARCH) \
|
2019-05-24 15:29:05 +00:00
|
|
|
CROSS_COMPILE=/usr/local/genode/tool/current/bin/genode-$(ARCH)- \
|
2015-10-01 11:25:19 +00:00
|
|
|
O=$(UBOOT_BUILD_DIR) \
|
|
|
|
-j4
|
|
|
|
|
|
|
|
#
|
|
|
|
# Platform settings
|
|
|
|
#
|
|
|
|
|
2017-01-11 11:26:19 +00:00
|
|
|
ifeq ($(PLATFORM), wand_quad)
|
2015-10-01 11:25:19 +00:00
|
|
|
UBOOT_IMG := $(UBOOT_BUILD_DIR)/u-boot.img
|
|
|
|
UBOOT_IMG_SPL := $(UBOOT_BUILD_DIR)/SPL
|
|
|
|
UBOOT_IMGS := $(UBOOT_IMG) $(UBOOT_IMG_SPL)
|
|
|
|
UBOOT_CONF := wandboard_config
|
|
|
|
FINISH_IMAGE := \
|
2015-11-13 12:28:22 +00:00
|
|
|
dd if=$(UBOOT_IMG_SPL) of=$(MMC_IMG) bs=1k seek=0 conv=notrunc,fsync; \
|
|
|
|
dd if=$(UBOOT_IMG) of=$(MMC_IMG) bs=1k seek=68 conv=notrunc,fsync;
|
2015-10-01 11:25:19 +00:00
|
|
|
endif
|
|
|
|
|
2017-01-11 11:26:19 +00:00
|
|
|
ifeq ($(PLATFORM), usb_armory)
|
2015-11-13 12:35:22 +00:00
|
|
|
UBOOT_IMG := $(UBOOT_BUILD_DIR)/u-boot.imx
|
|
|
|
UBOOT_IMGS := $(UBOOT_IMG)
|
|
|
|
UBOOT_CONF := usbarmory_config
|
|
|
|
FINISH_IMAGE := dd if=$(UBOOT_IMG) of=$(MMC_IMG) bs=512 seek=0 conv=fsync
|
|
|
|
endif
|
|
|
|
|
2015-10-01 11:25:19 +00:00
|
|
|
#
|
|
|
|
# Generic rules for the creation of the image
|
|
|
|
#
|
|
|
|
|
|
|
|
$(PLATFORM): $(MMC_IMG)
|
|
|
|
|
|
|
|
$(MMC_IMG): $(UBOOT_IMGS)
|
|
|
|
$(ECHO) "$(BRIGHT_COL)Composing MMC image...$(DEFAULT_COL)"
|
|
|
|
$(VERBOSE)dd if=/dev/zero of=$(MMC_IMG) bs=$(MMC_IMG_SIZE) seek=1 count=0
|
|
|
|
$(VERBOSE)$(FINISH_IMAGE)
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) "Successfully created MMC image."
|
2018-01-04 17:30:31 +00:00
|
|
|
$(ECHO) "You can install the image on an empty MMC via"
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) "! sudo dd if=$(MMC_IMG) of=/dev/<YOUR_MMC> bs=1K seek=1 conv=fsync"
|
|
|
|
$(ECHO)
|
|
|
|
$(ECHO) "This way, it'll end at $(MMC_IMG_SIZE) + 1 byte. To be safe, let"
|
|
|
|
$(ECHO) "your individual data (e.g. file system) start at $(MMC_IMG_SIZE) + 1M byte"
|
2015-10-01 11:25:19 +00:00
|
|
|
$(ECHO)
|
|
|
|
|
|
|
|
$(UBOOT_IMGS): $(UBOOT_BUILD_CONF) $(UBOOT_DIR)
|
|
|
|
$(ECHO) "$(BRIGHT_COL)Building U-Boot images...$(DEFAULT_COL)"
|
|
|
|
$(UBOOT_MAKE) -C $(UBOOT_BUILD_DIR)
|
|
|
|
|
|
|
|
$(UBOOT_BUILD_CONF): $(UBOOT_BRANCH_TAG)
|
|
|
|
$(ECHO) "$(BRIGHT_COL)Building U-Boot config...$(DEFAULT_COL)"
|
|
|
|
$(VERBOSE)mkdir -p $(UBOOT_BUILD_DIR)
|
|
|
|
$(UBOOT_MAKE) -C $(UBOOT_DIR) $(UBOOT_CONF)
|
|
|
|
|
|
|
|
$(UBOOT_BRANCH_TAG): $(UBOOT_TAG)
|
|
|
|
$(VERBOSE)git -C $(UBOOT_DIR) checkout $(UBOOT_BRANCH)
|
|
|
|
|
|
|
|
$(UBOOT_TAG):
|
|
|
|
$(ECHO) "$(BRIGHT_COL)Downloading U-Boot sources...$(DEFAULT_COL)"
|
|
|
|
$(VERBOSE)git clone $(UBOOT_URL) $(UBOOT_DIR)
|
|
|
|
|
|
|
|
.PHONY: $(PLATFORM)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean-up rules
|
|
|
|
#
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(UBOOT_BUILD_ROOT)
|
|
|
|
|
|
|
|
cleanall:
|
|
|
|
rm -rf $(UBOOT_DIR)
|