Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic No symbols in object file (Read 1926 times)
John Fitter
Junior Member
**
Offline


Posts: 26
Location: Australia
Joined: Mar 2nd, 2013
No symbols in object file
Aug 17th, 2018 at 10:34am
Print Post  
I have a problem that has defied me for a few days. Maybe someone else has seen this and has a solution.

I have an app that compiles fine. It is firmware for an instrument. I have ported it to FreeRTOS due to feature bloat and the RTOS allows more control over the symphony of tasks I now have.

The hardware is a generic STM32F103C with the STMDuino bootloader. Up to now this setup has worked very well with Visual Micro and I have numerous apps developed and working fine.

The FreeRTOS I am using is version 9 and is bundled with STMDuino. It was building and working well until I decided to change some tasks into timers. To do this it is necessary to make a few changes to definitions in "FreeRTOSConfig.h", to add "#include <utility/timers.h>", and to include "timers.c" in the build. This is all pure vanilla stuff and should take 5 minutes - here I am 3 days later and the build is still broken.

The app builds without errors and produces a binary. Sounds good - but - the linker throws a bunch of warnings about "undefined reference to xTimerCreate".

As I found out this is not a warning to be ignored. Running nm on Timers.o I find there are no symbols in it at all.

I am not inexperienced but after trying to track this down for days I cannot figure out what is going wrong. Clearly Timers.o is being built, the linker is linking it and producing a binary, but there are no functions in it. Of course the app is quite unlikely to work properly.

I suspect there is some "behind the scenes magic" going on or going wrong. Something is trying to make my life easier by doing stuff for me and not doing it well.

Any suggestions would be much appreciated. Thanks.
 
***** 3hrs later, after some more stuffing around, I have found the following;

I can get timers.o to build with symbols, but the app build still fails, this time with multiple definitions.

Here is how it works.

App specific definitions are in a local file "FreeRTOSConfig.h"
There is a define in this file which enables the timer functions. If it is set then there is stuff in timers.o

This file must be included before "MapleFreeRTOS900.h", which lives in the FreeRTOS folders. In this is an include for "FreeRTOS.h" which lives in the /utility folder, part of the FreeRTOS folders.

In this same folder is a template version of "FreeRTOSConfig.h". This is not the one I want to use. "FreeRTOS.h" includes this template version, but of course its contents should be ignored because it has an include protection and the local version has already been included.

What is actually happening is that the template version is being included.
Intellisense gets it right. If I view the local "FreeRTOSConfig.h" everything is enabled. If I view the template version it is all disabled. But the build process ignores all of this. It includes the template version and as a result none of the timers functions are built.

I proved this by setting the define for timers in the template version. "timers.o" was built with all its symbols and functions in it. Unfortunately there were lots of multiple definitions so the build failed.

So here is the question. xxx.ino has this at the top;

#include "FreeRTOSConfig.h"
#include <MapleFreeRTOS900.h>

The order of these includes is ignored by the build. The FreeRTOSConfig.h included by MapleFreeRTOS900.h is the one included and the local version is ignored.

This behaviour is not like any I have have experienced in many years of C programming. There is certainly some background magic happening. What?

Btw. Using VS2015, Arduino 1.6/1.8, Generic STM32F103C

« Last Edit: Aug 17th, 2018 at 1:48pm by John Fitter »  
Back to top
 
IP Logged
 
John Fitter
Junior Member
**
Offline


Posts: 26
Location: Australia
Joined: Mar 2nd, 2013
Re: No symbols in object file
Reply #1 - Aug 17th, 2018 at 3:03pm
Print Post  
SOLVED

Maybe this will be of help to other victims trying to use FreeRTOS with VS/VM.

The documentation for FreeRTOS states that to use timers you must include timers.c in your build, in addition to making some changes to FreeRTOSConfig.h.

So, in VM/VS I duly included timers.c as instructed. Here is what happened.

timers.c includes, among other things, FreeRTOS.h
FreeRTOS.h includes FreeRTOSConfig.h

FreeRTOSConfig.h is the app specific configuration and is supposed to be included before all other includes. If timers.c gets built first then the local template version of FreeRTOSConfig.h gets used, which is bad, or the build fails if the file is not there. It does not use the local header. It does get built first and I don't know why.

If the template version is replaced with the local version then the build succeeds but all of the timers.h symbols then get multiply defined, so the linker fails anyway.

The solution is to remove timers.c from the build.
It would appear that VM (or Arduino) will include the source file if the header is included. This is the dark magic that had me confused.
Grrrr I would rather have a pedantic IDE, then at least I would know what it is doing. I have been spending too much time in Eclipse, which is really pedantic.

So, all that was needed was to put three includes in the main source file in this order;
#include "FreeRTOSConfig.h"
#include <MapleFreeRTOS900.h>
#include <utility/timers.h> 

Also, for those contemplating using FreeRTOS on an ARM and GCC, take note. In the function portYIELD() in portmacro.h you need to change "__asm volatile" to "__asm__ __voltatile__" else intellisense gets itself lost in space....

Now, back to some real work.
 
« Last Edit: Aug 18th, 2018 at 1:26am by John Fitter »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: No symbols in object file
Reply #2 - Aug 17th, 2018 at 4:29pm
Print Post  
Useful thanks.

I am a little confused by what you are saying but think this relates to the order of files in the link stage? Are you saying that local project code should be earlier in the linker list than libraries and core?

Either: 

Link project sources then lib sources then core

or

Link Core, lib source and then project sources

or something else?

  
Back to top
IP Logged
 
John Fitter
Junior Member
**
Offline


Posts: 26
Location: Australia
Joined: Mar 2nd, 2013
Re: No symbols in object file
Reply #3 - Aug 18th, 2018 at 1:17am
Print Post  
I am no expert but it appears to me it is the build order that is the issue, not the linking. timers.o was built using the library copy of FreeRTOSConfig.h rather than the local version. The library copy does not have the defines to allow timers so timers functions and symbols were not included in the object file.

All I did was to add timers.c to the build in Solution Explorer. It seems that this file was compiled first, leading to the failure.

If I remove it from the list of source files and let the Arduino build process take over then everything works. Seems all I have to do is include the timers.h in the .ino file and the Arduino build finds timers.c and includes it in the build.

Looks like I have some misunderstanding of how the build process relates to what is displayed in Solution Explorer.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint