This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to link executable to discontinuous flash area

I am using uVision4.74 with STM32F407, I want to link my program to two sections, one section is 0x8000000 length 0x4000, and the other section is 0x8008000 length 0x38000. I did the setup in the options form Taget 'whatsoever', but the linked file used 0x8000000~0x80006AC and 0x8008000~0x08017C00

Is it a bug in the linker? It wasted so many space in section 1.

  • No the linker's pretty stupid, and does a lazy allocation. For optimum usage the linker would have to do multiple passes to get a "best fit", and that's complicated and time consuming.

    You'd really need to manager the scatter file, and balance what is placed in each section. You could presumably do this with a script if it really bugs you. Or you're forced to think about when you run out of space.

    I've used other linkers where you can prioritize the function ordering of the working set, so it can deal with cache line proximity, and faster memories (internal vs external flash for example), this again typically uses scripts and trace/performance data.

  • So This linker is too lazy!!!
    I know GNU linker support linker script, but I didn't find anywhere in the uVision to use linker script. Any idea?

  • Target Options -> Linker -> deselect: "Use Memory Layout from Target Dialog"

    Now you can use the script File:
    Target Options -> Linker -> Scatter File: "projectname.sct"

  • The GNU linker has historically been a pretty poor one for embedded work too. Then again you're not paying $10-20K per seat for it either.

    Most are lazy, quick and predictable. I'd take this over smart, slow and unpredictable. See also Hammerstein-Equord

    Good function placement is a science, it depends a lot on system level interactions, and chip choices (size, width, speed). A script that understands your system and priorities is the way to go.