Programming On Pandora


setup the cross compiler and build on your desktop?

Which cross compiler would that be? Which libs would you be building against?

It has already been concluded that there won't be any 'official' SDK released for the various desktop environments people might want to use - so having a compiler onboard pretty much makes things as simple as they could be.

I *could* set up a cross-compiler on my desktop, but having done it already for 15 different targets this year, I'm going to be quite happy to not have to do it for Pandora .. I could use the same compiler for Touchbook/Beagle/Pandora, though, that is true, but still there is the hassle of setting up access to the libs and all that. For my needs, compiling onboard is a quick and hassle-free solution to getting started with developing specifically for the Pandora right away ..
 
WizardStan said:
torpor said:
With a C/C++ compiler onboard it also makes *PORTS* a lot easier to get started .. look, its just 100% sensible to do this, and there is no good reason not to do it - the compiler is only a 15 megs extra! Just do it!
Who's been saying it won't have GCC on board? It is, in fact, only a few hundred K, so even more reason it shouldn't not be included.
GCC is of pretty limited usefulness without all the libraries and headers and whatnot that goes with. That starts to add up.
 
Last edited by a moderator:
torpor said:
Which cross compiler would that be?
gcc or CodeSourcery. Lots of people have offered to help with this. As I've said, if you're on Linux, it is trivial to download and install a cross compiler to start compiling for ARM right now.

torpor said:
Which libs would you be building against?
The same ones that would be on the Pandora if such an environment is setup. Literally. Exact same. If they're available on the Pandora, you could just copy them off and tell the cross compiler where to get them.

Having gcc and the SDL runtime doesn't mean you can compile SDL applications though; you'd still need the SDL headers and the static libraries to link to, and there again, we get into the question of which libraries do you include. I have no qualms with including gcc and the standard headers, but who gets to decide which dev libraries are included on the NAND? A better solution, if you want to compile on the Pandora, is to store the dev libraries on an SD card. That way you get exactly the libraries you want.
When I get home tonight, I'll upload the SDL for ARM package I built and then anyone can use it.
 
Last edited by a moderator:
WizardStan said:
When I get home tonight, I'll upload the SDL for ARM package I built and then anyone can use it.

Thanks!

Also, one more benefit of having a cross compiler rather than native compiler on pandora is that you can start coding for before owning it.
 
Last edited by a moderator:
torpor said:
Wear of the SD Cards? Well, playing a game will also wear down your SD cards.

SD cards wear out because of write operations. Playing games means a lot of read operations, which will not hurt, and few write operations. Developing means many, many small write operations: a huge amount is caused by editing the source files over and over again, many writes are caused by make and gcc (temporary files, changed object files ... ) and if you use caching it could even be worse. Therefore I would claim that it wears out your SD cards by a factor >2 faster than the typical usage scenario. Correct me if I'm wrong.

But you are right: If you plan to use a desktop, export the dev-fs via NFS on the desktop, mount it on the pandora and you are fine. No wear of anything.
 
Last edited by a moderator:
ARM compiled SDL library. Just decompress it to a directory you can find. I suggest ~user/dev because I like to put all my dev work in the dev directory.
This is based on the 1.2.11 source. They're up to 1.2.14 now, but it shouldn't make much difference. Writing an app is "simple": in your makefile, point your include variable at the include directory and your lib variable at the lib directory. Actually writing your programs is the exact same. Your makefile might look something like so:
Code:
# Setup SDL library, change SDL_DIR to wherever you copy it
ifeq ($(PLATFORM),PANDORA)
SDL_DIR     = ~user/dev/sdl4arm
else
SDL_DIR     = /usr
endif
SDL_CFLAGS := -I$(SDL_DIR)/include -D_GNU_SOURCE=1 -D_REENTRANT
SDL_LFLAGS := -L$(SDL_DIR)/lib -Wl,-rpath,/usr/lib -lSDL -lpthread

