Problems with I2C on F407VGT6

stm32_discoverer
Tue Feb 12, 2019 11:44 am
Hi everyone, I have a question about the I2C bus on the Board F407VGT6 Blackboard.I am using Arduino IDE 1.8.6, stm32core from Steverstrong Can’t compile the sketch…
#include <Wire.h>

HardWire HWire(1, I2C_FAST_MODE); // I2c1

void setup() {
Serial.begin(115200);
while(!Serial); delay(1000);
HWire.begin();
Serial.println("\nI2C Scanner");
}

uint32_t counter;

void loop() {
byte error, address;
int nDevices;

Serial.print(counter++);
Serial.println(": Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++) {
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.

HWire.beginTransmission(address);
error = HWire.endTransmission();

if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);

nDevices++;
}
else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found");
else
Serial.println("done");

delay(5000); // wait 5 seconds for next scan
}


stevestrong
Tue Feb 12, 2019 12:17 pm
It seems like an invalid installation path.
Normally, the Arduino_STM32 folder should be located under \Documents\Arduino\hardware.
Also see http://wiki.stm32duino.com/index.php?title=Installation.
Which board have you selected?
Upload method?

Also, please replace HardWire by TwoWire.


stm32_discoverer
Tue Feb 12, 2019 12:59 pm
I tried STM32 Discovery F407 and Generic STM32F407V series. The result is the same

stevestrong
Tue Feb 12, 2019 1:20 pm
Check again and correct your installation path.

stm32_discoverer
Tue Feb 12, 2019 1:47 pm
You was right,Steve, Arduino_STM32 folder wasn’t located under \Documents\Arduino\hardware.I fixed it.But now when compiling the sketch gives
In file included from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/usb.h:8:0,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/usb_serial.h:34,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/wirish.h:50,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\system/libmaple/Arduino.h:31,

from sketch\i2c_scanner_hardwire.ino.cpp:1:

C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/VCP/usb_conf.h:29:22: error: conflicting declaration 'typedef unsigned int uint32_t'

typedef unsigned int uint32_t;

^

In file included from c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\lib\gcc\arm-none-eabi\4.8.3\include\stdint.h:9:0,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/wirish.h:38,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\system/libmaple/Arduino.h:31,

from sketch\i2c_scanner_hardwire.ino.cpp:1:

c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdint.h:66:20: error: 'uint32_t' has a previous declaration as 'typedef __uint32_t uint32_t'

typedef __uint32_t uint32_t ;

^

exit status 1


stevestrong
Tue Feb 12, 2019 2:48 pm
Yepp, you hit a very delicate point.
Unfortunately, the compiler internal definition (unsigned long) does not match the core definition (unsigned int) for uint32_t.

Alternative solutions:
1. – change/comment out this line https://github.com/stevstrong/Arduino_S … conf.h#L29
or
2. – change the compiler definition in c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdint.h:66 to unsigned int

I applied solution nr 2. on my PC.


stm32_discoverer
Wed Feb 13, 2019 12:24 pm
Hi, Steve, now there’s another problem. I reinstalled Arduino IDE to version 1.8.8, followed all the steps according to the installation instructions:
-Download and install the version 1.8.5 of the Arduino IDE.
-Run the IDE, and on the Tools menu, select the Boards manager, and install the Arduino SAM boards (Cortex-M3) from the list of available boards.
-Download zip file containing the STM32 files .
-Unzip to create the Arduino_STM32 folder.
– Copy the Arduino_STM32 folder to My Documents/Arduino/hardware (Note: if the hardware folder doesn’t exist you will need to create it).
-Re-start the Arduino IDE.
Аnd now when you select any Board stm32 does not compile even an empty sketch. Throws errors.
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

stevestrong
Wed Feb 13, 2019 12:30 pm
You have to change the line in
c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdint.h:66

stm32_discoverer
Wed Feb 13, 2019 12:47 pm
Yes, I did as you wrote.And now there is another error:
In file included from c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\lib\gcc\arm-none-eabi\4.8.3\include\stdint.h:9:0,

from c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\inttypes.h:17,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/libmaple_types.h:36,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_regs.h:28,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_core.h:28,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_dcd.h:27,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_core.h:27,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h:29,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h:27,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\usbF4\usb.c:5:

c:\users\user-2\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdint.h:67:22: error: conflicting types for 'uint32_t'

typedef unsigned int uint32_t;

^

In file included from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/VCP/usbd_conf.h:28:0,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_def.h:27,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h:28,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h:27,

from C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\usbF4\usb.c:5:

C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/usbF4/VCP/usb_conf.h:29:24: note: previous declaration of 'uint32_t' was here

typedef unsigned long uint32_t;

^

exit status 1


stm32_discoverer
Wed Feb 13, 2019 1:02 pm
//typedef __uint16_t unsigned int ;
typedef unsigned int uint32_t;

stevestrong
Wed Feb 13, 2019 1:02 pm
It seems you downloaded Roger’s repo instead of mine.
In my repo that line looks different: https://github.com/stevstrong/Arduino_S … conf.h#L29.

stm32_discoverer
Wed Feb 13, 2019 1:39 pm
I checked, the core is yours

