Adding script to update various config files automaticaly.
This commit is contained in:
parent
ecbe54cab7
commit
1bfe2ef9f7
|
@ -332,7 +332,7 @@ if __name__ == '__main__':
|
|||
defines = gen_defines(proj)
|
||||
ports = gen_ports(gpio, proj)
|
||||
|
||||
with open(cur_path + '/board_gpio.tpl', 'r') as tpl_file:
|
||||
with open(cur_path + '/templates/board_gpio.tpl', 'r') as tpl_file:
|
||||
tpl = tpl_file.read()
|
||||
template = Template(tpl)
|
||||
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HALCONF_COMMUNITY_H
|
||||
#define HALCONF_COMMUNITY_H
|
||||
|
||||
/**
|
||||
* @brief Enables the community overlay.
|
||||
*/
|
||||
#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_COMMUNITY TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the FSMC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_FSMC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the NAND subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_NAND FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the 1-wire subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_ONEWIRE FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the EICU subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_EICU FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the CRC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_CRC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the RNG subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_RNG FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the EEPROM subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_EEPROM FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the TIMCAP subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_TIMCAP FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the TIMCAP subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_COMP FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* FSMCNAND driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||
#define NAND_USE_MUTUAL_EXCLUSION TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 1-wire driver related settings. */
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @brief Enables strong pull up feature.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#define ONEWIRE_USE_STRONG_PULLUP FALSE
|
||||
|
||||
/**
|
||||
* @brief Enables search ROM feature.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#define ONEWIRE_USE_SEARCH_ROM FALSE
|
||||
|
||||
/*===========================================================================*/
|
||||
/* EEProm driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables 24xx series I2C eeprom device driver.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#define EEPROM_USE_EE24XX FALSE
|
||||
/**
|
||||
* @brief Enables 25xx series SPI eeprom device driver.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#define EEPROM_USE_EE25XX FALSE
|
||||
|
||||
#endif /* HALCONF_COMMUNITY_H */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FSMC driver system settings.
|
||||
*/
|
||||
#define STM32_FSMC_USE_FSMC1 FALSE
|
||||
#define STM32_FSMC_FSMC1_IRQ_PRIORITY 10
|
||||
|
||||
/*
|
||||
* FSMC NAND driver system settings.
|
||||
*/
|
||||
#define STM32_NAND_USE_FSMC_NAND1 FALSE
|
||||
#define STM32_NAND_USE_FSMC_NAND2 FALSE
|
||||
#define STM32_NAND_USE_EXT_INT FALSE
|
||||
#define STM32_NAND_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
|
||||
#define STM32_NAND_DMA_PRIORITY 0
|
||||
#define STM32_NAND_DMA_ERROR_HOOK(nandp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* FSMC SRAM driver system settings.
|
||||
*/
|
||||
#define STM32_USE_FSMC_SRAM FALSE
|
||||
#define STM32_SRAM_USE_FSMC_SRAM1 FALSE
|
||||
#define STM32_SRAM_USE_FSMC_SRAM2 FALSE
|
||||
#define STM32_SRAM_USE_FSMC_SRAM3 FALSE
|
||||
#define STM32_SRAM_USE_FSMC_SRAM4 FALSE
|
||||
|
||||
/*
|
||||
* FSMC SDRAM driver system settings.
|
||||
*/
|
||||
#define STM32_USE_FSMC_SDRAM FALSE
|
||||
|
||||
/*
|
||||
* TIMCAP driver system settings.
|
||||
*/
|
||||
#define STM32_TIMCAP_USE_TIM1 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM2 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM3 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM4 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM5 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM8 FALSE
|
||||
#define STM32_TIMCAP_USE_TIM9 FALSE
|
||||
#define STM32_TIMCAP_TIM1_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM2_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM3_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM4_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM5_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM8_IRQ_PRIORITY 3
|
||||
#define STM32_TIMCAP_TIM9_IRQ_PRIORITY 3
|
||||
|
||||
/*
|
||||
* COMP driver system settings.
|
||||
*/
|
||||
#define STM32_COMP_USE_COMP1 FALSE
|
||||
#define STM32_COMP_USE_COMP2 FALSE
|
||||
#define STM32_COMP_USE_COMP3 FALSE
|
||||
#define STM32_COMP_USE_COMP4 FALSE
|
||||
#define STM32_COMP_USE_COMP5 FALSE
|
||||
#define STM32_COMP_USE_COMP6 FALSE
|
||||
#define STM32_COMP_USE_COMP7 FALSE
|
||||
|
||||
#define STM32_COMP_USE_INTERRUPTS TRUE
|
||||
#define STM32_COMP_1_2_3_IRQ_PRIORITY 5
|
||||
#define STM32_COMP_4_5_6_IRQ_PRIORITY 5
|
||||
#define STM32_COMP_7_IRQ_PRIORITY 5
|
||||
|
||||
#if STM32_COMP_USE_INTERRUPTS
|
||||
#define STM32_DISABLE_EXTI21_22_29_HANDLER
|
||||
#define STM32_DISABLE_EXTI30_32_HANDLER
|
||||
#define STM32_DISABLE_EXTI33_HANDLER
|
||||
#endif
|
||||
|
||||
/*
|
||||
* USBH driver system settings.
|
||||
*/
|
||||
#define STM32_OTG1_CHANNELS_NUMBER 8
|
||||
#define STM32_OTG2_CHANNELS_NUMBER 12
|
||||
|
||||
#define STM32_USBH_USE_OTG1 1
|
||||
#define STM32_OTG1_RXFIFO_SIZE 1024
|
||||
#define STM32_OTG1_PTXFIFO_SIZE 128
|
||||
#define STM32_OTG1_NPTXFIFO_SIZE 128
|
||||
|
||||
#define STM32_USBH_USE_OTG2 0
|
||||
#define STM32_OTG2_RXFIFO_SIZE 2048
|
||||
#define STM32_OTG2_PTXFIFO_SIZE 1024
|
||||
#define STM32_OTG2_NPTXFIFO_SIZE 1024
|
||||
|
||||
#define STM32_USBH_MIN_QSPACE 4
|
||||
#define STM32_USBH_CHANNELS_NP 4
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
__author__ = 'Fabien Poussin'
|
||||
__version__ = '0.1'
|
||||
|
||||
import os
|
||||
import re
|
||||
from argparse import ArgumentParser
|
||||
from traceback import print_exc
|
||||
from shutil import copy
|
||||
|
||||
parser = ArgumentParser(description='Generate ChibiOS-Contrib config and make files from ChibiOS')
|
||||
parser.add_argument('-s', '--src', default='../../ChibiOS-RT', type=str, help="ChibiOS folder")
|
||||
parser.add_argument('-d', '--dst', default='..', type=str, help='ChibiOS-Contrib folder')
|
||||
|
||||
|
||||
def makefile(lines):
|
||||
|
||||
|
||||
for l in range(len(lines)):
|
||||
|
||||
if 'CHIBIOS =' in lines[l]:
|
||||
lines[l] = lines[l][:-1] + '/../ChibiOS-RT\n'
|
||||
lines.insert(l + 1, 'CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib\n')
|
||||
|
||||
if '$(CHIBIOS)/os/hal/hal.mk' in lines[l] \
|
||||
or '$(CHIBIOS)/os/hal/ports/' in lines[l] \
|
||||
or '$(CHIBIOS)/os/various' in lines[l] :
|
||||
lines[l] = lines[l].replace('CHIBIOS', 'CHIBIOS_CONTRIB')
|
||||
|
||||
return "".join(lines)
|
||||
|
||||
|
||||
def halconf(lines):
|
||||
|
||||
idx_end = lines.index('#endif /* HALCONF_H */\n')
|
||||
lines.insert(idx_end - 1, '\n')
|
||||
lines.insert(idx_end - 1, '#include "halconf_community.h"')
|
||||
lines.insert(idx_end - 1, '\n')
|
||||
|
||||
return "".join(lines)
|
||||
|
||||
|
||||
def mcuconf(lines):
|
||||
|
||||
idx_end = lines.index('#endif /* MCUCONF_H */\n')
|
||||
lines.insert(idx_end - 1, '\n')
|
||||
lines.insert(idx_end - 1, '#include "mcuconf_community.h"')
|
||||
lines.insert(idx_end - 1, '\n')
|
||||
|
||||
return "".join(lines)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
args = parser.parse_args()
|
||||
sources = {}
|
||||
|
||||
for family in os.scandir(args.src + '/testhal/STM32/'):
|
||||
if not family.name[0].isupper() or not family.is_dir():
|
||||
continue
|
||||
|
||||
for test in os.scandir(family.path):
|
||||
try:
|
||||
sources[family.name] = {'makefile': None, 'halconf': None, 'mcuconf': None}
|
||||
|
||||
with open(test.path + '/Makefile', 'r') as file:
|
||||
sources[family.name]['makefile'] = makefile(file.readlines())
|
||||
|
||||
with open(test.path + '/halconf.h', 'r') as file:
|
||||
sources[family.name]['halconf'] = halconf(file.readlines())
|
||||
|
||||
with open(test.path + '/mcuconf.h', 'r') as file:
|
||||
sources[family.name]['mcuconf'] = mcuconf(file.readlines())
|
||||
|
||||
except Exception as e:
|
||||
print(test.path, e)
|
||||
del sources[family.name]
|
||||
continue
|
||||
|
||||
break
|
||||
|
||||
print(sources.keys())
|
||||
|
||||
for family in os.scandir(args.dst + '/testhal/STM32/'):
|
||||
if not family.name[0].isupper() or not family.is_dir():
|
||||
continue
|
||||
|
||||
for test in os.scandir(family.path):
|
||||
copy('templates/halconf_community.h', test.path)
|
||||
copy('templates/mcuconf_community.h', test.path)
|
||||
|
||||
with open(test.path + '/Makefile', 'w') as file:
|
||||
file.write(sources[family.name]['makefile'])
|
||||
|
||||
with open(test.path + '/halconf.h', 'w') as file:
|
||||
file.write(sources[family.name]['halconf'])
|
||||
|
||||
with open(test.path + '/mcuconf.h', 'w') as file:
|
||||
file.write(sources[family.name]['mcuconf'])
|
Loading…
Reference in New Issue