How to determine CPU's ID with ChibiOS?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
ruslanpopov
Posts: 35
Joined: Sun Aug 19, 2012 9:36 pm

How to determine CPU's ID with ChibiOS?

Post by ruslanpopov »

I need to obtaing an ID of the CPU. How can I di this with ChibiOS?
User avatar
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?

Post by Giovanni »

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
ruslanpopov
Posts: 35
Joined: Sun Aug 19, 2012 9:36 pm

Re: How to determine CPU's ID with ChibiOS?

Post by ruslanpopov »

Thanks. I have asked about the unique serial number.
efuentes
Posts: 35
Joined: Wed Jul 25, 2012 6:16 am

Re: How to determine CPU's ID with ChibiOS?

Post by efuentes »

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.
utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: How to determine CPU's ID with ChibiOS?

Post by utzig »

I use the following code to get the cpuid on an STM32F1xx (as a string).

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
Post Reply