[RK3288][Android6.0] 调试笔记 --- 系统识别不同硬件版本方法

Posted 请给我倒杯茶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RK3288][Android6.0] 调试笔记 --- 系统识别不同硬件版本方法相关的知识,希望对你有一定的参考价值。

本文转载自:http://m.blog.csdn.net/kris_fei/article/details/70226451

Platform: Rockchip
OS: android 6.0
Kernel: 3.10.92

需求:
硬件版本不一样,通过几个gpio的高低电平来表示不同版本,
u-boot/kernel/hal/framework/app层都需要用到,那么
可以使用系统自身的参数传递机制以及property API来实现.

以一个gpio为例.
改动:
u-boot
diff --git a/board/rockchip/rk32xx/rk32xx.c b/board/rockchip/rk32xx/rk32xx.c
index f043f77..e9a7466 100644
--- a/board/rockchip/rk32xx/rk32xx.c
+++ b/board/rockchip/rk32xx/rk32xx.c
@@ -164,6 +164,12 @@ static void board_init_adjust_env(void)
     }
 }
 //宏定义包起来
+/*Kris,161219, hw version verify. {*/
+#ifdef CONFIG_ECO_HW_REV
+u8 eco_hw_rev = 0;
+#endif
+/*Kris,161219, hw version verify. }*/
+
 #ifdef CONFIG_BOARD_LATE_INIT
 extern char bootloader_ver[24];
 int board_late_init(void)
@@ -182,6 +188,15 @@ int board_late_init(void)
     key_init();
 #endif
 
+/*Kris,161219, hw version verify. {*/
+#ifdef CONFIG_ECO_HW_REV
+#define GPIO_ECO_HW_REV                (GPIO_BANK8 | GPIO_A7)
       //获取gpio状态
+      gpio_direction_input(GPIO_ECO_HW_REV);
+      eco_hw_rev = gpio_get_value(GPIO_ECO_HW_REV);
+      printf("HW board check version:%d\n", gpio_get_value(GPIO_ECO_HW_REV));
+#endif
+/*Kris,161219, hw version verify. }*/
+
 #ifdef CONFIG_RK_POWER
     debug("pmic_init\n");
     pmic_init(0);
diff --git a/common/cmd_bootrk.c b/common/cmd_bootrk.c
index 17ad496..9f101c6 100755
--- a/common/cmd_bootrk.c
+++ b/common/cmd_bootrk.c
@@ -42,6 +42,14 @@ extern int do_bootm_linux(int flag, int argc, char *argv[],
 #if defined(CONFIG_POWER_RK818)
 extern bool is_rk81x_fg_init(void);
 #endif
+
+/*Kris,161219, hw version verify. {*/
+#ifdef CONFIG_ECO_HW_REV
+extern u8 eco_hw_rev;
+#endif
+/*Kris,161219, hw version verify. }*/
+
+
 extern int rkimage_load_image(rk_boot_img_hdr *hdr,
         const disk_partition_t *boot_ptn, const disk_partition_t *kernel_ptn);
 
@@ -486,6 +494,13 @@ static void rk_commandline_setenv(const char *boot_name, rk_boot_img_hdr *hdr, b
              "%s adc.incre=%d", command_line, g_increment);
 #endif
 
+/*Kris,161219, hw version verify. {*/
+#ifdef CONFIG_ECO_HW_REV
//利用u-boot到kernel的cmdline参数传递机制,传到kernel中.
+snprintf(command_line, sizeof(command_line),
+             "%s androidboot.eco_hw_rev=%s", command_line, eco_hw_rev?"Primary":"Secondary");
+#endif
+/*Kris,161219, hw version verify. }*/
+
     char *sn = getenv("fbt_sn#");
     if (sn != NULL) {
         /* append serial number if it wasn‘t in device_info already */
diff --git a/include/configs/rk32plat.h b/include/configs/rk32plat.h
index f80799f..ec5e41d 100755
--- a/include/configs/rk32plat.h
+++ b/include/configs/rk32plat.h
@@ -224,4 +224,8 @@
 
 #endif /* CONFIG_RK_POWER */
 
+
+/*Kris,161219, hw version verify.*/
+#define CONFIG_ECO_HW_REV
+
 #endif /* __RK32PLAT_CONFIG_H */
 
kernel:
diff --git a/arch/arm/mach-rockchip/common.c b/arch/arm/mach-rockchip/common.c
index e80880e..107b58c 100755
--- a/arch/arm/mach-rockchip/common.c
+++ b/arch/arm/mach-rockchip/common.c
@@ -340,6 +340,21 @@ static int __init rockchip_uboot_logo_setup(char *p)
 }
 early_param("uboot_logo", rockchip_uboot_logo_setup);
 
+/*Kris, 20161219, add check hw rev interface. {*/
//kernel中可以使用eco_hw_rev来判断了.
+int eco_hw_rev;
+static int __init early_eco_hw_rev(char *p)
+{
+       get_option(&p, &eco_hw_rev);
+       if (!strncmp(p, "Primary", 7))
+        eco_hw_rev = 1;
+    else if (!strncmp(p, "Secondary", 9))
+        eco_hw_rev = 0;
+       printk("androidboot.eco_hw_rev:%s\n", p);
+       return 0;
+}
+early_param("androidboot.eco_hw_rev", early_eco_hw_rev);
+/*Kris, 20161219, add check hw rev interface. }*/
+

userspace:
注意到cmdline的参数是androidboot.eco_hw_rev, ,在init进程中会解析以androidboot打头的cmdline参数,
可参考: http://blog.csdn.net/kris_fei/article/details/50925356
最终生成ro.boot.xxx格式的property. 而在HAL, Natvie, APP层都有对应的api去解析property,这样整个系统都可以使用了.

以上是关于[RK3288][Android6.0] 调试笔记 --- 系统识别不同硬件版本方法的主要内容,如果未能解决你的问题,请参考以下文章

[RK3288][Android6.0] 调试笔记 --- hwclock命令无法使用

[RK3288][Android6.0] 调试笔记 --- pmu(rk818)寄存器读写

[RK3288][Android6.0] 调试笔记 --- /data/app/预置apk安装失败

[RK3288][Android6.0] 调试笔记 --- 系统识别不同硬件版本方法

[RK3288][Android6.0] 调试笔记 --- 通用GPIO驱动控制LED

[RK3288][Android6.0] 调试笔记 --- 录音音量从HAL到APP层会变小问题