# Cross compiler, change TOOLSHOME to wherever you've installed one of the myriad of cross compilers, and CC/CXX to the actual binary names
ifeq ($(PLATFORM),PANDORA)
TOOLSHOME=~user/oe/tmp/cross/armv7a/bin
CC  = $(TOOLSHOME)/arm-angstrom-linux-gnueabi-gcc
CXX = $(TOOLSHOME)/arm-angstrom-linux-gnueabi-g++
else
CC = gcc
CXX = g++
endif

# Standard flags and stuff, don't mess with unless you know what they mean
WARN    = -Wall -W -Wshadow -Wpointer-arith \
	       -Wbad-function-cast -Wcast-qual 
WARNXX  = -Wall -W -Wshadow -Wpointer-arith -Wcast-qual 
ifeq($(PLATFORM),PANDORA)
DEF_FLAGS = -DPANDORA
else
DEF_FLAGS = -DDESKTOP
endif
OPT_FLAGS = -O2
CFLAGS   = $(OPT_FLAGS) $(WARN)   -I. $(DEF_FLAGS) $(EXTRA)
CXXFLAGS = $(OPT_FLAGS) $(WARNXX) -I. $(DEF_FLAGS) $(EXTRA)
LFLAGS   = -lpthread
CFLAGS += $(SDL_CFLAGS) 
LFLAGS += $(SDL_LFLAGS)

# Stuff to build here
OBJS=myprog.o extrafile.o datafiles.o
ifeq($(PLATFORM),PANDORA)
PROG=myprog.pandora
else
PROG=myprog
endif
TOCLEAN=$(PROG)

# And finally the instructions that actually build stuff
all: $(OBJS) $(PROG)

$(PROG): $(OBJS)
	$(CC) -o $(PROG) $(OBJS) $(CFLAGS) $(LFLAGS)

clean:
	$(RM) $(OBJS) 
	$(RM) $(TOCLEAN)

%.o: %.c
	$(CC) -o $@ $(CFLAGS) -c $<
And that should do it. Write your .c files, type "make", and let it do its magic. Outputs the file myprog.pandora, given that extension only so I can differentiate it from the PC version.
Speaking of PC version, if you want to build your app for a desktop instead of Pandora, change SDL_DIR to wherever the SDL library is installed on your PC (usually /usr) and set CC and CXX to the regular gcc and g++ respectively. ie:
Code:
SDL_DIR=/usr
CC=gcc
CXX=g++
DEF_FLAGS=
PROG=myprog
# note I removed the extension
Type "make clean && make" and it compiles into x86 code. Need to clean first, otherwise it will just try to rebuild using the ARM object files, and that won't work.
Note that I set DEF_FLAGS to set PANDORA for the Pandora file, but removed it for the PC file. You can then check for that inside of your program by "#ifdef PANDORA .... #endif" in case there's any Pandora specific stuff you want to do (screen resolution for example).
One final caveat. In the VERY limited experience I had with a Pandora (ie, a bunch of binaries I sent to Pickle once), the only graphic init call that worked was 800x480 fullscreen. No other resolution (and especially not Windowed) seemed to work, thought I may have been doing it wrong. It will need more experimentation.

And there you have it. Write your programs exactly as you would on your PC, even test them on your PC, and when you're ready to rebuild it for the Pandora, unpack the tar.gz file like I said, update your Makefile accordingly, and rebuild. The truly clever can even mount their Pandora as an external hard drive and copy the binary onto it as the last step in the Makefile, so you just "make", pick up your Pandora, and play ;)

edit: NEW AND IMPROVED MAKEFILE!
call "make" and it will build the PC version. Call as "make PLATFORM=PANDORA" and it will build the Pandora version. Don't forget to clean between the two.
Further improvements could be to stick the .o files into different directories depending on the platform so you don't need to clean between making the PC and Pandora version, but I'm too lazy for that. A better improvement would have put all the PANDORA specific stuff in one place, rather than calling ifeq four times, but again, lazy.
 
