How do I place the libaplc library in external memory ?

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Wed Jun 05, 2013 4:23 pm

Thanks indeed - my understanding of how the names got mapped was wrong and unnecessarily complicated.
I am now just using the name "BUFFER_SPACE" in all the code.

I don't quite understand what you mean by
but no input section to map to it

aplc_helloworld is now working again :
Code: Select all
  0: Message from eCore 0x8ca ( 3, 2): "Hello World from Aplc"
  1: Message from eCore 0x84b ( 1, 3): "Hello World from Aplc"
  2: Message from eCore 0x84b ( 1, 3): "Hello World from Aplc"

I am now trying to get sense from a more complicated program with multiple sprintf calls to replace the existing fprintf calls.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

Re: How do I place the libaplc library in external memory ?

Postby ysapir » Wed Jun 05, 2013 4:37 pm

The section, as defined in the LDF is merely a mapping of input sections, defined in the input (source) files, to output sections, appearing in the output (executable) files.

The part in curly braces are a list of input section names from the input files that map to a a specific output section. You can have multiple input sections mapped to a single output section. Examples:

Code: Select all
outsection1 : { a.o(asection) b.o(bsection) }
outsection2 : { a.o(insection) b.o(insection) }
outsection3 : { *.o(insection) }


Anyway, always check your object location after the build using "e-objdump -D" or "e-nm", to see if they are located in the expected place.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Wed Jun 05, 2013 6:14 pm

Thanks, yes.
The section, as defined in the LDF is merely a mapping of input sections, defined in the input (source) files, to output sections, appearing in the output (executable) files.

So the BUFFER_SPACE section should contain no program, just the buffer, Yes ?
Is there anything else I should do other than point to it for the program to write into it ?

OK, I think the buffer overwriting problem is sorted, I can have repeated sprintf statements and (with some being newlines) get :
Code: Select all
  0: Message from eCore 0x8ca ( 3, 2): "some text
testAplctext
some text"
  1: Message from eCore 0x84b ( 1, 3): "some text
testAplctext
some text"

