PROS double multiplication issues [SOLVED]

I’m having an issue with PROS. If I mutliply a double and do anything with the results (such as setting motors or printf) the cortex it stops working. Am I doing something wrong here?

this is what is printed when it happens:

Powered by PROS 2b10
This is a BETA version of PROS and may have issues.

Purdue Robotics OS (C)2011-2014 Purdue ACM SIGBOTS
This program has ABSOLUTELY NO WARRANTY, not even an implied
warra
The VEX Cortex has stopped working!
Error cause: 

Hi @BottomNotch,

Can you share example code with me so I can help you diagnose the issue?


double foo = 0.2;
double bar = 1;
printf("%g\n\r", foo*bar);

@BottomNotch I do not have access to a cortex right now but could you humor me in testing the following modifications with your code and report back if you still encounter the same issues with the cortex crashing.


double foo = 0.2;
double bar = 1;
printf("%f\n\r", (float)foo*bar);

same thing, except now the error cause is �

That is interesting. Could you PM me the output.elf file in your /bin directory that is generated from compiling both your sample and mine that is generating this error. I would like to look at the disassembly of them.

sure

I tried this, and it works ok.

void operatorControl() {
  double foo = 0.2;
  double bar = 0.1;
  printf("%f \n\r", foo*bar);

  while (1) {
    delay(20);
  }
}

So it may be the surrounding code. Do you have many other local variables defined?

I created a fresh project and this did not work. Could it be an issue with the toolchain? I had to custom build one because the one included with PROS seems to not work on Arch Linux or Slackware.

Which version of gcc are you using? (arm-none-eabi-gcc --version)

5.3.0

Ok, so I was building with 4.9.3, let me see if I have that version around and try again.

I don’t have 5.3 around, but I did try 5.2.1 and that was ok. Most likely issue is the toolchain, lets see what Purdue can come up with when they look into the .elf file.

I assume you are using the Makefile etc. that came with PROS.

I am using the same Makefile. Crap, building a toolchain on an old laptop with 1.6 GHz core duo and 2GB of RAM is not fun XD

Send me the .elf file as well before you do that (just the simple example I posted, zip it up first)

@jabibi also thinks it’s the toolchain after looking at my output.elf, still sending it you though.

Send us one other thing, dump the pre-processor defines into a file and send us that, it may be that you need another compiler/linker option set, you get those like this.
arm-none-eabi-gcc -dM -E - </dev/null

ok, I can do that in a few hours when I get home.

[quote=“jpearman, post:17, topic:36475”]

Send us one other thing, dump the pre-processor defines into a file and send us that, it may be that you need another compiler/linker option set, you get those like this.
arm-none-eabi-gcc -dM -E - </dev/null
[/quote]
preprocessor-defines.zip (2.72 KB)

Ok, try the following for me.

Edit the common.mk file in the project root directory, add -mfloat-abi=soft to the MCUCFLAGS as follows.

# Flags for the compiler
MCUCFLAGS=-mthumb -mcpu=cortex-m3 -mlittle-endian -mfloat-abi=soft

it should then look like this.

Then clean and build the project.

Jamess-MacBook-Pro-15:testpros james$ make clean
rm -f ./bin/output.elf
rm -rf ./bin
Jamess-MacBook-Pro-15:testpros james$ make
CC -I../include -I../src auto.c
CC -I../include -I../src init.c
CC -I../include -I../src opcontrol.c
LN ./bin/auto.o ./bin/init.o ./bin/opcontrol.o ./firmware/libccos.a -lgcc -lm to bin/output.elf
   text	   data	    bss	    dec	    hex	filename
  13940	      0	   3840	  17780	   4574	./bin/output.elf
arm-none-eabi-objcopy ./bin/output.elf -O binary ./bin/output.bin

Download and try that, let us know what happens.