Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

NAMESPACE

Blame
  • makefile.software 6.27 KiB
    #-----------------------------------------------------------------------------
    # NanoSoC Software Compilation Makefile 
    # A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
    #
    # Contributors
    #
    # David Mapstone (d.a.mapstone@soton.ac.uk)
    #
    # Copyright (C) 2021-3, SoC Labs (www.soclabs.org)
    #-----------------------------------------------------------------------------
    
    # Software Directory
    NANOSOC_SW_DIR     ?= $(SOCLABS_NANOSOC_TECH_DIR)/software
    
    # Default to DS-5 tool-chain
    TOOL_CHAIN = ds5
    
    # Software make options
    # - Pass onto the software makefile to define targetted CPU type
    # You can append additional make options for testcode here
    SW_MAKE_OPTIONS = CPU_PRODUCT=CORTEX_M0 TOOL_CHAIN=$(TOOL_CHAIN)
    
    # Bootrom Parameters:
    # Boot Loader image
    BOOTLOADER        ?= bootloader
    BOOTROM_ADDRW     ?= 8
    BOOTROM_HEX       ?= $(SOCLABS_NANOSOC_TECH_DIR)/testcodes/bootloader/$(BOOTLOADER).hex
    BOOTROM_BUILD_DIR ?= $(SOCLABS_PROJECT_DIR)/system/src/bootrom
    
    # Debug Tester image
    DEBUGTESTER  = debugtester
    
    # code target is used by other simulation targets (e.g. run_mti, sim_mti)
    # Before simulation, bootrom and testcode need to be compiled.
    code : testcode bootrom debugtester
    
    # Compile bootloader
    # Note : The use of ls after compile allows the computing server to sync up
    bootrom:
    	@(cd $(TESTCODES_DIR)/$(BOOTLOADER) ;\
    	$(MAKE) all $(SW_MAKE_OPTIONS) ;\
    	echo Compile done ;\
    	ls > /dev/null ;\
    	echo Copy $(BOOTLOADER).hex ;\
    	while [ ! -e $(BOOTLOADER).hex ] ; do \
    		echo Wait for hex file ...; \
    		ls > /dev/null; \
    		sleep 5; \
    		done; \
    	if [ ! -e  $(BOOTLOADER).hex ] ; then \
    		echo Problem reading hex file ;\
    		exit 1; \
    	fi ;\
    	mkdir -p $(BOOTROM_BUILD_DIR)/verilog/ ;\
    	mkdir -p $(BOOTROM_BUILD_DIR)/bintxt/ ;\
    	python3 bootrom_gen.py -a $(BOOTROM_ADDRW) -i $(BOOTLOADER).hex -v $(BOOTROM_BUILD_DIR)/verilog/bootrom.v -b $(BOOTROM_BUILD_DIR)/bintxt/bootrom.bintxt )
    	mkdir -p $(SIM_TOP_DIR)/bootloader
    	cp $(BOOTROM_HEX)  $(SIM_TOP_DIR)/bootloader/$(BOOTLOADER).hex
    
    # Compile test code
    # Note : The use of ls after compile allows the computing server to sync up
    testcode:
    ifeq ($(TESTNAME),)
    	$(error Please specify TESTNAME on the make command line)
    endif
    	@(if [ -d "$(TESTCODES_DIR)/$(TESTNAME)" ] ; then \
    	  cd $(TESTCODES_DIR)/$(TESTNAME) ;\
    	  $(MAKE) all $(SW_MAKE_OPTIONS) ; \
    	  echo Compile done ;\
    	  ls > /dev/null ;\
    	  echo Copy $(TESTNAME).hex ;\
    	  if [ -e  $(TESTNAME).hex ] ; then \
    	    mkdir -p $(SIM_DIR) ; \
    	    cp $(TESTNAME).hex $(SIM_DIR)/image.hex ; \
    	    cp adp.cmd $(SIM_DIR)/adp.cmd ; \
    	  else \
    	    while [ ! -e $(TESTNAME).hex ] ; do \
    	      echo Wait for $(TESTNAME).hex file ...; \
    	      ls > /dev/null ; \
    	      sleep 5 ; \
    	    done; \
    	    if [ -e  $(TESTNAME).hex ] ; then \
    		  mkdir -p $(SIM_DIR) ; \
    	      cp $(TESTNAME).hex $(SIM_DIR)/image.hex ; \
    	      cp $(TESTNAME).hex ../../image.hex ; \
    	    else \
    	      echo Problem reading hex file ;\
    	      exit 1; \
    	    fi ;\
    	  fi ;\
    	  cd $(SIM_DIR) ;\
    	elif [ -d "$(PROJ_SW_DIR)/$(TESTNAME)" ] ; then \
    	  cd $(PROJ_SW_DIR)/$(TESTNAME) ;\
    	  $(MAKE) all $(SW_MAKE_OPTIONS) ; \
    	  echo Compile done ;\
    	  ls > /dev/null ;\
    	  echo Copy $(TESTNAME).hex ;\
    	  if [ -e  $(TESTNAME).hex ] ; then \
    	    mkdir -p $(SIM_DIR) ; \
    	    cp $(TESTNAME).hex $(SIM_DIR)/image.hex ; \
    	    cp adp.cmd $(SIM_DIR)/adp.cmd ; \
    	  else \
    	    while [ ! -e $(TESTNAME).hex ] ; do \
    	      echo Wait for $(TESTNAME).hex file ...; \
    	      ls > /dev/null ; \
    	      sleep 5 ; \
    	    done; \
    	    if [ -e  $(TESTNAME).hex ] ; then \
    		  mkdir -p $(SIM_DIR) ; \
    	      cp $(TESTNAME).hex $(SIM_DIR)/image.hex ; \
    	    else \
    	      echo Problem reading hex file ;\
    	      exit 1; \
    	    fi ;\
    	  fi ;\
    	  cd $(SIM_DIR) ;\
    	else \
    	  echo "ERROR: invalid TESTNAME value ( $(TESTNAME) )" ;\
    	  exit 1 ;\
    	fi ;\
    	)
    
    
    # Compile debugtester
    # Note : The use of ls after compile allows the computing server to sync up
    debugtester:
    	@(cd $(NANOSOC_SW_DIR)/debug_tester ;\
    	$(MAKE) all $(SW_MAKE_OPTIONS) ;\
    	echo Compile done ;\
    	ls > /dev/null ;\
    	echo Copy $(DEBUGTESTER)_le.hex ;\
    	if [ -e  $(DEBUGTESTER)_le.hex ] ; then \
    	  cp $(DEBUGTESTER)_le.hex  $(SIM_TOP_DIR)/debugtester/$(DEBUGTESTER)_le.hex ;\
    	else \
    	  while [ ! -e $(DEBUGTESTER)_le.hex ] ; do \
    	    echo Wait for hex file ...; \
    	    ls > /dev/null ; \
    	    sleep 5 ; \
    	  done; \
    	  if [ -e  $(DEBUGTESTER)_le.hex ] ; then \
    	  	mkdir -p $(SIM_TOP_DIR)/debugtester ;\
    	    cp $(DEBUGTESTER)_le.hex  $(SIM_TOP_DIR)/debugtester/$(DEBUGTESTER)_le.hex ;\
    	  fi ;\
    	fi ;\
    	echo Copy $(DEBUGTESTER)_be.hex ;\
    	if [ -e  $(DEBUGTESTER)_be.hex ] ; then \
    	  	mkdir -p $(SIM_TOP_DIR)/debugtester ;\
    	  cp $(DEBUGTESTER)_be.hex  $(SIM_TOP_DIR)/debugtester/$(DEBUGTESTER)_be.hex ;\
    	else \
    	  while [ ! -e $(DEBUGTESTER)_be.hex ] ; do \
    	    echo Wait for hex file ...;\
    	    ls > /dev/null ;\
    	    sleep 5 ; \
    	  done; \
    	  if [ -e  $(DEBUGTESTER)_be.hex ] ; then \
    	    cp $(DEBUGTESTER)_be.hex  $(SIM_TOP_DIR)/debugtester/$(DEBUGTESTER)_be.hex ;\
    	  fi ;\
    	fi ;\
    	if [ ! -e $(DEBUGTESTER)_le.hex ] && [ ! -e $(DEBUGTESTER)_be.hex ] ; then \
    	    echo Problem reading hex file ;\
    	    exit 1 ;\
    	fi ;\
    	cd $(SIM_TOP_DIR)/debugtester )
    
    # Compile all software including boot ROM
    compile_all_code: bootrom debugtester
    	for thistest in $(TEST_LIST) ; do \
    	  echo Compiling $$thistest   ; \
    	  echo Removing old image.hex ;\
    	  rm -f image.hex  ;\
    	  $(MAKE) testcode TESTNAME=$$thistest;\
    	  if [ -e $(SIM_TOP_DIR)/$$thistest/image.hex ] ; then \
                echo OK    - image.hex     created for test $$thistest ;\
    	  else \
    	    echo ERROR - image.hex NOT created for test $$thistest ;\
    	    exit 1; \
    	  fi ; \
    	done
    
    # Remove all software compilation results
    clean_all_code:
    	@(cd $(NANOSOC_SW_DIR)/debug_tester ; $(MAKE) clean; )
    	@(cd $(TESTCODES_DIR)/$(BOOTLOADER) ; $(MAKE) clean; )
    	@for thistest in $(TEST_LIST) ; do \
    	  echo Cleaning $$thistest ...  ; \
    	  if [ -e $(TESTCODES_DIR)/$$thistest ]; then \
    	  	cd $(TESTCODES_DIR)/$$thistest ; \
    	  	$(MAKE) clean; \
    	  elif [ -e $(PROJ_SW_DIR)/$$thistest ]; then \
    	  	cd $(PROJ_SW_DIR)/$$thistest ; \
    	  	$(MAKE) clean; \
    	  fi \
    	done
    	@rm -rf $(BOOTROM_BUILD_DIR)
    
    # Remove only bootloader and default selected test
    clean_code:
    	@(cd $(TESTCODES_DIR)/$(BOOTLOADER) ; $(MAKE) clean; cd $(SIM_DIR); )
    	@(cd $(TESTCODES_DIR)/$(TESTNAME)   ; $(MAKE) clean; cd $(SIM_DIR); )