MBEDTLS compiling

Hello,

I get the following compilation error for device-os:

make PLATFORM=photon

mkdir -p …/build/target/communication/platform-6-prod-6/src/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DPLATFORM_GEN=2 -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb --specs=nano.specs -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=2.0.0-rc.3 -DRELEASE_BUILD -Werror -I./inc -I…/hal/inc -I…/hal/shared -I…/hal/src/photon -I…/hal/src/stm32f2xx -I…/hal/src/stm32 -I…/hal/network/util -I…/hal/network -I…/hal/src/photon/api -I…/hal/src/photon/include -I…/hal/src/photon/wiced/security/BESL/host/WICED/ -I…/hal/src/photon/wiced/security/BESL/include -I…/hal/src/photon/wiced/security/BESL -I…/hal/src/photon/wiced/security/BESL/crypto -I…/hal/src/photon/wiced/WWD/include/ -I…/hal/src/photon/wiced/platform/include/ -I…/hal/src/photon/wiced/platform/GCC/ -I…/hal/src/photon/wiced/security/BESL/supplicant/ -I…/hal/src/photon/libraries/crypto -I…/hal/src/photon/libraries/daemons/DNS_redirect -I…/third_party/miniz/miniz -I…/platform/shared/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I…/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I…/platform/MCU/shared/STM32/inc -I…/platform/MCU/STM32F2xx/CMSIS/Include -I…/platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I…/dynalib/inc -I…/services/inc -I…/third_party/nanopb/nanopb -I…/wiring/inc -I…/crypto/inc -I…/third_party/mbedtls/mbedtls/include -Isrc -I. -MD -MP -MF …/build/target/communication/platform-6-prod-6/src/handshake.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DLOG_COMPILE_TIME_LEVEL=LOG_LEVEL_NONE -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="“comm”" -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o …/build/target/communication/platform-6-prod-6/src/handshake.o src/handshake.cpp
In file included from src/handshake.cpp:25:
src/handshake.h:31:10: fatal error: mbedtls/rsa.h: No such file or directory
31 | #include “mbedtls/rsa.h”
| ^~~~~~~~~~~~~~~
compilation terminated.

And I can’t find rsa.h in the clone I’ve made of the git device-os repository. should the USE_MBEDTLS CFLAG really be defined during compile? Or am I missing something?

Thank you

HI @armystic

As a first step, can you please confirm you’ve updated your submodules with git submodule update --init --recursive before attempting make?

2 Likes

Thanks @mstanley , that indeed solved it.

I am now running into the following complaining MODULE_FUNCTION being undefined. I thought maybe specifying monolithic (MODULAR=n) would solve it as follows, but the problem still lingers:

make PLATFORM=photon MODULAR=n all

