software development(2):variant handling during-compile on the fly post-compile version control deployment

we should always avoid to use variant handling in software development, because one solution for all variants is the best solution.But sometimes we should compromise due to some limits.

Here are some scenarios I can see now:

  1. one platform solution for different microconroller/hardware. pre-compile. link different libs
  2. confilict functions. during-compile
  3. cross platform(algorithm development on PC, target is other MCU). during-compile. link different libs
  4. one ECU for different vehicle models. one-time configuraton. bootloader
  5. differnt Transmission type for one vehicle model. constant configuration

copy choosed target files to target directory

two targets(A and B),before compile copy targetA or targetB to copied_target, only files in copied_target are included in makefile
1
2
3
4
_____componentA
|______targetA
|______targetB
|______copied_target

during-compile

compile switch(macro)

compile switch
1
2
3
4
5
6
7
8
9



#else (GS_MAJOR_VER == GS_TARGET_B)
// implementation for GS_TARGET_B

#else
#error "no such target"
#endif

on the fly

one-time configuraton

parameter is seleted by vehicle configuration shored in NVM/flash.

parametes in flash, variant in NVM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
typedef enum
{
varaint1_enm,
variant2_enm
}Variants;

const VariantPar_st parameters[]={variant1_par, variant2_par};//all parametes for variants stored in flash

g_variant_u8 = getVariant();//getVariant() read variant from NVM.

if(varaint1_enm == g_variant_u8)
{
//load variant1 parameter or doing something special for variant1
}
else
{
//loac variant2 paramter or doing something special for variant2
}

constant configuration

Signal Multiplexing

One signal in the frame is used as a multiplexor and the remaining payload is interpreted depending on the value of the multiplexor signal.

adaptive algorithm

differnt parameter according different condition(eg.temperature/huminity/speed…)

post-compile

check your linker user manual and link different lib according to different target
1
-L{path to file containing library} -l${library name}

merge different parameters

pre-condition: parameter size for different variants is the same

executable file structure
1
2
3
4
5
------
Application area
------
Calibration area
------
variant1.hex/exe
1
2
3
4
5
------
Application area
------
Calibration area for variant1
------

version control

manage by version tools using branch, development path.

deployment

bootloader

use bootloader to flash seperate calibartion data during End of Line according to different vehilce models.

executable file structure
1
2
3
4
5
6
7
------
Bootloader area
------
Application area
------
Calibration area
------

sample label

different executable files for differnt ECUs.

References:

  1. Extended Signal Multiplexing in DBC Databases