[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/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 - How to use printf with the internal memory scenario

How to use printf with the internal memory scenario

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

How to use printf with the internal memory scenario

Postby eoghanoh » Thu Feb 20, 2014 12:34 pm

Hi,

something that might be useful to people.

When developing, you can use printf to print stuff to the debugger. It's very useful to see the output from a core right there in Eclipse (or whatever your choice of debugging environment is).

But you can't do this if you build with the internal LDF because the stdio standard library, which contains printf, is too big to fit in the 32k of onboard memory. So if you want printf support you must build using either the fast or legacy LDF. Using fast or legacy LDFs makes things more complicated to get started because it goes to shared memory and might overwrite your variables etc. Plus it'll be a lot slower (not that you should be worried to much about speed when debugging anyway).

Which got me thinking - I don't really need the standard io library, I just want to print stuff. So I had a look around and found tinyprintf, which was developed for debugging embedded systems over a serial port. I've modified it to work nicely with e-gdbserver (it needs to buffer the output otherwise e-gdbserver and e-gdb will display the output as one character on each line, and I've prevented overruns etc.)

So just just compile this into your project and you don't need stdio so you can still run everything internally. You don't even need to change your printf statements.

The max buffer size at the moment is defined as 256 which should be loads for most things, but obviously increase it if you need to. If you don't increase it your strings will simply be truncated. This was a quick and dirty way of doing it but I wanted to minimise changes to the file as I didn't want to break anything else and spend lots of time on it.

It does't handle floating points (there's an older version here which does but it would need to be modified similarly to how I have done it: ). For now though it's good enough for what I need it for and hopefully will be useful to other people. It makes things a lot easier being able to do it this way.

From looking at the output of e-size it seems to only add about 1.5kB to your binary.

I've been using it for a week now and it works great so I thought it was time to share.

The two files you need are attached to this post in a zip file.

I hope it helps.

Thanks,
Eoghan.
Attachments
printf.zip
printf source code
(3.87 KiB) Downloaded 888 times
eoghanoh
 
Posts: 23
Joined: Mon Dec 17, 2012 3:22 am

Re: How to use printf with the internal memory scenario

Postby shodruk » Fri Feb 21, 2014 12:12 pm

Thanks! That is very useful!
Shodruky
shodruk
 
Posts: 464
Joined: Mon Apr 08, 2013 7:03 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 11 guests

cron