Fatal error: stm32f4xx.h: No such file or directory

Hi im trying to compile the example receiver code for the adafruit rfm95 radio on the tracker SoM.

#include <SPI.h>
#include <RH_RF95.h>
SYSTEM_THREAD(ENABLED)
#define RFM95_CS A0
#define RFM95_RST A2
#define RFM95_INT A1
// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
void setup() 
{   
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
  while (!Serial);
  Serial.begin(9600);
  delay(100);
  Serial.println("Arduino LoRa RX Test!");
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  rf95.setTxPower(23, false);
}

void loop()
{
  if (rf95.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf95.recv(buf, &len))
    {
      Serial.println("Receive failed");
    }
  }
}

But during compiling i get the following error

fatal error: stm32f4xx.h: No such file or directory

Im using the Radiohead.h library.

this is the section of code that is giving me the error, its from the RadioHead.h file

#elif (RH_PLATFORM == RH_PLATFORM_STM32STD) // STM32 with STM32F4xx_StdPeriph_Driver
#include <stm32f4xx.h> // This is the line that is giving me the error, it says no such file directory
#include <wirish.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <HardwareSPI.h>
#define RH_HAVE_HARDWARE_SPI
#define Serial SerialUSB
#define RH_HAVE_SERIAL

Ive tried to compile it for device os 2.0.1 and the latest 3.0.0-rc.2 without any luck. The libraries are downloaded to the src folder.
Any help will be appreciated.

What IDE are you building with?
Can you check that actual state of the RH_PLATFORM macro?
Since the TrackerSoM does not feature a STM32Fx chip your build should not include that conditional block.
Have you set the correct target platform in your IDE?

1 Like

im using the vscode with particle workbench. and yes i have set the target to the tracker. also I understand that the tracker doesn’t use the stm32 chip but i keep getting this error.

Have you tried this suggestion?

what exactly do you mean by state of the macro? from what i see on the header file, there is nothing specific assigned to it, it just checks for what type of processor I’m using. Sorry if it seems like a stupid question.

RH_PLATFORM must be set somewhere in order to be checked against the respective reference (i.e. RH_PLATFORM_STM32STD).

Where does it actually get set and why?

Also where does RH_PLATFORM_STM32STD get set and what value are they?

Looking at the library I’d suspect the problem to stem from here

where RH_PLATFORM gets set to RH_PLATFORM_STM32STD erroneously.
BTW, it seems the nRF52840 isn’t supported by that library at all.

Ive gone through all the .cpp and .h file. The RHHardwareSPI.cpp file uses RH_PLATFORM at line 189. this is the only file outside of radiohead.h to use the RH_PLATFORM_STM32STD.

#elif (RH_PLATFORM == RH_PLATFORM_STM32STD) // STM32F4 discovery
uint8_t dataMode;
if (_dataMode == DataMode0)
dataMode = SPI_MODE0;
else if (_dataMode == DataMode1)
dataMode = SPI_MODE1;
else if (_dataMode == DataMode2)
dataMode = SPI_MODE2;
else if (_dataMode == DataMode3)
dataMode = SPI_MODE3;
else
dataMode = SPI_MODE0;
uint32_t bitOrder;
if (_bitOrder == BitOrderLSBFirst)
bitOrder = LSBFIRST;
else
bitOrder = MSBFIRST;
SPIFrequency frequency; // Yes, I know these are not exact equivalents.
switch (_frequency)
{
case Frequency1MHz:
default:
frequency = SPI_1_3125MHZ;
break;
case Frequency2MHz:
frequency = SPI_2_625MHZ;
break;
case Frequency4MHz:
frequency = SPI_5_25MHZ;
break;
case Frequency8MHz:
frequency = SPI_10_5MHZ;
break;
case Frequency16MHz:
frequency = SPI_21_0MHZ;
break;
}
SPI.begin(frequency, bitOrder, dataMode);

II have gone through all other .cpp and .h files and they use the RH_PLATFORM to check which processor is used but none have RH_PLATFORM_STM32STD

And yes i also have come to the conclusion that the nRF52840 is supported. If that is the case could you help me add the necessary code to the files?

@chickennuggies, I wonder if setting as RH_PLATFORM_ARDUINO would not work.

you mean in the RHHardwareSPI.cpp file? If so then i could try that out

@chickennuggies, what I mean is that if you #define ARDUINO in your code before the #include "RadioHead.h", then:

 #elif defined(ARDUINO)
  #define RH_PLATFORM RH_PLATFORM_ARDUINO

Hopefully, this will make the library work though I have my doubts.

no that didnt work also i got another error when i added the line you gave.
in the RadioHead.h file line 751

#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <wiring.h> // this line has squiggly red lines (for me its at line 751)
#endif
#ifdef RH_PLATFORM_ATTINY

@chickennuggies does it compile though?

no it gave me, same issue as the beginning

fatal error: stm32f4xx.h: No such file or directory
802 | #include <stm32f4xx.h>

The terminal process “C:\Users\Usr.particle\toolchains\buildtools\1.1.1\bin\bash.exe ‘-c’, ‘make -f ‘C:\Users\Usr.particle\toolchains\buildscripts\1.10.0\Makefile’ compile-user -s’” terminated with exit code: 2.

I was afraid of that. It’s picking up flags from the compiler environment (eg. arm).

@peekay123 @ScruffR Do you know how i can get hold of the header file that is causing the problem?

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