Where the problem now comes is when I try and include the aplc program output, in the same way I did with the aplc_helloworld example. Basically I get nothing.
Now to take a step back, I think there may be something wrong with the aplc version I have built on the Arm, for the Parallella.
The Windows version built on a PC works fine.
The Parallella version built on a PC runs fine in e-run (and runs fine if copied across on to the Arm board and run with e-run.
The Arm version built on the Arm runs fine.
But for the Parallella version built on the Arm, everything compiles fine but e-run outputs nothing. Which is now what I am seeing on the hardware.
Unless you know of any reason for this behaviour, I will re-build the Parallella version on the Arm, and try and get output from e-run.
The output I expect is via fprintf in the original aplc program, and from sprintf in the version for the hardware.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Wed Jun 05, 2013 9:06 pm

I will re-build the Parallella version on the Arm, and try and get output from e-run.

Hmm, well firstly the problem is not in the complicated bit, the aplc compiling to c - the c code is identical, and anyway can be compiled on the host fine.
I have copied the version on my lap-top, and re-built it. No problem, e-run gives output.
I have tar'ed that, and re-built it on the Arm. e-run does not give output.
I will keep chasing this.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Thu Jun 06, 2013 12:19 am

try and get output from e-run.

OK, I think that the problem with no output from e-run is due to a lower permissivity for sprintf and fprintf in newlib
The following work on all systems tried:
Code: Select all
sprintf(pointer,"some text");
 pointer = pointer + 9 ;
 sprintf(pointer,"Q");

But the following works on the PC, e-run on the PC, and the Arm, but not when using e-run on the Arm :
Code: Select all
sprintf(pointer++,"%c",trs1.value.cp[i3]);

I am using this as something I can create from a simple modification of the pre-existing :
Code: Select all
fprintf(aplcout,"%c",trs1.value.cp[i3]);

which has a similar range of works / does not work.

I think I have a newer version of the sdk on my laptop than on the Arm .
Is there any chance on upgrading to a newer version ? Or are there other problems ?
I also notice there is a general update recommended, but needs to be done from a gui screen, not over ssh.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

Re: How do I place the libaplc library in external memory ?

Postby 9600 » Thu Jun 06, 2013 8:35 am

Dr.BeauWebber wrote:I think I have a newer version of the sdk on my laptop than on the Arm . Is there any chance on upgrading to a newer version ? Or are there other problems ? I also notice there is a general update recommended, but needs to be done from a gui screen, not over ssh.


You should be fine to upgrade the SDK but just run it by Ben at Sundance first.

I don't think you'll need to bother with an O/S upgrade and this is probably better done by someone with physical access to the board.

Cheers,

Andrew
Andrew Back (a.k.a. 9600 / carrierdetect)
User avatar
9600
 
Posts: 997
Joined: Mon Dec 17, 2012 3:25 am

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Thu Jun 06, 2013 8:43 am

Thanks indeed,
Yes I have sent Ben an email and will await his reply, but thanks will then update the sdk.
a long haul but think we are getting there, this 'no output' problem was a long diversion.
cheers,
Beau
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

Re: How do I place the libaplc library in external memory ?

Postby ysapir » Thu Jun 06, 2013 9:23 am

If my memory serves me well, you already upgraded your eSDK to the latest one (4.13.03.30). If not, then please do so as soon as you can.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: How do I place the libaplc library in external memory ?

Postby ysapir » Thu Jun 06, 2013 9:28 am

Dr.BeauWebber wrote:Now to take a step back, I think there may be something wrong with the aplc version I have built on the Arm, for the Parallella.
The Windows version built on a PC works fine.
The Parallella version built on a PC runs fine in e-run (and runs fine if copied across on to the Arm board and run with e-run.
The Arm version built on the Arm runs fine.
But for the Parallella version built on the Arm, everything compiles fine but e-run outputs nothing. Which is now what I am seeing on the hardware.
Unless you know of any reason for this behaviour, I will re-build the Parallella version on the Arm, and try and get output from e-run.
The output I expect is via fprintf in the original aplc program, and from sprintf in the version for the hardware.


I am a little confused - can you please make some order here? You mention versions for ARM, PC and Parallella, the running on ARM and running on e-run. Can you please sort these?
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: How do I place the libaplc library in external memory ?

Postby Dr.BeauWebber » Thu Jun 06, 2013 11:17 am

You mention versions for ARM, PC and Parallella, the running on ARM and running on e-run. Can you please sort these?


OK, using as an example vector_sum.apl :
Code: Select all
V .is .io 9
# .is V
S .is +/V
# .is S

i.e. create a vector from 1 to 9,
and then add the vector up.
When converted to c the output is from statements like :
Code: Select all
fprintf(aplcout,"%c",trs1.value.cp[i3]);


On the PC under Cygwin, using the latest sdk for Cygwin built from GitHub :
Code: Select all
$ aplcc vector_sum.apl
$ ./a.exe
 1 2 3 4 5 6 7 8 9
 45

On the PC, cross-building a Parallella version, from the .c we have just created :
Code: Select all
$ ./e-aplcc vector_sum.c
$ ../../INSTALL/bin/e-run ./a.out
 1 2 3 4 5 6 7 8 9
 45

So OK so far.

On the Arm under Linux, using esdk.4.13.03.30_linux_armv7l.tgz
Code: Select all
$ ./h-aplcc vector_sum.apl
$ ./a.out
 1 2 3 4 5 6 7 8 9
 45

So native Arm under Linux version runs OK.
Cross build on the Arm for Parallella
Code: Select all
./e-aplcc vector_sum.c
$ e-run ./a.out
$

So no output fron fprintf(aplcout,"%c",trs1.value.cp[i3]); under this newlib.

Turn on function trace :
Code: Select all
$ ./e-aplcc -T vector_sum.c
$ e-run ./a.out
trace main statement 1
trace main statement 2
trace main statement 3
trace main statement 4

I think trace outputs from a simple printf.
What this should look like - i.e. on the Arm undr Linux :
Code: Select all
$ ./h-aplcc -T vector_sum.apl
$ ./a.out
trace main statement 1
trace main statement 2
 1 2 3 4 5 6 7 8 9
trace main statement 3
trace main statement 4
 45

Moving to the hardware Parallella version, we have to build an output buffer :
Code: Select all
char outbuf[4096] SECTION("BUFFER_SPACE");
char* pointer = outbuf ;

Also, to make quite sure that no problems creep in when we build the library, etc, we explicity compile all the library function at the same time - a bit slow, but eliminates a possible set of problems.

We now write to the buffer using statements of the form :
Code: Select all
sprintf(pointer++,"%c",trs1.value.cp[i3]);

This all runs fine but produces no output.

Now for testing we also put in some simpler sprintf statements first :
Code: Select all
sprintf(pointer,"some text");
pointer = pointer + 9 ;

sprintf(pointer,"\n");
pointer++ ;

sprintf(pointer,"Q");
pointer++ ;

sprintf(pointer,"some text");
pointer = pointer + 9 ;

This all builds OK, and runs :
Code: Select all
$ ./buildv7.sh
$ ./runv5.sh
  0: Message from eCore 0x8ca ( 3, 2): "some text
Qsome text"
  1: Message from eCore 0x84b ( 1, 3): "some text
Qsome text"
  2: Message from eCore 0x84b ( 1, 3): "some text
Qsome text"

etc.
So the simpler sprintf statements work, but the more complex ones, which should be outputting after above messages, are failing silently again under this newlib.
User avatar
Dr.BeauWebber
 
Posts: 114
Joined: Mon Dec 17, 2012 4:01 am
Location: England

PreviousNext

Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 6 guests

cron