Monday, March 17, 2014

MPLAB-X -- SDCC -- Fedora

I frequently use MPLAB-X (sadly, not entirely free as in speech) for PIC projects.  It works quite well even though it required me to go out and buy a new programmer.  Actually, I got two, both an ICD-3 and a PICkit 3.

Recently I needed to do an 8-bit project, and decided to use SDCC.  It isn't the most efficient compiler in the world, but it is free (as in speech and as in beer) and I kind of like it.  Since I've recently been doing a lot of 16 and 32 bit stuff, I haven't gotten piklab set up in ages, and besides, it doesn't work with the newer programmers.  And MPLAB-X does have an SDCC plugin.

Unfortunately, MPLAB-X apparently expects an older version of SDCC and it includes a couple of compiler switches that no longer exist.  Although this doesn't cause the build to fail, it does lead to annoying messages which might disguise warnings which I care about.

MPLAB-X-warnings

Although MPLAB-X allows you to add switches, it has no provision for removing switches, and I could not find a way to easily modify the defaults.

I did find that I could edit nbproject/Makefile-default.mk, but as soon as I added any files to the project, MPLAB wrote over the edits.

However, MPLAB provides a Makefile that doesn't get written over, and it has targets to be executed at various times during the build.  By using the .build-pre target, I could edit the other Makefile just prior to the build:

MPLABX-Makefile

But there is yet another (small) fly in the ointment. Because I have multiple programmers, I often create configurations for each programmer.  Now there is no longer a Makefile-default.mk but instead a Makefile-Red.mk and Makefile-Blue.mk (for the PICkit and ICD).  Fortunately, MPLAB provides a variable, CONF, with the name of the configuration, hence the ${CONF} in the edit.

Now by simply adding a line to the Makefile, my SDCC project builds cleanly and there is no concern about missing important warnings.

No comments:

Post a Comment