Random Homebrew: Bruce Lua
kxploited lua game

How do I link PSPtoolchain to Eclipse ?

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

How do I link PSPtoolchain to Eclipse ?

Postby praed0r » Wed Apr 18, 2012 3:13 am

Advertising
Hi,

I've just installed the PSP toolchain in Linux Mint 11
(was an absolute nightmare to install - finally sussed it out and got it installed)

I've also installed Eclipse Version: 3.5.2 (Galileo)
(This is the default version available on the Software Manager menu option on Mint)
I've also installed the Eclipse ADT C/C++ extension

I would now like to write a short PSP compatible program using the Eclipse IDE, (NOT "hello world" - but maybe - "Thank you all for your help" lol.) to test my installation is good and that it will produce a PBP file that works.

Can anyone give me a pointer on how to link PSP toolchain and Eclipse so I can produce PSP compatible code.

I would be very much obliged for any help on this

Praed0r
PSVita 2.02 Stock - 16Gb
PSP 3003 6.60 PRO-B10 - 24Gb
PSone - with flip up screen
PS2 Slim - with flip up screen
PS3 Phat - 320Gb Stock F/W
Tablet S - Rooted - ICS 4.0.3 - 24Gb
Nexus 7 32G - Rooted JB
Kindle Fire HD 8.9 32Gb Rooted - CM10.1
praed0r
 
Posts: 62
Joined: Sat Mar 17, 2012 11:28 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby m0skit0 » Wed Apr 18, 2012 8:52 am

Advertising
Never done PSP development with Eclipse, but AFAIK you just need to point to the right Makefile if environment variables are properly set up. Anyway, I would first do a manual compilation do see if the SDK is properly installed. Also I recommend you to get latest Eclipse version (3.7.0). You can just download it here, it just decompresses and good to go (thanks Java :mrgreen: ). Of course you need a JRE installed (which I assume you already got if Eclipse Galileo runs).
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby SsJVasto » Fri Apr 20, 2012 1:54 pm

praed0r wrote:I've just installed the PSP toolchain in Linux Mint 11
You have the PSPToolChain, or the PSPSDK, or both? Because the Toolchain is just a set of programs like psp-gcc, pack-pbp, etc. that help you by not having to compile in a command-line interface.
praed0r wrote:I've also installed the Eclipse ADT C/C++ extension
You installed ADT, or CDT? CDT is the C++ extendion for Eclipse, and ADT is the "Android Development Toolkit", which is basically a bunch of programs (like fastboot, adb, etc) to manage/root/update/dump your Android phone.
m0skit0 wrote:Anyway, I would first do a manual compilation do see if the SDK is properly installed.
Easiest way to do this is to type in
Code: Select all
praed0r@mintlinux11$ echo $PSPSDK
. The psp-gcc programs need this variable to know where the #include <*.h> files are, so if this returns a blank line, maybe you messed something up...
m0skit0 wrote:Also I recommend you to get latest Eclipse version (3.7.0)
Yeah, but watch out. The standard "Eclipse Classic" only supports Java development. You need to make sure you have a version of Eclipse that includes the CDT (C++ Development Toolkit). You can install this manually, but it's a hassle for nothing, and eclipse CDT allows you to develop in Java as well, so it's not a loss to get this version.


First of all, make sure you have everything you need. What I use nowadays, since it's all in one place and is constantly updated, is the MINPSP (Minimalist PSPSDK). You can find this here:
http://www.jetdrone.com/minpspw
  • There is the Debian-flavor version (Debian, Ubuntu, Mepis, all "apt"-based repositories, or linux that supports .deb installs);
  • There is the Source-code version (if you have a more hardcore OS, like Gentoo, where you need to compile each program manually);
  • There is the Win32 installer (works on 32bit and 64bit, I personally tested on WinXP 32bit, Win7 32bit, and Win7 64bit);
The minpsp is a mix of PSPSDK and PSPToolchain (if you remember back in the PS2DEV.ORG days), and the guy who maintains it released a plugin for eclipse to be able to select directly "Create PSP MakeFile Project", which you can get here:
http://code.google.com/p/minpsp-eclipse-plugin/
But ideally, you should just set-up a software repository in Eclipse.

Also available on his website is a PDF file. Basically it explains the following:
  • Installing Eclipse;
  • Installing the SDK;
  • Using Models created in Blender (3D modeling GNU program);
  • PSP Debugging using Eclipse (and usbhostfs_ps, pspsh, psplink and usb_driver);
It's a good read (44 pages), and explains pretty well the development process.

