Pumpkin, Inc.

Pumpkin User Forums

Salvo Pro - Compiled Library Missing Functions

For issues specific to the PIC24 MCU and dsPIC DSC line of microcontrollers from Microchip, including compiler (e.g. MCC 30) and IDE (e.g. MPLAB) issues.

Salvo Pro - Compiled Library Missing Functions

Postby jc_hsfl » Sat May 24, 2014 5:58 pm

Hi, I'm having a problem using the compiled libraries with Salvo Pro for MCC30. I use the standard CSK libraries (dspic 4.2.2), and my program compiles without any problems. But then when I use my own compiled libraries, they're missing the following functions:

OSDelay
OSCtxSw
OSGetTicks

I'm trying to compile it using XC16, so I had to modify the makefile at the following location:

C:\Pumpkin\Salvo\Src\Make\MCC30\Makefile
Code: Select all
MCC30-V3-HOME      ="C:/Program Files (x86)/Microchip/xc16/v1.21"
PUMPKIN            ="c:/Pumpkin"
MCC30-CC-V3        =$(MCC30-V3-HOME)/bin/xc16-gcc
MCC30-AS-V3        =$(MCC30-V3-HOME)/bin/xc16-as
MCC30-LIB-V3       =$(MCC30-V3-HOME)/bin/xc16-ar

I compile with Cygwin using "make -f Makefile dspic". The same problem also occurs when using a CLC option.

It seems like the library consistently is missing the functions contained in salvoportmcc30-lm.s/salvoportmcc30-sm.s.

Here's my salvoclc1.h, using "make -f Makefile dspic CLC=1":
Code: Select all
#undef OSCOMPILER             
#undef OSEVENTS               
#undef OSEVENT_FLAGS         
#undef OSEVENTS               
#undef OSMESSAGE_QUEUES       
#undef OSTASKS               
#undef OSBIG_SEMAPHORES       
#undef OSBYTES_OF_COUNTS       
#undef OSBYTES_OF_DELAYS     
#undef OSBYTES_OF_EVENT_FLAGS 
#undef OSBYTES_OF_TICKS       
#undef OSCALL_OSCREATEEVENT   
#undef OSCLEAR_GLOBALS         
#undef OSCLEAR_UNUSED_POINTERS
#undef OSCOLLECT_LOST_TICKS   

#define OSCOMPILER              OSMPLAB_C30
#define OSEVENTS                20
#define OSEVENT_FLAGS           20
#define OSEVENTS                20
#define OSMESSAGE_QUEUES        20
#define OSTASKS                 20
#define OSBIG_SEMAPHORES        TRUE    // 16-bit Sempahores
#define OSBYTES_OF_COUNTS       4       // 32 bit Counters
#define OSBYTES_OF_DELAYS       4       // 32 bit Delays
#define OSBYTES_OF_EVENT_FLAGS  4       // 32 bit Event Flags
#define OSBYTES_OF_TICKS        4       // 32 bit OS Ticks
#define OSCALL_OSCREATEEVENT    OSFROM_BACKGROUND   // Events only in mainline code
#define OSCLEAR_GLOBALS         TRUE    // Clear all globals at init
#define OSCLEAR_UNUSED_POINTERS TRUE    // Null out unused TCBP/ECBP
#define OSCOLLECT_LOST_TICKS    TRUE    // Collect lost ticks

Am I missing a step or some sort of #define that only the C30 compiler has?
jc_hsfl
 
Posts: 16
Joined: Fri May 23, 2014 2:25 am

Re: Salvo Pro - Compiled Library Missing Functions

Postby aek » Thu May 29, 2014 8:43 am

I posted a question on the forums just in case it was a FAQ that you get (so feel free to respond on the forums if it might help others). I still haven't figured out why I'm certain MCC30 assembly functions (e.g. context switch, os delay) aren't recognized when I compile my application code (library and app compiled with XC16 v1.21). When I switch to your stock libraries, the application compiles just fine.

When I do a 'string' dump of my custom library archives, I see the compiled assembly object was included for the appropriate large/small memory model. Here's what it returns:

--begin string dump snippit from custom lib--
c:/pumpkin/salvo/src/MCC30/salvoportmcc30-lm.s
__C30COFF
SAVE_W8_W13
SIZEOF_RTN_ADDR
$AUTOLINE$
_OSDispatch
_OSReturn
_OSDethunkTFP
_OSframeP
--end string dump--

In your library, the closest pattern of strings I could find was this:

--begin string dump snippit from dspic 4.2.2 lib--
__C30ELF
SAVE_W8_W13
SIZEOF_RTN_ADDR
_OSDispatch
_OSframeP
_OScTcbP
_OSCtxSw
_OSReturn
_OSDethunkTFP
--end string dump--

Quite different from what I've got. Have you seen this problem before?

As a note, the only reason I'm compiling from source is to see if it helps with strange problems I'm having with my application code resetting. I've followed the 3 rules very carefully, but still have strange problems (thankfully my code either immediately works or it doesn't, and when it works, it works great!).

For reference, I've included my modified Makefile for Salvo the MCC30 port (Salvo pro dspic 4.2.2), custom library config file, and library archive. I'm going for a large code/data model library. I'm using Cygwin to compile this.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo Pro - Compiled Library Missing Functions

Postby aek » Thu May 29, 2014 8:55 am

That is odd.

I would try a few things:

1) Observe the make process in cygwin to ensure that the assembly of the .s file(s) is successful.

2) I would reduce the under of #defines and corresponding #undefs in the salvoclc1.h file just to keep the test case simple.

3) Sometimes, assemblers and compilers are unhappy assembling/compiling more than a single function ("module") per file. But I am pretty perplexed as to why OSCtxSw() would not get picked up when others are.

