cancel
Showing results for 
Search instead for 
Did you mean: 

Access ''MCU device ID code'' on STM32F103

Posted on May 27, 2015 at 03:29

Hi,

I'm writing a bootloader, and need to determine the device density and flash size.

I can read the flash size OK, from memory address 0x1FFFF7E0

However I can't seem to read the ''MCU device ID code'' , which is described on page 1076 of RM0008

DBGMCU_IDCODE

Address: 0xE004 2000

Only 32-bits access supported. Read-only

''This code is accessible using the

JTAG debug port (4 to 5 pins) or the SW debug port (two pins) or by the user software. It is

even accessible while the MCU is under system reset.''

However I just get zero when I read this address.

I can't see anything in the docs that say that there is a config register that needs to be enabled to read this register, and I don't have SWD or JPEG enabled by default in the bootloader code, as it doesn't need to communicate via SWD

I noticed that this memory address is ''MCU DEVICE ID code located in the external

PPB memory map''  but I'm not sure if this makes any difference to the code that needs to read it

  uint32 *devID =    (uint32 *) (0xE0042000);

Thanks

Roger

2 REPLIES 2
Posted on May 27, 2015 at 08:07

OK.

Just to answer my own question

See  http://www.st.com/st-web-ui/static/active/en/resource/technical/document/errata_sheet/CD00190234.pdf

''The

DBGMCU_IDCODE

and DBGMCU_CR debug registers are accessible only in debug mode (not accessible by the user software).When these registers are read in user mode,the returned value is 0x00.''

So basically RM0008 is incorrect and has been superseded by the Errata

So.. It looks like I cant accurately detemine device density from the code :0-(

I can get total flash size, but not the page size. I'm not sure if there is a link between these two, e.g. is up to 128kb flash in 1k pages, and devices with more then 128k flash in 2k pages ??

jpeacock
Associate III
Posted on May 27, 2015 at 13:57

There are other sources for system information.  Look at the Cortex SCB->CPUID register to get the device family (Cortex), variant (M series). and member (M0, M3, M3+, M4, M7)  That tells you if it's a 'F10x series (1K pages) or 'F2xx or later (2K pages).

You can also get some ST specific information, device and revision, from DBGMCU.

  Jack Peacock