diff --git a/tools/configure.c b/tools/configure.c index 5cfeaa7f46..dbf81db8ba 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -79,7 +79,7 @@ static void show_usage(const char *progname, int exitcode); static void debug(const char *fmt, ...); -static const char *find_archname(const char *boardname); +static int find_archname(const char *boardname, const char *configname); static void parse_args(int argc, char **argv); static bool check_directory(const char *directory); static void verify_directory(const char *directory); @@ -121,6 +121,7 @@ static bool g_debug = false; /* Enable debug output */ static const char *g_appdir = NULL; /* Relative path to the application directory */ static const char *g_archdir = NULL; /* Name of architecture subdirectory */ +static const char *g_chipdir = NULL; /* Name of chip subdirectory */ static const char *g_boarddir = NULL; /* Name of board subdirectory */ static char *g_configdir = NULL; /* Name of configuration subdirectory */ @@ -166,6 +167,68 @@ static const char *g_archnames[] = NULL }; +/* Recognized chip names */ + +static const char *g_chipnames[] = +{ + "a1x", + "am335x", + "c5471", + "cxd56xx", + "dm320", + "efm32", + "imx6", + "imxrt", + "kinetis", + "kl", + "lc823450", + "lpc17xx_40xx", + "lpc214x", + "lpc2378", + "lpc31xx", + "lpc43xx", + "lpc54xx", + "max326xx", + "moxart", + "nrf52", + "nuc1xx", + "sam34", + "sama5", + "samd2l2", + "samd5e5", + "samv7", + "stm32", + "stm32f0l0g0", + "stm32f7", + "stm32h7", + "stm32l4", + "str71x", + "tiva", + "tms570", + "xmc4", + "at32uc3", + "at90usb", + "atmega", + "mcs92s12ne64", + "pic32mx", + "pic32mz", + "lm32", + "mor1kx", + "m32262f8", + "sh7032", + "gap8", + "nr5m100", + "sim", + "qemu", + "esp32", + "z16f2811", + "ez80", + "z180", + "z8", + "z80", + NULL +}; + /* Optional configuration files */ static const char *g_optfiles[] = @@ -248,52 +311,49 @@ static void debug(const char *fmt, ...) } } -static const char *find_archname(const char *boardname) +static int find_archname(const char *boardname, const char *configname) { const char **archname; - DIR *dirp; - struct dirent *dentry; + const char **chipname; + struct stat statbuf; + int ret; + + /* Try each combination of board and chip names */ for (archname = g_archnames; *archname != NULL; archname++) { - /* Get the architecture directory under boards */ - - snprintf(g_buffer, BUFFER_SIZE, "boards/%s", *archname); - - /* Open the architecture directory */ - - dirp = opendir(g_buffer); - if (dirp == NULL) + for (chipname = g_chipnames; *chipname != NULL; chipname++) { - debug("ERROR: Failed to open: %s\n", g_buffer); - continue; - } - - /* Now search for a sub-directory that has the board name */ - - while ((dentry = readdir(dirp)) != NULL) - { - /* Check if the directory entry matches the boardname. - * We really should also verify that it is a directory. + /* Get the architecture directory under boards. Path format: + * board////configs/ */ - if (strcmp(boardname, dentry->d_name) == 0) + snprintf(g_buffer, BUFFER_SIZE, "boards%c%s%c%s%c%s%cconfigs%c%s", + g_delim, *archname, g_delim, *chipname, g_delim, boardname, + g_delim, g_delim, configname); + + /* Check if there is a directory at this path */ + + ret = stat(g_buffer, &statbuf); + if (ret == 0 && S_ISDIR(statbuf.st_mode)) { - closedir(dirp); - return *archname; + g_archdir = *archname; + g_chipdir = *chipname; + return 0; } } - - closedir(dirp); } - return NULL; + g_archdir = "unknown"; + g_chipdir = "unknown"; + return -1; } static void parse_args(int argc, char **argv) { char *ptr; int ch; + int ret; /* Parse command line options */ @@ -407,12 +467,11 @@ static void parse_args(int argc, char **argv) show_usage(argv[0], EXIT_FAILURE); } - g_archdir = find_archname(g_boarddir); - if (g_archdir == NULL) + ret = find_archname(g_boarddir, g_configdir); + if (ret != 0) { fprintf(stderr, "ERROR: Architecture for board %s not found\n", g_boarddir); - g_archdir = "unknown"; } } @@ -645,12 +704,18 @@ static void config_search(const char *boarddir) char *boardname; char *configname; char *delim; + char *tmp; /* Get the board directory near the beginning of the 'boarddir' path: - * //configs/ + * ///configs/ */ + /* Make a modifiable copy */ + strncpy(g_buffer, boarddir, BUFFER_SIZE); + + /* Skip over */ + delim = strchr(g_buffer, g_delim); if (delim == NULL) { @@ -658,27 +723,42 @@ static void config_search(const char *boarddir) } else { - *delim = '\0'; - boardname = delim + 1; + /* Skip over */ - delim = strchr(boardname, g_delim); + tmp = delim + 1; + delim = strchr(tmp, g_delim); if (delim == NULL) { - debug("ERROR: delimiter not found in path: %s\n", boardname); + debug("ERROR: delimiter not found in path: %s\n", tmp); } else { - *delim = '\0'; - delim = strrchr(delim + 1, g_delim); + /* Save the */ + + *delim = '\0'; + boardname = delim + 1; + + delim = strchr(boardname, g_delim); if (delim == NULL) { - debug("ERROR: Configuration directory not found in path: %s\n", - boardname); + debug("ERROR: delimiter not found in path: %s\n", boardname); } else { - configname = delim + 1; - fprintf(stderr, " %s:%s\n", boardname, configname); + /* Save the */ + + *delim = '\0'; + delim = strrchr(delim + 1, g_delim); + if (delim == NULL) + { + debug("ERROR: Configuration directory not found in path: %s\n", + boardname); + } + else + { + configname = delim + 1; + fprintf(stderr, " %s:%s\n", boardname, configname); + } } } } @@ -708,12 +788,12 @@ static void check_configdir(void) g_configtop = strdup(g_buffer); /* Get and verify the path to the selected configuration: - * boards///configs/ + * boards////configs/ */ - snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%cconfigs%c%s", - g_topdir, g_delim, g_delim, g_archdir, g_delim, g_boarddir, - g_delim, g_delim, g_configdir); + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%c%s%cconfigs%c%s", + g_topdir, g_delim, g_delim, g_archdir, g_delim, g_chipdir, + g_delim, g_boarddir, g_delim, g_delim, g_configdir); debug("check_configdir: Checking configpath=%s\n", g_buffer); if (!verify_optiondir(g_buffer)) @@ -726,12 +806,12 @@ static void check_configdir(void) g_configpath = strdup(g_buffer); /* Get and verify the path to the scripts directory: - * boards//scripts + * boards////scripts */ - snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%cscripts", + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%c%s%cscripts", g_topdir, g_delim, g_delim, g_archdir, g_delim, - g_boarddir, g_delim); + g_chipdir, g_delim, g_boarddir, g_delim); debug("check_configdir: Checking scriptspath=%s\n", g_buffer); g_scriptspath = NULL; diff --git a/tools/configure.sh b/tools/configure.sh index 422ab7a857..03b84ce327 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -135,7 +135,7 @@ else boarddir=`echo ${boardconfig} | cut -d':' -f1` fi -# Try to detect architecture for convenience. +# Detect the architecture of this board. archs="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" chips="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 @@ -168,8 +168,8 @@ if [ ! -d "${configpath}" ]; then configlist=`find ${TOPDIR}/boards -name defconfig` for defconfig in ${configlist}; do config=`dirname ${defconfig} | sed -e "s,${TOPDIR}/boards/,,g"` - boardname=`echo ${config} | cut -d'/' -f2` - configname=`echo ${config} | cut -d'/' -f4` + boardname=`echo ${config} | cut -d'/' -f3` + configname=`echo ${config} | cut -d'/' -f5` echo " ${boardname}:${configname}" done echo "" diff --git a/tools/refresh.sh b/tools/refresh.sh index 56ad913cf5..66c758627c 100755 --- a/tools/refresh.sh +++ b/tools/refresh.sh @@ -115,6 +115,24 @@ fi # Detect the architecture of this board. ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" +ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" +CHIPLIST="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 + lpc17xx_40xx lpc214x lpc2378 lpc31xx lpc43xx lpc54xx max326xx moxart nrf52 + nuc1xx sam34 sama5 samd2l2 samd5e5 samv7 stm32 stm32f0l0g0 stm32f7 stm32h7 + stm32l4 str71x tiva tms570 xmc4 at32uc3 at90usb atmega mcs92s12ne64 pic32mx + pic32mz lm32 mor1kx m32262f8 sh7032 gap8 nr5m100 sim qemu esp32 z16f2811 + ez80 z180 z8 z80" + +for arch in ${ARCHLIST}; do + for chip in ${CHIPLIST}; do + if [ -f ${TOPDIR}/boards/${arch}/${chip}/${boarddir}/Kconfig ]; then + ARCHSUBDIR=${arch} + CHIPSUBDIR=${chip} + echo " Detected ${ARCHSUBDIR} Architecture" + echo " Detected ${CHIPSUBDIR} Chip" + fi + done +done for arch in ${ARCHLIST}; do if [ -f boards/${arch}/${BOARDSUBDIR}/Kconfig ]; then @@ -144,7 +162,7 @@ fi WD=${PWD} -BOARDDIR=boards/$ARCHSUBDIR/$BOARDSUBDIR +BOARDDIR=boards/$ARCHSUBDIR/$CHIPSUBDIR/$BOARDSUBDIR SCRIPTSDIR=$BOARDDIR/scripts MAKEDEFS1=$SCRIPTSDIR/Make.defs diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 0bc7c3d80b..9dd6443cdb 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -293,11 +293,22 @@ for line in $testlist; do # Detect the architecture of this board. ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" + CHIPLIST="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 + lpc17xx_40xx lpc214x lpc2378 lpc31xx lpc43xx lpc54xx max326xx moxart nrf52 + nuc1xx sam34 sama5 samd2l2 samd5e5 samv7 stm32 stm32f0l0g0 stm32f7 stm32h7 + stm32l4 str71x tiva tms570 xmc4 at32uc3 at90usb atmega mcs92s12ne64 pic32mx + pic32mz lm32 mor1kx m32262f8 sh7032 gap8 nr5m100 sim qemu esp32 z16f2811 + ez80 z180 z8 z80" for arch in ${ARCHLIST}; do - if [ -f $nuttx/boards/${arch}/${boarddir}/Kconfig ]; then - archdir=${arch} - fi + for chip in ${CHIPLIST}; do + if [ -f ${TOPDIR}/boards/${arch}/${chip}/${boarddir}/Kconfig ]; then + archdir=${arch} + chipdir=${chip} + echo " Detected ${archdir} Architecture" + echo " Detected ${chipdir} Chip" + fi + done done if [ -z "${archdir}" ]; then @@ -305,7 +316,7 @@ for line in $testlist; do exit 1 fi - path=$nuttx/boards/$archdir/$boarddir/configs/$configdir + path=$nuttx/boards/$archdir/$chipdir/$boarddir/configs/$configdir if [ ! -r "$path/defconfig" ]; then echo "ERROR: no configuration found at $path" showusage