diff --git a/modules/core b/modules/core index 9fe2a064e..8eb97ff55 160000 --- a/modules/core +++ b/modules/core @@ -1 +1 @@ -Subproject commit 9fe2a064e97b9802410e36108b3df1f43c94a7b1 +Subproject commit 8eb97ff55ea62693f3820906c9d6e022c6e5c8ce diff --git a/scripts/clang_tidy_wrapper.sh b/scripts/clang_tidy_wrapper.sh index f5ad327cf..4cced27f8 100755 --- a/scripts/clang_tidy_wrapper.sh +++ b/scripts/clang_tidy_wrapper.sh @@ -48,7 +48,7 @@ extra_args=() # is then missing. To bypass this, generated MCU file is added via include # flag, and CORE_MCU_STUB symbol is explicitly defined so that only stub # implementations from core are available. -extra_args+=(-extra-arg="-include$script_dir/../src/board/gen/mcu/$mcu/MCU.h") +extra_args+=(-extra-arg="-include$script_dir/../src/board/generated/mcu/$mcu/CoreMCUGenerated.h") extra_args+=(-extra-arg="-DCORE_MCU_STUB") case $compiler in diff --git a/scripts/gen/gen_mcu.sh b/scripts/gen/gen_mcu.sh index d43be7d67..95e5a2dc6 100755 --- a/scripts/gen/gen_mcu.sh +++ b/scripts/gen/gen_mcu.sh @@ -1,247 +1,25 @@ #!/usr/bin/env bash -# core module already provides defines and Makefile for MCU via -# its own gen_mcu.sh script. +# core module already provides defines and Makefile via mcu Makefile target. # This script is used to provide additional project-specific -# configuration on top of base configuration. +# configuration on top of base configuration if required. script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) -base_yaml_file=$1 -yaml_file=$2 -gen_dir=$3 -extFreq=$4 +mcu=$1 +core_yaml_file=$(make --no-print-directory -C "$script_dir"/../../modules/core/src MCU="$mcu" print-MCU_YML_FILE) +project_yaml_file=${script_dir}/../../config/mcu/$mcu.yml +gen_dir=$2 yaml_parser="dasel -n -p yaml --plain -f" out_header="$gen_dir"/MCU.h out_makefile="$gen_dir"/MCU.mk -if ! "$script_dir"/../../modules/core/scripts/gen_mcu.sh "$base_yaml_file" "$gen_dir" "$extFreq" +if ! make --no-print-directory -C "$script_dir"/../../modules/core/src MCU="$mcu" MCU_GEN_DIR="$gen_dir" then exit 1 fi echo "Generating MCU configuration..." -printf "%s\n" "### gen_mcu.sh ADDITIONS ###" >> "$out_makefile" - mkdir -p "$gen_dir" -declare -i app_start_page -declare -i boot_supported -declare -i boot_start_page -declare -i boot_end_page -declare -i app_boot_jump_offset -declare -i adc_prescaler -declare -i adc_samples -declare -i boot_size -declare -i factory_flash_page -declare -i factory_flash_page_offset -declare -i eeprom_flash_page_1 -declare -i eeprom_flash_page_2 -declare -i total_flash_pages - -if [[ $($yaml_parser "$yaml_file" flash.boot-start-page) != "null" ]] -then - # Having just "if [[ $boot_start_page != "null" ]]" check later will - # fail because boot_start_page is defined as integer, so even if - # dasel returns null for boot-start-page key, the value will be 0 - boot_supported=1 -fi - -app_start_page=$($yaml_parser "$yaml_file" flash.app-start-page) -boot_start_page=$($yaml_parser "$yaml_file" flash.boot-start-page) -boot_end_page=0 -app_boot_jump_offset=$($yaml_parser "$yaml_file" flash.app-boot-jump-offset) -adc_prescaler=$($yaml_parser "$yaml_file" adc.prescaler) -adc_samples=$($yaml_parser "$yaml_file" adc.samples) -boot_size=0 -factory_flash_page=0 -factory_flash_page_offset=0 -eeprom_flash_page_1=0 -eeprom_flash_page_2=0 -total_flash_pages=0 - -if [[ $app_start_page == "null" ]] -then - app_start_page=0 -fi - -if [[ $boot_supported -ne 0 ]] -then - { - printf "%s\n" "DEFINES += HW_SUPPORT_BOOTLOADER" - } >> "$out_makefile" -else - # No bootloader, start at first page - app_start_page=0 -fi - -{ - printf "%s\n" "DEFINES += FLASH_PAGE_APP=$app_start_page" -} >> "$out_makefile" - -if [[ $($yaml_parser "$base_yaml_file" flash.pages) != "null" ]] -then - app_start_address=$($yaml_parser "$base_yaml_file" flash.pages.["$app_start_page"].address) - - if [[ $boot_supported -ne 0 ]] - then - boot_start_address=$($yaml_parser "$base_yaml_file" flash.pages.["$boot_start_page"].address) - fi - - total_flash_pages=$($yaml_parser "$base_yaml_file" flash.pages --length) -else - # All flash pages have common size - app_start_address=$($yaml_parser "$base_yaml_file" flash.page-size) - flash_start_address=$($yaml_parser "$base_yaml_file" flash.flash-start) - ((app_start_address*=app_start_page)) - ((app_start_address+=flash_start_address)) - - if [[ $boot_supported -ne 0 ]] - then - boot_start_address=$($yaml_parser "$base_yaml_file" flash.page-size) - ((boot_start_address*=boot_start_page)) - ((boot_start_address+=flash_start_address)) - fi - - total_flash_pages=$($yaml_parser "$base_yaml_file" flash.size)/$($yaml_parser "$base_yaml_file" flash.page-size) -fi - -{ - printf "%s%x\n" "FLASH_ADDR_APP_START := 0x" "$app_start_address" - printf "%s\n" 'FLASH_ADDR_FW_METADATA := $(shell printf "0x%x" $$(( $(FLASH_ADDR_APP_START) + $(CORE_FW_METADATA_OFFSET) )) )' -} >> "$out_makefile" - -if [[ $boot_supported -ne 0 ]] -then - { - printf "%s%x\n" "FLASH_ADDR_BOOT_START := 0x" "$boot_start_address" - } >> "$out_makefile" -fi - -if [[ $($yaml_parser "$yaml_file" flash.emueeprom) != "null" ]] -then - factory_flash_page=$($yaml_parser "$yaml_file" flash.emueeprom.factory-page.page) - factory_flash_page_offset=$($yaml_parser "$yaml_file" flash.emueeprom.factory-page.start-offset) - eeprom_flash_page_1=$($yaml_parser "$yaml_file" flash.emueeprom.page1.page) - eeprom_flash_page_2=$($yaml_parser "$yaml_file" flash.emueeprom.page2.page) - - if [[ $factory_flash_page_offset == "null" ]] - then - factory_flash_page_offset=0 - fi - - { - printf "%s\n" "FLASH_PAGE_FACTORY := $factory_flash_page" - printf "%s\n" "FLASH_PAGE_EEPROM_1 := $eeprom_flash_page_1" - printf "%s\n" "FLASH_PAGE_EEPROM_2 := $eeprom_flash_page_2" - printf "%s\n" 'DEFINES += FLASH_PAGE_FACTORY=$(FLASH_PAGE_FACTORY)' - printf "%s\n" 'DEFINES += FLASH_PAGE_EEPROM_1=$(FLASH_PAGE_EEPROM_1)' - printf "%s\n" 'DEFINES += FLASH_PAGE_EEPROM_2=$(FLASH_PAGE_EEPROM_2)' - } >> "$out_makefile" - - if [[ $($yaml_parser "$base_yaml_file" flash.pages) == "null" ]] - then - # Common flash page size - { - printf "%s\n" 'EMU_EEPROM_PAGE_SIZE := $(shell echo $$(( ($(FLASH_PAGE_EEPROM_2) - $(FLASH_PAGE_EEPROM_1)) * $(CORE_MCU_FLASH_PAGE_SIZE_COMMON) )) )' - printf "%s\n" 'DEFINES += EMU_EEPROM_PAGE_SIZE=$(EMU_EEPROM_PAGE_SIZE)' - # Offset is never used when flash pages have the same size - printf "%s\n" 'EMU_EEPROM_FLASH_USAGE := $(shell echo $$(( $(EMU_EEPROM_PAGE_SIZE) * 3 )) )' - } >> "$out_makefile" - else - emueeprom_factory_size=$($yaml_parser "$base_yaml_file" flash.pages.["$factory_flash_page"].size) - emueeprom_page1_size=$($yaml_parser "$base_yaml_file" flash.pages.["$eeprom_flash_page_1"].size) - emueeprom_page2_size=$($yaml_parser "$base_yaml_file" flash.pages.["$eeprom_flash_page_2"].size) - - emueeprom_page_size=$emueeprom_factory_size - ((emueeprom_page_size-=factory_flash_page_offset)) - emueeprom_flash_usage=$((emueeprom_page_size + emueeprom_page1_size + emueeprom_page2_size)) - - { - printf "%s\n" "EMU_EEPROM_PAGE_SIZE := $emueeprom_page_size" - printf "%s\n" 'DEFINES += EMU_EEPROM_PAGE_SIZE=$(EMU_EEPROM_PAGE_SIZE)' - printf "%s\n" "EMU_EEPROM_FLASH_USAGE := $emueeprom_flash_usage" - } >> "$out_makefile" - fi - - # When emulated EEPROM is used, one of the pages is factory page with - # default settings. Database shouldn't be formatted in this case. - # The values from factory page should be used as initial ones. - printf "%s\n" "DEFINES += DATABASE_INIT_DATA=0" >> "$out_makefile" -else - { - printf "%s\n" "EMU_EEPROM_FLASH_USAGE := 0" - printf "%s\n" "DEFINES += DATABASE_INIT_DATA=1" - } >> "$out_makefile" -fi - -if [[ $app_boot_jump_offset != "null" ]] -then - printf "%s\n" "DEFINES += FLASH_OFFSET_APP_JUMP_FROM_BOOTLOADER=$app_boot_jump_offset" >> "$out_makefile" -fi - -# Calculate boot size -# First boot page is known, but last isn't - determine - -if [[ $boot_supported -ne 0 ]] -then - boot_end_page=$total_flash_pages - - for ((i=0;i $boot_start_page ]] - then - boot_end_page=$i - break - fi - fi - done - - total_boot_pages=$((boot_end_page-boot_start_page)) - - if [[ $($yaml_parser "$base_yaml_file" flash.pages) != "null" ]] - then - for ((i=0;i> "$out_makefile" -fi - -if [[ $adc_prescaler != "null" ]] -then - printf "%s\n" "DEFINES += HW_ADC_PRESCALER=$adc_prescaler" >> "$out_makefile" -fi - -if [[ $adc_samples != "null" ]] -then - printf "%s\n" "DEFINES += HW_ADC_SAMPLES=$adc_samples" >> "$out_makefile" -fi \ No newline at end of file +source "$script_dir"/mcu/main.sh \ No newline at end of file diff --git a/scripts/gen/gen_target.sh b/scripts/gen/gen_target.sh index 875479886..f2fc84fbe 100755 --- a/scripts/gen/gen_target.sh +++ b/scripts/gen/gen_target.sh @@ -7,26 +7,34 @@ gen_dir=$3 yaml_parser="dasel -n -p yaml --plain -f" out_header="$gen_dir"/Target.h out_makefile="$gen_dir"/Makefile - -echo "Generating target definitions..." +mcu=$($yaml_parser "$yaml_file" mcu) +target_name=$(basename "$yaml_file" .yml) +mcu_gen_dir=$(dirname "$gen_dir")/../mcu/$mcu +hw_test_yaml_file=$(dirname "$yaml_file")/../hw-test/$target_name.yml mkdir -p "$gen_dir" echo "" > "$out_header" echo "" > "$out_makefile" -{ - printf "%s\n\n" "#pragma once" - printf "%s\n" "#include \"board/Internal.h\"" - printf "%s\n" "#include \"core/src/MCU.h\"" - printf "%s\n" "#include \"core/src/arch/common/UART.h\"" - printf "%s\n" "#include \"core/src/arch/common/I2C.h\"" -} >> "$out_header" +if [[ ! -d $mcu_gen_dir ]] +then + if ! "$script_dir"/gen_mcu.sh "$mcu" "$mcu_gen_dir" + then + exit 1 + fi +fi + +echo "Generating target definitions..." -source "$script_dir"/target/core.sh -source "$script_dir"/target/peripherals.sh -source "$script_dir"/target/digital_inputs.sh -source "$script_dir"/target/digital_outputs.sh -source "$script_dir"/target/analog_inputs.sh -source "$script_dir"/target/unused_io.sh +source "$script_dir"/target/main.sh -printf "\n%s" "#include \"board/common/Map.h.include\"" >> "$out_header" \ No newline at end of file +if [[ -f $hw_test_yaml_file ]] +then + # HW config files go into the same dir as target ones + if ! "$script_dir"/gen_hwconfig.sh "$project" "$hw_test_yaml_file" "$gen_dir" + then + exit 1 + else + printf "%s\n" "DEFINES += TESTS_HW_SUPPORT" >> "$out_makefile" + fi +fi \ No newline at end of file diff --git a/scripts/gen/mcu/adc.sh b/scripts/gen/mcu/adc.sh new file mode 100755 index 000000000..391b642a8 --- /dev/null +++ b/scripts/gen/mcu/adc.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +declare -i adc_prescaler +declare -i adc_samples + +adc_prescaler=$($yaml_parser "$project_yaml_file" adc.prescaler) +adc_samples=$($yaml_parser "$project_yaml_file" adc.samples) + +if [[ $adc_prescaler != "null" ]] +then + printf "%s\n" "DEFINES += HW_ADC_PRESCALER=$adc_prescaler" >> "$out_makefile" +fi + +if [[ $adc_samples != "null" ]] +then + printf "%s\n" "DEFINES += HW_ADC_SAMPLES=$adc_samples" >> "$out_makefile" +fi \ No newline at end of file diff --git a/scripts/gen/mcu/flash.sh b/scripts/gen/mcu/flash.sh new file mode 100755 index 000000000..94323687d --- /dev/null +++ b/scripts/gen/mcu/flash.sh @@ -0,0 +1,191 @@ +#!/usr/bin/env bash + +declare -i app_start_page +declare -i boot_supported +declare -i boot_start_page +declare -i boot_end_page +declare -i app_boot_jump_offset +declare -i boot_size +declare -i factory_flash_page +declare -i factory_flash_page_offset +declare -i eeprom_flash_page_1 +declare -i eeprom_flash_page_2 +declare -i total_flash_pages + +if [[ $($yaml_parser "$project_yaml_file" flash.boot-start-page) != "null" ]] +then + # Having just "if [[ $boot_start_page != "null" ]]" check later will + # fail because boot_start_page is defined as integer, so even if + # dasel returns null for boot-start-page key, the value will be 0 + boot_supported=1 +fi + +app_start_page=$($yaml_parser "$project_yaml_file" flash.app-start-page) +boot_start_page=$($yaml_parser "$project_yaml_file" flash.boot-start-page) +boot_end_page=0 +app_boot_jump_offset=$($yaml_parser "$project_yaml_file" flash.app-boot-jump-offset) +boot_size=0 +factory_flash_page=0 +factory_flash_page_offset=0 +eeprom_flash_page_1=0 +eeprom_flash_page_2=0 +total_flash_pages=0 + +if [[ $app_start_page == "null" ]] +then + app_start_page=0 +fi + +if [[ $boot_supported -ne 0 ]] +then + { + printf "%s\n" "DEFINES += HW_SUPPORT_BOOTLOADER" + } >> "$out_makefile" +else + # No bootloader, start at first page + app_start_page=0 +fi + +{ + printf "%s\n" "DEFINES += FLASH_PAGE_APP=$app_start_page" +} >> "$out_makefile" + +if [[ $($yaml_parser "$core_yaml_file" flash.pages) != "null" ]] +then + app_start_address=$($yaml_parser "$core_yaml_file" flash.pages.["$app_start_page"].address) + + if [[ $boot_supported -ne 0 ]] + then + boot_start_address=$($yaml_parser "$core_yaml_file" flash.pages.["$boot_start_page"].address) + fi + + total_flash_pages=$($yaml_parser "$core_yaml_file" flash.pages --length) +else + # All flash pages have common size + app_start_address=$($yaml_parser "$core_yaml_file" flash.page-size) + flash_start_address=$($yaml_parser "$core_yaml_file" flash.flash-start) + ((app_start_address*=app_start_page)) + ((app_start_address+=flash_start_address)) + + if [[ $boot_supported -ne 0 ]] + then + boot_start_address=$($yaml_parser "$core_yaml_file" flash.page-size) + ((boot_start_address*=boot_start_page)) + ((boot_start_address+=flash_start_address)) + fi + + total_flash_pages=$($yaml_parser "$core_yaml_file" flash.size)/$($yaml_parser "$core_yaml_file" flash.page-size) +fi + +{ + printf "%s%x\n" "FLASH_ADDR_APP_START := 0x" "$app_start_address" + printf "%s\n" 'FLASH_ADDR_FW_METADATA := $(shell printf "0x%x" $$(( $(FLASH_ADDR_APP_START) + $(CORE_FW_METADATA_OFFSET) )) )' +} >> "$out_makefile" + +if [[ $boot_supported -ne 0 ]] +then + { + printf "%s%x\n" "FLASH_ADDR_BOOT_START := 0x" "$boot_start_address" + } >> "$out_makefile" +fi + +if [[ $($yaml_parser "$project_yaml_file" flash.emueeprom) != "null" ]] +then + factory_flash_page=$($yaml_parser "$project_yaml_file" flash.emueeprom.factory-page.page) + factory_flash_page_offset=$($yaml_parser "$project_yaml_file" flash.emueeprom.factory-page.start-offset) + eeprom_flash_page_1=$($yaml_parser "$project_yaml_file" flash.emueeprom.page1.page) + eeprom_flash_page_2=$($yaml_parser "$project_yaml_file" flash.emueeprom.page2.page) + + if [[ $factory_flash_page_offset == "null" ]] + then + factory_flash_page_offset=0 + fi + + { + printf "%s\n" "FLASH_PAGE_FACTORY := $factory_flash_page" + printf "%s\n" "FLASH_PAGE_EEPROM_1 := $eeprom_flash_page_1" + printf "%s\n" "FLASH_PAGE_EEPROM_2 := $eeprom_flash_page_2" + printf "%s\n" 'DEFINES += FLASH_PAGE_FACTORY=$(FLASH_PAGE_FACTORY)' + printf "%s\n" 'DEFINES += FLASH_PAGE_EEPROM_1=$(FLASH_PAGE_EEPROM_1)' + printf "%s\n" 'DEFINES += FLASH_PAGE_EEPROM_2=$(FLASH_PAGE_EEPROM_2)' + } >> "$out_makefile" + + if [[ $($yaml_parser "$core_yaml_file" flash.pages) == "null" ]] + then + # Common flash page size + { + printf "%s\n" 'EMU_EEPROM_PAGE_SIZE := $(shell echo $$(( ($(FLASH_PAGE_EEPROM_2) - $(FLASH_PAGE_EEPROM_1)) * $(CORE_MCU_FLASH_PAGE_SIZE_COMMON) )) )' + printf "%s\n" 'DEFINES += EMU_EEPROM_PAGE_SIZE=$(EMU_EEPROM_PAGE_SIZE)' + # Offset is never used when flash pages have the same size + printf "%s\n" 'EMU_EEPROM_FLASH_USAGE := $(shell echo $$(( $(EMU_EEPROM_PAGE_SIZE) * 3 )) )' + } >> "$out_makefile" + else + emueeprom_factory_size=$($yaml_parser "$core_yaml_file" flash.pages.["$factory_flash_page"].size) + emueeprom_page1_size=$($yaml_parser "$core_yaml_file" flash.pages.["$eeprom_flash_page_1"].size) + emueeprom_page2_size=$($yaml_parser "$core_yaml_file" flash.pages.["$eeprom_flash_page_2"].size) + + emueeprom_page_size=$emueeprom_factory_size + ((emueeprom_page_size-=factory_flash_page_offset)) + emueeprom_flash_usage=$((emueeprom_page_size + emueeprom_page1_size + emueeprom_page2_size)) + + { + printf "%s\n" "EMU_EEPROM_PAGE_SIZE := $emueeprom_page_size" + printf "%s\n" 'DEFINES += EMU_EEPROM_PAGE_SIZE=$(EMU_EEPROM_PAGE_SIZE)' + printf "%s\n" "EMU_EEPROM_FLASH_USAGE := $emueeprom_flash_usage" + } >> "$out_makefile" + fi + + # When emulated EEPROM is used, one of the pages is factory page with + # default settings. Database shouldn't be formatted in this case. + # The values from factory page should be used as initial ones. + printf "%s\n" "DEFINES += DATABASE_INIT_DATA=0" >> "$out_makefile" +else + { + printf "%s\n" "EMU_EEPROM_FLASH_USAGE := 0" + printf "%s\n" "DEFINES += DATABASE_INIT_DATA=1" + } >> "$out_makefile" +fi + +if [[ $app_boot_jump_offset != "null" ]] +then + printf "%s\n" "DEFINES += FLASH_OFFSET_APP_JUMP_FROM_BOOTLOADER=$app_boot_jump_offset" >> "$out_makefile" +fi + +# Calculate boot size +# First boot page is known, but last isn't - determine + +if [[ $boot_supported -ne 0 ]] +then + boot_end_page=$total_flash_pages + + for ((i=0;i> "$out_makefile" +fi \ No newline at end of file diff --git a/scripts/gen/mcu/main.sh b/scripts/gen/mcu/main.sh new file mode 100755 index 000000000..40ef0059a --- /dev/null +++ b/scripts/gen/mcu/main.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +{ + printf "%s%s\n" '-include $(BOARD_GEN_DIR_MCU_BASE)/' "$mcu/CoreMCUGenerated.mk" +} > "$out_makefile" + +for FILE in "$script_dir"/mcu/* +do + if [[ "$FILE" != *"$(basename "$BASH_SOURCE")"* ]] + then + source "$FILE" + fi +done \ No newline at end of file diff --git a/scripts/gen/target/core.sh b/scripts/gen/target/core.sh deleted file mode 100755 index 0034897fc..000000000 --- a/scripts/gen/target/core.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -mcu=$($yaml_parser "$yaml_file" mcu) -target_name=$(basename "$yaml_file" .yml) - -# MCU processing first -mcu_gen_dir=$(dirname "$gen_dir")/../mcu/$mcu -mcu_yaml_file=$(dirname "$yaml_file")/../mcu/$mcu.yml -hw_test_yaml_file=$(dirname "$yaml_file")/../hw-test/$target_name.yml - -if [[ ! -f $mcu_yaml_file ]] -then - echo "$mcu_yaml_file doesn't exist" - exit 1 -fi - -if [[ ! -d $mcu_gen_dir ]] -then - core_mcu_config_path=$(find "$script_dir"/../../modules/core/src -type f -name "*$mcu.yml") - - if ! "$script_dir"/gen_mcu.sh "$core_mcu_config_path" "$mcu_yaml_file" "$mcu_gen_dir" "$extClockMhz" - then - exit 1 - fi -fi - -if [[ -f $hw_test_yaml_file ]] -then - # HW config files go into the same dir as target ones - if ! "$script_dir"/gen_hwconfig.sh "$project" "$hw_test_yaml_file" "$gen_dir" - then - exit 1 - else - printf "%s\n" "DEFINES += TESTS_HW_SUPPORT" >> "$out_makefile" - fi -fi - -{ - printf "%s%s\n" '-include $(MAKEFILE_INCLUDE_PREFIX)$(BOARD_GEN_DIR_MCU_BASE)/' "$mcu/MCU.mk" -} >> "$out_makefile" - -# Normally, ext clock freq is generated in MCU.mk file by core module, however, various boards -# can use the same MCU with different clock speed. Therefore, define this in target makefile. -extClockMhz=$($yaml_parser "$yaml_file" extClockMhz) - -if [[ "$extClockMhz" != "null" ]] -then - printf "%s\n" "DEFINES += CORE_MCU_EXT_CLOCK_FREQ_MHZ=$extClockMhz" >> "$out_makefile" -fi - -# If CORE_MCU_CPU_FREQ_MHZ symbol isn't defined, use external clock frequency as core frequency -{ - printf "%s\n" 'ifeq (,$(findstring CORE_MCU_CPU_FREQ_MHZ,$(DEFINES)))' - printf "%s\n" "DEFINES += CORE_MCU_CPU_FREQ_MHZ=$extClockMhz" - printf "%s\n" "endif" -} >> "$out_makefile" - -board_name=$($yaml_parser "$yaml_file" boardNameOverride) - -if [[ $board_name == "null" ]] -then - board_name=$target_name -fi - -printf "%s\n" "#define BOARD_STRING \"$board_name\"" >> "$out_header" -printf "%s\n" "DEFINES += FW_UID=$($script_dir/gen_fw_uid.sh "$target_name")" >> "$out_makefile" \ No newline at end of file diff --git a/scripts/gen/target/main.sh b/scripts/gen/target/main.sh new file mode 100755 index 000000000..e60e7ecae --- /dev/null +++ b/scripts/gen/target/main.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +{ + printf "%s\n\n" "#pragma once" + printf "%s\n" "#include \"board/Internal.h\"" + printf "%s\n" "#include \"core/src/MCU.h\"" + printf "%s\n" "#include \"core/src/arch/common/UART.h\"" + printf "%s\n" "#include \"core/src/arch/common/I2C.h\"" +} >> "$out_header" + +{ + printf "%s%s\n" '-include $(BOARD_GEN_DIR_MCU_BASE)/' "$mcu/MCU.mk" +} >> "$out_makefile" + +# External clock freq can be generated by core module, however, various boards +# can use the same MCU with different clock speed. Therefore, define this in target makefile. + +extClockMhz=$($yaml_parser "$yaml_file" extClockMhz) + +if [[ "$extClockMhz" != "null" ]] +then + printf "%s\n" "DEFINES += CORE_MCU_EXT_CLOCK_FREQ_MHZ=$extClockMhz" >> "$out_makefile" +fi + +board_name=$($yaml_parser "$yaml_file" boardNameOverride) + +if [[ $board_name == "null" ]] +then + board_name=$target_name +fi + +printf "%s\n" "#define BOARD_STRING \"$board_name\"" >> "$out_header" +printf "%s\n" "DEFINES += FW_UID=$($script_dir/gen_fw_uid.sh "$target_name")" >> "$out_makefile" + +for FILE in "$script_dir"/target/* +do + if [[ "$FILE" != *"$(basename "$BASH_SOURCE")"* ]] + then + source "$FILE" + fi +done + +printf "\n%s" "#include \"board/common/Map.h.include\"" >> "$out_header" \ No newline at end of file diff --git a/scripts/tests_exec.sh b/scripts/tests_exec.sh index 10dc853b6..67f64ceb1 100755 --- a/scripts/tests_exec.sh +++ b/scripts/tests_exec.sh @@ -53,7 +53,7 @@ for test in $binaries do if [ "$hw_testing" == "1" ] then - board=$(echo "$test" | cut -d/ -f3) + board=$(echo "$test" | rev | cut -d/ -f4 | rev) if [[ -f ../config/hw-test/"$board".yml ]] then