Page 1 of 1

How to determine CPU's ID with ChibiOS?

Posted: Fri Sep 07, 2012 10:33 pm
by ruslanpopov
I need to obtaing an ID of the CPU. How can I di this with ChibiOS?

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

Posted: Sat Sep 08, 2012 7:07 am
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

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

Posted: Sat Sep 08, 2012 12:52 pm
by ruslanpopov
Thanks. I have asked about the unique serial number.

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

Posted: Sat Sep 08, 2012 10:53 pm
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.

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

Posted: Sun Sep 09, 2012 12:22 am
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