renesas / fsp

Flexible Software Package (FSP) for Renesas RA MCU Family
https://renesas.github.io/fsp/
Other
192 stars 82 forks source link

lfs with MBEDTLS_PSA_ITS_FILE_C doesn't compile #279

Open Vernon-Naidoo-1 opened 1 year ago

Vernon-Naidoo-1 commented 1 year ago

FSP Version: 4.3 Debugger: J-Link (SWD) Processor: RA6M2 OS: FreeRTOS IDE: VS Code Build Type: CMake Toolchain: arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi

I understand that this isn't the toolchain specified along side the FSP release, but that version of the toolchain breaks other 3rd party parts of our code.

How to replicate:

Add mbedtls (crypto only), attach lfs file system and the sce7, try running the renesas example code for generating a persistent key and using with AES, with the specified toolchain.

Issue

This code fails to compile when enabling MBEDTLS_PSA_ITS_FILE_C. I have traced this and it seems to work (at least the demo code does) if I redefine remove in this line #define remove(file) lfs_remove(MBEDTLS_CONFIG_LFS, file) To something else and update the calls in psa_its_file.c. It seems that there is a conflict with the file definition arising from the toolchain itself.

Please advise on this issue.

Vernon-Naidoo-1 commented 1 year ago

Update: the rename function suffers from the same problem. Not sure if the others would too if another feature was turned on

renesas-brandon-hussey commented 1 year ago

Hi @Vernon-Naidoo-1 , we are working on updating FSP to support that GCC version. We tried to replicate the error you are encountering with FSP v4.3.0 and e2 studio and were not able to do so. You're going to need to provide more information for us to figure out the issue. Can you provide us the command line for the build and the output you're seeing?

Vernon-Naidoo-1 commented 1 year ago

Hi @renesas-brandon-hussey. I'm using CMake on VS code in a wsl environment to build

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

This is the build command line cmake -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_PATH -DLIBRARY_LOG_LEVEL=0 -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug $BUILD_DEFINES -DUSR_LOG_LVL=$DEBUG_LVL

It should also be noted that I've updated to fsp 4.5 and this problem persists. Also, this is primarily a c++ project with a few c interfaces and the FSP c code. What information would you need?

Vernon-Naidoo-1 commented 1 year ago

Sorry missed the second part of your request. Looking more closely at the errors, you may need to include the nlohmann c++ json library to see the conflicts, as this seems to use the toolchain version of these functions and that seems to be when the conflict arrises. There are a lot of error when these functions are left as is but here are a few pertaining to this. There's 157 errors in total though all are along these lines, since the definition of these functions in the toolchain are different to the ones in the lfs headers. If you need the entire output please let me know as I'll have to sanitise it before sending.

  /opt/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/12.2.1/bits/fs_ops.h:344:8: error: variable or field 'lfs_rename_raw' declared void
  344 |   void rename(const path& __from, const path& __to);
      |        ^~~~~~
/opt/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/12.2.1/bits/fs_ops.h:344:8: error: expected primary-expression before 'const'
  344 |   void rename(const path& __from, const path& __to);
      |        ^~~~~~
/opt/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/12.2.1/bits/fs_ops.h:344:8: error: expected primary-expression before 'const'
  344 |   void rename(const path& __from, const path& __to);
      |        ^~~~~~
/opt/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/12.2.1/bits/fs_ops.h:345:71: error: expected initializer before 'noexcept'

/home/build/workspace/project/json/include/nlohmann/detail/output/serializer.hpp:846:41: error: missing template arguments before '(' token
  846 |             const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
      |                                         ^
In file included from /home/build/workspace/project/json/include/nlohmann/json.hpp:59:
/home/build/workspace/project/json/include/nlohmann/detail/output/serializer.hpp: In member function 'void nlohmann::json_abi_v3_11_2::detail::serializer<BasicJsonType>::dump_float(number_float_t, std::false_type)':
/home/build/workspace/project/json/include/nlohmann/detail/output/serializer.hpp:846:41: error: missing template arguments before '(' token
  846 |             const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
renesas-brandon-hussey commented 8 months ago

This is being internally tracked using FSPRA-2354.