mkdir -p …/build/target/hal/platform-6/./src/photon/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DPLATFORM_GEN=2 -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb --specs=nano.specs -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -fno-builtin-memcpy -fno-builtin-memcmp -fno-builtin-memset -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DSYSTEM_VERSION_STRING=2.0.0-rc.3 -DRELEASE_BUILD -Werror -I./inc -I./shared -I./src/photon -I./src/stm32f2xx -I./src/stm32 -I./network/util -I./network -I./src/photon/api -I./src/photon/include -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/include -I./src/photon/wiced/security/BESL -I./src/photon/wiced/security/BESL/crypto -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/platform/include/ -I./src/photon/wiced/platform/GCC/ -I./src/photon/wiced/security/BESL/supplicant/ -I./src/photon/libraries/crypto -I./src/photon/libraries/daemons/DNS_redirect -I…/third_party/miniz/miniz -I…/platform/shared/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I…/platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I…/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I…/platform/MCU/shared/STM32/inc -I…/platform/MCU/STM32F2xx/CMSIS/Include -I…/platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I…/services/inc -I…/third_party/nanopb/nanopb -I…/dynalib/inc -I…/bootloader/src/photon -I…/bootloader/…/hal/src/photon/wiced/platform/MCU -I…/bootloader/…/hal/src/photon/wiced/platform/MCU/STM32F2xx/WAF -I…/bootloader/src/stm32f2xx -I…/wiring/inc -I…/crypto/inc -I…/third_party/mbedtls/mbedtls/include -I…/communication/inc -I…/third_party/miniz/miniz -I./src/photon/include -I./src/photon/libraries/daemons/DNS_redirect -I./src/photon/libraries/daemons/HTTP_server -I./src/photon/libraries/protocols/DNS -I./src/photon/libraries/utilities/linked_list -I./src/photon/libraries/utilities/ring_buffer -I./src/photon/platforms/BCM9WCDUSI09 -I./src/photon/wiced -I./src/photon/wiced/RTOS/FreeRTOS -I./src/photon/wiced/RTOS/FreeRTOS/WICED -I./src/photon/wiced/RTOS/FreeRTOS/WWD -I./src/photon/wiced/RTOS/FreeRTOS/WWD/ARM_CM3 -I./src/photon/wiced/RTOS/FreeRTOS/ver8.2.1/Source/include -I./src/photon/wiced/RTOS/FreeRTOS/ver8.2.1/Source/portable/GCC/ARM_CM3 -I./src/photon/wiced/WWD -I./src/photon/wiced/internal -I./src/photon/wiced/network/LwIP -I./src/photon/wiced/network/LwIP/WICED -I./src/photon/wiced/network/LwIP/WWD -I./src/photon/wiced/network/LwIP/WWD/FreeRTOS -I./src/photon/wiced/network/LwIP/ver1.4.1/src/include -I./src/photon/wiced/network/LwIP/ver1.4.1/src/include/ipv4 -I./src/photon/wiced/platform/ARM_CM3 -I./src/photon/wiced/platform/ARM_CM3/CMSIS -I./src/photon/wiced/platform/GCC -I./src/photon/wiced/platform/MCU -I./src/photon/wiced/platform/MCU/STM32F2xx -I./src/photon/wiced/platform/MCU/STM32F2xx/WAF -I./src/photon/wiced/platform/MCU/STM32F2xx/peripherals -I./src/photon/wiced/platform/include -I./src/photon/wiced/security/BESL/crypto/ -I./src/photon/wiced/security/BESL/crypto/ -I./src/photon/wiced/security/BESL/DTLS/ -I./src/photon/wiced/security/BESL/DTLS/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/ed25519/ -I./src/photon/wiced/security/BESL/crypto_open/unit/ -I./src/photon/wiced/security/BESL/P2P/ -I./src/photon/wiced/security/BESL/P2P/ -I./src/photon/wiced/security/BESL/P2P/ -I./src/photon/wiced/security/BESL/TLS/ -I./src/photon/wiced/security/BESL/TLS/ -I./src/photon/wiced/security/BESL/WPS/ -I./src/photon/wiced/security/BESL/WPS/ -I./src/photon/wiced/security/BESL/WPS/ -I./src/photon/wiced/security/BESL/WPS/ -I./src/photon/wiced/security/BESL/supplicant/ -I./src/photon/wiced/security/BESL/supplicant/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/include/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/security/BESL/host/WICED/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/ -I./src/photon/wiced/WWD/internal/chips/4343x/ -I./src/photon/wiced/WWD/internal/chips/4334x/ -I./src/photon/wiced/WWD/internal/chips/4390x/ -I./src/photon/wiced/WWD/internal/chips/4390/ -I./src/photon/wiced/WWD/internal/chips/43362/ -I./src/photon/wiced/WWD/internal/bus_protocols/ -I./src/photon/wiced/WWD/internal/bus_protocols/SDIO/ -I./src/photon/wiced/WWD/internal/bus_protocols/SoC/43909/ -I./src/photon/wiced/WWD/internal/bus_protocols/SoC/4390/ -I./src/photon/wiced/WWD/internal/bus_protocols/SPI/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/ -I./src/photon/wiced/WWD/include/network/ -I./src/photon/wiced/WWD/include/network/ -I./src/photon/wiced/WWD/include/network/ -I./src/photon/wiced/WWD/include/RTOS/ -I./src/photon/wiced/WWD/include/platform/ -I./src/photon/wiced/WWD/include/platform/ -I./src/photon/wiced/WWD/include/platform/ -I./src/photon/wiced/WWD/include/platform/ -I./src/photon/wiced/WWD/include/platform/ -I./src/stm32f2xx -I./src/stm32 -I. -MD -MP -MF …/build/target/hal/platform-6/./src/photon/dct_hal.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSFLASH_APPS_HEADER_LOC=0x0000 -DUSE_STDPERIPH_DRIVER -D_STM32F215RGT6_ -D_STM3x_ -D_STM32x_ -DMAX_WATCHDOG_TIMEOUT_SECONDS=22 -DFIRMWARE_WITH_PMK_CALC_SUPPORT -DADD_LWIP_EAPOL_SUPPORT -DNXD_EXTENDED_BSD_SOCKET_SUPPORT -DOPENSSL -DSTDC_HEADERS -DUSE_SRP_SHA_512 -DADD_NETX_EAPOL_SUPPORT -DUSE_MICRORNG -DWWD_STARTUP_DELAY=10 -DBOOTLOADER_MAGIC_NUMBER=0x4d435242 -DNETWORK_NetX=1 -DNetX_VERSION=“v5.5_sp1” -DNX_INCLUDE_USER_DEFINE_FILE -D__fd_set_defined -DSYS_TIME_H_AVAILABLE -DRTOS_ThreadX=1 -DThreadX_VERSION=“v5.6” -DTX_INCLUDE_USER_DEFINE_FILE -DWWD_DIRECT_RESOURCES -DLOG_COMPILE_TIME_LEVEL=LOG_LEVEL_NONE -D_POSIX_C_SOURCE=200809 -DLOG_MODULE_CATEGORY="“hal”" -std=gnu11 -Wno-pointer-sign -c -o …/build/target/hal/platform-6/./src/photon/dct_hal.o src/photon/dct_hal.c
In file included from …/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/dct.h:30,
from src/photon/dct_hal.h:14,
from src/photon/dct_hal.c:1:
…/platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/hw_config.h:52:5: error: “MODULE_FUNCTION” is not defined, evaluates to 0 [-Werror=undef]
52 | #if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER

