6
\$\begingroup\$

I'm trying to write a linker script for my first firmware for STM32F103C8T6 microcontroller. I have an example script that works. What I'm trying to understand is why it works.

The linker script I have defines two memory locations:

MEMORY
{
 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
}

Official STM32 programming manual section 2.2 states that "Code" memory section starts with address 0x00000000. The next section is RAM, which is 0x20000000, just like stated in my linker script.

Where the FLASH origin value 0x08000000 comes from?

asked Dec 25, 2017 at 19:42
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Have you got the datasheet and reference manual for your processor, the datasheet will have a memory map and show flash at 0x08000000 \$\endgroup\$ Commented Dec 25, 2017 at 19:46
  • \$\begingroup\$ Hm, indeed, the datasheet says 0x00000000 is "Aliased to Flash or system memory depending on Boot pins" \$\endgroup\$ Commented Dec 25, 2017 at 19:54
  • 1
    \$\begingroup\$ see section 2.3.8 of this st.com/content/ccc/resource/technical/document/datasheet/33/d4/… \$\endgroup\$ Commented Dec 25, 2017 at 20:03

2 Answers 2

1
\$\begingroup\$

The linked programming manual shows a code region starting at 0x00000000 which is 0.5GB in size. The datasheet for the part shows flash memory at 0x08000000 onwards.

0x00000000 is where the address for the initial stack pointer is, with 4bytes on being the address of the first instruction to execute.

On the stm32 the area mapped to 0x00000000 is changed based on boot pin setting to allow execution of user loaded code, or running a built in bootloader.

answered Dec 25, 2017 at 20:00
\$\endgroup\$
2
\$\begingroup\$

Apparently, the 0x08000000 value comes from the datasheet section 4. Memory region starting from 0x00000000 is "Aliased to Flash or system memory depending on Boot pins", and "Flash memory" starts from 0x08000000.

answered Dec 25, 2017 at 19:57
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.