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_SPI,comm/spi
37 CONFIG_MODULE_CC2420,devices/radio/cc2420
38 CONFIG_MODULE_UART,comm/uart
39 CONFIG_MODULE_I2C,comm/i2c
40 CONFIG_MODULE_MF2_CLIENT,comm/mf2_client
41 CONFIG_MODULE_MF2_SERVER,comm/mf2_server
42 CONFIG_MODULE_PWM,hardware/pwm
43 CONFIG_MODULE_PWM_NG,hardware/pwm_ng
44 CONFIG_MODULE_ADC,hardware/adc
45 CONFIG_MODULE_AES,crypto/aes
46 CONFIG_MODULE_MD5,crypto/md5
47 CONFIG_MODULE_RC4,crypto/rc4
48 CONFIG_MODULE_HAMMING,encoding/hamming
49 CONFIG_MODULE_TIMER,hardware/timer
50 CONFIG_MODULE_BASE64,encoding/base64
51 CONFIG_MODULE_CIRBUF,base/cirbuf
52 CONFIG_MODULE_DIAGNOSTIC,debug/diagnostic
53 CONFIG_MODULE_ERROR,debug/error
54 CONFIG_MODULE_FIXED_POINT,base/math/fixed_point
55 CONFIG_MODULE_TIME_EXT,base/time_ext
56 CONFIG_MODULE_GEOMETRY,base/math/geometry
57 CONFIG_MODULE_VECT2,base/math/vect2"
60 echo Generating aversive configuration files
62 # does the .config file exists ?
64 echo "No such file <$1>"
68 echo "# Aversive configuration" > $2
71 ##### MCU, compilation options, output format
74 echo -n "MCU = " >> $2
75 echo `grep "CONFIG_MCU_.*=y" $1 | sed s,CONFIG_MCU_,, | sed s,=y,, | tr "[A-Z]" "[a-z]"` >> $2
77 echo -n "OPT = " >> $2
78 echo `grep "CONFIG_OPTM_.*=y" $1 | sed s,CONFIG_OPTM_,, | sed s,=y,, | tr "[A-Z]" "[a-z]"` >> $2
80 if grep "CONFIG_FORMAT_IHEX=y" $1 > /dev/null 2> /dev/null
82 echo "FORMAT = ihex" >> $2
83 echo "FORMAT_EXTENSION = hex" >> $2
86 if grep "CONFIG_FORMAT_SREC=y" $1 > /dev/null 2> /dev/null
88 echo "FORMAT = srec" >> $2
89 echo "FORMAT_EXTENSION = srec" >> $2
92 if grep "CONFIG_FORMAT_BINARY=y" $1 > /dev/null 2> /dev/null
94 echo "FORMAT = binary" >> $2
95 echo "FORMAT_EXTENSION = bin" >> $2
99 ##### Math lib and printf
102 if grep "CONFIG_MATH_LIB=y" $1 > /dev/null 2> /dev/null
104 echo "MATH_LIB = -lm" >> $2
106 echo "MATH_LIB = " >> $2
109 if grep "CONFIG_MINIMAL_PRINTF=y" $1 > /dev/null 2> /dev/null
111 echo "PRINTF_LDFLAGS = -Wl,-u,vfprintf -lprintf_min" >> $2
114 if grep "CONFIG_STANDARD_PRINTF=y" $1 > /dev/null 2> /dev/null
116 echo "PRINTF_LDFLAGS = " >> $2
119 if grep "CONFIG_ADVANCED_PRINTF=y" $1 > /dev/null 2> /dev/null
121 echo "PRINTF_LDFLAGS = -Wl,-u,vfprintf -lprintf_flt" >> $2
124 if grep "CONFIG_FDEVOPEN_COMPAT=y" $1 > /dev/null 2> /dev/null
126 echo "CFLAGS += -D__STDIO_FDEVOPEN_COMPAT_12" >> $2
129 if grep "CONFIG_MODULE_HOSTSIM=y" $1 > /dev/null 2> /dev/null
131 echo "PTHREAD_CFLAGS = -pthread" >> $2
132 echo "PTHREAD_LDFLAGS = -pthread" >> $2
141 if grep "CONFIG_AVRDUDE=y" $1 > /dev/null 2> /dev/null
143 echo "PROGRAMMER = avrdude" >> $2
146 echo -n "AVRDUDE_PROGRAMMER = " >> $2
147 echo `grep "CONFIG_AVRDUDE_PROG_.*=y" $1 | sed s,CONFIG_AVRDUDE_PROG_,, | sed s,=y,, | tr [A-Z_] [a-z\-]` >> $2
149 echo -n "AVRDUDE_PORT = " >> $2
150 echo `grep "CONFIG_AVRDUDE_PORT" $1 | sed s,CONFIG_AVRDUDE_PORT=,,` >> $2
152 echo -n "AVRDUDE_BAUDRATE = " >> $2
153 echo `grep "CONFIG_AVRDUDE_BAUDRATE" $1 | sed s,CONFIG_AVRDUDE_BAUDRATE=,,` >> $2
155 if grep "CONFIG_AVRDUDE_CHECK_SIGNATURE=y" $1 > /dev/null 2> /dev/null
157 echo "AVRDUDE_FLAGS_SIGNATURE_CHECK =" >> $2
159 echo "AVRDUDE_FLAGS_SIGNATURE_CHECK = -F" >> $2
163 if grep "CONFIG_AVARICE=y" $1 > /dev/null 2> /dev/null
165 echo "PROGRAMMER = avarice" >> $2
166 if ! grep "CONFIG_FORMAT_BINARY=y" $1 > /dev/null 2> /dev/null
168 echo "WARNING: With avarice, output format should be binary"
172 if grep "CONFIG_AVARICE_PROG_MKI=y" $1 > /dev/null 2> /dev/null
174 echo "AVARICE_PROGRAMMER = mkI" >> $2
177 if grep "CONFIG_AVARICE_PROG_MKII=y" $1 > /dev/null 2> /dev/null
179 echo "AVARICE_PROGRAMMER = mkII" >> $2
182 echo -n "AVARICE_PORT = " >> $2
183 echo `grep "CONFIG_AVARICE_PORT" $1 | sed s,CONFIG_AVARICE_PORT=,,` >> $2
185 echo -n "AVARICE_DEBUG_PORT = " >> $2
186 echo `grep "CONFIG_AVARICE_DEBUG_PORT" $1 | sed s,CONFIG_AVARICE_DEBUG_PORT=,,` >> $2
190 ##### Generation of the module list
192 echo -n "MODULES =" >> $2
194 for i in $MODULES_LIST
196 config=`echo $i | cut -d ',' -f1-1`
197 path=`echo $i | cut -d ',' -f2-2`
200 if grep $config=y $1 2>/dev/null >/dev/null
202 echo -n " "$path >> $2
205 if grep -q "${config}_CREATE_CONFIG=y" $1; then
206 CONF_FILE=`basename $path`_config.h
209 echo Cannot create default conf file $CONF_FILE, file exists
211 if [ ! -f $AVERSIVE_DIR/modules/$path/config/$CONF_FILE ]; then
212 echo Cannot create default conf file $CONF_FILE, no config sample in $AVERSIVE_DIR/modules/$path/config/$CONF_FILE
214 echo Creating default conf file $CONF_FILE .
215 cp $AVERSIVE_DIR/modules/$path/config/$CONF_FILE .