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

Assembling gcc_startup_nrf52810.S to Object file

I'm trying to develop from the Linux command line, using arm gcc tools, for the nRF52 Development kit, and can't get the startup assembly file assembled to an object file:

nRF5_SDK_15.3.0_59ac345/modules/nrfx/mdk/gcc_startup_nrf52810.S

I'd thought that using a simple command like:

/usr/local/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-as    nRF5_SDK_15.3.0_59ac345/modules/nrfx/mdk/gcc_startup_nrf52810.S

would have produced the default .o output file. Instead I'm getting an error:

nRF5_SDK_15.3.0_59ac345/modules/nrfx/mdk/gcc_startup_nrf52810.S:35: Error: bad or irreducible absolute expression

The line in question:

.align __STARTUP_CONFIG_STACK_ALIGNEMENT

That alignment value is #defined so perhaps this has to be run through the C preprocessor before being assembled.

Parents
  • Yes that's what a .S file means as opposed to a .s file. It needs to go through the preprocessor first. Usually you don't use 'as' directly, you use the normal 'gcc' command, with all the correct defines which need to be defined and it will recognise the file type and call as with all the correct arguments, which include all the platform specific and other defines which are expected. 

    But anyway why are you trying to roll your own here? All (well many) of the examples in the SDK have a version for pca10040e which is set up exactly for compiling for the nRF52810, including all the correct memory flags and other flags. I suggest starting with one of those makefiles in the armgcc directory of any project which takes your fancy and working from there. If you want to use that to get the full command line for assembling the startup file and compiling the other, you can look at the actual compilation line run, if you don't want to use a Makefile. 

Reply
  • Yes that's what a .S file means as opposed to a .s file. It needs to go through the preprocessor first. Usually you don't use 'as' directly, you use the normal 'gcc' command, with all the correct defines which need to be defined and it will recognise the file type and call as with all the correct arguments, which include all the platform specific and other defines which are expected. 

    But anyway why are you trying to roll your own here? All (well many) of the examples in the SDK have a version for pca10040e which is set up exactly for compiling for the nRF52810, including all the correct memory flags and other flags. I suggest starting with one of those makefiles in the armgcc directory of any project which takes your fancy and working from there. If you want to use that to get the full command line for assembling the startup file and compiling the other, you can look at the actual compilation line run, if you don't want to use a Makefile. 

Children
  • Thanks yes that creates an Object file.

    As for doing things the easy way I totally agree. However this is a new target device to me and as I never use C++ I'm having a go using the gcc C++ compiler. I'm now building the simplest main() function you'll ever see but it's not working. Was simply trying to illuminate an LED on the nRF52 Development Kit and failed at that. I am however building, or appear to be building, a C++ Project ;)

    Back to the datasheet to see why this don't work. I assume it's because I've not enabled that peripheral, but struggling to see in the data sheet how you do that. Section 6.1.1 specifically states that you have to disable the current Peripheral before enabling the new peripheral, you're going to use. I don't see an enable for the GPIO Peripheral.

    int main(int argc, char **argv)
    {
        uint32_t *p0_outset = (uint32_t *)0x50000508;
        uint32_t *p0_dirset = (uint32_t *)0x50000518;

        *p0_dirset |= 0x01 << 17;
        *p0_dirset |= 0x01 << 18;

        *p0_outset |= 0x01 << 17;
        while (1) {
        }
    }

    P0.17 & 18 are both LEDs. Negative logic, so I assume just setting the pin to be an Output, given the reset state of the register. Just a case of finding the enable for the peripheral.

    Thanks a million for your help with the .S file.

Related