Get CPU ID from user-space

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get CPU ID from user-space

2,295 Views
BrilliantovKiri
Senior Contributor I

Hello!

How can I get CPU ID, e.g. iMX53/1, from user-space?
I can parse /proc/cpuinfo but this is not very, I think, good way.

Thank you and excuse me my bad english.

Labels (1)
0 Kudos
Reply
3 Replies

1,477 Views
BrilliantovKiri
Senior Contributor I
/proc/cpuinfo contained information from kernel and I can change it. As sample on TI Davinci: # cat /proc/cpuinfo Processor : ARM926EJ-S rev 5 (v5l) BogoMIPS : 215.44 Features : swp half thumb fastmult edsp java CPU implementer : 0x41 CPU architecture: 5TEJ CPU variant : 0x0 CPU part : 0x926 CPU revision : 5 Hardware : DaVinci DM36x EVM Revision : 0000 Serial : 0000000000000000 And search in linux: $ grep EVM -rnI . | grep DM36x ./arch/arm/mach-davinci/board-dm365-evm.c:998:MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM36x EVM") For iMX53 QSB this: MACHINE_START(MX53_LOCO, "Freescale MX53 LOCO Board") I think if I change this description I see it in /proc/cpuinfo.
0 Kudos
Reply

1,478 Views
positron
Contributor I

First of all, Why do you think "parsing /proc/cpuinfo" is not a good way?

0 Kudos
Reply

1,478 Views
StevieRG
Contributor II

I'm not sure if this is any help but there is a file rootfs/usr/include/vpu_lib.h which might give some clues how to do this.

I've never looked at this to see if or how it works, I just remember I edited it once to fix some compiler warnings. In that file are some macros that use an externally defined variable "system_rev", I don't know where that comes from or what's really in it but looking at the macros it seems to contain CPU info. These macros are used in the mxc_vpu_test sample to identify CPU type. This is what's in the file (with my small casts mod):

extern unsigned int system_rev;

#define CHIP_REV_1_0            0x10

#define CHIP_REV_2_0 0x20

#define CHIP_REV_2_1            0x21

#define mxc_cpu()               (system_rev >> 12)

#define mxc_is_cpu(part)        ((mxc_cpu() == part) ? 1 : 0)

#define mxc_cpu_rev()           (system_rev & 0xFF)

// SRG 9-5-12 added casts to unsigned int to fix signed comparison warning

#define mxc_cpu_is_rev(rev)     \

        ((mxc_cpu_rev() == (unsigned int)rev) ? 1 : ((mxc_cpu_rev() < (unsigned int)rev) ? -1 : 2))

#define MXC_REV(type)                           \

static inline int type## _rev (int rev)         \

{                                               \

        return (type() ? mxc_cpu_is_rev(rev) : 0);      \

}

#define cpu_is_mx27() mxc_is_cpu(0x27)

#define cpu_is_mx51() mxc_is_cpu(0x51)

#define cpu_is_mx53() mxc_is_cpu(0x53)

#define cpu_is_mx5x() (mxc_is_cpu(0x51) || mxc_is_cpu(0x53))

#define cpu_is_mx6q() mxc_is_cpu(0x63)

MXC_REV(cpu_is_mx27);

0 Kudos
Reply