10

I'm new to ARM programming using Keil Microvision V5.12 compiler. I can't compile a simple assembly project getting this error:

.\Objects\learn.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.

I've tried searching and couldn't find any solution for this problem.

This is what I do:

  1. Create a project (without the startup file)
  2. Add a new assembly file (learn.s)
  3. Click Build Target.

Can anybody help?

Javid
  • 2,755
  • 2
  • 33
  • 60

5 Answers5

21

I Added this answer for newbies,
So, After create new project do same as picture:

enter image description here

Prof. Hell
  • 729
  • 12
  • 19
  • 1
    I'm selecting your answer as accepted because it has more upvotes than the answer that was previously accepted. – Javid Dec 11 '19 at 18:44
7

There is no 'FIRST' object in your source code. Your scatter file likely looks something like:

LR_IROM1 0x08000000 0x00040000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00040000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x20000000 0x0000A000  {  ; RW data
   .ANY (+RW +ZI)
  }
}

The _FIRST object that the linker wants to put into the image is the area called RESET. You do not have a RESET region in your code. Add something along the lines of

AREA    RESET, DATA, READONLY

to your assembly file where you want execution to begin.

Create a project with the startup file and look for the AREA RESET ..... declaration and copy that.

For Cortex it looks like:

                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
                EXPORT  __Vectors_End
                EXPORT  __Vectors_Size

__Vectors       DCD     __initial_sp               ; Top of Stack
                DCD     Reset_Handler              ; Reset Handler
                DCD     NMI_Handler                ; NMI Handler
                DCD     HardFault_Handler          ; Hard Fault Handler
                DCD     MemManage_Handler          ; MPU Fault Handler
                DCD     BusFault_Handler           ; Bus Fault Handler
                DCD     UsageFault_Handler         ; Usage Fault Handler
                DCD     0     

Each of those handlers needs to be declared, but you can just add the stack pointer and reset handler to get started.

SilverCode
  • 189
  • 4
  • Thanks a LOT! I have another question. In the code you provided, how can I access the exported data from the code (ie. __Vectors)? – Javid Dec 07 '14 at 09:29
  • In C? extern "C" the value e.g. extern "C" unsigned int __Vectors; and then use it (it will likely be read only if used on a real target) – SilverCode Dec 08 '14 at 22:03
  • No not C. Take a look at this question: http://stackoverflow.com/questions/27371905/how-to-write-at-least-two-areas-in-arm-assembly – Javid Dec 09 '14 at 05:16
3

For ARM LPC the startup assembly file Startup.s is something like this:

AREA MyStacks, DATA, NOINIT, ALIGN=2 IrqStackSpace SPACE IRQ_STACK_LEGTH * 4
FiqStackSpace SPACE FIQ_STACK_LEGTH * 4
AbtStackSpace SPACE ABT_STACK_LEGTH * 4
UndtStackSpace SPACE UND_STACK_LEGTH * 4

    AREA    RESET, DATA, READONLY

bottom_of_heap SPACE 1

    AREA    RESET, DATA, READONLY

StackUsr SPACE 1

Just replacing does the trick.

ARM Coder
  • 31
  • 2
0

This error will occur If you select HSI in Clock configuration at cubeMX although you've already selected HSE in RCC. If you choose one of them (HSI/HSE) it will be solved

0

I face same problem. Source (.c) fil and (.uvproj) file should same location and you can not copy from others location.So create