microsoft / ms-tpm-20-ref

Reference implementation of the TCG Trusted Platform Module 2.0 specification.
Other
333 stars 133 forks source link

Building STM32 sample implementation #59

Closed acwiek closed 2 years ago

acwiek commented 2 years ago

Hi, together with my organization we are planning to create a universal opensource TPM 2.0 hardware module. We would like to use the stm32 sample as a reference point but ran into some problems. I've checked out a specific commit that adds samples for Nucleo (f8a1c48cd0a7c7c942967d24be3caf4956eeb994). This method allowed me to ignore (for now) other errors that appear when building a project from the master branch. I thought, that maybe I'm using the wrong toolchain version, so I switched back to GCC 4.8 and tried a different Atollic version as well as the new successor - STM32CubeIDE, but with no luck. The same error remains also for an old Windows Atollic version.
I wonder how the project was developed because I was unable to build it in any way. Fixing minor bugs involving missing includes and the small fixes in the preprocessor defines, I have come to a point that is hard for me to go through. Curent issue seems to be related to the macro located in CryptEccData.c:86 file # define ECC_ENTRY(val, x) (bigNum)&##val##_##x that triggers this specific error message.

arm-none-eabi-gcc -c "/home/acwiek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptEccMain.c" -mcpu=cortex-m4 -std=gnu11 -g3 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32L476xx -DWOLFSSL_USER_SETTINGS -DUSE_WOLFCRYPT -c -I../Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I../../Shared/TPMDevice/include -I../../Shared/Platform/Include -I../../Shared/Platform/Include/prototypes -I../../../../external/wolfssl -I../../../../TPMCmd/tpm/include -I../../../../TPMCmd/tpm/include/prototypes -I"/home/acwiek/git/ms-tpm-20-ref/Samples/Nucleo-TPM/Shared/Platform/include/prototypes" -I"/home/acwiek/git/ms-tpm-20-ref/Samples/Nucleo-TPM/Shared/Platform/include" -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Middlewares/TPMCmd/crypt/CryptEccMain.d" -MT"Middlewares/TPMCmd/crypt/CryptEccMain.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Middlewares/TPMCmd/crypt/CryptEccMain.o"
/home/acwiek/git/ms-tpm-20-ref/TPMCmd/tpm/src/crypt/CryptEccData.c:86:39: error: pasting "&" and "NIST_P256" does not give a valid preprocessing token
   86 | # define ECC_ENTRY(val, x)    (bigNum)&##val##_##x
      |                                       ^

We have high hopes for this project and think it will enrich the open-source community, so we would appreciate any help from you.

pietrushnic commented 2 years ago

Just to be clear organization in this context is LPN Plant and project is called lpnTPM. Project was granted by NLNet foundation. We would be glad to contribute improvements to ms-tpm-20-ref code base to make microcontroller based TPM working out of the box.

bradlitterell commented 2 years ago

Fixed in a later commit: https://github.com/microsoft/ms-tpm-20-ref/pull/11/commits/7558fa325be7eaa6148489ef71d2adc788680ec6