From 7d969dbea9999b16b332d46fa844a29577ff6f4e Mon Sep 17 00:00:00 2001 From: Nathan Rossi Date: Tue, 21 Apr 2015 13:31:08 +1000 Subject: u-boot-extra.inc: Rework MicroBlaze config.mk generation * Rework the config.mk for MicroBlaze into a seperate task * Change to using a python task for better handling of content and parsing of the xparameters file Signed-off-by: Nathan Rossi --- recipes-bsp/u-boot/u-boot-extra.inc | 59 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/recipes-bsp/u-boot/u-boot-extra.inc b/recipes-bsp/u-boot/u-boot-extra.inc index b7569864..4301bb46 100644 --- a/recipes-bsp/u-boot/u-boot-extra.inc +++ b/recipes-bsp/u-boot/u-boot-extra.inc @@ -13,27 +13,40 @@ UBOOT_XPARAMETERS ?= "${@expand_workdir_paths("MACHINE_XPARAMETERS", d)}" # Install the MicroBlaze System configuration into the board configuration, # and generate a u-boot specific config.mk -do_configure_prepend () { - if [ "${SOC_FAMILY}" = "microblaze" -a -e "${UBOOT_XPARAMETERS}" ]; then - CONFIG_MK=${S}/board/xilinx/microblaze-generic/config.mk - cp ${UBOOT_XPARAMETERS} ${S}/board/xilinx/microblaze-generic/xparameters.h - - # Generate the config.mk from CFLAGS and XPARAMETERS file - echo "# This file is generated by the meta-xilinx layer." > ${CONFIG_MK} - echo "" >> ${CONFIG_MK} - - # Export CCARGS - for i in ${TUNE_CCARGS}; do - echo "PLATFORM_CPPFLAGS += $i" >> ${CONFIG_MK} - done - echo "" >> ${CONFIG_MK} - - # Calculate the TEXT_BASE address at RAM_END - 4MB - RAM_START=$(grep "XILINX_RAM_START" ${UBOOT_XPARAMETERS} | grep -o "0x.*$") - RAM_SIZE=$(grep "XILINX_RAM_SIZE" ${UBOOT_XPARAMETERS} | grep -o "0x.*$") - BASE_OFFSET=$(printf "0x%08x" "$[$RAM_START + $RAM_SIZE - 0x400000]") - - echo "TEXT_BASE = $BASE_OFFSET" >> ${CONFIG_MK} - echo "CONFIG_SYS_TEXT_BASE = $BASE_OFFSET" >> ${CONFIG_MK} - fi +python do_configmk_generate () { + import re, sys, os, shutil + + machine_xparameters = d.getVar("UBOOT_XPARAMETERS", True) + + if d.getVar("SOC_FAMILY") == "microblaze" and machine_xparameters and os.path.exists(machine_xparameters): + boardpath = os.path.join("board", "xilinx", "microblaze-generic") + configmk = os.path.join(d.getVar("S", True), boardpath, "config.mk") + xparameters = os.path.join(d.getVar("S", True), boardpath, "xparameters.h") + + shutil.copyfile(machine_xparameters, xparameters) + + # Search the xparameters.h file for the RAM base addr and size. + ram = None + with open(machine_xparameters, "r") as f: + filedata = f.read() + ramstart = re.search("XILINX_RAM_START.*?(0x.*)", filedata) + ramsize = re.search("XILINX_RAM_SIZE.*?(0x.*)", filedata) + if ramstart and ramsize: + ram = (int(ramstart.group(1), 16), int(ramsize.group(1), 16)) + + # build up the config.mk file from known info + with open(configmk, "wb") as f: + f.write("# This file is generated by the meta-xilinx layers.\n") + f.write("\n") + + for i in d.getVar("TUNE_CCARGS", True).split(): + f.write("PLATFORM_CCPFLAGS += %s\n" % i) + f.write("\n") + + if ram != None: + base_offset = ram[0] + ram[1] - 0x400000 + f.write("TEXT_BASE = 0x%x\n" % base_offset) + f.write("CONFIG_SYS_TEXT_BASE = 0x%x\n" % base_offset) } +addtask configmk_generate before do_configure after do_unpack + -- cgit v1.2.3-54-g00ecf