Hope this helped :)
If you have further questions, don't hesitate to PM me. I love programming on the PSP, it's so much fun!
PSVita Model PCH-1001 (OFW 1.81);
PS3 Model CECH-2101B (OFW 4.31);
PSP Model PSP-2001 (God of War Edition)(CFW 6.60 PRO-B10);
PSP Model PSP-1001b (CFW 4.01-m33 + Kernel Plugin);
User avatar
SsJVasto
 
Posts: 35
Joined: Wed Mar 21, 2012 5:24 pm
Location: Canada

Re: How do I link PSPtoolchain to Eclipse ?

Postby praed0r » Sat Apr 21, 2012 7:36 pm

Thanks Guys,

Got the toolchain/sdk up and running with Eclipse Indigo on Windows 7 Home Premium.

Used it to compile a demo from the SDK (Polyphonic), copied the resultant PBP and SFO to my PSP, worked a treat.

Now I just have to learn C, MIPS and the PSP system hardware - simple really - lol.

Hopefully my past programming experience in Visual Basic, 6502,6809 and 68k assembly will prove useful.

Once again - thanks for your help.

Praed0r
PSVita 2.02 Stock - 16Gb
PSP 3003 6.60 PRO-B10 - 24Gb
PSone - with flip up screen
PS2 Slim - with flip up screen
PS3 Phat - 320Gb Stock F/W
Tablet S - Rooted - ICS 4.0.3 - 24Gb
Nexus 7 32G - Rooted JB
Kindle Fire HD 8.9 32Gb Rooted - CM10.1
praed0r
 
Posts: 62
Joined: Sat Mar 17, 2012 11:28 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby SsJVasto » Tue Apr 24, 2012 7:42 pm

praed0r wrote:Used it to compile a demo from the SDK (Polyphonic), copied the resultant PBP and SFO to my PSP, worked a treat.

Yeah, you don't need the SFO file, only the EBOOT.PBP is needed after compilation.

praed0r wrote:Now I just have to learn C, MIPS and the PSP system hardware - simple really - lol.

Well, C is a given, I suggest C++, simply for the Object-Oriented aspect, but if you go too far (Friend functions, operator overload, exceptions) the PSP can't really take it... The SDK was build for C, but the C++ compiler/linker allows normal class use (like heritage, polymorphism, etc).

praed0r wrote:Hopefully my past programming experience in Visual Basic, 6502,6809 and 68k assembly will prove useful.

Well, VB is pretty much only useful to develop WIN32 applications, like tools to manage your PSP. If you know what VB is like, you should have basic understanding of "Class", "Public", "Private", "Protected", etc. Assembly isn't really useful in PSP programming, unless you want to manually alter a savefile for HBL, or if you're like me and like working with hexadecimal values. One good point of knowing assembly is that you know what data-structures (float, int, char) look like in memory, which greatly helps in means of optimization. Considering the PSP only had 32MB of RAM (24MB accessible, 8MB reserved), you'd better get used to counting bytes!

(I say that because I like to make 3D stuff, and push the limit of my PSP... Make something so heavy that it lags, then optimize, optimize, optimize!)

praed0r wrote:Hopefully my past programming experience in Visual Basic, [...] will prove useful.

Visual Studio isn't a bad language, it's just very heavy and wordy. If you want a good idea of what to expect on PSP (or if you want adaptable information) you should check the following subjects:
- Linux case-sensitivity;
- Linux Posix threads;
- OpenGL graphics;
- OpenAL sound;
- SDL (for the input methods);
- BSD-style sockets.

I think that's pretty much it, everything else on PSP is standard C, like any other OS/platform.

:)
PSVita Model PCH-1001 (OFW 1.81);
PS3 Model CECH-2101B (OFW 4.31);
PSP Model PSP-2001 (God of War Edition)(CFW 6.60 PRO-B10);
PSP Model PSP-1001b (CFW 4.01-m33 + Kernel Plugin);
User avatar
SsJVasto
 
Posts: 35
Joined: Wed Mar 21, 2012 5:24 pm
Location: Canada

Re: How do I link PSPtoolchain to Eclipse ?

Postby m0skit0 » Tue Apr 24, 2012 8:36 pm

SsJVasto wrote:Well, C is a given, I suggest C++, simply for the Object-Oriented aspect

Myth: "object-oriented is better". Depends on what you want to code.

SsJVasto wrote: If you know what VB is like, you should have basic understanding of "Class", "Public", "Private", "Protected", etc.

Depends on what VB version he's used to.

SsJVasto wrote:Assembly isn't really useful in PSP programming

Again, depends on what you want to do.

