[RK3399][Android7.1] 调试笔记 --- CPU的serial number读取

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kris_fei/article/details/86598674

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

描述:
系统除了device id, WiFi MAC,Andoid ID这些值以外,cpu的serial也是唯一的,因此也可以用它来做授权判断等应用。


读取:

rk3399_mid:/ $ cat /proc/cpuinfo

......
processor	: 5
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 2

Serial		: b8a0bcb99f6bf8b1

代码分析:
对应读取接口在cpuinfo.c

static int c_show(struct seq_file *m, void *v)
{
	......

	seq_printf(m, "Serial\t\t: %08x%08x\n",
		   system_serial_high, system_serial_low);

	return 0;
}

system_serial_high/system_serial_low的设置是在rockchip-cpuinfo.c中:

static int rockchip_cpuinfo_probe(struct platform_device *pdev)
{
	......
	//从efuse中读取
	cell = nvmem_cell_get(dev, "cpu-version");

	......
	for (i = 0; i < 8; i++) {
		buf[i] = efuse_buf[1 + (i << 1)];
		buf[i + 8] = efuse_buf[i << 1];
	}

	system_serial_low = crc32(0, buf, 8);
	system_serial_high = crc32(system_serial_low, buf + 8, 8);

	dev_info(dev, "Serial\t\t: %08x%08x\n",
		 system_serial_high, system_serial_low);

	return 0;
}

开机能看到如下log:
[ 0.700224] rockchip-cpuinfo cpuinfo: Serial : b8a0bcb99f6bf8b1


加粗样式参考:
cat /proc/cpuinfo

猜你喜欢

转载自blog.csdn.net/kris_fei/article/details/86598674