Chipkit Max32 example doesn't compile

I’m trying to compile an example project for my Chipkit Max32. It’s the Microdhippic32/arduino-blink example. It compiles and links fine for the default boards, a cerebot32mx4 and a pinguino32, but will not link for the mega_pic32 board, which is the Max32. (the compile is okay). This is a cut and paste from the log. Any assistance greatly appreciated. I’m using Platformio version ide 1.6.0 cli 3.1.0 on Linux Mint 17.3.
Linking .pioenvs/mega_pic32/firmware.elf
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtbegin.o:(.sdata+0x0): multiple definition of __dso_handle' /home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/../../lib/gcc/pic32mx/4.8.3/size/crtbegin.o:(.sdata+0x0): first defined here /home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/../../lib/gcc/pic32mx/4.8.3/size/crtend.o:(.dtors+0x0): multiple definition ofDTOR_END
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.dtors+0x0): first defined here
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.tm_clone_table+0x0): multiple definition of `TMC
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.tm_clone_table+0x0): first defined here
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/gcc/pic32mx/4.8.3/…/…/…/…/bin/pic32-ld: Link terminated due to previous error(s).
collect2: error: ld returned 255 exit status
*** [.pioenvs/mega_pic32/firmware.elf] Error 255

Just generate a project for the max 32 and copy/paste the blink.ino (which I probably would rename Blink.cpp) into the Max32 project.

Does it work ?

Hi Byran,
thanks for the reply. I tried what you suggested and I still get the same errors. Compiles okay but link gets errors in the crtbegin.o and crtend.o modules. Same problem if it’s called blink.cpp or blink.ino. (tried both).
:-\ Ian

Hi Ian,
I retried this morning and it still works for me. I can’t find how to generate the same errors.

Since it’s the linking step that fails, it’s not related to your max32 board. I’ll try to update my toolchain and I’ll come back to post the result.

What happens if you delete the toolchain-microchippic32 file in .platformio/packages/ ?

Hi Byran,
Tried deleting the toolchain, when I ran the build again it helpfully downloaded it again for me, ran the compile, and…
exactly the same errors.
Maybe I should completely deinstall PlatformIO and reinstall it from scratch.
I using Linux Mint 17.3 AMD 64 bit. Would that make a difference?..

I actually can’t tell you if that makes a difference. Maybe @ivankravets could answer that question.

That’s wierd because I’m using both Ubuntu and Kubuntu (amd64) and it works…

I’m curious to see what would happen if you reinstall platformIO from scratch as you said.

Well, i reinstalled. Actually I reinstalled Atom without PlatformIO, that was okay. Then I resinstalled PlatformIO again, which I think resinstalled Atsom again and the PlatformIO. Anyway nothing changed. I still get the same errors. I didn’t uninstall first, but I figured that shouldn’t be necessary. Maybe I should. Maybe there’s a corrupt library somewhere that doesn’t go away or get overwritten by a reinstall. Maybe there’s an odd setting somewhere. I have Ubuntu installed as well, maybe I’ll try it on that.
:-\ Ian

I used to finish uninstalling PlatformIO by supressing the .plaformIO hidden folder in /home/user/ (I’m not sure about the path but that’s the .platformio hidden folder in the user folder).

Maybe try that and try also on ubuntu. Let me know !

Well, tried it on Ubuntu, with mixed results. At first the example wouldn’t compile, got error messages about tone.o missing. Then it worked. Then it didn’t work again. Then it worked again. Now it seems to be stable, and working. Maybe it was downloading the Pic toolchain in the background while I was trying to compile or something. But, bottom line is it works. So there is clearly something amiss with my install on Mint. Absolutely no clue where to start looking… Aaahhh, the joys of computing. Maybe I’ll try your trick, delete (or move it somewhere) ~/.platformio. Maybe that will do something. Maybe tomorrow. It’s gone midnight in this neck of the woods, time for beddy bo boes for me :slight_smile:

Could you try this toolchain? Place it to ~/.platformio/packages/toolchain-microchippic32/ folder and keep package.json from previous version.

Hi Ivan,
Not entirely sure how to replace the toolchain. The library structure of the download in the link you gave me is quite different to the one already in the packages module. I tried just adding the new library to the existing folder but (of course) got the same error. So I tried deleting everything in the toolchain-microchippic32 folder except the package.jason file, and copying the chipkig-core from the download into it. I now get a pic32-g++ not found error. Hardly surprising as it’s hidden another couple of folders down in the new library. It’s in toolchain-microchippic32/chipkit-core/pic32/compiler/pic32-tools/bin/bin/gcc/ Oddly there is another one one level up, under the second bin/ folder.
So I eventually worked out that the folders I needed from the download were: chipkit-core/pic32/compiler/pic32-tools/bin/, chipkit-core/pic32/compiler/pic32-tools/lib, and chipkit-core/pic32/compiler/pic32-tools/pic32mx to be placed in toolchain-microchippic32. This way the library structure was the same and a cursory inspection of the contents of the libraries indicated that all the required files were present. The other libraries in the download; cores, libraries, tools, and variants, I ignored as I assumed they were already present somewhere else in ~/.platformio. Tried the compile again but got the original error back again, about crtbegin.o and crtend.o being multiply defined.
Just for fun I copied the rest of the libraries in the download, and the other files (boards.txt etc) into the toolchain-microchippic32 folder and tried the compile again. Same result.
Is there any other information I can give you that might point you in the direction of the error? A verbose listing of the compile and link maybe?
For the record I tried it with the -v option. here’s the result.

ian@Ian-Mint ~/PlatformIO/ChipKitTest2 $ pio run --verbose
[Thu Oct 6 16:40:19 2016] Processing mega_pic32 (platform: microchippic32, board: mega_pic32, framework: arduino)

Collected 32 compatible libraries
Looking for dependencies…
Project does not have dependencies
pic32-g++ -o .pioenvs/mega_pic32/firmware.elf -w -Os -mdebugger -mprocessor=32MX795F512L -mno-peripheral-libs -nostartfiles -Wl,–gc-sections /home/ian/.platf
ormio/packages/framework-arduinomicrochippic32/cores/pic32/cpp-startup.S /home/ian/.platformio/packages/framework-arduinomicrochippic32/cores/pic32/crti.S -Wl
,–script=“chipKIT-application-32MX795F512.ld” -Wl,–script=chipKIT-application-COMMON.ld .pioenvs/mega_pic32/src/blink.o -L/home/ian/.platformio/packages/fra

mework-arduinomicrochippic32/cores/pic32 -L/home/ian/.platformio/packages/framework-arduinomicrochippic32/variants/Max32 -L.pioenvs/mega_pic32 -Wl,–start-gro
up .pioenvs/mega_pic32/libFrameworkArduinoVariant.a .pioenvs/mega_pic32/libFrameworkArduino.a -lm -Wl,–end-group
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtbegin.o:(.sdata+0x0): multiple definition of __dso_handle ' /home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/../../lib/gcc/pic32mx/4.8.3/size/crtbegin.o:(.sdata+0x0): first defined here /home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/../../lib/gcc/pic32mx/4.8.3/size/crtend.o:(.dtors+0x0): multiple definition ofDTOR_END
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.dtors+0x0): first defined here
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.tm_clone_table+0x0): multiple definition of `_TMC

