Very simple test program

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Very simple test program

Postby tnt » Wed Feb 27, 2013 7:38 am

Hi,

I'm trying to build & run a very simple test program to have a platform to run some tests. This is all using CLI, I have no GUI available since I work remotely and I'm no fan of eclipse anyway.

The host software is :

Code: Select all
#include <stdio.h>

#include <e-host.h>
#include <e-loader.h>


int main(int argc, char *argv[])
{
        Epiphany_t _epiphany, *epiphany = &_epiphany;
        int rv;

        e_set_host_verbosity(2);
        e_set_loader_verbosity(2);

        rv = e_load("../epiphany/main.srec", 1, 1, 0);
        if (rv == EPI_ERR) {
                fprintf(stderr, "[!] Error loading Epiphany program.\n");
                return -1;
        }

        rv = e_open(epiphany);
        if (rv) {
                fprintf(stderr, "[!] Failed to open epiphany\n");
                return -1;
        }

        sleep(1);
        printf("%08x\n", e_read_word(epiphany, 0, 0x2000));
        sleep(1);
        printf("%08x\n", e_read_word(epiphany, 0, 0x2000));

        e_close(epiphany);

        return 0;
}


The epiphany code is :

Code: Select all
int main(int argc, char *argv[])
{
   int *p = (int*)0x2000;

   while (1) {
      *p = *p + 1;
   }

   return 0;
}


And I build it with :

Code: Select all
e-gcc    -c -o main.o main.c
e-gcc   main.o   -o main
e-objcopy --srec-forceS3 --output-target srec main main.srec


What I would expect is the two printf to print two different values since the epiphany core is supposed to loop indefinitely incrementing 0x2000 (which is in the core specific SRAM).

Unfortunately that doensn't really work. Resulsts range from printing the same value twice to just crashing (depending on the order I do the e_open and e_load). I also get some warnings from the e_loader :

"Warning (Non zero _start): The start of program is detected in the address 7fffffff"

Can anyone point to what I'm doing wrong ?

Cheers,

Sylvain
tnt
 
Posts: 408
Joined: Mon Dec 17, 2012 3:21 am

Re: Very simple test program

Postby tnt » Wed Feb 27, 2013 9:43 am

Ok, now it works.

So there was several things wrongs:

- The 'run' argument was set to '0' (left over from an old test)
- The default linker script doesn't do anything sensible it seems ... it places everything at 0x80000000 which correspond to nothing. At first I thought it was external RAM but it's not.
- The e-loader doesn't seem to have any support to load code in in shared DRAM (or did I miss something ?)

So I just reused the matmul-16 link script for now, but since I want to experiment with code in shared DRAM, I'll need to figure something out.

Cheers,

Sylvain
tnt
 
Posts: 408
Joined: Mon Dec 17, 2012 3:21 am

Re: Very simple test program

Postby tnt » Wed Feb 27, 2013 12:35 pm

tnt
 
Posts: 408
Joined: Mon Dec 17, 2012 3:21 am

Re: Very simple test program

Postby ysapir » Wed Feb 27, 2013 2:46 pm

@tnt, see comment on the Hub.


UPDATE: (for the sake of forum readers)
thanks for the correct comment. At this time the loader is intended for loading programs into internal memory space. I prepared a patch for external but it is not integrated and tested yet. As of now, only the internal.ldf profile is supported, but there will be a fix soon.

BTW, this is why in the matmul example I use pointers to access data objects residing in DRAM, instead of statically allocating them there.



BTW, you are right that the default linker script is not relevant for producing code that should run on hardware. This is why you should always provide the "-T linker_script.ldf" parameter to your build line. The default code generation should work well with the simulator.

The reason why it does not make sense to imply a memory map is that the compiler code is generic and shared across systems. Our EMEK prototypes had a different memory map than the Parallella's.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 9 guests

cron