How to determine CPU's ID with ChibiOS?
Moderators: RoccoMarco, lbednarz, tfAteba
-
ruslanpopov
- Posts: 35
- Joined: Sun Aug 19, 2012 9:36 pm
How to determine CPU's ID with ChibiOS?
I need to obtaing an ID of the CPU. How can I di this with ChibiOS?
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: How to determine CPU's ID with ChibiOS?
Hi,
Do you need the MCU type or an unique serial number? The CPU type is exported by board.h as a macro. An unique serial number is not abstracted by the OS, some MCUs have factory-programmed serial numbers but it is not a common feature.
Giovanni
Do you need the MCU type or an unique serial number? The CPU type is exported by board.h as a macro. An unique serial number is not abstracted by the OS, some MCUs have factory-programmed serial numbers but it is not a common feature.
Giovanni
-
ruslanpopov
- Posts: 35
- Joined: Sun Aug 19, 2012 9:36 pm
Re: How to determine CPU's ID with ChibiOS?
It depends on the microcontroller that you are using. For the STM32F2/F4, I think it is at 0x1FFF7A10 and it extends for 12 bytes.
Re: How to determine CPU's ID with ChibiOS?
I use the following code to get the cpuid on an STM32F1xx (as a string).
Fabio Utzig
Code: Select all
#define ASCII(x) (((x)&0xF) < 10) ? (((x)&0xF)+'0') : (((x)&0xF)-10+'A')
char cpuid_str[25];
uint32_t *p = (uint32_t *) 0x1ffff7e8;
int i = 0, j = 0;
while (p <= (uint32_t *) 0x1ffff7f0) {
for (i = 0; i < 8; i++)
cpuid_str[7-i+j] = ASCII(*p >> (i*4));
p++;
j += 8;
}
str[24] = 0;
Fabio Utzig