nRF Connect with VSCode: how to generate assembly files

I'm using the latest nRF Connect (2.4.2) in VSCode (on Windows) to develop an application on an nRF52840.  I would like to look at some of the assembly code generated by the compiler.  How do I do that in this environment?  With gcc I would use the -S switch; is it the same here?  Where do I add this switch--Build Configuration (how?), CMakeLists.txt (what would the magic incantation be?), or somewhere else?

I can't easily hook up my j-link pod and just look at it in the debugger, since it requires a fair amount of mechanical disassembly.

Thanks in advance for any info.

--mkj

Parents
  • Hi mkj,

     

    As you mention, normally you output .asm via the "-S" switch in GCC.

    Adding custom compiler switches can be done using "CONFIG_COMPILER_OPT", but the adding the -S switch does not combine well with the build system in zephyr.

     

    What you can do is, after the fact, use objdump to disassemble your .elf file:

    arm-zephyr-eabi-objdump -S --disassemble my-build-folder/zephyr/zephyr.elf > disassembly.lst

     

    Kind regards,

    Håkon

  • Hi,

    isn't the a way to get assembly files to be kept in the build folder? I'm so far using arm-none-eabi-objdump to get assembly from zephyr.elf but would prefer to get it automatically at every build. I have tried different directives in CMakeLists.txt without any success.  

    BR

    Mattias

  • Hi Mattias,

     

    I spent some extra time on this, and found that this seems to work:

    # SPDX-License-Identifier: Apache-2.0
    
    set(MY_OBJDUMP /opt/zephyr-sdk/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump)
    
    set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
      COMMAND ${MY_OBJDUMP} -S --disassemble ${CMAKE_BINARY_DIR}/zephyr/zephyr.elf > ${CMAKE_BINARY_DIR}/zephyr/zephyr.asm
    )
    
    cmake_minimum_required(VERSION 3.20.0)
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    ...rest of file

     

    Note that the placement is before find_package(...) in the projects CMakeLists.txt file.

     

    Could you try this and see if it works in your project as well?

     

    Kind regards,

    Håkon

  • Hi Mattias and mkj,

     

    There is a configuration, CONFIG_OUTPUT_DISASSEMBLY, that can be set and it'll create a .lst output.

     

    I'll leave the former CMakeLists.txt hack, in case you actually need to run a post-process command, but I would recommend just setting the above kconfig if you want to see the assembly lst file.

     

    My deepest apologies for missing this configuration..

     

    Kind regards,

    Håkon

Reply
  • Hi Mattias and mkj,

     

    There is a configuration, CONFIG_OUTPUT_DISASSEMBLY, that can be set and it'll create a .lst output.

     

    I'll leave the former CMakeLists.txt hack, in case you actually need to run a post-process command, but I would recommend just setting the above kconfig if you want to see the assembly lst file.

     

    My deepest apologies for missing this configuration..

     

    Kind regards,

    Håkon

Children
Related