Menu

Using the QPC in ATMEL SAM4S (ARM Cortex M4)

2015-10-04
2015-10-07
  • Sergio Alejandro Gonzalez

    First, huge thanks to quantum-leaps for the extraordinary work behind QP C.

    I'm trying to learn QP and propagating it in the laboratory i work, but I actually running into a wall regarding compiling the mos simplistic of the examples, the dining philosopher problem.

    I'm using latest: QP/C 5.5.0 (2015-09-04) and I'm using GCC for compiling, in Win64 environment.

    I decide to introduce the philo.c table.c and dpp.h into my actual working source I use. Which compiles fine, but when I add in my main():

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */
    QF_init();    /* initialize the framework and the underlying RT kernel */
    

    the linker complains with:

    LN SAM4S_TFT01-3.2.elf
    usr/applications/TFT01-3.2/main.o: In function main': M:\Workshop\Sources\gcc/../../../../../usr/main.cpp:790: undefined reference toPhilo_ctor()'

    In my config.mk I did the following:

       ${QPC_PATH}/source/qv.c                                  \
       ${QPC_PATH}/source/qf_act.c                              \
       ${QPC_PATH}/source/qf_dyn                                \
       ${QPC_PATH}/source/qf_time
    

    and also:

       ${QPC_PATH}/include                                  \
       ${QPC_PATH}/source                                   \
       ${QPC_PATH}/ports/arm-cm/qv/gnu
    

    The funny thing is that the linker complains only with the constructor. If I only place QF_init...everything compiles smoothly.

    The other question I have is 'vanilla' o 'preemptive'. As you can see from above I chose 'vanilla' by only adding qv...but not sure if I'm right.

    Regards.

     
  • Quantum Leaps

    Quantum Leaps - 2015-10-05

    Since you are using the GNU-ARM compiler, I would highly recommend that you try to adapt the existing project for this toolset.

    I realize that your goal is to build a project for your Atmel SAM4S MCU, but I would start with an attempt to bulid one of the provided examples for GNU. For example, C:\qp\qpc\examples\arm-cm\dpp_ek-tm4c123gxl\qk\gnu. The Makefile is provided in this directory, so you only need to adapt the location of your GNU-ARM toolset. (The makefile used GNU-ARM downloaded from http://gnutoolchains.com/arm-eabi ). This should really take a few minutes of your time, but if you can build DPP for EK-TM4C123GXL (Cortex-M4F), you would test many things, like your toolset, make ulility, runtime libraries, etc.)

    Only after you successfullly build one of the provided example projects, I would move on to a new chip. It's just easier to move one step at a time.

    I hope this makes sense to you.

    --MMS

     
  • Sergio Alejandro Gonzalez

    Thank you, and your answer is totally correct.

    Nevertheless, I worked around the issue by using the makefile of dpp_ek-tm4c123gxl\qk\gnu and realizing the qk kernel involved more sources than I originally included in my makefile.
    Then I also discovered that qk is in C and I have a complex C and C++ porgram and when including dpp.h, it lacks c++ extern directives. Adding them was the simple fix to "undefined references" in the constructor.

    Now is working and I can see the dpp and work with it in my SAM4s and hopefully, I will learn to implement hierarchical statecharts!.

    Besides my gratitude, I would like to tell you guys that the book, "Practical UML Statecharts
    in C/C++ " it is indeed, one of the best books I've ever read in the topic. Impressive work guys and huge regards to Miro.

     
    • Quantum Leaps

      Quantum Leaps - 2015-10-07

      For a C++ program, QP/C++ would be a better choice than QP/C . Specifically, the DPP example in the QP/C++ download is written in C++ and would not run into the issues of extern "C" linking that you experienced with QP/C.

      I'm really glad to hear that you like the PSiCC2 book :-)

      --MMS

       

Log in to post a comment.