stevestrong
Wed Feb 13, 2019 1:42 pm
Why is then the online version not matching your local version?

stm32_discoverer
Wed Feb 13, 2019 2:15 pm
Now once again compiled a blank sketch, Arduino IDE version 1.8, Arduino_STM32 StevStrong core, the board – STM32 Discovery F407. now gives here such error
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:1: error: 'ETH_REF_CLK' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:14: error: 'ETH_MDIO' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:24: error: 'ETH_CRS_DV' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:36: error: 'ETH_TX_EN' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:47: error: 'ETH_TX_D0' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:58: error: 'ETH_TX_D1' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:69: error: 'ETH_MDC' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:78: error: 'ETH_RX_D0' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\ethernet.c:14:89: error: 'ETH_RX_D1' undeclared here (not in a function)
ETH_REF_CLK, ETH_MDIO, ETH_CRS_DV, ETH_TX_EN, ETH_TX_D0, ETH_TX_D1, ETH_MDC, ETH_RX_D0, ETH_RX_D1
^
exit status 1

stevestrong
Wed Feb 13, 2019 6:28 pm
Thanks for pointing out that issue, I just pushed the fix for that.
Please get the new version from github.

For bugs you can also start an issue on github.


stm32_discoverer
Thu Feb 14, 2019 7:43 am
Hi Steve, I updated your core, and now when I compile an empty sketch, I get errors again
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\rccF4.c: In function 'rcc_clk_init':
C:\Users\user-2\Documents\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple\libmaple\rccF4.c:463:6: error: #elif with no expression
#elif
^
exit status 1

stevestrong
Thu Feb 14, 2019 8:22 am
Hm, weird, I don’t get that error, maybe because I use the newest GCC version.
But I corrected it (replaced #elif with #else) anyway. Thanks for reporting.

stm32_discoverer
Thu Feb 14, 2019 9:26 am
Steve, I updated your core again, and when I compile an empty sketch – everything is ok, but when I compile an sketch just with – Serial.begin (115200);, I get an error again
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
// put your main code here, to run repeatedly:
}


stevestrong
Thu Feb 14, 2019 9:37 am
This is because you have selected the F4 discovery board.
Although this board is present in the repo, but is actually not tested, and I am not sure whether it has direct USB serial connection feature or not.

The main target of my F4 repo are the F407 generic boards (black and mini VET6) and Arch max v1.1, so that I cannot guarantee that any other board will work.
Also note that the USB serial feature can be selected in the Arduino IDE menu.

For VGT6 I would suggest to either clone my repo and make a new VGT6 board variant based on VET6, or submit a PR with the newly generated variant.


stm32_discoverer
Thu Feb 14, 2019 10:05 am
Ok, but now I’m trying to compile the – i2c_scanner_hardwire sketch again,the board is – Generic STM32F407V series, and I get an error again
#include "Wire.h"

TwoWire HWire(1, I2C_FAST_MODE); // I2c1
// optionally, it is possible to use the default declared Wire(1) instance with normal speed
//#define HWire Wire

void setup() {
Serial.begin(115200);
while(!Serial); delay(1000);
HWire.begin();
Serial.println("\nI2C Scanner");
}

uint32_t counter;

void loop() {
byte error, address;
int nDevices;
Serial.print(counter++);
Serial.println(": Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++) {
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
HWire.beginTransmission(address);
error = HWire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
nDevices++;
}
else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found");
else
Serial.println("done");
delay(5000); // wait 5 seconds for next scan
}


stevestrong
Thu Feb 14, 2019 10:57 am
It seems I forgot to update all I2C files last time i changed HardWire to TwoWire.
I have corrected this, please check it out again.

stm32_discoverer
Thu Feb 14, 2019 11:45 am
Yes Steve,finally that’s ok now, the sketch compilation was successful!!! :) If you don’t mind, I’ll I’ll continue to detect bugs when compiling various sketches of the F407 Boards

stevestrong
Thu Feb 14, 2019 11:48 am
No problem, I would be glad to have some else testing it.

BennehBoy
Thu Feb 14, 2019 1:43 pm
STM core has VGT6 in the new 1.5.0 release, along with USB CDC (Serial), i2c works.

mrburnette
Thu Feb 14, 2019 4:33 pm
[BennehBoy – Thu Feb 14, 2019 1:43 pm] –
STM core has VGT6 in the new 1.5.0 release, along with USB CDC (Serial), i2c works.

Steve’s F4 is not going away and he has indicated that bug-fixes will be managed via github after this forum shuts down.

I’m a serious pusher for users to move to the STM Official Core, but there will be users that will stay with Roger’s F1 and Steve’s F4 based upon their needs. Roger has not indicated to me that he will continue to do break-fix on the F1 after April 27th.

IMHO, having Steve’s F4 maintained into the future is far more important as it offers a lean migration path from F1 to F4 … important for end-users pushing the limits of the F1 today.

Ray


stevestrong
Fri Feb 15, 2019 8:29 am
Yes Ray, I intend to maintain in the future both my F1 and F4 libmaple-based repos.

Leave a Reply

Your email address will not be published. Required fields are marked *