Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  New to Rockbox Development, Plugins?
« previous next »
  • Print
Pages: 1 [2] 3

Author Topic: New to Rockbox Development, Plugins?  (Read 7307 times)

Offline safetydan

  • Developer
  • Member
  • *
  • Posts: 248
Re: New to Rockbox Development, Plugins?
« Reply #15 on: March 14, 2007, 06:43:06 PM »
The error you got there while building looks a little odd. Perhaps trying doing an update from SVN and then a clean build. So something like

cd "rockbox source directory"
svn update
cd "build directory"
make clean
make

and see what happens.

To actually get your plugin to compile, you'll need to add a line to apps/plugins/SOURCES with the name of your plugin's .c file. If you're familiar with C, you should be able to figure out where it goes in that file.

Logged

Offline 007quick

  • Member
  • *
  • Posts: 70
Re: New to Rockbox Development, Plugins?
« Reply #16 on: March 14, 2007, 06:44:26 PM »
Ok I understand now.
Unfortunetly I know nothing about adding files (though that is what you must do)
Now that you have explained it properly someone else will have to help you.
Sorry that I couldn't solve your problem! :-\
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #17 on: March 14, 2007, 07:42:17 PM »
Ok! Now it compiled. The output for the update was

Code: [Select]
U	apps/plugins/credits.c
U manual/rockbox_interface/tagcache.tex
Updated to revision 12768.

I didn't understand what was happened, but at least it's working now :)
And I managed to start debugging my plugin, thanks for the help, I may be back soon :P
Don't worry 007quick, and thanks again!
Logged

Offline safetydan

  • Developer
  • Member
  • *
  • Posts: 248
Re: New to Rockbox Development, Plugins?
« Reply #18 on: March 14, 2007, 08:22:43 PM »
That output from SVN you posted is telling you that it updated (see the 'U' at the start of the line) two files. And now your copy of the source is the same as revision 12768 of the main repository.
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #19 on: March 14, 2007, 09:34:38 PM »
I managed to compile my plugin (still with some warnings) but the my_plugin.rock file doens't appear in .rockbox/rocks of the unzipped 'make zip' zip file. Neither it apears in the plugin menu of the Sansa once I loaded it.
I'm not sure if I added the 'my_plugin.c' line in the correct place in the "rockbox/apps/plugins/SOURCES" file. I put it under "/* plugins common to all models */", but I'm not sure if it's ok. And furthermore, I may not be complying with some standards, if are there any... by now I'm just interested in making it work in my Sansa... the begining of my code is (there are some comments in spanish):

Code: [Select]
#include "plugin.h"

/* GROSOR puede tener los valores 1,2,4,8,16 */
#define GROSOR 8
#define X_ARENA (LCD_WIDTH/GROSOR)
#define Y_ARENA (LCD_HEIGHT/GROSOR)

#define LEFT 0
#define RIGHT 1
#define UP 2
#define DOWN 3

#define DEFAULT_VEL 3
#define FRUTAS_POR_PANTALLA 100

#define ROJO LCD_RGBPACK(255,0,0)
#define BLANCO LCD_RGBPACK(255,255,255)
#define NEGRO LCD_RGBPACK(0,0,0)

#define X_INI 5
#define Y_INI 5

#define MAX_LENGTH 100
#define INIT_LENGTH 3

/* here is a global api struct pointer. while not strictly necessary,
   it's nice not to have to pass the api pointer in all function calls
   in the plugin */
static struct plugin_api* rb;

/* MIS DECLARACIONES DE TIPOS */
struct coord {
    int x;
 
(...)

The warnings, which I couldn't figure out, are:

Code: [Select]
my_plugin.c:55: warning: function declaration isn't a prototype
my_plugin.c: In function 'plugin_start':
my_plugin.c:216: warning: implicit declaration of function 'TEST_PLUGIN_API'

and those lines are:

Code: [Select]
(...)
    bool crecer;
};

