I can't access C variables from another processor's Assembly code
Hi,
I'm working on a project with TS201S EZ-Kit which uses both processors, DSP_A and DSP_B.
I put a C code on DSP_B and an Assembly code on DSP_A and I wish the Assembly code could access a variable declared on the C code of the other processor.
I don't know why, but altough I use the .EXTERN declaration on the variable it creates two different variables with the same name, one for the C code and the other for the assembly code. Attached is my .ldf file.
Could you take a look at it and tell me if there is something wrong with it?
$OBJECTS_DSPA consists of the objects which are supposed to be on DSP_A memory or at SDRAM memory.
$OBJECTS_DSPB consists of the objects which are supposed to be on DSP_B memory or at SDRAM memory.
The variable which I want to share is at var_globais.doj.
GPS_02A.doj was made of the Assembly code; GPS_02B.doj was made of the C code; all the other object files were made of C code.
Regards,
Pedro Paulo.
Just correcting, in the above thread I get the following error:
[Error li1021] The following symbols referenced in processor 'DSP_A' could not be resolved:
'BufferCircular [_BufferCircular]' referenced from 'GPS_02A.doj'
'Buffer_Indice [_Buffer_Indice]' referenced from 'GPS_02A.doj'
Where BufferCircular and Buffer_Indice are variables declared in the C code.
I only have duplicated variables if I put GPS_02A.doj both in DSP_A and DSP_B.
But can someone help me with this?
Regards,
Pedro.
Hi Pedro,
The LDF looks ok, to be able to advise further we would need to see an example of how/where the variables are being declared in both cases.
If you do not with to share your code publicly, you can contact private support through the link below. Once you have been issued a support number, you will be able to send an email and include your example as an attachment.
If you do contact private support, please include a link to this thread.
Regards,
Craig.
Hi Craig, thanks for your answer.
Unfortunatelly, due to intelectual property reasons I can't share the application code. What I can show is specifically how and where I declare the variables. Would that help?
File GPS_02A.asm (DSP_A):
[At the begining of the file, with no code before it]
#include <defTS201.h>
#include "TSEZKitDef.h"
#include "cache_macros.h";
.EXTERN _Buffer_Indice;
.EXTERN _BufferCircular;
(...)
File GPS_02B.c (DSP_B):
[At the begining of the file, with no code before it]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sysreg.h>
#include <builtins.h>
#include "Algoritmo/var_globais.hpp"
#include "defts201.h"
asm("#include <cache_macros.h>");
asm("#include <defts201.h>");
asm(".GLOBAL _BufferCircular;");
volatile char BufferCircular[327360];
asm(".GLOBAL _Buffer_Indice;");
int Buffer_Indice = 0;
(...)
(both files were added to GPS_02 project)
I played a little with the .ldf and with some variables past week and it seems that the Linker doesn't link files that are meant to run in different processors although they are at the same project. If that is the case, even declaring the variables correctly won't work as VisualDSP++ deal as they were in different projects (although there are at the same project).
Is that right? If so, is there another way to access a single variable from both processors?
Thanks,
Pedro Paulo.
Hi Pedro,
On a closer look, you have not included the "LINK_AGAINST(dxe_name)" command in your LDF to tell the linker to resolve symbols in multiprocessor memory. e.g.:
PROCESSOR DSP_A
{
...
OUTPUT( $COMMAND_LINE_OUTPUT_DIRECTORY\DSP_A.dxe )
...
LINK_AGAINST(OUTPUT( $COMMAND_LINE_OUTPUT_DIRECTORY\DSP_B.dxe )
...
}
PROCESSOR DSP_B
{
...
OUTPUT( $COMMAND_LINE_OUTPUT_DIRECTORY\DSP_B.dxe )
...
LINK_AGAINST(OUTPUT( $COMMAND_LINE_OUTPUT_DIRECTORY\DSP_A.dxe )
...
}
Can you try adding this, and see if your application links with this? The Linker Manual contains a brief overview of the necessary commands for multiprocessor systems (and those commands are then documented in detail elsewhere in the manual) under:
Help > Contents > Manuals > Software Tool Manuals > Linker and Utilities Manual > E LDF Programming Examples for TigerSHARC Processors > Linking an ADSP-TS101 MP Shared Memory System
Regards,
Craig.
Please log in to reply.