2012年3月28日 星期三

How to separate config into project

How to separate config into project:

Ex: If we want to access different DRAM, we must build differnet config into image

1. bootloader:
Bootloader need to build different configuration

step1:
Makefile:

+project_config \
+project_512m_config : unconfig
+ @./mkconfig -a cpuproject arm cpu cpuproject
+ @if [ "$(findstring 512m, $@)" ] ; then \
+ echo "#define CONFIG_DRAM_512" >> ./include/config.h ; \
+ else \
+ echo "#define CONFIG_DRAM_1G" >> ./include/config.h ; \
+ fi;


step2: Using this flag to separate DRAM setting
+#ifdef CONFIG_DRAM_512
+ init_ddr();
+#endif



2. kernel
We use parameter to feed build kernel.

step1: Using parameter to feed build kernel
kernel:
make -C $(KERNEL_PATH) ARCH=$(ARCH) $(KERNEL_CONFIG)
make -C $(KERNEL_PATH) BUILD_PLATFORM=$(PLATFORM) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) bzImage

kernel/Makefile:
+ifeq ($(BUILD_PLATFORM),test)
+KBUILD_CFLAGS += -DCONFIG_TEST1
+else
+KBUILD_CFLAGS += -DCONFIG_TEST2
+endif
+

step2: Using this flag to separate different config

+#if defined(CONFIG_TEST1)
+ init_test1();
+#else
+ init_test2();
+#end

沒有留言:

張貼留言