Eclipse Development

I havent tried it, but give this a shot.


#!/usr/bin/env python

#Auto Makefile Generator
#Copyright under terms of GPL
#Based on Team 245's old Makefile....
#		Copyright (C) 2005  Team 245
#
#		This program is free software; you can redistribute it and/or modify
#		it under the terms of the GNU General Public License as published by
#		the Free Software Foundation; either version 2 of the License, or
#		(at your option) any later version.
#
#		This program is distributed in the hope that it will be useful,
#		but WITHOUT ANY WARRANTY; without even the implied warranty of
#		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#		GNU General Public License for more details.
#
#		You should have received a copy of the GNU General Public License
#		along with this program; if not, write to the Free Software Foundation,
#		Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


import os

DEBUG=False
VERSION="0.1.92 (0.2 beta 3)"

def printGPLBanner():
	print "Makefile Generator, version "+VERSION+", Copyright (C) 2005 Adam-Bots"
	print "This software comes with ABSOLUTELY NO WARRANTY"
	print "This is free software, and you are welcome to redistribute it under certain conditions; See the accompanying license for details"
	
def isCygwin():
	import os;
	return os.platform=='cygwin'

def isLinux():
	import os;
	return os.platform.beginswith('linux')

def mccPath():
	#Find path to the MCC folder.
	if isCygwin():
		pass
def sprint(msg,level=0):
	# Prints a message of a given verbosity:
		#Level 0 : Print regardless of status
		#Level 1 : Print if DEBUG is set
	if level == 0:
		print msg
	elif level == 1:
		if DEBUG:
			print "DEBUG:",msg
	else:
		print msg
def mccCommand():
	return "mcc18"
def mccArgs():
	return "-D_FRC_BOARD -w3 pa=3 -O+ -nw=2066"
def linkerCommand():
	return "mplink"
def mp2hexCommand():
	return "mp2hex"
def ifiLoaderCommand():
	return "picloader_textmode"
def ifiSerialDevice():
	return "/dev/ttyS0"
def ifiReadLogfile():
	return "./read.log"
def codePath():
	unixish_path="Z:"+os.getcwd()+"//"
	return unixish_path.replace("/","\\")
def libPath():
	return "/opt/mcc18/lib"
def includePath():
	return "/opt/mcc18/h"
def includePathWindows():
	return "Z:\\\\opt\\\\mcc18\\\\h"

printGPLBanner();
print
print
print

