This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Assembly Startup Files.

Hello,

I'm trying to create a project from scratch and write my own drivers. I have strong background in C but unfortunately I don't know anything about assembly.
I could use a little help to understand the base of the projects / examples that are provided by nRF5 SDK.

I'm using the Segger Embedded Studio. My current version is:
SEGGER Embedded Studio for ARM
Release 4.50  Build 2020021311.41397
Windows x64

First I created a new Project.

File > New Project > Create the project in a new solution > A C/C++ executable for a Cortex-M processor executing from FLASH memory > "Selecting my part number" nRF52832_xxAA > FINISH.

Then I got the file setup you can see in the picture below.

Now, this project runs the main() fine on my nRF52832 module.

The main.c file contains:

File    : main.c
Purpose : Generic application start

*/

#include <stdio.h>
#include <stdlib.h>

/*********************************************************************
*
*       main()
*
*  Function description
*   Application entry point.
*/
void main(void) {
  int i;

  for (i = 0; i < 100; i++) {
    printf("Hello World %d!\n", i);
  }
  do {
    i++;
  } while (1);
}

/*************************** End of file ****************************/

And I saw in debugging printing the "Hello world" as expected.

Now to the question:

Question1: I see different assembly files than the examples have. As long as the project above builds and runs fine can I add my own C code on top of it?
Initializing clocks, etc...

In the examples (to be exact in peripheral/uart example) I saw 3 different assembly files.

ses_startup_nrf_common.s
ses_startup_nrf51.s
thumb.crt0.s

Question 2: What's the difference between them? Do I have to use them or I can just use the ones the Segger Embedded Studio generated?

Parents
  • Hi,

     

    ses_startup_nrf_common.s

    This file includes certain options, like running vectors in RAM etc, and a very crucial section, loading all sections marked "nrf_sections", which is used by basically all applications in the SDK.

    ses_startup_nrf51.s

    That is the startup file for nrf51, which holds a weak implementation of all interrupt vectors.

    Weak means that you can override the definitions by declaring the interrupt handler in your application, thus it'll go there instead of the weak implementation in the asm file. 

    thumb.crt0.s

    See here: https://studio.segger.com/index.htm?https://studio.segger.com/arm_crt0.htm 

    I see different assembly files than the examples have. As long as the project above builds and runs fine can I add my own C code on top of it?

    I wouldn't recommend building on top of generic cortex asm files. Use the one's that matches the device you're running on, in this case nrf51.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    ses_startup_nrf_common.s

    This file includes certain options, like running vectors in RAM etc, and a very crucial section, loading all sections marked "nrf_sections", which is used by basically all applications in the SDK.

    ses_startup_nrf51.s

    That is the startup file for nrf51, which holds a weak implementation of all interrupt vectors.

    Weak means that you can override the definitions by declaring the interrupt handler in your application, thus it'll go there instead of the weak implementation in the asm file. 

    thumb.crt0.s

    See here: https://studio.segger.com/index.htm?https://studio.segger.com/arm_crt0.htm 

    I see different assembly files than the examples have. As long as the project above builds and runs fine can I add my own C code on top of it?

    I wouldn't recommend building on top of generic cortex asm files. Use the one's that matches the device you're running on, in this case nrf51.

     

    Kind regards,

    Håkon

Children
Related