SsJVasto wrote:if you're like me and like working with hexadecimal values

You don't need assembly to work with "hexadecimal values" (all values are hexadecimal; hexadecimal is just a numbering system). All programming languages work perfectly with hexadecimal representation.

SsJVasto wrote:One good point of knowing assembly is that you know what data-structures (float, int, char) look like in memory, which greatly helps in means of optimization.

Myth: "coding assembly will give you more optimized code". C compiler will optimize your code better than you do manually. And anyway, optimization is the very last step of coding. Wasting time optimizing too soon is a bad idea.

SsJVasto wrote:Linux case-sensitivity

Do you mean filesystem case-sensivity? In which case, you're wrong: PSP uses FAT32 as filesystem, and AFAIK it has no case-sensivity support. PSP's driver definitely has no case-sensivity. And anyway Windows also can have case-sensivity in files if you turn that on but only for NTFS. Otherwise I don't know what you mean by case-sensitivity.

SsJVasto wrote:Linux Posix threads;

Sorry but PSP has nothing like POSIX or Windows threads. PSP's threads are very primitive. PSP has not even real multitasking abilities. PSP threads must give up CPU so other threads can run. Kernel does not implement anything to give a fair share of CPU time. In fact you need also to manually let kernel threads execute, otherwise the Syscon will shut up the PSP.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby SsJVasto » Wed Apr 25, 2012 1:11 pm

m0skit0 wrote:
SsJVasto wrote:Well, C is a given, I suggest C++, simply for the Object-Oriented aspect

Myth: "object-oriented is better". Depends on what you want to code.

D'uh... You wont make 3 objects linked together to overload operators and handle exceptions to display "Hello World". Considering it's a PSP, mostly Games and Applications will be developped, in which case it's good to have objects such as "Player" "Game" or "Model"/"Sprite". And the fact that you don't need to use object-oriented is true, but we're not in 1991. Objects are very useful in pretty much all/any context...

m0skit0 wrote:
SsJVasto wrote:Assembly isn't really useful in PSP programming

Again, depends on what you want to do.
SsJVasto wrote:One good point of knowing assembly is that you know what data-structures (float, int, char) look like in memory, which greatly helps in means of optimization.

Myth: "coding assembly will give you more optimized code". C compiler will optimize your code better than you do manually. And anyway, optimization is the very last step of coding. Wasting time optimizing too soon is a bad idea.


All I meant is that if you know assembly, you can produce much more optimized code and will understand the PSPSDK fairly better. Here are some examples of what I mean by optimization (and the Compiler does not handle this)

Code: Select all
If you want to store a number between 1 and 50, you should use an unsigned char (u8) instead of an int (1byte vs 4bytes);
Using bitmasks, you can store 8 boolean values in a single byte, instead of declaring a bool that takes 1 byte on its own;
Sacrifice RAM to gain CPU or vice versa (I like to use the least RAM possible, even if I gain a few cycles of work)


You also said that optimization should be the last step. Well, that's half true... You always need to "analysis phase" where you need to figure out what you need in your project. You can omit this step, but if you forgot a detail while implementing some structure, you'll need to rework them and possibly your algorithms, as well. Also, there's a flag in your C/C++ compiler that tells it how much to optimize your code. By default, it's a -O2 (optimization level: 2), but you can specify on of {0, 1, 2, 3}, in which 0 uses more RAM, and 3 uses more CPU.

m0skit0 wrote:
SsJVasto wrote:if you're like me and like working with hexadecimal values

You don't need assembly to work with "hexadecimal values" (all values are hexadecimal; hexadecimal is just a numbering system). All programming languages work perfectly with hexadecimal representation.
All I meant is that it's useful if you want to use bitmasks, shift registers, or manually manipulate hex values.

m0skit0 wrote:
SsJVasto wrote:Linux case-sensitivity

Do you mean filesystem case-sensivity? In which case, you're wrong: PSP uses FAT32 as filesystem, and AFAIK it has no case-sensivity support. PSP's driver definitely has no case-sensivity. And anyway Windows also can have case-sensivity in files if you turn that on but only for NTFS. Otherwise I don't know what you mean by case-sensitivity.

AFAIK the PSP is case-sensitive. I had some issues when implementing my music player with the filename (extension was .MP3 instead of .mp3). The only difference I saw was the SAME restriction as in linux: When a filename/foldername is ALL CAPITAL, the linux filesystem will recognize the file "FILENAME" as well as "filename". You can see this behaviour on PSP with your folders. When you go to the SEPLUGINS/ folder, if you put "GAME.TXT", after a reboot it will be called "game.txt", but if you put "Game.txt" or "GAME.txt", the filename will stay the same. I had the same issue on my Debian machine: I had a "DOWNLOADS/" folder, but my script stopped working because it sometimes saw "downloads/".