sprint("Opening the Makefile",1)
print
outfile=open('Makefile','w')
outfile.write('#This is automatically generated by the configure.py script
#Keep your dirty hands off');
outfile.write("
")
outfile.write('#Run ./configure.py to generate a fresh one.')
outfile.write("
")
outfile.write('MCC18='+mccCommand())
outfile.write("
")
outfile.write("PIC=18F8722 # Don't change")
outfile.write("
")
outfile.write("ARGS="+mccArgs())
outfile.write("
")
outfile.write("LINKER="+linkerCommand())
outfile.write("
")
outfile.write("MP2HEX="+mp2hexCommand())
outfile.write("
")
outfile.write("IFILOAD="+ifiLoaderCommand())
outfile.write("
")
outfile.write("SERIAL_DEV="+ifiSerialDevice())
outfile.write("
")
outfile.write("READLOG="+ifiReadLogfile())
outfile.write("
")
outfile.write("LIB_PATH="+libPath())
outfile.write("
")
outfile.write("CODE_PATH="+codePath())
outfile.write("
")
outfile.write("INCLUDE_PATH="+includePath())
outfile.write("
")
outfile.write("INCLUDE_PATHW="+includePathWindows())
outfile.write("
")
outfile.write("



")


sprint("Enumerating Target Object Files...")
import os;
all_targets=""
pipe=os.popen("find . -maxdepth 1 -name \"*.c\" | gawk '{gsub(/\\.c/,\".o\");print}' | uniq",'rt') 
line=pipe.readline()
while line != "":
	all_targets+=line[2:-1]
	all_targets+=" "
	line=pipe.readline()

all_targets.rstrip()

outfile.write("ALL_TARGETS="+all_targets);
outfile.write("
")
sprint("Enumerating Header Files...")

pipe=os.popen("find . -name \"*.h\"",'rt')
line=pipe.readline()
headers=""
while line != "":
        headers+=line[2:-1]
        headers+=" "
        line=pipe.readline()
headers.rstrip()


outfile.write("INCLUDE_FILES="+headers);
outfile.write("
")
outfile.write("############ Targets: ")
outfile.write("
")
outfile.write("default: FrcCode.hex")
outfile.write("
")

sprint("Writing static targets...")
outfile.write("""
#Remove all the individual file backup (The files ending with ~)
#NOTE that this does NOT remove your tbz2 backups!
clean-backup-files:
	@echo -e "Removing all the ~ backup files your annoying editor makes..."
	@find . -name "*~" |xargs rm -f

#Removes all compiled files from the directory
clean: clean-backup-files clean-deps nohex
	@echo -e "Cleaning compiler intermediate files..."
	@rm -rf *.o *.err

#Remove deps folder
clean-deps:
	@echo -e "Cleaning dependency folder..."
	@rm -rf .deps
	@mkdir .deps
	@touch .deps/dummy

#Remove hexfiles
nohex:
	@echo -e "Cleaning linker output and hex files..."
	@rm -rf *.hex *.cod *.cof

#These all start the IFI Loader.
safeload: prettycode clean check load
load: FrcCode.hex
	$(IFILOAD) FrcCode.hex $(SERIAL_DEV)

read:
	@echo -e "Monitoring $(SERIAL_DEV) for data"
	@echo -e "Output will also be logged to $(READLOG)"
	@echo -e "---------"
	@cat $(SERIAL_DEV) | tee $(READLOG) || /bin/true
	
	
prettycode:
	@echo -e "Using indent to autoformat your .c and .h files..."
	@indent *.c *.h
all: clean FrcCode.hex
%.o: %.c
	@echo -e "Compiling $@..."
	@echo -e "1.   Checking Dependencies for $@"
	@cpp -nostdinc -isystem $(INCLUDE_PATH) -M -MP $< -MF .deps/$*.deps
	@echo -e "2.   Launching Compiler..."
	@echo -n "A thought to keep you occupied:  "
	@fortune -s || echo "GET FORTUNE"
	@$(MCC18) -p=$(PIC) -fo $@ $< /i\\""$(INCLUDE_PATHW)"\\" $(ARGS) 
	@echo -e "Done with $@."




FrcCode.hex :  $(ALL_TARGETS) $(INCLUDE_FILES)
	@echo -e "Linking..."
	$(LINKER) /l\\""$(LIB_PATH)"\\" \\""18f8722.lkr"\\" $(ALL_TARGETS) \\""$(CODE_PATH)FRC_library.lib"\\" /m\\""FrcCode.map"\\" /o\\""FrcCode.cof"\\"
	$(MP2HEX) FrcCode.cof



.deps/*: 
	@echo -e "Creating Dependency Makefiles..."
	@mkdir -p .deps
	@touch .deps/dummy
	@echo -e "Done!"

include .deps/*
""")
print
print

sprint("Makefile is generated, setting up working directory....")
os.system('rm -rf .deps')
os.system('mkdir .deps')
os.system('touch .deps/dummy')

print
print
print

sprint("Finished. To build, run 'make'")


EDIT: I got Eclipse up and running on my XP laptop. I got it compiling code and all. Ill be grabbin a copy of Astros code and making sure it all runs on windows.

I got a basic distro of Eclipse, CDT, and the toolchain up.

Win32 - Eclipse 3.2.1, CDT 3.1.1, MCC18 toolchain (com.astro73.fdt version) (130.6 MB)

This package is for Windows. This should allow teams to get started using Eclipse quickly. All settings are at defaults.

NOTE: This package does not include Cygwin Make. You must have either Cygwin make or a native Win32 Make. MinGW Make will not work. If you get errors about being unable to find “W:” or similar, you are using MinGW Make.

To make your own version:

  1. Download the eclipse archive, extract
  2. Download the CDT archive file, extract to the same location
  3. Grab the com.astro73.fdt.mcc18.toolchain JAR file from the above file and put it in your plugins dir
  4. Compress the entire directory.

[edit]This project got approved on sourceforge: https://sourceforge.net/projects/firstclipse/. No code up yet, but the project’s there. I’ll save the joining process for another post.[/edit]

First, I forgot to say that mirroring the download is ok.

I’ve moved the subversion to SourceForge, and the jar file for what I posted earlier is in the downloads section on the project page.

If you want commit access, you will need a SourceForge ID. Please send that to me and I will add you to the project.

In order to develop the plugins, you will need:

  • Eclipse SDK 3.2+
  • Eclipse CDT SDK
  • Subclipse (use the instuctions for Callisto)
  • PyDev (only needed if you want to work on the wrapper scripts)

Note that if you just installed PyDev, you need to go to the preferences and configure your interpreters.

Instructions on loading the projects:

  1. Go to File > New > Project…
  2. Select SVN > Checkout Projects from SVN. Hit Next.
  3. Select Create a new repository location. Hit Next.
  4. Enter https://firstclipse.svn.sourceforge.net/svnroot/firstclipse as the URL. Hit Next.
  5. Accept the SSL fingerprint (I recomend permanently)
  6. When asked for the folder, select everything under trunk (except for mcc-wrapper if you’re not dealing with the Python stuff).
  7. Hit Finish.
  8. Wait. It will probably take awhile. Grab another dew. Brew some coffee. Think about how awesome this will be when done.

When all is said and done, you should have 6 plugins, 1 site, 1 feature patch, and maybe 1 other project (mcc-wrapper).

Almost all of it is just framework. Hardly any real code.

Notes:

  • This is the bleeding edge. It may not always work or even compile.
  • I recomend setting your workspace to UTF-8, but this is not required.
  • Please use the Java 1.4 compiler.

Here is some information for those of you who are not familiar with Eclipse.

Eclipse is an extensible, cross-platform IDE. With the C/C++ Development Tooling (CDT), it will work with and compile C code. Subclipse allows for the easy usage of Subversion. (I’ve also found Eclipse to be flexible. I run it off my flash drive.)

This stock configuration works fine for FIRST. I’ve used it for 2 years so far, and will use it for a 3rd. There are, however, some rough edges and other tools that are not cross-platform. Things like slightly incomplete syntax highlighting, IFI_Loader, error reporting, and Win32 GNU Make.

The goal of FIRSTclipse is to polish an already usable program. We aren’t writing something from scratch. We’re adding on to a very excellent application.

The current target list:

  • compiler toolchain support
  • Error parser
  • Library/binary parser
  • More complete syntax handling
  • HEX file loader
  • Wrapper scripts to run mcc18 under Linux
  • Documentation for all of this.

Things that will be provided:

  • A complete “extract and go” package of everything you need (except MCC18, which we can’t distribute)
  • An installer for GNU Make (Windows)
  • A project for the default code

My hope is that there will be some mentors involved with this, helping or coding alongside the students.

Any questions may be posted here or PM’d, emailed, IM’d, etc. to me.

I can whip out a quick NSIS installer for the Win32 version if you need it.

Questions:

  1. Without an error parser, what exactly happens when there is a compiler/linker error? How does a developer receive feedback?
  2. Can one use IFI_Loader with this project? Other than non-W32 compatibility, why would you not
    want to use IFI_Loader? 1. How easy will it be to finish the C18 syntax highlighting support? What skills are needed/can I help?
  3. How easy is it to go back and forth with a given code base from Eclipse to MPLAB?
  4. And is this project truly ready to go as far as compiling C18 code goes? Eg. what steps are needed, from downloading the Sourceforge project, to start downloading code to the PIC?
  5. What is compiler toolchain support?
    *]Does MPLAB support library/binary parsing? Or is this just does help with code completion?
    Thanks in advance, and let me know how I can help/where you need it the most, even if it’s just writing documentation. I want to see this working really soon.

Answers:

  1. The output of the compiler does show up in the console tab, so you can see errors, however, apparently, in the SourceForge version, they are not parsed. This is fixed in the updated version of my original plug-in but I haven’t merged that into the SF project yet, because of naming convention issues with the plug-in.
  2. One can use IFI_Loader with this project? Mainly it’s to provide support for non W-32 toolchains; however, it’s also nice to be able to just right click on a file and select something like “Load to RC…”
  3. How easy will it be to finish the C18 syntax highlighting support? What skills are needed/can I help?
    This is the hard part, in the current version of the CDT there isn’t an easy way to add new keywords. However, I believe this will change in CDT 4. Since they plan on adding Visual C support, the editors are undergoing major changes.
    The only problems right now are that certain keywords specific to the C18 dialect of C (e.g., rom, ram, near, far, overlay), are not highlighted, but everything else is highlighted and works properly.
  4. How easy is it to go back and forth with a given code base from Eclipse to MPLAB?
    This is very easy, you just have to have keep the MPLAB project files when you import your code into eclipse. Then you can use MPLAB to edit the code whenever you want to use MPSIM or anything like that. However, certain features of Eclipse like local history (in which Eclipse has it’s sort of own internal revision control system), won’t work as well, since Eclipse doesn’t know what you have changed.
  5. And is this project truly ready to go as far as compiling
    C18 code goes? Yes, if you want to see what a version looks like (since there isn’t an update site on sourceforge yet) you can download eclipse and the CDT, and then install the plug-ins from the http://team254.bcp.org/update_site/ update site. The other issues mentioned are still there, but I believe it is a much better alternative to MPLAB already.
  6. What is compiler toolchain support?
    Basically, allowing you to set options in the Eclipse GUI for the compiler.
    Eclipse then automatically generates makefiles for the compiler toolchain (i.e., MCC18 and MPLINK, and maybe later MPASM), and then compiles the code.
  7. Does MPLAB support library/binary parsing? Or is this just does help with code completion?
    To the first question, I don’t believe so. To the second question, I think it does, but not as much as you might think, since it can already get a lot of information from the header files.
  8. In terms of other problems, such as the lack of Win32 GNU Make, you can either use MSYS (not MinGW) or Cygwin, but they are slightly larger downloads.

There are two big features of Eclipse I failed to mention:

  • Autocompletion
  • Content indexing

Autocompletion means if you start typing a function, eclipse will show a list of possible functions, and then show you its arguments when you select one.

Content indexing means that if you select a function or a variable and hit F3, Eclipse will show you where it is declared. Ctrl+F3 shows you where it is defined (the actual code).

What is in the SourceForge downloads area is just the additions I made to Eclipse and the CDT in my own distribution on my website. I did not put the full Eclipse package in SF because of its size.

The update site of the whole project is http://firstclipse.sourceforge.net/update/. Note that this includes everything, so you’ll get some odd additions to Eclipse with no real functionality.

The error parser I believe is fine, but I have had problems compiling it. It seems that if you compile the plugins in the Java 5.0 mode, it won’t find some classes. I can make a release of it, and (if people verify that it’s ok) add it to the extract-and-go package.

The addition of the loader will mean that we can add functionality to it. Storing and retrieving EEPROM settings. Reading hex files. Whatever. We can also add virtual serial ports; in addition to using hardware, you could use, eg, a “serial server” instead. (esp useful if your development system has no serial ports. This is not for USB-Serial adapters.) Note that this is still under development, and I would not recommend using it until we work out the details.

Here’s my list of priorities (feel free to critique as fit):

  1. Toolchain
  2. Error parser
  3. mcc18/wine wrappers
  4. loader
  5. binary parser
  6. syntax highlighting

Also, I’m considering adding these additions:

  • Dashboard
  • CMUcam2 miniapp

Both of these would use the same serial library used by the loader code.

The serial called something I’m/we’re developing called JSerial. I looked at the “standard” Java library (JavaComm), and I found that it was a pain to gather and install, there was no source available, and the latest version had no Win32 support. (Not even getting into licensing problems.) The current version is in SVN. (Or will be in a few minutes.)

Thank you for the offer to handle NSIS, but Eclipse requires no installation. You extract it and run it. And I know NSIS already. (If people would like an installation program, we can add that.)

Check out http://sourceforge.net/project/showfiles.php?group_id=62859 from some Java code using CMUCam2. For serial communication I have use http://users.frii.com/jarvi/rxtx/ and liked it.

Good news! FIRST didn’t introduce a radically different controller! No dramatic changes need to be made!

:o I should have inspected RXTX more after discarding JavaComm.

As for the camera stuff, I’ll look into it. I won’t be able to use the GUI code, since it’s written with AWT. We’ll see how it is.

I go to http://firstclipse.sourceforge.net/update/ then I click on the link to com.astro73.fdt_0.0.001.jar

I get this:

An error has been encountered in accessing this page.

  1. Server: firstclipse.sourceforge.net
  2. URL path: /update/features/com.astro73.fdt_0.0.001.jar
  3. Error notes: File does not exist: /home/groups/f/fi/firstclipse/htdocs/update/features/com.astro73.fdt_0.0.001.jar
  4. Error type: 404
  5. Request method: GET
  6. Request query string:
  7. Time: 2007-01-08 19:02:45 PST (1168311765)
    Reporting this problem: The problem you have encountered is with a project web site hosted by SourceForge.net. This issue should be reported to the SourceForge.net-hosted project (not to SourceForge.net).
    If this is a severe or recurring/persistent problem, please do one of the following, and provide the error text (numbered 1 through 7, above):
  1. Contact the project via their designated support resources.
  2. Contact the project administrators of this project via email (see the upper right-hand corner of the Project Summary page for their usernames) at user-name
    @users.sourceforge.net If you are a member of the project that maintains this web content, please refer to the Site Documentation regarding the project web service for further assistance.

How do I set up my development environment?

Thanks in advance,
Robinson

Very weird. That should work. I’ll look at it when I can access it.

In the mean time, I put a new version of the extract-and-run at http://astro73.com/download/eclipse/. It’s the “full” file. It includes the toolchain, the error parser, and Subclipse. It is not, however, tested, so I can’t say if it will work. This is the version I’ll use to setup my team if it works.

I’ll post the jars for those two plugins on SourceForge later.

As for the update site, I’ll make sure to upload the new version later. (The major change is in the branding.)

Changes in the toolchain plugin:

  • Added targets for 2004-2005 controllers vs. 2006-2007 controllers
  • Fixed branding

EDIT: Ah. It’s a bug. The actual file is “…_0.0.1.jar”.

i would definitely like to use it

Wow…I know I’m kinda late in the proccess here but I think this is a great devolpment. I started using Eclipse in my programming classes in college and am in love with it. I helped out with the programming back in the day and I know how big of a headache MPLAB could be. I don’t have any real experience writing extensions but I’m going to install the beta version on my box and try it out.

Great job guys

I’m wondering what happened to this project. I’ve decided to switch from Visual Studio to Eclipse for most of my general coding primarily because I remember hearing a while a go that it’s possible for me to code for FRC in Eclipse. By the way, will this project be able to load code onto an RC directly from Eclipse on a Win64 or Win32 system? I’m running Windows Vista 64-bit here at home and our team uses a Win2k laptop, a WinXP 32-bit desktop, and two Win2k desktops. As one of the programmers I end up coding at home and on the laptop mostly. I’m just wondering just how much needs to be done for us to get a working beta before the start of the next season.

I’ve gotten the Eclipse IDE, but it won’t work on my computer. It says I need the Java Virtual Machine 1.5 or higher, but I can’t seem to find it. Does anyone get me a link to where I can get it from?

BTW, it says I have JVM 1.4.2_14.

The current version of Java is Version 6 Update 3. Here](http://www.java.com/en/download/windows_xpi.jsp?locale=en&host=www.java.com) is the link for the latest version of Java.

It says that I am up to date on the latest download.

I got curious and looked in my hard drive. What I found was that right in the C Drive was the file Eclipse keeps referring to what I have. Moving into my program files, I found the Java folder. Here’s what I found. Now what? Any ideas?





Just delete everything in your Java folder except for the JDK 6.01_03 and JRE 6.01_03. Java doesn’t remove old versions when it updates, since some Java apps require certain versions of the JVM. The good news is that clearing out all of those old ones will probably free up a gigabyte or more of storage space :slight_smile:

My team is all linux right now, and we currently use emacs with the configure python script. I have limited knowledge in eclipse, but would like to help out with this project. I hope its still alive!

However, I keep hearing that FIRST will switch RCs in 2009. Nobody seems to know what this means exactly, but I hope it will still work with this plugin.