/* FUNCIONES AUXILIARES */
int** CrearMundo() {                                    <-- LINE 55

    int** m = malloc(sizeof(int*)*X_ARENA);
    int i;
(...)

and

Code: [Select]
(...)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
    TEST_PLUGIN_API(api);                               <-- LINE 216
    (void)parameter;
(...)


I can paste the rest of the code if it's needed. Hope someone can help. Thx!
Logged

Offline safetydan

  • Developer
  • Member
  • *
  • Posts: 248
Re: New to Rockbox Development, Plugins?
« Reply #20 on: March 14, 2007, 10:04:34 PM »
You might want to look at the helloworld.c example in apps/plugins. It looks like you've missed a few things. For example your plugin must have

    PLUGIN_HEADER

somewhere in it.

As for the warning, "function declaration isn't a prototype" it means that your function declaration isn't valid. You've got

    int** CrearMundo() {

it should be

    int** CrearMundo(void) {
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #21 on: March 14, 2007, 10:39:19 PM »
I did take a look at helloworld.c, but I must have missed that line... :P
Concerning the prototype, I usually forget differences between C and C++  :-\
I had to change a lot of "for (int i" and "function(int &var" too :) I'm not really sure why I can still use bool, true and false; I tought it was only a C++ datatype.

Okkk... now I'm getting this error:

Code: [Select]
/home/rockbox/build/apps/plugins/my_plugin.o: In function `CrearMundo':
my_plugin.c:(.text+0x64): undefined reference to `malloc'
/home/rockbox/build/apps/plugins/my_plugin.o: In function `crearVibora':
my_plugin.c:(.text+0xf0): undefined reference to `malloc'
/home/rockbox/build/apps/plugins/my_plugin.o: In function `matarVibora':
my_plugin.c:(.text+0x874): undefined reference to `free'
collect2: ld returned 1 exit status
make[2]: *** [/home/rockbox/build/apps/plugins/my_plugin.elf] Error 1
make[1]: *** [rocks] Error 2
make: *** [all] Error 2

in spite of including the line "#include $stdlib.h$" (less and more marks insted of $). Is it wrong to use dynamic memory for rockbox? Is there an stdlib availible for it?
« Last Edit: March 14, 2007, 10:40:57 PM by neoAKiRAz »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: New to Rockbox Development, Plugins?
« Reply #22 on: March 14, 2007, 10:44:13 PM »
You can't use malloc or free in Rockbox.  I believe memory must be statically allocated.
Logged

Offline safetydan

  • Developer
  • Member
  • *
  • Posts: 248
Re: New to Rockbox Development, Plugins?
« Reply #23 on: March 14, 2007, 10:45:07 PM »
Welcome to the wonderful world of embedded software development. There is no malloc so you'll pretty much have to statically allocate things. If you really, really need a dynamic chunk of memory you can steal the audio buffer, but that's generally not needed (and stops audio playback anyway).
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #24 on: March 14, 2007, 10:54:49 PM »
Great! Changing dynamic to static :P
It wasn't really needed in this case anyway...

I suppose there's no dynamic memory because of the much simpler OS that can be run in a embbeded system... I'm really curious about the 'art' of porting Rockbox, I'd like to know how it works.
I'm guessing most of the Rockbox source is written in C, and a compiler is made for every different CPU in each target... and then the libraries (meaning system calls for LCD, audio access, etc) may be partially made in assembly language. Is it something like that?

I'll keep working on this, greetz! And Thx.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: New to Rockbox Development, Plugins?
« Reply #25 on: March 14, 2007, 11:18:55 PM »
Yeah pretty much.  Theres actually some decent docs on this in the wiki:

http://www.rockbox.org/twiki/bin/view/Main/RockboxArchitecture

Also, if you look at the target tree:

http://svn.rockbox.org/viewvc.cgi/trunk/firmware/target/?pathrev=12771

You can see how some of the code is divided.  I say some since a lot of it isn't neatly separated yet, but the newer stuff mostly is.
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #26 on: March 14, 2007, 11:50:19 PM »
Thanks for the info, I'll take a look at it later. Actually I should have read that before wanting to see my code in my Sansa LCD, but I'm sooo anxious :)

And, yes, it's working. Horribly, but at least the color of the snake is ok :)
I wanted to know if is there a way of compiling only my .C since the execution of 'make' takes about 3-4 mins in my machine (just checking that there are no changes in the rest of all ^_^'). I'm a little forgotten in C, so "gcc -c my_plugin.c .../plugins.h" didn't work :P
Any other idea??
Logged

Offline safetydan

  • Developer
  • Member
  • *
  • Posts: 248
Re: New to Rockbox Development, Plugins?
« Reply #27 on: March 15, 2007, 12:36:15 AM »
If you do another svn update, you should get a new version of the configure script. If you rerun that (i.e. run tools/configure again and select the simulator options as before), you should have a new makefile that will let you build your plugins faster using "make rocks".
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #28 on: March 15, 2007, 01:43:15 AM »
I updated to revision 12772 (9 files updated).
Then I run the configure script, where I chose '50' for Sansa-e260 again and N for Normal build.
The output was:

Code: [Select]
Normal build selected
Using source code root directory: /home/rockbox
Using arm-elf-gcc 4.0.3 (400)
Created Makefile

Then I tried 'make rocks', but it took an awful long time. I suppose it was because of the new downloaded files. So I modified my_plugin.c and ran it again but the same "is up to date" and "nothing to be done with" arose, and it took about 3-4 min. So I guess it didn't work. Did I miss something?
Logged

Offline neoAKiRAz

  • Member
  • *
  • Posts: 27
Re: New to Rockbox Development, Plugins?
« Reply #29 on: March 15, 2007, 02:27:17 AM »
It worked!!!  :D
I have a beautiful white 8-pixel thick snake crawling over a black background after a red fruit. Hehe!
It speeds up and down with the wheel and grows with the round select button (for debug purpouses only :P)
Now I can go to sleeep...  ;D

Thanks for all the help!

PS: The script was right, "much happiness arose" from running "../tools/configure" from the build directory. Ho ho.
Logged

  • Print
Pages: 1 [2] 3
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  New to Rockbox Development, Plugins?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.087 seconds with 16 queries.