PS: FAT32 is case-sensitive in linux.

m0skit0 wrote:
SsJVasto wrote:Linux Posix threads;

Sorry but PSP has nothing like POSIX or Windows threads. PSP's threads are very primitive. PSP has not even real multitasking abilities. PSP threads must give up CPU so other threads can run. Kernel does not implement anything to give a fair share of CPU time. In fact you need also to manually let kernel threads execute, otherwise the Syscon will shut up the PSP.

Yes they're basic, but the fact it's not "real multitask" isn't the language's fault, it's the hardware's. Every single mono-core (non dual/triple/quad/cell cores) is technically "non-multitasking". The difference is the PSP's Scheduler is priority-based, and that can be confusing. No, 2 threads never run at once on PSP, nor do they on a Pentium4 machine. Priorities 1-11 are reserved, where 11 is the Callback Thread (the 10 other are hardware-based threads, like keeping the screen alive, or WiFi transfers that don't halt the CPU). I have 4 threads in my game engine, and I don't think it lags, nor do I see the threads as primitive. It's just hard to debug the threads, because if a single thread crashes, the whole program crashes, and you need to figure out where it crashed...
PSVita Model PCH-1001 (OFW 1.81);
PS3 Model CECH-2101B (OFW 4.31);
PSP Model PSP-2001 (God of War Edition)(CFW 6.60 PRO-B10);
PSP Model PSP-1001b (CFW 4.01-m33 + Kernel Plugin);
User avatar
SsJVasto
 
Posts: 35
Joined: Wed Mar 21, 2012 5:24 pm
Location: Canada

Re: How do I link PSPtoolchain to Eclipse ?

Postby m0skit0 » Wed Apr 25, 2012 2:43 pm

SsJVasto wrote:Considering it's a PSP, mostly Games and Applications will be developped

And hacks, and then C is better.

SsJVasto wrote:And the fact that you don't need to use object-oriented is true, but we're not in 1991. Objects are very useful in pretty much all/any context...

As I said: myth. Read this (for example). You can search around the interwebs why OOP is not that wonderful.

SsJVasto wrote:All I meant is that if you know assembly, you can produce much more optimized code

As I said: myth. Compiler will optimize you code anyway. And your example has nothing to do with assembly: that's knowing how to program correctly, not knowing assembly. And anyway, as I said, compiler will optimize that for you in most cases.

SsJVasto wrote:the fact it's not "real multitask" isn't the language's fault, it's the hardware's

Both hardware and software. And anyway, C has no threads by its own, it only uses what the OS offers. So "isn't the language's fault" means nothing in this context.

SsJVasto wrote:The difference is the PSP's Scheduler is priority-based, and that can be confusing

All OS have priority-based schedulers. PSP's multitasking is preemptive as I said: you have to release the CPU manually. This is primitive.

About the FAT32, I don't want to argue until I've checked it, but I won't check, so I'll just STFU.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby JJS » Wed Apr 25, 2012 4:27 pm

Just want to chime in on the 32 bit vs. 8 bit example. It won't work out to saving memory in reality. The PSP CPU can only access 4 byte aligned memory, this means a 1 byte variable will cost you just as much as a 4 byte variable in terms of memory usage. EDIT: Not true, sorry.

Also the -O3 option will actually cost more RAM than -O2 because they cause aggressive loop unrolling and inlining. This might actually make your performance worse because the program doesn't fit in the cache anymore. The PSPs cache is tiny and each instruction is 4 byte long, so it is already crowded in there.

Another thing about C++ vs. C usage on the PSP: Since C++ always passes the this-pointer in a method call it costs performance each time and forces parameter passing on the stack for methods with 4+ parameters (only $a0-$a3 are used for parameters, then it must go through the stack). Also it means more code obviously.

About the thread crashing: If you have an exception handler installed (like PSPLink), it is possible to recover from crashed threads. I have often seen single threads crash while the others run on while developing on HBL.

PSP's multitasking is cooperative btw. and not preemptive.
JJS
Big Beholder
 
Posts: 1516
Joined: Mon Sep 27, 2010 2:18 pm

Re: How do I link PSPtoolchain to Eclipse ?

Postby SsJVasto » Wed Apr 25, 2012 8:31 pm