CodeTwister said:
torpor said:
Wear of the SD Cards? Well, playing a game will also wear down your SD cards.

SD cards wear out because of write operations. Playing games means a lot of read operations, which will not hurt, and few write operations. Developing means many, many small write operations: a huge amount is caused by editing the source files over and over again, many writes are caused by make and gcc (temporary files, changed object files ... ) and if you use caching it could even be worse. Therefore I would claim that it wears out your SD cards by a factor >2 faster than the typical usage scenario. Correct me if I'm wrong.

But you are right: If you plan to use a desktop, export the dev-fs via NFS on the desktop, mount it on the pandora and you are fine. No wear of anything.
OK but SD cards have like 1,000,000 writes per area and they have wear leveling, suppose you save your source file every 10 seconds... so even if your card is full and there's no wear leveling it will take you 19 years (if you do every 10 seconds constantly and don't sleep.) Guys it's not that big of a deal, you're gonna want to re-buy SD cards every 3-5 years for capacity/price reasons anyway.Has anyone here EVER worn out a modern SD card? I don't know anyone that's ever worn out an SD or a flash drive.
 
Last edited by a moderator:
WizardStan said:
edit: NEW AND IMPROVED MAKEFILE!
call "make" and it will build the PC version. Call as "make PLATFORM=PANDORA" and it will build the Pandora version. Don't forget to clean between the two.
Further improvements could be to stick the .o files into different directories depending on the platform so you don't need to clean between making the PC and Pandora version, but I'm too lazy for that. A better improvement would have put all the PANDORA specific stuff in one place, rather than calling ifeq four times, but again, lazy.
Hey since our apps are mostly gonna be small and quick to compile why not just force a clean before every compile in the makefile? Then you don't have to worry about typing it.
 
Last edited by a moderator:
I'm learning Python at the moment. One of the big reasons I'm getting the Pandora as I'll have a platform to mess around with and a community to share that with :D

The other thing I'm getting is a Nokia N900, for the same reasons really.

Although I'm happy enough using IDLE on my PC it would be great if something like that for the Pandora would be made. Fingers crossed!
 
Timstertoo said:
Although I'm happy enough using IDLE on my PC it would be great if something like that for the Pandora would be made. Fingers crossed!

I don't understand what you are getting at ?

Idle is basicaly just an improved text editor. Would could run IDLE on the Pandora if you want. Python code is usally portable so you would compile it on the Pandora just as you would on your computer. Maybe you're hitting at a cross compiling (no idea how it would work with Python but I am a real newbie when it comes to programming) ?

Personnaly I would use Geany, Kwrite or another good text editor instead of IDLE. IDLE does seem to have a few nice fonctionality... but it just doesn't inspire me confidence. Having it crash when I input Japanese character in it didn't help. I guess it would be better it is would use GTK or qt.

EDIT: BTW what book or ressource are you using ? Personnaly I've been mostly using Programming in Python 3 - A Complete Introduction to the Python Language (Mark Summerfield). I only half way though that though :/
 
Last edited by a moderator:
marshal said:
EDIT: BTW what book or ressource are you using ? Personnaly I've been mostly using Programming in Python 3 - A Complete Introduction to the Python Language (Mark Summerfield). I only half way though that though :/
You're aware that no one uses Py3 yet right?
 