4) One thing you can do is leave salvoportmcc30.s out of the library, and add it to the project to assemble it as part of your project. This is sort of a "split" build, and is legal, assuming you can ensure that whatever settings were used to build the library also apply to the project project-wide ... Does the app then build successfully / are all requisite functions found? You can even add salvoportmcc30.s to the project with it already in the library -- the linker should prefer the "outside" one over the "library" one, if i) that's the default linker behavior, or ii) the functions are declared as weak in the .s file and the assembler supports the weak keyword (it is in the compiler, I dunno re the assembler, assemblers are usually more brute-force).

5) There is a small chance that the file has hidden characters that are causing a problem -- you could copy (in an editor) the contents of salvoportmcc30.s, paste it into a new file, and try adding that into the library.

As for the deeper problem, ensure that you have not enabled an incompatible optimization (see the RM-MCC30.PDF reference manual). And of course, make sure your salvocfg.h has OSTASKS etc. set high enough for your run-time usage.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo Pro - Compiled Library Missing Functions

Postby jc_hsfl » Fri May 30, 2014 1:25 am

Ok, looks like the missing functions were due to my custom library configuration, and perhaps some strange issues using Cygwin and the modifications I did to use XC16.

Note that instead of going through the Makefiles to generate library archives, I just went for a straight source build of my application code. Using MPLAB IDE v2.10 w/ C30 v3.31, I added in all the source files and the appropriate large memory model assembly port file. As mentioned in the user manual, I set all large models for code/data, and also did scalars. Then defined preprocessor macro OSMCC30_LARGE_CM.

Here's what my final salvocfg.h looked like by the time I was able to successfully compile the application:
Code: Select all
// Library Specification
#define OSUSE_LIBRARY        FALSE
//#define OSLIBRARY_TYPE       OSL
//#define OSLIBRARY_CONFIG     OSA
//#define OSCUSTOM_LIBRARY_CONFIG 0

// Compile Time Options
//#define OSCOMPILER              OSMPLAB_C30
#define OSEVENTS                4
#define OSEVENT_FLAGS           4
#define OSMESSAGE_QUEUES        4
#define OSTASKS                 20

#define OSBYTES_OF_COUNTS       2       // 16 bit counters
#define OSBYTES_OF_DELAYS       2       // 16 bit delays
#define OSBYTES_OF_EVENT_FLAGS  2    // 16 bit event flags
#define OSBYTES_OF_TICKS        4       // 32 bit os ticks

#define OSCLEAR_GLOBALS             TRUE    // Clear all gobals at init
#define OSCLEAR_UNUSED_POINTERS     TRUE    // Null out unused tcb/ecb
#define OSENABLE_BINARY_SEMAPHORES  TRUE
#define OSENABLE_DELAYS             TRUE
#define OSENABLE_TIMEOUTS           TRUE


This resolves my resetting issue where my task table was corrupted in this thread:
viewtopic.php?f=21&t=2530

For completeness, I switched the IDE compiler to XC16 v1.21. The code successfully compiled and it runs the same application code well too.

Everything now works like a charm (hopefully it stays that way!).

Thanks again!
jc_hsfl
 
Posts: 16
Joined: Fri May 23, 2014 2:25 am

Re: Salvo Pro - Compiled Library Missing Functions

Postby Andrew » Fri May 30, 2014 2:44 pm

You fixed the error of overlapping tcbs on tasks 1-4?
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: Salvo Pro - Compiled Library Missing Functions

Postby jc_hsfl » Fri May 30, 2014 6:11 pm

Yes, my original application code was actually correct. But the code I wrote to debug (and posted) had the overlapping TCBP's.

After compiling from source, all the original application code worked as originally written.
jc_hsfl
 
Posts: 16
Joined: Fri May 23, 2014 2:25 am

Re: Salvo Pro - Compiled Library Missing Functions

Postby jc_hsfl » Fri May 30, 2014 7:35 pm

Update:

After more work spent on trying to build custom static libraries using MPLAB X v2.10 w/ XC16 v1.21, it looks like the problem is that XC16 defaults to a ELF/DWARF format output. When using this default output type, the library inclusion in MPLAB does not pick up the missing functions.

Salvo Pro Static Library Project: MPLAB X Project Properties:
Image

When setting the static library project's output option to output to COFF, the static library now works successfully when included into application projects.
jc_hsfl
 
Posts: 16
Joined: Fri May 23, 2014 2:25 am

Re: Salvo Pro - Compiled Library Missing Functions

Postby jc_hsfl » Fri May 30, 2014 7:57 pm

Ok, scratch that. After using the static library, the task table is corrupted again. Also, this time I'm getting resets with the IOPUWR flag set, instead of TRAPR.

Custom static lib task table:
Code: Select all
Salvo 4.2.2  Ticks: 151
EligQ:    ,   ,   ,   ,   ,
DelayQ:    ,t1  Total delay: 301 ticks
task stat prio    addr   t->  e->  d-> delay
  1  wait   3  00000256    .  e 1    .   109
  4   to    8  00000000    .    .
  7  stop   4  00000000    .    .

evnt type t->    value
  1  BSem t 1        0
  2  BSem   .        0
  3  BSem   .        1
  4  BSem   .        1
  5  dstr
  6  dstr
  7  dstr
  8  dstr


I'll need to drop the static library method for now and move on. But would be interested in figuring this out for the future for a faster compilation of app code.
jc_hsfl
 
Posts: 16
Joined: Fri May 23, 2014 2:25 am


Return to PIC24 & dsPIC

Who is online

Users browsing this forum: No registered users and 1 guest

cron