JJS wrote:Just want to chime in on the 32 bit vs. 8 bit example. It won't work out to saving memory in reality. The PSP CPU can only access 4 byte aligned memory, this means a 1 byte variable will cost you just as much as a 4 byte variable in terms of memory usage.
But what about arrays? because the GL functions (sceGu(m)DrawArray(), etc) can accept u8 for its (x,y,z) and (u,v) coord, but if it aligns all u8 into u32, I don't see the advantage of using smaller variables anymore...

JJS wrote:Also the -O3 option will actually cost more RAM than -O2 because they cause aggressive loop unrolling and inlining. This might actually make your performance worse because the program doesn't fit in the cache anymore. The PSPs cache is tiny and each instruction is 4 byte long, so it is already crowded in there.
Indeed, you're right, I mixed up the order. -O[0-3] where 0 is optimized for RAM and 3 is optimized for CPU.

JJS wrote:Another thing about C++ vs. C usage on the PSP: Since C++ always passes the this-pointer in a method call it costs performance each time and forces parameter passing on the stack for methods with 4+ parameters (only $a0-$a3 are used for parameters, then it must go through the stack). Also it means more code obviously.
Yes, you're right about the this pointer, but in some cases, if you have a big enough class, it's better to just pass a 4-byte pointer, rather than 3 INT and a FLOAT, you know? I'd rather do
Code: Select all
// 1 invisible pointer (4 bytes)
Vertices->Render();
than
Code: Select all
// 0 invisible pointers, 1 variable (int) and 3 pointers (16 bytes)
Render(qty, vertXYZ, normXYZ, texUV); //considering vertXYZ, normXYZ and texUV are arrays


Theoretically (unless my mind is warped) these 2 codes should be the same:
Code: Select all
class TestClass
{
public:
  int arraySize_;
  int *array_;
  int strLength_;
  char *someString_;

public:
  void SetIntArray(int arraySize, int *arr)
  {
    array_ = new int[arraySize];
    for( int i=0; i<arraySize; i++ )
      array_[i] = arr[i];
  }
  void SetString(int strSize, char *str)
  {
    someString_ = new int[strSize];
    for( int i=0; i<strSize; i++ )
      someString_[i] = str[i];
  }
};

Code: Select all
struct TestClass
{
  int arraySize_;
  int *array_;
  int strLength_;
  char *someString_;
};
void SetIntArray(TestClass *this, int arraySize, int *arr)
{
  this->array_ = new int[arraySize];
  for( int i=0; i<arraySize; i++ )
    this->array_[i] = arr[i];
}
void SetString(TestClass *this, int strSize, char *str)
{
  this->someString_ = new int[strSize];
  for( int i=0; i<strSize; i++ )
    this->someString_[i] = str[i];
}

If I recall, that's the type of interfacing you need to create if you want to use C++ classes in a PRX library. Object-Oriented isn't evil, nor is it a gift from God. It's just another way of categorizing your program into reusable modules. There are advantages (like I mentioned above) and there are disadvantages, as you mentioned. For myself, I use C++ for this reason:
All C is compatible in C++. I can structure my code accordingly so I can figure out what I'm doing, but I also have the wonderful printf() instead of std::cout, you have access to std::string (even though I still use char*, it's fun to be able to append from time to time). In C++, you can make a whole C program without using ANY C++ libraries or classes, but the other way around isn't true.

m0skit0 wrote:
SsJVasto wrote:The difference is the PSP's Scheduler is priority-based, and that can be confusing

All OS have priority-based schedulers. PSP's multitasking is preemptive as I said: you have to release the CPU manually. This is primitive.

I haven't seen this behaviour on PSP... You may be right, and if you are, I must have a fucked up PSP or something... I run in my game engine the Main Thread (runs on its own, started by XMB), turn on the Callbacks thread, turn on the Graphics thread, turn on the Controller thread, then the Music Thread, followed by the Music thread. I don't have to tell them when to play and when not to, and I haven't seen any lag on either of them... I guess the sceGuVBlankStart() (or whatever it's called) must pause the thread for 1/60-(drawing time) seconds, but again, that's not controlled by me. Can you elaborate on this a little? Maybe that's why I'm having random crashes XD
PSVita Model PCH-1001 (OFW 1.81);
PS3 Model CECH-2101B (OFW 4.31);
PSP Model PSP-2001 (God of War Edition)(CFW 6.60 PRO-B10);
PSP Model PSP-1001b (CFW 4.01-m33 + Kernel Plugin);
User avatar
SsJVasto
 
Posts: 35
Joined: Wed Mar 21, 2012 5:24 pm
Location: Canada

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

Friends

Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita