Help compiling to PIC chip

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
fdeck
Posts: 2
Joined: Fri Jun 12, 2015 1:45 am

Help compiling to PIC chip

Post by fdeck » Fri Jun 12, 2015 4:21 am

I'm an original Kickstarter supporter, and have been playing with my MicroPython board. I'd like to try the 16 bit PIC version, but need just a bit of hand holding: What commands were used to compile the code? I'm running MPLABX under Windows, and the process for using an existing makefile is utterly un-documented.

I would be perfectly willing to set up a PC with Linux if it would make things easier.

Meanwhile, thanks for creating this wonderful tool!

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: RE: Help compiling to PIC chip

Post by Damien » Fri Jun 12, 2015 7:23 am

fdeck wrote:What commands were used to compile the code?
Quite simply you just type "make" and it will build. But that requires a working make environment (which you can set up on Windows) as well as the mplabx command line compiler and linker.

You have 3 options: 1) get a working make environment going under Windows, 2) create an mplabx project and import all the needed uPy source files, 3) run Linux in a virtual machine and compile it in there.

I'd suggest the first or second option. If you go for the second option then you'll need to generate 2 header files by hand: mpversion.h and qstrdefs.generated.h

fdeck
Posts: 2
Joined: Fri Jun 12, 2015 1:45 am

Re: Help compiling to PIC chip

Post by fdeck » Sat Jun 13, 2015 12:43 am

Thanks. I'll give it a whirl. Did you original write it on a Windows machine? Would it be possible to share the .X project file? This is all just for a learning project, but it's much appreciated.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: Help compiling to PIC chip

Post by Damien » Sat Jun 13, 2015 5:24 am

I do not have a mplabx project file. You probably know better than me how to make one!

User avatar
bminch
Posts: 2
Joined: Mon Jun 22, 2015 12:00 am
Location: Massachusetts, USA
Contact:

Re: Help compiling to PIC chip

Post by bminch » Wed Jun 24, 2015 7:24 pm

On a related note, I am trying to build the pic16bit port of micropython under Mac OSX as a precursor to trying to get it running on another 16-bit PIC part (PIC24FJ256GB206). I had to change the path to XC16 from /opt/microchip/xc16/v1.24 to /Applications/microchip/xc16/v1.24, but otherwise I haven't made any other changes to the Makefile. When I attempted to build the project, it got to the point of trying to link everything together into an .elf file at which point it exited with the following error:

LINK build/firmware.elf
__TEXT __DATA __OBJC others dec hex
size: file: build/firmware.elf is not an object file
make: *** [build/firmware.elf] Error 1
make: *** Deleting file `build/firmware.elf'

I do have an Ubuntu machine with the Microchip tools installed on it and was able to get the project to build out of the box on that machine. I would really rather develop on my Mac, if possible. Does anyone have any ideas about why the linker might be trying to interpret the .elf file as an object file?

Brad Minch.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Help compiling to PIC chip

Post by dhylands » Wed Jun 24, 2015 8:36 pm

I had this problem when switching between a unix flavor of the build done on Linux and a unix flavor of the build on MacOSX. I was build essentially from a network drive.

So make sure that you remove the build directory.

If you still hit the problem, then it would be good to see the output by adding V=1 to the make command line.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: Help compiling to PIC chip

Post by Damien » Wed Jun 24, 2015 9:06 pm

If the error is just coming from running size on the output elf file then you can just remove that line from the Makefile.

The reason it's broken is because the Makefile is using the host "size" program instead of the target/cross-compile version of "size". So you might be able to fix it by using the right "size" binary.

Line 61 of the Makefile is what you should look at.

User avatar
bminch
Posts: 2
Joined: Mon Jun 22, 2015 12:00 am
Location: Massachusetts, USA
Contact:

Re: Help compiling to PIC chip

Post by bminch » Wed Jun 24, 2015 10:34 pm

There does not appear to be a target/cross-compiler version of size, at least not one that comes with the Microchip tool suite. It appears that the version of size that comes on a typical Linux installation understands .elf files, but the one that comes with Mac OSX does not. If I comment out line 61 of the Makefile, the build process goes through just fine.

Brad Minch.

EasyRider
Posts: 94
Joined: Wed Dec 30, 2015 8:17 am

Re: Help compiling to PIC chip

Post by EasyRider » Sun Jan 10, 2016 6:16 am

I am looking at setting up a Microchip development environment on Ubuntu system to compile pic-16 bit (24 and 33 parts) port of micropython.

Did anyone use Microchip XC16 compiler and which version supports optimization to compile micropython or did you use anything else?

All assistance and pointers would be appreciated.

Regards
John

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Help compiling to PIC chip

Post by devnull » Mon Oct 22, 2018 1:47 am

Has anybody recently succeeded in running on any PIC devices ??

Post Reply