Last edited by a moderator:
I've got Core python programming, but it's mostly as a reference whenever I want to make a small script (I don't have the skills for anything bigger). I read about halfway through, should try to finish it at some point.
 
klikklak said:
I've got Core python programming, but it's mostly as a reference whenever I want to make a small script (I don't have the skills for anything bigger). I read about halfway through, should try to finish it at some point.

Core Python's good, Wesley Chun's a really nice fellow.
 
Last edited by a moderator:
marshal said:
Timstertoo said:
Although I'm happy enough using IDLE on my PC it would be great if something like that for the Pandora would be made. Fingers crossed!

I don't understand what you are getting at ?

Idle is basicaly just an improved text editor. Would could run IDLE on the Pandora if you want. Python code is usally portable so you would compile it on the Pandora just as you would on your computer. Maybe you're hitting at a cross compiling (no idea how it would work with Python but I am a real newbie when it comes to programming) ?

Personnaly I would use Geany, Kwrite or another good text editor instead of IDLE. IDLE does seem to have a few nice fonctionality... but it just doesn't inspire me confidence. Having it crash when I input Japanese character in it didn't help. I guess it would be better it is would use GTK or qt.

EDIT: BTW what book or ressource are you using ? Personnaly I've been mostly using Programming in Python 3 - A Complete Introduction to the Python Language (Mark Summerfield). I only half way though that though :/

I'm a total n00b at programming, you're giving me way too much credit if you think I'm getting at anything :D

I used to be ok with Basic, but that's 25 years ago. If only I would've continued then..

What I mean, and I'm probably using terms in wrong places thus confusing you, is that the IDLE python interpretor on the PC let's me type (text editor as you said) and then run programs in Python. If it's not right it gives me an error and where it is. Also it highlights where it goes wrong in the program if I make a mistake with indentations or missing a ":" or whatever.

If that's easily portable to the Pandora I'm a happy man! Any similar program will do me fine too. I have plenty of learning ahead before I need anything niftier then that. ;-)

I'm doing the first steps with Head First Programming (http://oreilly.com/catalog/9780596802387) which is pretty much a primer on programming in general but happens to use Python throughout the book as language. So I kill 2 birds with one stone.

After that I'm not sure yet, I'll have a look at the book you mentioned and I'll need a reference book that explains all the functions to me that are part of the core of Python.

There is also this book which is available on the website itself: http://inventwithpython.com/ and seeing as I've always secretely have been fantasizing about designing games I think it'll be my next stop. Also short and easy and nothing too fancy yet but enough to keep me occupied for a while.

Concering Python 3, I saw someone else mention in this thread that nobody uses it, it seems to me it's the future so I'd be better of learning that straight off then getting stuck into a version that will be obsolete, or in the very least outdated, soon.
 
Last edited by a moderator:
Timstertoo said:
marshal said:
Timstertoo said:
Although I'm happy enough using IDLE on my PC it would be great if something like that for the Pandora would be made. Fingers crossed!

I don't understand what you are getting at ?

Idle is basicaly just an improved text editor. Would could run IDLE on the Pandora if you want. Python code is usally portable so you would compile it on the Pandora just as you would on your computer. Maybe you're hitting at a cross compiling (no idea how it would work with Python but I am a real newbie when it comes to programming) ?

Personnaly I would use Geany, Kwrite or another good text editor instead of IDLE. IDLE does seem to have a few nice fonctionality... but it just doesn't inspire me confidence. Having it crash when I input Japanese character in it didn't help. I guess it would be better it is would use GTK or qt.

EDIT: BTW what book or ressource are you using ? Personnaly I've been mostly using Programming in Python 3 - A Complete Introduction to the Python Language (Mark Summerfield). I only half way though that though :/

I'm a total n00b at programming, you're giving me way too much credit if you think I'm getting at anything :D

I used to be ok with Basic, but that's 25 years ago. If only I would've continued then..

What I mean, and I'm probably using terms in wrong places thus confusing you, is that the IDLE python interpretor on the PC let's me type (text editor as you said) and then run programs in Python. If it's not right it gives me an error and where it is. Also it highlights where it goes wrong in the program if I make a mistake with indentations or missing a ":" or whatever.

If that's easily portable to the Pandora I'm a happy man! Any similar program will do me fine too. I have plenty of learning ahead before I need anything niftier then that. ;-)

