4 # usage generate_aversive_config config_file dst_module_file
8 # order is important !! High level modules first (defines link order)
10 MODULES_LIST="CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL,/devices/brushless_motors/brushless_3phase_digital_hall
11 CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_DOUBLE,/devices/brushless_motors/brushless_3phase_digital_hall_double
12 CONFIG_MODULE_HOSTSIM,base/hostsim
13 CONFIG_MODULE_MENU,ihm/menu
14 CONFIG_MODULE_PARSE,ihm/parse
15 CONFIG_MODULE_RDLINE,ihm/rdline
16 CONFIG_MODULE_VT100,ihm/vt100
17 CONFIG_MODULE_LCD,devices/ihm/lcd
18 CONFIG_MODULE_MULTISERVO,devices/servo/multiservo
19 CONFIG_MODULE_AX12,devices/servo/ax12
20 CONFIG_MODULE_ENCODERS_SPI,devices/encoders/encoders_spi
21 CONFIG_MODULE_ENCODERS_MICROB,devices/encoders/encoders_microb
22 CONFIG_MODULE_ENCODERS_EIRBOT,devices/encoders/encoders_eirbot
23 CONFIG_MODULE_TRAJECTORY_MANAGER,devices/robot/trajectory_manager
24 CONFIG_MODULE_BLOCKING_DETECTION_MANAGER,devices/robot/blocking_detection_manager
25 CONFIG_MODULE_OBSTACLE_AVOIDANCE,devices/robot/obstacle_avoidance
26 CONFIG_MODULE_POSITION_MANAGER,devices/robot/position_manager
27 CONFIG_MODULE_ROBOT_SYSTEM,devices/robot/robot_system
28 CONFIG_MODULE_PID,devices/control_system/filters/pid
29 CONFIG_MODULE_RAMP,devices/control_system/filters/ramp
30 CONFIG_MODULE_QUADRAMP,devices/control_system/filters/quadramp
31 CONFIG_MODULE_QUADRAMP_DERIVATE,devices/control_system/filters/quadramp_derivate
32 CONFIG_MODULE_BIQUAD,devices/control_system/filters/biquad
33 CONFIG_MODULE_CONTROL_SYSTEM_MANAGER,devices/control_system/control_system_manager
34 CONFIG_MODULE_TIME,base/time
35 CONFIG_MODULE_SCHEDULER,base/scheduler
36 CONFIG_MODULE_CALLOUT,base/callout
37 CONFIG_MODULE_SPI,comm/spi
38 CONFIG_MODULE_CC2420,devices/radio/cc2420
39 CONFIG_MODULE_XBEE,devices/radio/xbee
40 CONFIG_MODULE_UART,comm/uart
41 CONFIG_MODULE_I2C,comm/i2c
42 CONFIG_MODULE_MF2_CLIENT,comm/mf2_client
43 CONFIG_MODULE_MF2_SERVER,comm/mf2_server
44 CONFIG_MODULE_PWM,hardware/pwm
45 CONFIG_MODULE_PWM_NG,hardware/pwm_ng
46 CONFIG_MODULE_ADC,hardware/adc
47 CONFIG_MODULE_AES,crypto/aes
48 CONFIG_MODULE_MD5,crypto/md5
49 CONFIG_MODULE_RC4,crypto/rc4
50 CONFIG_MODULE_HAMMING,encoding/hamming
51 CONFIG_MODULE_TIMER,hardware/timer
52 CONFIG_MODULE_BASE64,encoding/base64
53 CONFIG_MODULE_CIRBUF,base/cirbuf
54 CONFIG_MODULE_DIAGNOSTIC,debug/diagnostic
55 CONFIG_MODULE_ERROR,debug/error
56 CONFIG_MODULE_FIXED_POINT,base/math/fixed_point
57 CONFIG_MODULE_TIME_EXT,base/time_ext
58 CONFIG_MODULE_GEOMETRY,base/math/geometry
59 CONFIG_MODULE_VECT2,base/math/vect2"
62 echo Generating aversive configuration files
64 # does the .config file exists ?
66 echo "No such file <$1>"
70 echo "# Aversive configuration" > $2
73 ##### MCU, compilation options, output format
76 echo -n "MCU = " >> $2
77 echo `grep "CONFIG_MCU_.*=y" $1 | sed s,CONFIG_MCU_,, | sed s,=y,, | tr "[A-Z]" "[a-z]"` >> $2
79 echo -n "OPT = " >> $2
80 echo `grep "CONFIG_OPTM_.*=y" $1 | sed s,CONFIG_OPTM_,, | sed s,=y,, | tr "[A-Z]" "[a-z]"` >> $2
82 if grep "CONFIG_FORMAT_IHEX=y" $1 > /dev/null 2> /dev/null
84 echo "FORMAT = ihex" >> $2
85 echo "FORMAT_EXTENSION = hex" >> $2
88 if grep "CONFIG_FORMAT_SREC=y" $1 > /dev/null 2> /dev/null
90 echo "FORMAT = srec" >> $2
91 echo "FORMAT_EXTENSION = srec" >> $2
94 if grep "CONFIG_FORMAT_BINARY=y" $1 > /dev/null 2> /dev/null
96 echo "FORMAT = binary" >> $2
97 echo "FORMAT_EXTENSION = bin" >> $2
101 ##### Math lib and printf
104 if grep "CONFIG_MATH_LIB=y" $1 > /dev/null 2> /dev/null
106 echo "MATH_LIB = -lm" >> $2
108 echo "MATH_LIB = " >> $2
111 if grep "CONFIG_MINIMAL_PRINTF=y" $1 > /dev/null 2> /dev/null
113 echo "PRINTF_LDFLAGS = -Wl,-u,vfprintf -lprintf_min" >> $2
116 if grep "CONFIG_STANDARD_PRINTF=y" $1 > /dev/null 2> /dev/null
118 echo "PRINTF_LDFLAGS = " >> $2
121 if grep "CONFIG_ADVANCED_PRINTF=y" $1 > /dev/null 2> /dev/null
123 echo "PRINTF_LDFLAGS = -Wl,-u,vfprintf -lprintf_flt" >> $2
126 if grep "CONFIG_FDEVOPEN_COMPAT=y" $1 > /dev/null 2> /dev/null
128 echo "CFLAGS += -D__STDIO_FDEVOPEN_COMPAT_12" >> $2
131 if grep "CONFIG_MODULE_HOSTSIM=y" $1 > /dev/null 2> /dev/null
133 echo "PTHREAD_CFLAGS = -pthread" >> $2
134 echo "PTHREAD_LDFLAGS = -pthread" >> $2
143 if grep "CONFIG_AVRDUDE=y" $1 > /dev/null 2> /dev/null
145 echo "PROGRAMMER = avrdude" >> $2
148 echo -n "AVRDUDE_PROGRAMMER = " >> $2
149 echo `grep "CONFIG_AVRDUDE_PROG_.*=y" $1 | sed s,CONFIG_AVRDUDE_PROG_,, | sed s,=y,, | tr [A-Z_] [a-z\-]` >> $2
151 echo -n "AVRDUDE_PORT = " >> $2
152 echo `grep "CONFIG_AVRDUDE_PORT" $1 | sed s,CONFIG_AVRDUDE_PORT=,,` >> $2
154 echo -n "AVRDUDE_BAUDRATE = " >> $2
155 echo `grep "CONFIG_AVRDUDE_BAUDRATE" $1 | sed s,CONFIG_AVRDUDE_BAUDRATE=,,` >> $2
157 if grep "CONFIG_AVRDUDE_CHECK_SIGNATURE=y" $1 > /dev/null 2> /dev/null
159 echo "AVRDUDE_FLAGS_SIGNATURE_CHECK =" >> $2
161 echo "AVRDUDE_FLAGS_SIGNATURE_CHECK = -F" >> $2
165 if grep "CONFIG_AVARICE=y" $1 > /dev/null 2> /dev/null
167 echo "PROGRAMMER = avarice" >> $2
168 if ! grep "CONFIG_FORMAT_BINARY=y" $1 > /dev/null 2> /dev/null
170 echo "WARNING: With avarice, output format should be binary"
174 if grep "CONFIG_AVARICE_PROG_MKI=y" $1 > /dev/null 2> /dev/null
176 echo "AVARICE_PROGRAMMER = mkI" >> $2
179 if grep "CONFIG_AVARICE_PROG_MKII=y" $1 > /dev/null 2> /dev/null
181 echo "AVARICE_PROGRAMMER = mkII" >> $2
184 echo -n "AVARICE_PORT = " >> $2
185 echo `grep "CONFIG_AVARICE_PORT" $1 | sed s,CONFIG_AVARICE_PORT=,,` >> $2
187 echo -n "AVARICE_DEBUG_PORT = " >> $2
188 echo `grep "CONFIG_AVARICE_DEBUG_PORT" $1 | sed s,CONFIG_AVARICE_DEBUG_PORT=,,` >> $2
192 ##### Generation of the module list
194 echo -n "MODULES =" >> $2
196 for i in $MODULES_LIST
198 config=`echo $i | cut -d ',' -f1-1`
199 path=`echo $i | cut -d ',' -f2-2`
202 if grep $config=y $1 2>/dev/null >/dev/null
204 echo -n " "$path >> $2
207 if grep -q "${config}_CREATE_CONFIG=y" $1; then
208 CONF_FILE=`basename $path`_config.h
211 echo Cannot create default conf file $CONF_FILE, file exists
213 if [ ! -f $AVERSIVE_DIR/modules/$path/config/$CONF_FILE ]; then
214 echo Cannot create default conf file $CONF_FILE, no config sample in $AVERSIVE_DIR/modules/$path/config/$CONF_FILE
216 echo Creating default conf file $CONF_FILE .
217 cp $AVERSIVE_DIR/modules/$path/config/$CONF_FILE .