1. Download Eclipse from http://www.eclipse.org/downloads. I think that page detects your browser agent and puts the right download at the top of the list. I grabbed the linux one.
2. Untar it somewhere (I used /usr/local/bin/eclipse). It comes as a prebuilt exe so no compiling needed.
3. Run Eclipse as root, or at least with a user that has write permission to the Eclipse directory. The interface will be crappy but functional. Don't worry.
4. Go to Help -> Software Updates, select "Find new software to install".
5. Add a new Remote Site, name it "CDT" and set the URL to http://download.eclipse.org/tools/cdt/r ... eclipse3.1. Uncheck any other update site options (I have Callisto and Eclipse), make sure only your new CDT entry is checked. CDT is the C/C++ extensions for Eclipse.
6. Make sure "Ignore features not applicable to the environment" is checked
7. Click Finish. Eclipse will go and check for new updates. It will find CDT, just check the entire tree (ie: click the top level checkbox). Hit Next, accept the license, let it run. It'll take a while if you're on a slow connect, lots to download. Did you forget to run Eclipse suid root? Bad luck, you're going to have to redownload everything :)
8. When it's finished it will prompt you to either restart the environment, quit Eclipse or carry on (not sure of the exact wording now, you'll see the prompt). Select "Restart Eclipse", or, if I've just suffered amnesia and there isn't an option, quit Eclipse then reload it as root. This is really really important because files are written during the reload.
9. When Eclipse has loaded, click the option to go to the workbench (far right icon/image thing). Go to Help - About, then click Plugin Details. If CDT installed you'll have lots of C/C++ items in the list.
10. Exit Eclipse again. Bored yet?
11. Open a shell and edit <install>eclipse/plugins/org.eclipse.cdt.debug.mi.core_3.0.2/plugins.xml
12. Look for tag: point="org.eclipse.cdt.debug.core.CDebugger", in this node you'll see cpu="native", change this to cpu="*". Save and exit.
13. Run Eclipse again as root but with the -clean flag specified as a command line option.
14. Finally quit Eclipse. Now you can start using it properly.
We'll debug the SDK sprite sample as a demo. This assumes you have PSPLink and PSP-GDB working from shell correctly.
15. Load Eclipse under your normal user account. Yay, it looks like a 21st Century IDE.
16. Go File - New Project. In the dialog expand "C" and select "Standard Make C". Hit Next, name the project "Sprite". Hit Finish.
17. You'll be left with an empty project (or workspace, or solution for you Visual Studio people). On the left hand side you'll see what would be a tree thing for your project, with Sprite at the top. Right click in the panel and select Import
18. Select General -> FileSystem and hit Next. The next dialog is basically an import browser for existing code. Use the top browse button to go and select the pspsdk/samples/gu/sprite directory. Don't worry, this process doesn't affect the original, it will create a duplicate in your workspace folder (which is your home folder by default). Make sure you select all the files, sometimes Eclipse didn't select everything.
19. Now we need to fiddle the SDK code. There are relative paths to headers in the common/ directory - because Eclipse duped the project into the workspace folder these are now broken. Fix the paths in sprite.c AND in Makefile.
Ok, that's what you have to do to get PSP code loaded into Eclipse. One thing that's *really* annoying if you're a VS user is Eclipse won't build changed files unless they're saved (Imight be wrong but it wouldn't for me). So go Window -> Preferences, expand General and click on Workspace. In there check "Save before build". Will save your sanity when you wonder why your new build didn't get the code changes :)
20. Now you can go Project -> Build Project or Build All. You might need to make a random change and save again before the build works. If you got it all right Eclipse will pick up the Makefile, use psp-gcc, pop the console window to front and show you the build output. You're done. Now you could switch back to pcterm and ./sprite.elf, but don't do that just yet.
21. Add the -g flag to CFLAGS in the Makefile to indicate we want debugging symbols (line 5:)
Code: Select all
CFLAGS = -g -G0 -Wall -O2
23. Go Project -> Build Project. Check the output in the console to make sure the new -g flag in the Makefile was noticed.
Code: Select all
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -g -G0 -Wall -O2 -c -o sprite.o sprite.c
25. Go to your pcterm session and type:
Code: Select all
debug ./sprite.elf
26. A grand total of nothing should happen on your PSP, you'll see this in pcterm:
Code: Select all
host0:/> debug ./sprite.elf
host0:/> PSPLink GDBServer (c) 2k6 TyRaNiD/Lovely2
GDBServer: Loaded host0:/sprite.elf - UID 0x044C7627
28. Click on "C/C++ Local Application", then click the New Item button (the paper sheet with the yellow star thing).
29. This will pop a new entry into the list and bring up its settings on the left side of the dialog. Name it something like PSPGDB or whatever. On the Main tab, select the sprite project for "Project" and select sprite.elf for the "C/C++ Application".
30. Skip all the other tabs, go to the Debugger tab. In the Debugger field, drop down the selection and choose GDB Server. Check "Stop at Main on startup". Under the "Main" subtab on the Debugger tab, enter psp-gdb for the debugger. Drop down the connection options and choose TCP, set Hostname to "localhost" (or 127.0.0.1 if your box is retarded), set port to 10001.
31. Magically, if you got it all right, the Debug button at the bottom will spring into life. Click it!
32. Eclipse will look like it did nothing. Yes, this can be a dumb IDE IMO. But go to your usbhostfs session and (if you used -v option) you'll see all the GDB communications.
33. In Eclipse go to Window -> Open Perspective -> Debug. Yay, here's your debug stuff. As proof it works click the green arrow button that clearly looks like a Run option, and watch the PSP execute sprite.elf
Things I haven't quite figured out yet... Eclipse won't always show the values of vars. Also I can't get it to properly terminate the app on the PSP once you've clicked the run button (although you can terminate it properly if you've stopped at a breakpoint and are stepping over code). If anyone figures that out, let me know.
*edit* Tyranid says it's his fault, please fill his inbox with spam requesting it's fixed immediately ;)
Hopefully this will help someone, or at least provide a quick guide to trying out Eclipse. With a bit more work I'm pretty sure it can all be made mostly automatic.
Cheers...