IDLE will probably run on the Pandora but there are other editors you can use too. IDLE is nice in its convenience but it also causes problems with input and with apps that don't terminate quickly or that don't use console input (eg. if you write a game.)
I used IDLE for a while but now I mostly just use notepad ++ and a couple console windows.
 
Last edited by a moderator:
Timstertoo said:
There is also this book which is available on the website itself: http://inventwithpython.com/ and seeing as I've always secretely have been fantasizing about designing games I think it'll be my next stop. Also short and easy and nothing too fancy yet but enough to keep me occupied for a while.

Concering Python 3, I saw someone else mention in this thread that nobody uses it, it seems to me it's the future so I'd be better of learning that straight off then getting stuck into a version that will be obsolete, or in the very least outdated, soon.
inventwithpython seems cool, good luck and let me know how it is. I was considering working through it just for fun even though I've been using Python for about 8 years now.

As for py2 being obsolete soon, that's very unlikely. Py3 breaks backwards compatibility in a lot of ways, so all libraries have to be rewritten for Py3. Most people haven't even CONSIDERED moving to Py3. It'll be a good 3 years at least before people stop using py2.

It's not necessarily bad to learn Py3 first, just know there are differences and a lot of the libraries you'll want to use (eg. Pygame) still have no or very little/untested Py3 support. So you'll probably have to learn both.

Also they're coming out with Py2.7 soon, 2.6 was many months ago, and they're going up to Py2.9. It's not dead for many years to come.

[edit]
also say hello to the Tutor mailing list, I've been a member since '05 and we love helpin' out new members. Just be sure you formulate your questions well and don't try to get us to do homework for you and we'll be happy :) You should also check out Alan Gauld's python tutorial, it's apparently quite good. Also join the Pygame and Pyglet mailing lists as you're gonna want to try to get up to speed on those if you want to do some game development. And a couple months down the line (like say September) there will be another Pyweek competition (a week-long game programming competition). There's one in March, they have them every 6 months. You should set a goal to be somewhat familiar with one of the game libraries by then, and you can enter! It's a great motivator and everyone involved are really nice. I'm competing in the March one but I'll do the September one as well. I've been in all of them.
 
Last edited by a moderator:
rabidpoobear said:
inventwithpython seems cool, good luck and let me know how it is. I was considering working through it just for fun even though I've been using Python for about 8 years now.

As for py2 being obsolete soon, that's very unlikely. Py3 breaks backwards compatibility in a lot of ways, so all libraries have to be rewritten for Py3. Most people haven't even CONSIDERED moving to Py3. It'll be a good 3 years at least before people stop using py2.

It's not necessarily bad to learn Py3 first, just know there are differences and a lot of the libraries you'll want to use (eg. Pygame) still have no or very little/untested Py3 support. So you'll probably have to learn both.

Also they're coming out with Py2.7 soon, 2.6 was many months ago, and they're going up to Py2.9. It's not dead for many years to come.

This I didn't know. I thought the next version would simply be Py3. I did notice that Pygame would be a nono for a bit with Py3 but I didn't realise the incentive for them to step it up would be quite that far away.

Guess that most things I learn will be applicable to both. Mainly the general programming skills. So hopefully once I get that under control it will be just a matter of the right documentation and forums to find the differences between the two and adapt accordingly.

Thanks!
 
Last edited by a moderator:
Timstertoo said:
Guess that most things I learn will be applicable to both. Mainly the general programming skills. So hopefully once I get that under control it will be just a matter of the right documentation and forums to find the differences between the two and adapt accordingly.
You're quite right. The changes from 2.x to 3.0 are mostly syntactic; as a new user, the only ones you're likely to encounter are the print statement and integer division. Also, as of Python 2.6, the 2to3 tool is included to aid translating 2.x code to 3.x code. There's no tool for converting in the other direction, so for now you're best off targeting 2.6; just try to write your code so that it's easily convertible.
 
Last edited by a moderator:
Back
Top