Debugging



  • @stoffera: Working from the temperature task example (the stuff that load Wi-Fi config from an SD card), I figured I would need to initialize the SD filesystem before I can write to it.

    Looking at mbed's cookbook on the subject, I added the following to my app_controller.cpp file

    #include <SDFileSystem.h>
    
    SDFileSystem sdfs(SD_SPI_MOSI, SD_SPI_MISO, SD_SPI_CLK, SD_SPI_CS, "sd");
    

    Now, when I compile, I get an error during linking that seems to suggest I'm exceeding the max size of binaries:

    ...
    Compiling C++: app_controller.cpp
    Linking messenger.elf
    /usr/local/openmono/gcc-arm-none-eabi-5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld: messenger.elf section `.rodata' will not fit in region `rom'
    /usr/local/openmono/gcc-arm-none-eabi-5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld: section .cyloadablemeta loaded at [000000000003ffc0,000000000003ffff] overlaps section .rodata loaded at [000000000003acf8,0000000000041dd7]
    /usr/local/openmono/gcc-arm-none-eabi-5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld: region `rom' overflowed by 0 bytes
    collect2: error: ld returned 1 exit status
    make: *** [messenger.elf] Error 1
    

    Size-wise, my program is actually a little smalle than the temperature example task, so I'm not sure what I'm doing wrong.

    Any suggestions?



  • @mhvelplund That seems strange. Just to confirm the correct approach:

    Your sdfs object must be a member of your AppController class. Such that you define it as a member in app_controller.h and initialize it separately in the initializer list in the implementation file: app_controller.cpp.

    app_controller.h:

    #include <SDFileSystem.h>
    class AppController : public mono::Application {
    public:
        SDFileSystem sdfs;
    
        AppController();
    }
    

    app_controller.cpp:

    AppController::AppController() :
        sdfs(SD_SPI_MOSI, SD_SPI_MISO, SD_SPI_CLK, SD_SPI_CS, "sd")
    {
         // do not use the SD card from the constructor, do it in monoWakeFromReset()
    }
    

    Let me know if this is your setup, and it still does not work.



  • @stoffera I've tried both with the SDFileSystem as a global and as a member var in the app controller, and I only access it in or after the wake from sleep. No dice.
    It links fine in a hello world app where I do nothing but initialise the SD FS and write a log line, and obviously it works in the temperature app.

    Based on the error message ("messenger.elf section '.rodata' will not fit in region 'rom'"), it seems like I'm accidentally putting more than 32 kb data in the constants sectition of RAM but I can't see how. Can I use objdump to see what is stealing all the space?



  • @mhvelplund said in Debugging:

    Can I use objdump to see what is stealing all the space?

    Yes, hopefully the linker has created an .elf file. You need to use the arm-none-eabi-objdump tool, that exists in /usr/local/openmono/gcc-arm-none-eabi-5_2-2015q4/bin on the Mac.

    The command should be something like this:

    $ arm-none-eabi-objdump -t -j .rodata messenger.elf 
    

    This will list the symbol table for the .rodata section. You can also use -s to see source code and assembly. But the rodata section does not contain code - but data.



  • @stoffera ther's no ELF file, but I guess that's because the linker fails. None of the .o files in the build dir have an .rodata section or an .cyloadablemeta section for that matter.
    So the extra data seems to be something that gets linked in when I refer to the SDFileSystem object from the mbed framework.



  • hmm, that is a though one. Could you share the source files with me - either using git or a Gist? You can use the Chat function, if you don't like sharing the source code with the masses.



  • @stoffera i put the code up on Git in a public repo. It's obviously a work in progress, and the reason I got bogged down in logging in the first place is because the rest didn't work as intended ;) The aim of the task is to provide a Phone-like keypad for typing messages.

    You can turn the SDFS code on and off by (un)commenting the #CDEFS=-DSDFS line in the Makefile.

    I'm running the tool chain on OSX.



  • @mhvelplund, found the issue, and it is:

    ONLY_CPP_FLAGS += -std=c++11
    

    Sorry, but the runtime for C++ 11 is just too large for embedded development with only 64kb of ram.

    So you must live without the syntactic sugar and lambda functions that comes with C++ 11.

    • Use 0 instead of nullptr
    • You can't set member variable directly from *.h files
    • std::vector cannot be initialized with curly braces
    • etc.

    BTW: Your idea about a phone-like keypad is great. If generic enough I would like it to become a part of the mono framework!



  • @stoffera I can live without it. I haven't written anything in C++ since the late 90's, so to be honest, I only added C++ 11 because it seemed to be the dialect preferred in example code on the net. With that in mind, I doubt anything I produce i C++ will be of production quality ;)

    Thanks a bunch for the help!


Log in to reply