本文转载自: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] 调试笔记 --- 系统识别不同硬件版本方法【转】的更多相关文章

  1. [RK3288][Android6.0] 调试笔记 --- Goodix GT9和GT9F区别【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/78341425 Platform: RK3288 OS: Android 6.0 Kernel ...

  2. [RK3288][Android6.0] 调试笔记 --- 软硬键盘同时使用【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/78748313 Platform: RK3288 OS: Android 6.0 Kernel ...

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

    本文转载自:http://m.blog.csdn.net/kris_fei/article/details/69553422 Platform: ROCKCHIPOS: Android 6.0Kern ...

  4. [RK3288][Android6.0] 调试笔记 --- 普通串口的添加 【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/54574073   标签: rk3288 串口添加 2017-01-16 14:52 1079 ...

  5. [RK3288][Android6.0] 调试笔记 --- 替换系统签名【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/55100299 Platform: RK3288OS: Android 6.0Kernel: ...

  6. [RK3288][Android6.0] 调试笔记 --- eMMC分区号和名字的对应【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/77318410 Platform: Rockchip OS: Android 6.0 Kern ...

  7. [RK3288][Android6.0] 调试笔记 --- 测试I2C设备正常传输方法【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/71515020 Platform: RockchipOS: Android 6.0Kernel ...

  8. RK3288][Android6.0] 调试笔记 --- 关闭按键音后无法录音问题【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/70052413 Platform: ROCKCHIPOS: Android 6.0Kernel ...

  9. [RK3288][Android6.0] 调试笔记 --- 如何确认声卡是否注册成功【转】

    本文转载自:http://blog.csdn.net/kris_fei/article/details/78399875 Platform: RK3288 OS: Android 6.0 Kernel ...

随机推荐

  1. windows创建任务计划(周期执行bat脚本)

    https://jingyan.baidu.com/article/ca00d56c767cfae99febcf73.html windows找到任务计划程序: 这台电脑->管理

  2. Python入门--6--今天抄袭人家一篇日志--numpy这个

    Numpy NumPy的主要对象是同种元素的多维数组. 这是一个所有元素都是同一类型.通过一个正整数元祖索引的元素表格(通常元素都是数字) 在Numpy中维度(dimensions)叫做:轴 轴的个数 ...

  3. MyBatis的参数,不能传入null

    今天在调试的过程中发现一个bug,把传入的参数写到查询分析器中执行没有问题,但是在程序中执行就报错:org.springframework.jdbc.UncategorizedSQLException ...

  4. django学习之- simple_tag

    如何将前端的数据直接通过python模块进行渲染,使用django的simple_tag功能,如下 django后端编写: 1:在对应的app目录下创建目录:templatetags 2:在templ ...

  5. (2)Swing窗体基本设置

    import javax.swing.*; import javax.swing.plaf.FontUIResource; import java.awt.*; import java.util.En ...

  6. python入门示例程序

    该实例是raspi和dsp电机运动控制板的串口uart通信: import serial class SerialHandler(): ''' raspi serial for communicati ...

  7. codevs科技庄园

    /* 因为每一秒只能走一个单位长度,而每走一个单位长度又会消耗一个体力值,如果体力值没有了时间还有也只能按照体力值计算,反之一样,所以V对于时间和体力值取小 cnt记录有桃子的树的个数,node[cn ...

  8. Codeforces 375 D Tree and Queries

    Discription You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...

  9. 构建可读性更高的 ASP.NET Core 路由

    原文:构建可读性更高的 ASP.NET Core 路由 一.前言 不知你在平时上网时有没有注意到,绝大多数网站的 URL 地址都是小写的英文字母,而我们使用 .NET/.NET Core MVC 开发 ...

  10. Android判断屏幕锁屏的方法总结

    由于做一个项目,需要判断屏幕是否锁屏,发现网上方法很多,但是比较杂,现在进行总结一下: 总共有两类方法: 一.代码直接判定 二.接收广播 现在先说第一类方法(代码直接判定): 1.通过PowerMan ...