/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/…/…/lib/gcc/pic32mx/4.8.3/size/crtend.o:(.tm_clone_table+0x0): first defined here
/home/ian/.platformio/packages/toolchain-microchippic32/bin/bin/gcc/pic32mx/4.8.3/…/…/…/…/bin/pic32-ld: Link terminated due to previous error(s).
collect2: error: ld returned 255 exit status
*** [.pioenvs/mega_pic32/firmware.elf] Error 255

Please move issue here Issues · platformio/platform-microchippic32 · GitHub

mogplus8 - are you still interested in trying to solve this particular issue? I’m happy to try and help out - find me at the github link above.

*Brian Schmalz (chiptKIT-core dev)

Hi Brian, thanks for the note. Yes I’d like to sort this out, although as I mentioned before it’s not urgent or anything. I’m still very much in the early stages of playing with microcontrollers, and so far I’ve mostly been playing with Arduino Nano, Mega2560 and Due. but I like the Max32 as it is a 32 bit micro in a Meag2560 format. If you have some hints about what I could sort the problem I’d really appreciate it.

I’ll update microchippic32 development platform with latest toolchain and Arduino core. Maybe this will fix issue.

It might, but as I mentioned in an earlier post it seems to work fine under Ubuntu (the latest version, can’t remember the number…) so it is more likely to do with something I’ve done or not done, or something I’ve stuffed up. I tend to dive in and do things without really understanding what I’m doing, so it wouldn’t surprise me if I’ve broken something… :-\

@mogplus8 Please update Microchip PIC32 development platform to the latest version via pio update.