[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Parallella Community • View topic - Minimal c program

Minimal c program

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Minimal c program

Postby yuumei » Sun Jun 16, 2013 1:46 pm

yuumei
 
Posts: 4
Joined: Wed May 22, 2013 1:58 pm

Re: Minimal c program

Postby ysapir » Sun Jun 16, 2013 3:55 pm

There are a couple of things to note here:

In C, the leading underscore in a function's name is added implicitly by the compiler. So, a function func() in your code is renamed to _func() internally, and this is how it appears in the object file (when you do e-objdump these are the names you see). Thus, you should call your startup function as "start()" instead.

The bigger problem is that on the Epiphany, the start() function, being the first to be invoked after reset (or SYNC interrupt, to be more precise) should be mapped to the first vector in the IVT (address 0x00000000). Thus, the function itself should contain only one instruction which is the "b <addr-of-the-actual-function>" branch instruction. Alternatively, you should put that "b" instruction in the IVT manually (as a replacement for CRT0) and use your start() as the target address.

The current program flow, with the default stdlib is:

_start() - the IVT entry
.normal_start() - the actual start() function, which merely jumps to:
_epiphany_start() - initialization of stack and buffers, then jump to
main()

and you can see how it's done in file "libgloss/epiphany/crt0.S" in the epiphany-sourceware repo:

User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: Minimal c program

Postby yuumei » Mon Jun 17, 2013 7:54 am

Ah, thank you for the information!

I think I will need to look at how the stack works a bit more :) The reason I was looking at this was because a simple "int main() { return 0; }" was 33K... which I believe would not fit onto the local memory. So could I ask, is there a way to use c and still fit on the epiphany local memory? Maybe I am including something I shouldn't.
yuumei
 
Posts: 4
Joined: Wed May 22, 2013 1:58 pm

Re: Minimal c program

Postby ysapir » Mon Jun 17, 2013 11:46 am

Of course there is, and we do it all the time. A simple, empty "int main()" will not occupy 33KB. I don't know how you got this output.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: Minimal c program

Postby yuumei » Mon Jun 17, 2013 1:07 pm

yuumei
 
Posts: 4
Joined: Wed May 22, 2013 1:58 pm

Re: Minimal c program

Postby timpart » Mon Jun 17, 2013 6:37 pm

The size of the object file on disc is often bigger than the amount of memory it occupies on chip. It seems to have plenty of debugging information in there. Not sure if it has the source code but some cases I've tried seem big enough to fit that in as well.

Tim
timpart
 
Posts: 302
Joined: Mon Dec 17, 2012 3:25 am
Location: UK

Re: Minimal c program

Postby yuumei » Wed Jun 19, 2013 10:57 am

yuumei
 
Posts: 4
Joined: Wed May 22, 2013 1:58 pm

Re: Minimal c program

Postby aolofsson » Wed Jun 19, 2013 12:53 pm

Here's a pretty good tutorial on creating REALLY small programs I saw a while back. :D

http://www.muppetlabs.com/~breadbox/sof ... eensy.html

Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: Minimal c program

Postby ysapir » Wed Jun 19, 2013 2:44 pm

User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: Minimal c program

Postby LamsonNguyen » Thu Jun 20, 2013 6:42 am

Agreed, no words can express how awesome it is. :shock:
LamsonNguyen
 
Posts: 138
Joined: Sun Dec 16, 2012 7:09 pm


Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 5 guests

cron