Created Mon, 28 Jan 2013 12:50:05 +0000 by YOBE.
Mon, 28 Jan 2013 12:50:05 +0000
Hello,
:evil: :evil: I have lost a LOT of time trying to find out what was wrong with my code. I need to use the sqrt() function, but now I found out that this one is not working in Mpide 20120903. Perhaps I do something wrong, but I do not think so.
When I upload it with 201209, the result is always -0.000 When I compile and upload with 20111221, the function works!!!
Is this a bug or do I miss something????
Regards,
This is the code:
/* Test several data types en sqrt */
byte Byte; word Word; long Long; int Int; float Float; double Double; long double x; int A;
void setup () { Serial.begin(115200); Serial.write (82); // Send "R" to inform PC that Chipkit is Ready.
}
void loop (){
A=112; Word=(A*A); Serial.print(" Word="); Serial.print(Word);
Float=Word; Serial.print(" Float="); Serial.print(Float);
Float=sqrt(Float); Serial.print(" SqrtFloat="); Serial.print(Float,8);
Double=Word; Serial.print(" Double="); Serial.print(Double,8);
Double=sqrt(Double); Serial.print(" SqrtDouble="); Serial.print(Double,8);
delay(10000);
}
Mon, 28 Jan 2013 17:33:08 +0000
Hi YOBE,
I'm not sure which board you are using, but it's likely affected by a missing option in the boards.txt file. Please see this patch: https://github.com/chipKIT32/chipKIT32-MAX/commit/0ab0a4509c2a234215cf8c3e7dc29b2ec5c6919d
You can download the updated boards.txt file here and copy it over your existing file (assuming that you don't have local modifications). https://github.com/chipKIT32/chipKIT32-MAX/blob/0ab0a4509c2a234215cf8c3e7dc29b2ec5c6919d/hardware/pic32/boards.txt
Rick is in the process of putting together a new set of mpide builds that has this fix (and others).
Mon, 28 Jan 2013 23:35:59 +0000
I am using ChipKit Uno32. I will try the txt file this evening. Thanks for the feedback.
But could you give me a small explanation what this file is doing exactly? Is it some kind of config/setting for the selected board?
Greets Yorick
Tue, 29 Jan 2013 02:21:59 +0000
The boards.txt file specifies the options for each board. In this case, we want to add the -fno-short-double option to the C/C++ compiler to tell it that the 'double' type is 64 bits wide. Actually, we want to use that option for all boards. The math library is compiled for 64-bit doubles but the compiler defaults to 32-bit doubles.
Tue, 29 Jan 2013 04:53:53 +0000
This may look stupid, but when I copy all the text from the .txt file from your link and paste it in the "boards.txt" (hardware/pic32/) the Mpide compiler can not be started anymore!! You see the startup screen and then suddenly it disappears. When I put back the original boards.txt the compiler starts up again.
I tried with a new copy from your link, but problem remains.
Do I need to use the patch link??
This is a piece of the copy I paste over the original content of boards.txt:
############################################################uno_pic32.name=chipKIT UNO32# new itemsuno_pic32.platform=pic32uno_pic32.board=_BOARD_UNO_uno_pic32.board.define=#uno_pic32.compiler.define=uno_pic32.ccflags=ffffuno_pic32.ldscript=chipKIT-application-32MX320F128.ld# end of new items# Use a high -Gnum for devices that have less than 64K of data memory# For -G1024, objects 1024 bytes or smaller will be accessed by# gp-relative addressinguno_pic32.compiler.c.flags=-O2::-c::-mno-smart-io::-w::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doubleuno_pic32.compiler.cpp.flags=-O2::-c::-mno-smart-io::-w::-fno-exceptions::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doubleuno_pic32.upload.protocol=stk500v2uno_pic32.upload.maximum_size=126976uno_pic32.upload.speed=115200uno_pic32.bootloader.low_fuses=0xffuno_pic32.bootloader.high_fuses=0xdduno_pic32.bootloader.extended_fuses=0x00uno_pic32.bootloader.path=not-supporteduno_pic32.bootloader.file=not-supporteduno_pic32.bootloader.unlock_bits=0x3Funo_pic32.bootloader.lock_bits=0x0Funo_pic32.build.mcu=32MX320F128Huno_pic32.build.f_cpu=80000000Luno_pic32.build.core=pic32uno_pic32.build.variant=Uno32#uno_pic32.upload.using=############################################################mega_pic32.name=chipKIT MAX32# new itemsmega_pic32.platform=pic32mega_pic32.board=_BOARD_MEGA_mega_pic32.board.define=mega_pic32.ccflags=ffffmega_pic32.ldscript=chipKIT-application-32MX795F512.ld# end of new itemsmega_pic32.upload.protocol=stk500v2mega_pic32.upload.maximum_size=520192mega_pic32.upload.speed=115200mega_pic32.bootloader.low_fuses=0xffmega_pic32.bootloader.high_fuses=0xddmega_pic32.bootloader.extended_fuses=0x00mega_pic32.bootloader.path=not-supportedmega_pic32.bootloader.file=not-supportedmega_pic32.bootloader.unlock_bits=0x3Fmega_pic32.bootloader.lock_bits=0x0Fmega_pic32.build.mcu=32MX795F512Lmega_pic32.build.f_cpu=80000000Lmega_pic32.build.core=pic32mega_pic32.build.variant=Max32#mega_pic32.upload.using=############################################################mega_usb_pic32.name=chipKIT MAX32-USB for Serial# new itemsmega_usb_pic32.platform=pic32mega_usb_pic32.board=_BOARD_MEGA_USB_mega_usb_pic32.board.define=-D_USE_USB_FOR_SERIAL_mega_usb_pic32.ccflags=ffffmega_usb_pic32.ldscript=chipKIT-application-32MX795F512.ld# end of new itemsmega_usb_pic32.upload.protocol=stk500v2mega_usb_pic32.upload.maximum_size=520192mega_usb_pic32.upload.speed=115200mega_usb_pic32.bootloader.low_fuses=0xffmega_usb_pic32.bootloader.high_fuses=0xddmega_usb_pic32.bootloader.extended_fuses=0x00mega_usb_pic32.bootloader.path=not-supportedmega_usb_pic32.bootloader.file=not-supportedmega_usb_pic32.bootloader.unlock_bits=0x3Fmega_usb_pic32.bootloader.lock_bits=0x0Fmega_usb_pic32.build.mcu=32MX795F512Lmega_usb_pic32.build.f_cpu=80000000Lmega_usb_pic32.build.core=pic32mega_usb_pic32.build.variant=Max32#mega_usb_pic32.upload.using=############################################################chipkit_uc32.name=chipKIT uC32# new itemschipkit_uc32.platform=pic32chipkit_uc32.board=_BOARD_UC32_chipkit_uc32.board.define=chipkit_uc32.ccflags=ffffchipkit_uc32.ldscript=chipKIT-application-32MX340F512.ld# end of new items# Use a high -Gnum for devices that have less than 64K of data memory# For -G1024, objects 1024 bytes or smaller will be accessed by# gp-relative addressingchipkit_uc32.compiler.c.flags=-O2::-c::-mno-smart-io::-w::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doublechipkit_uc32.compiler.cpp.flags=-O2::-c::-mno-smart-io::-w::-fno-exceptions::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doublechipkit_uc32.upload.protocol=stk500v2chipkit_uc32.upload.maximum_size=520192chipkit_uc32.upload.speed=115200chipkit_uc32.bootloader.low_fuses=0xffchipkit_uc32.bootloader.high_fuses=0xddchipkit_uc32.bootloader.extended_fuses=0x00chipkit_uc32.bootloader.path=not-supportedchipkit_uc32.bootloader.file=not-supportedchipkit_uc32.bootloader.unlock_bits=0x3Fchipkit_uc32.bootloader.lock_bits=0x0Fchipkit_uc32.build.mcu=32MX340F512Hchipkit_uc32.build.f_cpu=80000000Lchipkit_uc32.build.core=pic32chipkit_uc32.build.variant=uC32#chipkit_uc32.upload.using=############################################################cerebot_mx3ck_512.name=Cerebot MX3cK 512# new itemscerebot_mx3ck_512.platform=pic32cerebot_mx3ck_512.board=BOARD_CEREBOT_MX3CK_512_cerebot_mx3ck_512.board.define=cerebot_mx3ck_512.ccflags=ffffcerebot_mx3ck_512.ldscript=chipKIT-application-32MX340F512.ld# end of new items# Use a high -Gnum for devices that have less than 64K of data memory# For -G1024, objects 1024 bytes or smaller will be accessed by# gp-relative addressingcerebot_mx3ck_512.compiler.c.flags=-O2::-c::-mno-smart-io::-w::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doublecerebot_mx3ck_512.compiler.cpp.flags=-O2::-c::-mno-smart-io::-w::-fno-exceptions::-ffunction-sections::-fdata-sections::-G1024::-g::-mdebugger::-Wcast-align::-fno-short-doublecerebot_mx3ck_512.upload.protocol=stk500v2cerebot_mx3ck_512.upload.maximum_size=520192cerebot_mx3ck_512.upload.speed=115200cerebot
Tue, 29 Jan 2013 05:01:39 +0000
Did you lose the line breaks and separators? Here's a link to the raw file.
You can probably do a "save as" in your web browser to download the file directly.
Tue, 29 Jan 2013 05:46:51 +0000
I will try your sugesttion.
I could solve the problem by first making the copy to Word and then paste it into the txt file. This made Mpide running. But when I now try to compile my test program, I get this error message.
c:/yorick home/google drive/mpide-0023-windows-20120903/mpide-0023-windows-20120903/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: MPIDE Version not specfied correctly c:/yorick home/google drive/mpide-0023-windows-20120903/mpide-0023-windows-20120903/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: MPIDE Version not specfied correctly collect2: ld returned 1 exit status
I will now try your proposal,
Thanks for the quick replies :-))
Tue, 29 Jan 2013 05:52:03 +0000
Your proposal works fine to have Mpide working again (similar effect as when I used Word to copy and paste).
BUT during compiling I keep get the same error:
c:/yorick home/google drive/mpide-0023-windows-20120903/mpide-0023-windows-20120903/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: MPIDE Version not specfied correctly c:/yorick home/google drive/mpide-0023-windows-20120903/mpide-0023-windows-20120903/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: MPIDE Version not specfied correctly collect2: ld returned 1 exit status
Tue, 29 Jan 2013 06:16:07 +0000
The only change was to the boards.txt file, right? All of the other files are the same as from the original install image? I'll have to consult someone else, not sure why you would get that error.
Tue, 29 Jan 2013 06:30:40 +0000
Yes,
I only changed the boards.txt file like you told me. But this results in an error when I try to compile a sketch.
Hope you can help me solve this issue.
Regards and thanks for the support
I do not know if this has added value, but when I use the new boards.txt file in Mpide 201112, I get this error during compiling:
c:/yorick home/mpide-0023-windows-20111221/mpide-0023-windows-20111221/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: cannot open linker script file C:\Yorick Home\mpide-0023-windows-20111221\mpide-0023-windows-20111221\hardware\pic32\cores\pic32/chipKIT-application-32MX320F128.ld: Invalid argument collect2: ld returned 1 exit status
Tue, 29 Jan 2013 17:04:17 +0000
The names of the linker scripts change after 20111221 to MPIDE 903 (actually 818). If you are going to use a boards.txt from a newer MPIDE release, many things will not work when dumped with an older MPIDE. Make sure your boards.txt is consistent with the version of MPIDE you are using. that only makes sense :|
FYI: We added a bunch of features in the MPID 818 - 1013 timeframe, the linker scripts changed dramatically. The names also changed as we took the board name out the linker script and made them processor based as we really don't care what board the processor is on. That way, it makes sense if many boards use the same processor they actually call a named linker script that applys. It is stupid to call the Uno32 linker script when used on an MX3cK, but make sense to call the MX320... as both have the same processor.
Go look in core for the linkerscripts in MPIDE 1221 and edit boards.txt to call the correct one that is available in 1221.
Wed, 30 Jan 2013 01:04:02 +0000
@ Keith,
I do not not completely understand what you are explaining, but is seems you cannot mix older boards.txt files with new Mpide releases. This I do understand.
BUT: in the latest Mpide 20120903, the sqrt() function does NOT work, so I got the advice the update my boards.txt file!! This results in errors when I try to compile my program. By means of test I copied the boards.txt file to an older version of Mpide, but result is the same.
What can I do to solve the issue with a not working sqrt() function in 20120903???
Regards,
Wed, 30 Jan 2013 21:53:05 +0000
Hello YOBE,
I was not able to pinpoint this issue. It does seem to only occur with a PIC32MX320F128H. I tried both a Uno32 and a MX3ck against a MX4cK. Your code on the MX4cK worked fine.
It also seems to be affected by Serial.print/println(). The below code works fine:
int number;
int result;
void setup() {
Serial.begin(9600);
number = 112*112;
result = sqrt(number);
Serial.println(result);
}
void loop() {
}
However this code, does not:
int number;
int result;
void setup() {
Serial.begin(9600);
number = 112*112;
Serial.println(number);
result = sqrt(number);
Serial.println(result);
}
void loop() {
}
Both were done in 0903
Best Regards,
JordanR
Thu, 31 Jan 2013 00:05:10 +0000
Thanks Jordan.
Someone else an idea how to solve the root cause?
Fri, 01 Feb 2013 06:19:05 +0000
Nobody who can solve this issue????
Fri, 01 Feb 2013 22:01:50 +0000
Hi YOBE,
Instead of replacing your entire boards.txt file, try following the instructions here to modify it. http://www.chipkit.org/forum/viewtopic.php?f=20&t=1528#p6644 The team is currently working on a new build of mpide that picks up this fix as well as other improvements.
Sat, 02 Feb 2013 09:19:15 +0000
:lol: :) ;) :P :D
Hi Jason,
YES, this solved the problem. Like you say, you need to use the original boards.txt and add the math links. The results are also much more detailed now (double is now really double)!!
Thanks a lot.
Keep us informed when new Mpide will be published :P :P
Sat, 02 Feb 2013 17:21:13 +0000
Great, I'm happy to hear that you got it working. Info on a new release will be posted on the forum when it is ready.