changeset 88:ccde45a06737

nuc-fw: beginning of the configuration mechanism
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 23 Aug 2013 02:02:59 +0000
parents 321f6a9ae989
children d01098eccf21
files .hgignore nuc-fw/cfgmagic/functions nuc-fw/cfgmagic/post-target nuc-fw/cfgmagic/processconf.sh nuc-fw/cfgmagic/target.gtamodem nuc-fw/cfgmagic/target.pirelli nuc-fw/include/Makefile
diffstat 7 files changed, 253 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Thu Aug 22 18:53:27 2013 +0000
+++ b/.hgignore	Fri Aug 23 02:02:59 2013 +0000
@@ -9,7 +9,9 @@
 ^loadtools/fc-loadtool
 ^loadtools/fc-xram
 
+^nuc-fw/build\.conf$
 ^nuc-fw/finlink/.*\.map
+^nuc-fw/include/config\.
 
 ^target-utils/.*/crt0\.S$
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/cfgmagic/functions	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,68 @@
+target() {
+	if [ $# -lt 1 ]
+	then
+		echo "target setting: required argument missing" 1>&2
+		exit 1
+	fi
+	if [ -n "$TARGET" ]
+	then
+		echo "Error: target specified more than once" 1>&2
+		exit 1
+	fi
+	if [ ! -f "cfgmagic/target.$1" ]
+	then
+		echo "Error: target $1 not known" 1>&2
+		exit 1
+	fi
+	# looks good, proceed
+	TARGET="$1"
+	. "cfgmagic/target.$1"
+	. cfgmagic/post-target
+}
+
+feature() {
+	if [ $# -lt 1 ]
+	then
+		echo "feature setting: required argument missing" 1>&2
+		exit 1
+	fi
+	if [ -z "$TARGET" ]
+	then
+		echo "Please specify the target before any features" 1>&2
+		exit 1
+	fi
+	if [ ! -f "cfgmagic/feature.$1" ]
+	then
+		echo "Error: feature $1 not known" 1>&2
+		exit 1
+	fi
+	# looks good, proceed
+	. "cfgmagic/feature.$1"
+}
+
+export_to_c() {
+	if [ $# != 1 ]
+	then
+		echo "export_to_c: wrong number of arguments" 1>&2
+		exit 1
+	fi
+	c_export_list="$c_export_list $1"
+}
+
+export_to_mk() {
+	if [ $# != 1 ]
+	then
+		echo "export_to_mk: wrong number of arguments" 1>&2
+		exit 1
+	fi
+	mk_export_list="$mk_export_list $1"
+}
+
+export_to_m4() {
+	if [ $# != 1 ]
+	then
+		echo "export_to_m4: wrong number of arguments" 1>&2
+		exit 1
+	fi
+	m4_export_list="$m4_export_list $1"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/cfgmagic/post-target	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,86 @@
+# This shell script fragment is sourced after the selected target.
+# Here we'll put code that logically goes with the target hw-related
+# stuff, but which we wish to avoid duplicating in every target.*
+# fragment.
+
+# The per-target fragment must have defined CONFIG_IRAM_SIZE, CONFIG_XRAM_SIZE
+# and CONFIG_FWFLASH_SIZE.
+if [ -z "$CONFIG_IRAM_SIZE" ]
+then
+	echo "Error: target.$TARGET failed to define CONFIG_IRAM_SIZE" 1>&2
+	exit 1
+fi
+
+if [ -z "$CONFIG_XRAM_SIZE" ]
+then
+	echo "Error: target.$TARGET failed to define CONFIG_XRAM_SIZE" 1>&2
+	exit 1
+fi
+
+if [ -z "$CONFIG_FWFLASH_SIZE" ]
+then
+	echo "Error: target.$TARGET failed to define CONFIG_FWFLASH_SIZE" 1>&2
+	exit 1
+fi
+
+# export them to C and to the m4-based ld script generation logic
+export_to_c	CONFIG_IRAM_SIZE
+export_to_m4	CONFIG_IRAM_SIZE
+export_to_c	CONFIG_XRAM_SIZE
+export_to_m4	CONFIG_XRAM_SIZE
+export_to_c	CONFIG_FWFLASH_SIZE
+export_to_m4	CONFIG_FWFLASH_SIZE
+
+# Because we'll be using a lot of TI's code that is very liberally sprinkled
+# with conditionals on their voodoo numbers for CHIPSET etc, we really have
+# no choice but to continue using these nasty numbers, at least where
+# possible.
+
+if [ -z "$DBB_type" ]
+then
+	echo "Error: target.$TARGET failed to define DBB_type" 1>&2
+	exit 1
+fi
+
+case "$DBB_type" in
+	751992*)
+		# This is the only Calypso variant we currently work with,
+		# and we have no authoritative knowledge of the correct
+		# CHIPSET number - only a current best guess.
+		CHIPSET=10
+		# let's hope for the best
+		;;
+	*)
+		echo "Error: unknown DBB_type=$DBB_type" 1>&2
+		exit 1
+		;;
+esac
+export_to_c	CHIPSET
+
+if [ -z "$ABB_type" ]
+then
+	echo "Error: target.$TARGET failed to define ABB_type" 1>&2
+	exit 1
+fi
+
+case "$ABB_type" in
+	Iota*)
+		ANLG_FAM=2
+		;;
+	Syren*)
+		ANLG_FAM=3
+		;;
+	*)
+		echo "Error: unknown ABB_type=$ABB_type" 1>&2
+		exit 1
+		;;
+esac
+export_to_c	ANLG_FAM
+
+# Ensure that device_class is set - various feature configurations
+# will certainly depend on it.
+if [ -z "$device_class" ]
+then
+	echo "Error: target.$TARGET failed to define device_class" 1>&2
+	exit 1
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/cfgmagic/processconf.sh	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,65 @@
+#!/bin/sh
+# The top level Makefile invokes this Bourne shell script after ensuring
+# that the build.conf file is present.  The job of this script is to grok
+# that configuration file and to produce include/config.{h,mk,m4} files
+# corresponding to the selected configuration.
+#
+# The current directory is expected to be the top level of nuc-fw, i.e.,
+# all fragments are sourced as cfgmagic/blah.
+# Don't run this script directly - let the Makefile do it for you.
+
+set -e
+. cfgmagic/functions
+TARGET=
+c_export_list=
+mk_export_list=
+m4_export_list=
+
+. ./build.conf
+
+if [ -z "$TARGET" ]
+then
+	echo "Error: target not set in build.conf" 1>&2
+	exit 1
+fi
+
+# Once we get some actual functionality, the following definitions
+# will likely depend on the target and feature configuration,
+# but for now all we have is a FreeNucleus RTOS demo.
+
+BUILD_COMPONENTS="nucdemo nucleus sprintf sysglue"
+export_to_mk BUILD_COMPONENTS
+
+BUILD_DEFAULT_IMAGE=ramImage
+export_to_mk BUILD_DEFAULT_IMAGE
+
+# Now generate the output files!
+
+parse_export_list() {
+	for var in $1
+	do
+		eval "value=\"\$$var\""
+		emit_def "$var" "$value"
+	done
+}
+
+# make config.h
+emit_def() {
+	echo "#define	$1	$2" >> include/config.h
+}
+: > include/config.h
+parse_export_list "$c_export_list"
+
+# make config.mk
+emit_def() {
+	echo "$1=	$2" >> include/config.mk
+}
+: > include/config.mk
+parse_export_list "$mk_export_list"
+
+# make config.m4
+emit_def() {
+	echo 'define(`'"$1'"',`'"$2')dnl" >> include/config.m4
+}
+: > include/config.m4
+parse_export_list "$m4_export_list"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/cfgmagic/target.gtamodem	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,14 @@
+CONFIG_TARGET_GTAMODEM=1
+export_to_c	CONFIG_TARGET_GTAMODEM
+export_to_mk	CONFIG_TARGET_GTAMODEM
+
+device_class=modem
+
+CONFIG_IRAM_SIZE=0x80000
+CONFIG_XRAM_SIZE=0x100000
+CONFIG_FWFLASH_SIZE=0x300000
+# the post-target fragment exports these
+
+DBB_type=751992A
+ABB_type=Iota3025
+# the post-target fragment will turn these into TI's voodoo numbers
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/cfgmagic/target.pirelli	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,14 @@
+CONFIG_TARGET_PIRELLI=1
+export_to_c	CONFIG_TARGET_PIRELLI
+export_to_mk	CONFIG_TARGET_PIRELLI
+
+device_class=phone
+
+CONFIG_IRAM_SIZE=0x80000
+CONFIG_XRAM_SIZE=0x800000
+CONFIG_FWFLASH_SIZE=0x800000
+# the post-target fragment exports these
+
+DBB_type=751992A
+ABB_type=Iota3014
+# the post-target fragment will turn these into TI's voodoo numbers
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuc-fw/include/Makefile	Fri Aug 23 02:02:59 2013 +0000
@@ -0,0 +1,4 @@
+all:
+
+clean:
+	rm -f config.*