======================================== Do not apply this patch to the main line ========================================
What is this tool? ------------------ This tool converts boards.cfg to defconfig and Kconfig files. It automatically generates - arch/${ARCH}/Kconfig - board/${VENDOR}/${BOARD}/Kconfig - board/${BOARD}/Kconfig - configs/${TARGET_BOARD}_defconfig How to use? ----------- Open tools/print_allconfigs with an editor. Adjust cross compilers part for your environment. # Specify your favoriate cross tools CROSS_COMPILE_ARC=arc-linux- CROSS_COMPILE_AARCH64=aarch64-linux-gnu- CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi- [snip] CROSS_COMPILE_X86=i386-linux- And then, run "tools/genkconfig". Why is this patch here? ----------------------- The file boards.cfg is touched very frequently. All the time, new/old boards are being added/removed. The next commit was generated based on the u-boot/master at the time I posted it. It will become out-dated soon. You can update it with this tool. Signed-off-by: Masahiro Yamada <yamad...@jp.panasonic.com> --- Changes in v5: - Add CPU select menu for PowerPC Changes in v4: - Remove debug code - Do not specify CONFIG_SYS_CPU if the cpu field of boards.cfg is '-' - Adjust to the current boards.cfg fields spec. - Add "select CPU" to PowerPC Kconfig - Generate only one defconfig per board Changes in v3: - Create SPL defconfig into configs/<board>_spl_defconfig instead of conigs/spl/<board>_defconfig. Like the same for TPL. Because I want to handle Falcon boot more genericlly. If you build only configs/<board>_spl_defconfig, it is Falcon boot. - Create board select menu based on the 8th field of boards.cfg. It is common that many entries (= 7th field) share the same config header. So this change help to reduce the code redandancy. Changes in v2: - Do not output CONFIG_BOARD_MAINTAINERS and CONFIG_BOARD_STATUS - Delete board/Kconfig and move "source board/*/*/Kconfig" statements to arch/*/Kconfig. tools/genkconfig | 371 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/print_allconfigs | 77 ++++++++++ 2 files changed, 448 insertions(+) create mode 100755 tools/genkconfig create mode 100755 tools/print_allconfigs diff --git a/tools/genkconfig b/tools/genkconfig new file mode 100755 index 0000000..2d9cf1a --- /dev/null +++ b/tools/genkconfig @@ -0,0 +1,371 @@ +#!/bin/bash + +set -e + +rm -rf configs +mkdir configs +find board -name Kconfig | xargs rm -f + +get_arch() +{ + case "$arch" in + powerpc) echo PPC;; + *) echo ${1^^};; + esac +} + +get_ppc_cpu () +{ + case "$1" in + 74xx_7xx) echo 74xx_7xx;; + mpc512x) echo MPC512X;; + mpc5xx) echo 5xx;; + mpc5xxx) echo MPC5xxx;; + mpc824x) echo MPC824X;; + mpc8260) echo MPC8260;; + mpc83xx) echo MPC83xx;; + mpc85xx) echo MPC85xx;; + mpc86xx) echo MPC86xx;; + mpc8xx) echo 8xx;; + ppc4xx) echo 4xx;; + *) echo >&2 Unkown PPC CPU $1; exit 1;; + esac +} + +arch_list="arc arm avr32 blackfin m68k microblaze mips nds32 nios2 openrisc powerpc sandbox sh sparc x86" +ppc_cpu_list="74xx_7xx mpc512x mpc5xx mpc5xxx mpc824x mpc8260 mpc83xx mpc85xx mpc86xx mpc8xx ppc4xx" + +for arch in $arch_list +do + ARCH=$(get_arch $arch) + + case "$arch" in + blackfin) menu="Blackfin";; + m68k) menu="M68000";; + microblaze) menu="MicroBlaze";; + nios2) menu="Nios II";; + openrisc) menu="OpenRISC";; + powerpc) menu="PowerPC";; + sandbox) menu="Sandbox";; + sh) menu="SuperH";; + x86) menu="x86";; + *) menu=${arch^^};; + esac + +cat <<EOF > arch/$arch/Kconfig +menu "$menu architecture" + depends on $ARCH + +config SYS_ARCH + string + default "$arch" + +EOF + +if [ "$arch" = "powerpc" ]; then +cat <<EOF >> arch/$arch/Kconfig +choice + prompt "CPU select" + +config 74xx_7xx + bool "74xx" + +config MPC512X + bool "MPC512X" + +config 5xx + bool "MPC5xx" + +config MPC5xxx + bool "MPC5xxx" + +config MPC824X + bool "MPC824X" + +config MPC8260 + bool "MPC8260" + +config MPC83xx + bool "MPC83xx" + +config MPC85xx + bool "MPC85xx" + +config MPC86xx + bool "MPC86xx" + +config 8xx + bool "MPC8xx" + +config 4xx + bool "PPC4xx" + +endchoice + +EOF +for cpu in $ppc_cpu_list +do + echo "source \"arch/powerpc/cpu/$cpu/Kconfig\"" >> arch/powerpc/Kconfig +done + +fi + +if [ "$arch" = "sandbox" ]; then +cat <<EOF >> arch/$arch/Kconfig +config SYS_BOARD + string + default "$arch" + +config SYS_CONFIG_NAME + string + default "$arch" +EOF +elif [ "$arch" != "powerpc" ]; then +cat <<EOF >> arch/$arch/Kconfig +choice + prompt "Target select" + +EOF +fi + +done + +for cpu in $ppc_cpu_list +do +cat <<EOF > arch/powerpc/cpu/$cpu/Kconfig +menu "$cpu CPU" + depends on $(get_ppc_cpu $cpu) + +config SYS_CPU + string + default "$cpu" + +choice + prompt "Target select" + +EOF + +done + +write_defconfig() { + + if [ "$spl_enable" = "y" ]; then + echo >> $defconfig "CONFIG_SPL=y" + fi + + if [ "$tpl_enable" = "y" ]; then + echo >> $defconfig "CONFIG_TPL=y" + fi + + if [ "$tpl_enable" = "y" ]; then + prefix="+ST:" + elif [ "$spl_enable" = "y" ]; then + prefix="+S:" + else + prefix= + fi + + if [ "$extra_options" ]; then + # O2MNT_O2M110, O2MNT_O2M112, O2MNT_O2M113 boards include + # double-quotations in the extra option field. + # We must escape them. + echo >> $defconfig "CONFIG_SYS_EXTRA_OPTIONS=\"$(echo "$extra_options" | sed -e 's/"/\\"/g')\"" + fi + + if [ "$arch" = sandbox ]; then + touch $defconfig + else + echo >> $defconfig "${prefix}CONFIG_$ARCH=y" + if [ "$arch" = powerpc ]; then + echo >> $defconfig "${prefix}CONFIG_$CPU=y" + fi + echo >> $defconfig "${prefix}CONFIG_$TARGET=y" + fi +} + +write_kconfig () +{ + echo >> $kconfig + echo >> $kconfig "if $TARGET" + echo >> $kconfig + + if [ "$cpu" != "-" -a "$arch" != "powerpc" ]; then + echo >> $kconfig "config SYS_CPU" + echo >> $kconfig " string" + if [ "$spl_cpu" != "$cpu" ]; then + echo >> $kconfig " default \"$spl_cpu\" if SPL_BUILD" + echo >> $kconfig " default \"$cpu\" if !SPL_BUILD" + else + echo >> $kconfig " default \"$cpu\"" + fi + echo >> $kconfig + fi + + if [ "$board" != "-" ]; then + echo >> $kconfig "config SYS_BOARD" + echo >> $kconfig " string" + echo >> $kconfig " default \"$board\"" + echo >> $kconfig + fi + + if [ "$vendor" != "-" ]; then + echo >> $kconfig "config SYS_VENDOR" + echo >> $kconfig " string" + echo >> $kconfig " default \"$vendor\"" + echo >> $kconfig + fi + + if [ "$soc" != "-" ]; then + echo >> $kconfig "config SYS_SOC" + echo >> $kconfig " string" + echo >> $kconfig " default \"$soc\"" + echo >> $kconfig + fi + + echo >> $kconfig "config SYS_CONFIG_NAME" + echo >> $kconfig " string" + echo >> $kconfig " default \"$config_name\"" + echo >> $kconfig + + echo >> $kconfig "endif" +} + +sed -e 's/Orphan/Active/' -e 's/aarch64/arm/' -e '/#/d' -e '/^$/d' boards.cfg | \ +awk '$8 == "-" { $8 = $7 } { tmp = $7; $7 = $8; $8 = tmp; print }' | \ +sed -e 's/arm720t/arm0720t/' -e 's/arm920t/arm0920t/' \ +-e 's/arm926ejs/arm0926ejs/' -e 's/arm946t/arm0946t/' \ +-e 's/tegra20/tegra020/' -e 's/tegra30/tegra030/' | \ +tools/reformat.py -i -d '-' -s 8 | \ +sed -e 's/arm0720t/arm720t/' -e 's/arm0920t/arm920t/' \ +-e 's/arm0926ejs/arm926ejs/' -e 's/arm0946t/arm946t/' \ +-e 's/tegra020/tegra20/' -e 's/tegra030/tegra30/' | +awk '{ tmp = $7; $7 = $8; $8 = tmp; print }' | \ +while read -r status arch cpu soc vendor board target options maintainers +do + + echo "processing $target" + + # Tegra SoCs have different "cpu" and "spl_cpu" + spl_cpu=${cpu#*:} + cpu=${cpu%:*} + + config_name=$target + extra_options= + + [ "$options" != "-" ] && { + tmp="${options%:*}" + if [ "$tmp" ] ; then + config_name="$tmp" + fi + + if [ "${tmp}" != "$options" ] ; then + extra_options=${options#*:} + fi + } + + all_configs=$(tools/print_allconfigs $target) + + if echo $all_configs | grep -q "CONFIG_SPL=y"; then + spl_enable=y + else + spl_enable= + fi + + if echo $all_configs | grep -q "CONFIG_TPL=y"; then + tpl_enable=y + else + tpl_enable= + fi + + if [ "$vendor" = "armltd" ]; then + prompt=$target + elif [ "$config_name" = "lacie_kw" -o "$config_name" = "spear3xx_evb" \ + -o "$config_name" = "spear6xx_evb" ]; then + prompt=$board + else + if [ "${config_name^^}" = "${target^^}" ]; then + prompt=$target + else + prompt=$config_name + fi + fi + + TARGET=$(echo TARGET_${prompt^^} | sed -e 's/-/_/g') + + ARCH=$(get_arch $arch) + if [ "$arch" = powerpc ]; then + CPU=$(get_ppc_cpu $cpu) + fi + defconfig=configs/${target}_defconfig + write_defconfig + + if [ "$board" = "-" ]; then + kconfig=board/$vendor/Kconfig + elif [ "$vendor" = "-" ]; then + kconfig=board/$board/Kconfig + else + kconfig=board/$vendor/$board/Kconfig + fi + + if [ "$target" != "sandbox" -a \( "$vendor" = "armltd" -o \ + "$config_name" != "$config_name_prev" -o "$board" != "$board_prev" \) ]; then + write_kconfig + if [ "$arch" = powerpc ]; then + arch_kconfig=arch/powerpc/cpu/$cpu/Kconfig + else + arch_kconfig=arch/$arch/Kconfig + fi + + echo "source \"$kconfig\"" >> ${arch_kconfig}2 + echo >> $arch_kconfig "config $TARGET" + echo >> $arch_kconfig " bool \"Support $prompt\"" + echo >> $arch_kconfig + fi + + config_name_prev=$config_name + board_prev=$board +done + +for arch in $arch_list +do +if [ "$arch" != sandbox -a "$arch" != powerpc ]; then +cat<<EOF >> arch/$arch/Kconfig +endchoice + +EOF + +sort arch/$arch/Kconfig2 | uniq >> arch/$arch/Kconfig +rm arch/$arch/Kconfig2 + +fi + +cat<<EOF >> arch/$arch/Kconfig + +endmenu +EOF + +done + +for cpu in $ppc_cpu_list +do +cat<<EOF >> arch/powerpc/cpu/$cpu/Kconfig +endchoice + +EOF + +sort arch/powerpc/cpu/$cpu/Kconfig2 | uniq >> arch/powerpc/cpu/$cpu/Kconfig +rm arch/powerpc/cpu/$cpu/Kconfig2 + +cat<<EOF >> arch/powerpc/cpu/$cpu/Kconfig + +endmenu +EOF + +done + +for i in $(find board -path "board/*/Kconfig") +do + # dropping the empty line at the beginning + sed -e "1d" $i > $i.tmp + mv $i.tmp $i +done diff --git a/tools/print_allconfigs b/tools/print_allconfigs new file mode 100755 index 0000000..e00c333 --- /dev/null +++ b/tools/print_allconfigs @@ -0,0 +1,77 @@ +#!/bin/sh +# Print all config macros for specified board +# +# Usage: tools/getconfigs <board> + +# Specify your favoriate cross tools +CROSS_COMPILE_ARC=arc-linux- +CROSS_COMPILE_AARCH64=aarch64-linux-gnu- +CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi- +CROSS_COMPILE_AVR32=avr32-linux- +CROSS_COMPILE_BLACKFIN=bfin-elf- +CROSS_COMPILE_M68K=m68k-linux- +CROSS_COMPILE_MICROBLAZE=microblaze-linux- +CROSS_COMPILE_MIPS=mips-linux- +CROSS_COMPILE_NDS32=nds32le-linux- +CROSS_COMPILE_NIOS2=nios2-linux- +CROSS_COMPILE_OPENRISC=or32-linux- +CROSS_COMPILE_POWERPC=powerpc-linux- +CROSS_COMPILE_SH=sh4-gentoo-linux-gnu- +CROSS_COMPILE_SPARC=sparc-elf- +CROSS_COMPILE_X86=i386-linux- + +if [ ! -r boards.cfg ]; then + echo >&2 "boards.cfg: not found" + echo >&2 "Run \"tools/print_allconfigs <target_board>\" at the top directory" + echo >&2 "Exit." + exit 1 +fi + +if [ $# != 1 ]; then + echo >&2 "Usage: tools/print_allconfigs <target_board>" + echo >&2 "Exit." + exit 2 +fi + +target=$1 + + +get_arch() { + local target=$1 + + awk '$7 == "'$target'" { print $2 }' boards.cfg +} + +arch=$(get_arch $target) + +if [ -z "$arch" ]; then + echo >&2 "$target: target board not found in boards.cfg" + echo >&2 "Exit." + exit 3 +fi + +ARCH=$(echo $arch | tr '[:lower:]' '[:upper:]') + +eval CROSS_COMPILE=\$CROSS_COMPILE_$ARCH + +export CROSS_COMPILE + +rm -f include/autoconf.mk + +make ${target}_config include/autoconf.mk >/dev/null || { \ + echo >&2 "make failed." + echo >&2 "Please check if CROSS_COMPILE_<ARCH> is correctly set." + echo >&2 "Exit." + exit 4 +} + +if [ ! -f include/autoconf.mk ]; then + echo >&2 "include/autoconf.mk: not found." + echo >&2 "Internal error." + echo >&2 "Exit." + exit 5 +fi + +cat include/autoconf.mk + +exit 0 -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot