Menu

Problem with Linking QP in Keil

2015-09-19
2015-09-19
  • Sylvester Idoge

    Sylvester Idoge - 2015-09-19

    Hello,

    I am new to event programming with QP. I have read Practical Statecharts in C/C++: Quantum Programming for
    Embedded Systems (PSiCC). I now understand event programming to a good extent.My problem has to do
    with Keil linking QP in STM32F4 Discovery (STM32F407VG MCU).

    In my setup, I created a folder name qp_test where I store all keil files.I copy port, include and source folder from C:\qp\qpc to qp_test folder. I added port\qk\arm, source and include folder into keil compiler path (C/C++ tab).
    I also include path to ST peripherals library (src and inc). I created QP, QP_port and QS in keil project items and add all necessary files from the files found in port, include and source folder that was copy to qp_test folder.

    I create a simple blinky project using QM by following the illustration on QM manual and also, by studying the examples found in C:\qp\qpc\examples. When I build the project, I got the errors shown below.

    I build the ST nucleo baord examples(C:\qp\qpc\examples\arm-cm\dpp_nucleo-l152re\qk\arm) successfully. I mimicked the compiler include path in the working example but no success in linking. I will be very grateful if someone point to the right direction.

    --------------------- KEIL V5.14 ERRORS--------------------------------------
    Build target 'QP_Blinky'
    linking...
    .
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol QS_onGetTime (referred from qep_hsm.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol Q_onAssert (referred from qep_hsm.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol QF_onCleanup (referred from qk.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol QF_onStartup (referred from qk.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol QK_onIdle (referred from qk.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol QS_onFlush (referred from qk.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol Q_BUILD_DATE (referred from qs.o).
    \Objects\qp-blinky.axf: Error: L6218E: Undefined symbol Q_BUILD_TIME (referred from qs.o).

    Not enough information to list image symbols.
    Finished: 1 information, 0 warning and 8 error messages.
    ".
    \Objects\qp-blinky.axf" - 8 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed: 00:00:00

    Sylvester
    Nigeria

     
  • Quantum Leaps

    Quantum Leaps - 2015-09-19

    You have a couple of problems in your project.

    First, you apparently have copied all QP source files into your project. But some of the source files are only intended for specific build configuration. For example, source files starting with qs_ are needed only in the Spy build configuration. Similarly, you need to choose the kernel for your project. If you choose QK, you should not include qv.c. Conversely, if you choose the QV kernel, you should not include any source files starting with qk. Finally, in any build configuration you need to define the Q_onAssert() assertion handler.

    But rather than re-inventing the wheel, I always highly recommend to start with the existing, working example project and modify it, rather than starting from scratch. That's kind of the whole purpose of having the hundreds of various build configurations provided in the examples directory.

    For instance, you could open the project qpc\examples\arm-cm\dpp_nucleo-l152re\qk\arm\dpp-qk.uvprojx in your Keil IDE. It does not matter that it is not exactly the board you have. It will cost you just a minute to just open it and try to build. If it builds cleanly, you will convince yoursef that your QP installation is complete and that your Keil toolset is compatible with the provided projects. That's alreay a lot of good news.

    Next, just look how the project is structured. For example, you will see that it has three build configurations (the drop-down box at the top of your Keil IDE): dpp-dbg, dpp-rel, and dpp-spy. In the dpp-dbg configuration, please expand the QS folder in the Project view. You will see that all .c files in this folder are excluded from the build. Conversely, if you select the dpp-spy configuration, you will see that the same files are now included in the build.

    You should also take a look at the Project Options dialog box and note the settings for include files and pre-defined symbols.

    In the end, I would recommend that you copy the dpp-qk.uvprojx and dpp-qk.uvoptx files, rename it to your project, and auto-replace the name dpp-qk to whatever you like in the files. This would be a much better starting point.

    It's really too bad that the Keil IDE does not provide "Save-as" option for projects...

    I hope that my comments make sense to you.

    --MMS

     
    • Chinmay Nagarkar

      Just a thought... I was using eclipse to do this, and since I'm using qk, I had to manually remove each file (Resource -> Exclude from Project). From a makefile perspective, I guess you can exclude files easily. From an idea friendliness perspectiv,e it may be easy to just put the files that are specific to a build configuration into one location (e.g. all qxk... files go into the qxk directory). That way, if I need qxk I just include that directory... I think an eclipse plugin to handle all this stuff would be awesome... :)

       
      • Quantum Leaps

        Quantum Leaps - 2017-05-25

        Ecliplse CDT (C Development Tooling) has this very unusual behavior that it automatically takes all files in a given "linked folder". So, if the folder has some files that you don't wish to build, you have to explicitly exclude them from the build. The problem is that if some files are added later on, they will be automatically included next time the Eclipse project is built. As I said, this is highly unusual and annoying, but this is how Eclipse CDT works.

        So, I agree with Chinmay that a better QP source code structure would be to have the source code divided into sub-directories with functionality that don't necessarily goes together. For example, the QK kernel functionality should be separate from the QV kernel, which should be separate from the QXK. This is because if you use one kernel, you specifically don't want to use any other kenels.

        The main problem with re-organizing the QP source code is backwards compatibility with existing QP applications. Re-organization of QP source code would break any existing project files.

        So, as a compromise the next release of QP/C/C++ will contain a second source directory called src, which will contian the following sub-directories:

        qpc\
          +-source\  - exitsting source directory with "flat" structure
          |            (for backwards-compatilitiy)
          +-src\     - new source directory grouped by functionality
             +-qf\    - core framework (QEP + QF)
             +-qk\    - QK kernel
             +-qv\    - QV kernel (only one file qv.c)
             +-qxk\   - QXK kernel
             +-qs\    - QS software tracing
             +-qf_pkg.h
             +-qs_pkg.h
             +-qxk_pkg.h
        

        This new qpc\src will be relesed in the next QP/C/C++ 5.9.1 and for now it will co-exist with the source directory. The source directory duplication will be phased out in the future.

        --MMS

         

        Last edit: Quantum Leaps 2017-05-25
  • Sylvester Idoge

    Sylvester Idoge - 2015-09-19

    Hello,

    Thanks for your quick response. I got it working by modifying pp-qk.uvprojx and dpp-qk.uvoptx files as adviced.

    Thanks alot
    Sylvester

     
  • Sylvester Idoge

    Sylvester Idoge - 2015-09-19

    Hello,

    I am able to build qp application from scratch by reverting to keil 4.7V. It work without much hustle.

    Thanks

     

Log in to post a comment.