Hey @armystic,

Would you be interested in trying neopo?

It provides an incredibly straightforward interface for building Particle projects on the command line and manages local toolchains identically to Workbench.


As an experiment, I tried to replicate your build process and I get the same error about MODULE_FUNCTION.

#!/bin/bash
PATH="$PATH:/home/nrobinson/.particle/toolchains/gcc-arm/9.2.1/bin"
cd /home/nrobinson/.particle/toolchains/deviceOS/2.0.0-rc.3
make PLATFORM=photon MODULAR=n all

However, if I run make in the modules directory as suggested by the compile-all target in the Workbench makefile, make PLATFORM=photon MODULAR=n all runs successfully.

#!/bin/bash
PATH="$PATH:/home/nrobinson/.particle/toolchains/gcc-arm/9.2.1/bin"
cd /home/nrobinson/.particle/toolchains/deviceOS/2.0.0-rc.3/modules
make PLATFORM=photon MODULAR=n all

Edit: Sorry for not remembering that you had difficulties building roughly a month ago:

In all seriousness though, using neopo would allow you to easily setup the local Particle toolchain and get right to building firmware within a few minutes.

1 Like

Thank you @nrobinson2000 , changing to modules directory compiled without a hitch. :ok_hand:

neopo is on my list of things to do. At this stage I'm using first principles, but will get to that. Looks like a very cool tool for particle development. Just wondering wouldn't Particle CLI (or Particle VS Studio) do the same thing and more? [I haven't installed or played with Particle VS yet]

And for the gcc toolchain, looks like it is very pedantic about the exact version, so had to install the 9.2.1 version to get any further

May I know where I find this Workbench makefile you refer to? I couldn't find any compile-all targets in makefiles under device-os

1 Like

When installing Workbench or neopo, the ~/.particle/toolchains directory is created and populated with all the required dependencies for local development, eliminating the need to hunt down specific versions of dfu-util, gcc-arm, or openocd:

~/.particle/toolchains/
├── buildscripts
│   └── 1.9.2
├── buildtools
│   └── 1.1.1
├── deviceOS
│   └── 3.0.0-beta.1
├── gcc-arm
│   └── 9.2.1
└── openocd
    └── 0.11.2-adhoc6ea4372.0

The "Workbench makefile" is located at ~/.particle/toolchains/buildscripts/1.9.2/Makefile, and it is used internally by both Workbench and neopo to build Particle projects. Here is an online copy.

In a sense, yes. Neopo is an unofficial tool that is the culmination of several years of my efforts to simplify local Particle development at the command line.

Particle CLI does not yet deal with local development. You must upload your source code to Particle's servers and download the produced binary. You have less control over how your binary is produced.

Particle Workbench is an exceptional tool, but it requires Visual Studio Code to operate. In environments where running a large Electron application is unfeasible or undesirable, neopo is an excellent alternative, providing access to the same toolchains and makefile used by Workbench.

In addition to supporting most of the build features of Workbench, neopo provides a Python API for running neopo commands and using Particle CLI from within Python, creating limitless ways to automate Particle development.

Finally, tab completion is included with neopo, making it much easier to find suitable arguments. (If you're interested in tab completion for Particle CLI, I've made a script for that as well.)

1 Like

Thank you @nrobinson2000 . A light-weight local development tool is great, so neopo sounds like just the right tool. So as you explain this tool uses ~/.particle; this would not interfere with a parallel version of local development (in another space) directly from command line would it? Are you saying that ~/.particle gets created by either neopo or the Workbench?

1 Like

Workbench and neopo can both use the toolchains stored in ~/.particle without any conflicts. If you want neopo to use a different directory you can export either the NEOPO_LOCAL or NEOPO_PATH variables.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.