floating point issue with Renesas IAQ library (PSOC Creator 4.4, 4200M family)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
pgiacomini
Level 2
Level 2
5 sign-ins First solution authored First reply posted

I am attempting to incorporate the Renesas ZMOD4410 IAQ functionality into a PSOC 4200M project. Calls to some of the floating point functions in newlib libm and libgcc consistently cause a hard fault. I have been working with Renesas support to resolve the issue and they suggested a possibility that there is a mismatch between either the version of the GNU compiler or command line flags between the IAQ libraries and the PSOC libraries.

----

Last details sent to Renesas:

I did some testing and have attached some screenshots of the details of the failure with the configuration included in the optimization, linker, and Stack/Heap configuration shown in the screenshots. The bl_dmul screenshot shows the instruction that causes the hard fault and the stack_trace screenshot shows the stack at the beginning of the error handler (handler.jpg). This set of traces are for no optimization and the fault consistently occurs on the d_mul instruction.

I found that changes to the optimization level changes the actual instruction (which is still consistent for each optimization level) that causes the fault. No matter what the optimization levels, the instruction that cause the error is always in the libgcc or libm floating point routines resulting from a call from calc_iaq_2nd_gen_internal().

------

I have attached screenshots with additional details.

----

Last details from Renesas

Here is the details that Renesas provided on the compilation of the IAQ library.

  • Compiler version: We use 7-2018q2 version. Can you check for an update of your compiler?
  • Our additional/differing flags are: -static -O3 -std=gnu11 -fsigned-char -fdata-sections; We do not use -ffat-lto-objects. On the description of the options I don't see any issues with the different options

 

---

Any suggestions on how to proceed?

thanks,

pete

0 Likes
1 Solution

Hi Dheeraj,

I was able to resolve the issue. 

It turns out that there was a bug in my code that uses a portion of the PSOC FLASH as an emulated EEPROM. There was a bad pointer. Our first generation sensor had 32K of FLASH and the pointer to the base of the emulated EEPROM was hard-coded to the last few rows of FLASH. Our second generation sensor has 64K of FLASH and the Renesas ZMOD IAQ code was the first application where the code was large enough that this caused an issue, Because of the bad pointer, parts of the library code were getting overwritten. After I fixed that I was able to get the ZMOD libraries to work as expected.

Thanks for all your help,

pete

 

View solution in original post

0 Likes
3 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello @pgiacomini ,

Do you know if the library you are using was compiled targeting HardFP or SoftFP ABI? PSoC Creator supports only SoftFP. 

You can use any version of the GCC other than the one provided with PSoC Creator. You can download the most compatible version of the toolchain for your library from here.  Once installed, go to PSoC Creator > Tools > Options > Project Management > ARM Toolchains. Then point to the new GNU installation directory. 

To make use of this new version in your project, right-click on your project > Build Settings. Change the Toolchain to ARM GCC Generic. 

You can set the GCC Compiler flags under CM0 ARM > Compiler > Command Line > Custom Flags. I recommend adding one more flag to take take care of converting double floating point constants to single floating point using the "-fsingle-precision-constant".

Please provide the screenshot of the call stack as well. Consider attaching the project if the error persists with these changes. It will provide us more insight into what's going wrong.

Hope this helps 🙂

Regards,
Dheeraj

0 Likes
pgiacomini
Level 2
Level 2
5 sign-ins First solution authored First reply posted

Hi Dheeraj,

Thanks for the quick response and guidance.

I will check with Renesas on the FP ABI compilation used for the IAQ library.

Renesas has made some addition suggestions on code and configuration changes that I will try before changing the GNU compiler.

I have attached the screenshot that includes the call stack.

I need to put together a simpler version of the project to implement the latest Renesas suggestions. Once I do so, I  will be able to supply a project for your examination. However, it will take a few weeks before I can do so since I am working on a different project  that I must complete before getting back to the IAQ sensor testing.

thanks,

pete

0 Likes

Hi Dheeraj,

I was able to resolve the issue. 

It turns out that there was a bug in my code that uses a portion of the PSOC FLASH as an emulated EEPROM. There was a bad pointer. Our first generation sensor had 32K of FLASH and the pointer to the base of the emulated EEPROM was hard-coded to the last few rows of FLASH. Our second generation sensor has 64K of FLASH and the Renesas ZMOD IAQ code was the first application where the code was large enough that this caused an issue, Because of the bad pointer, parts of the library code were getting overwritten. After I fixed that I was able to get the ZMOD libraries to work as expected.

Thanks for all your help,

pete

 

0 Likes