Some updates to F4

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Some updates to F4

Post by RogerClark » Wed May 06, 2015 6:50 am

I just took a quick look at the F4 and there are several things that I think can be improved straight away,

Firstly its missing the enum that maps pin names e.g PA0 to he PIN_MAP[0]

Also the compiler is being set as cortex-m3 but the processor is a cortex-m4

I've tried changing this and it still seems to compile OK.

One thing I have noticed is that sometimes it doesn't run after the upload via STlink,

I thought this could be because I switched to cortex-m4 and that the compile had failed, but I pressed the reset button and it had uploaded OK

and the next upload was OK

So I think its something in the stlink uploader that is intermittent.

I have swictched to an open source uploader (Texane-stlink) instead of the STM proprietary uploader but its the same one as we use on all platforms on the F103, so it should be OK.

Re: Serial

Yes.

Very odd. I'm not sure why Hardware Serial doesn't seem to work. As far as I can tell its being initialised and setup etc, but its definitely not working

HW serial 1 is connected to the OTG USB port, so I wonder if I damaged it by connecting it to my PC at some time, but if its not working for you either. Then perhaps we have both tried connecting OTG to the PC or its a different problem

Anyway, I will push the change to the repo, so that sketches like this work

Code: Select all

void setup() {
  // put your setup code here, to run once:
//Serial1.begin(115200);
Serial2.begin(115200);
//Serial3.begin(115200);
//Serial4.begin(115200);
pinMode(PD12,OUTPUT);
pinMode(PD13,OUTPUT);
pinMode(PD14,OUTPUT);
pinMode(PD15,OUTPUT);
}
int c;

void loop() {
  // put your main code here, to run repeatedly:
//Serial1.println("Serial");
Serial2.println("Serial1");
//Serial3.println("Serial2");
//Serial4.println("Serial3");
toggle(PD12);
toggle(PD13);

toggle(PD14);
toggle(PD15);


delay(250);
}

void toggle(int pin)
{
  digitalWrite(pin,!digitalRead(pin));
}

User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Hardware serial 1

Post by RogerClark » Wed May 06, 2015 7:09 am

Looking at the F4 code, I think reason that HW serial 1 is not working is that its shared with the OTG USB port, i.e I think that's the USB host port

I guess perhaps the thing to do is to map Serial to HW serial 2, and use that for debugging

Funsailor
Posts: 5
Joined: Tue Jul 14, 2015 10:51 am

Re: Some updates to F4

Post by Funsailor » Tue Jul 21, 2015 10:09 pm

Hi Roger,
now I test a STM32F4 Discovery.
I check in the actual gitub version and have this Problem:

C:\Arduino\hardware\Arduino_STM32\STM32F4\cores\maple/libmaple/spiF4.h:78:8: error: '__always_inline' does not name a type
static __always_inline void spi_gpio_cfg(uint8 as_master,

and

c:\users\mikel\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdlib.h:67:5: error: expected unqualified-id before 'int'
int _EXFUN(abs,(int));

any idea?

-> in the file
..\STM32F4\cores\maple\arduino.h
is the wrong include "variant.h"
I set this in comment
------------------------------
#ifndef Arduino_h
#define Arduino_h
#include "WProgram.h"
#endif

//#include "variant.h"
------------------------------

User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Some updates to F4

Post by RogerClark » Tue Jul 21, 2015 10:16 pm

ummm

__always_inline is a one of the issues on the To Do list.

I thought from what Rick Kimball has written that this is a built in name inside gcc

perhaps its a typo.

The best person to ask is @martinayotte as he has done all the recent changes in the F4 repo.

User avatar
martinayotte
Posts: 1241
Joined: Mon Apr 27, 2015 1:45 pm

Re: Some updates to F4

Post by martinayotte » Wed Jul 22, 2015 3:01 am

For the __always_inline inline problem, yes, I figured out, I did the merge from Rick, but I've never pushed it back to github F4 folder. (I'm apologise here ;) )
This line should be inserted in STM32F4/cores/maple/libmaple/libmaple_types.h at line 50

Code: Select all

#define __always_inline inline __attribute__((always_inline))
For the other error, I've no clue, and it is especially strange.

User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Some updates to F4

Post by RogerClark » Wed Jul 22, 2015 4:05 am

Martin

Thanks.

I've directly updated that source (edited the file on GitHub)

Hopefully that will fix one of the issues, but I agree, I'm not sure whats going on with the other issue.

Perhaps if the OP tries with the change for __always_line the other issue may go away (but probably not )

User avatar
martinayotte
Posts: 1241
Joined: Mon Apr 27, 2015 1:45 pm

Re: Some updates to F4

Post by martinayotte » Wed Jul 22, 2015 4:13 pm

I've dig a bit further the second issue, I found that I had to comment that line back in May.
I don't understand the real issue, but simply commenting it solved it.

Code: Select all

arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdlib.h:67:5: error: expected unqualified-id before 'int'
int _EXFUN(abs,(int));

Code: Select all

//int   _EXFUN(abs,(int));

User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Some updates to F4

Post by RogerClark » Wed Jul 22, 2015 9:02 pm

Martin

Thanks

I recall seeing errors with EXFUN() before, but I cant recall what i did to overcome them.

I think possibly that i saw similar issues when making some other changes, ( to the F1), but suspect i didn't end up implementing the changes, due to the EXFUN() issue.

This problem, may be something that Rick has also come across, as he has explored building with different IDEs etc.

But I think its best for the OP to get back to us first, in case they solved their own problem

User avatar
martinayotte
Posts: 1241
Joined: Mon Apr 27, 2015 1:45 pm

Re: Some updates to F4

Post by martinayotte » Thu Jul 23, 2015 1:31 am

Actually, I don't understand this purely GCC issue, the error message is not meaningful.
Trying to google about it, I only seeing that is parenthesis syntax issue. I hate those bugs ! :evil: (they are not in my code ;) )
Maybe Rick expert will bring us light on that ?
How it is working on F1 ? :( I presume it depend of sketch context ...
In the mean time, Funsailor, simply commenting out like I did ...

User avatar
Rick Kimball
Posts: 1078
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Some updates to F4

Post by Rick Kimball » Fri Jul 24, 2015 3:25 pm

I grabbed the latest github source and when I compile for the STM32 Discovery F407 I get this message:

Code: Select all

/home/kimballr/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_discovery_f407 -DVECT_TAB_BASE -DERROR_LED_PORT=GPIOD -DERROR_LED_PIN=14 -mcpu=cortex-m4 -DF_CPU=168000000L -DARDUINO=10606 -DARDUINO_STM32F4_DISCOVERY_F407 -DARDUINO_ARCH_STM32F4 -DMCU_STM32F406VG -mthumb -DSTM32_HIGH_DENSITY -DSTM32F2 -DSTM32F4 -DBOARD_discovery_f4 -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple/usbF4 -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_OTG_Driver/inc -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/libmaple/usbF4/VCP -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple -I/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/variants/discovery_f407 /tmp/build1716864136632058487.tmp/sketch/sketch_jul24a.cpp -o /tmp/build1716864136632058487.tmp/sketch/sketch_jul24a.cpp.o 
In file included from sketch_jul24a.ino:1:0:
/mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F4/cores/maple/Arduino.h:6:21: fatal error: variant.h: No such file or directory
 #include "variant.h"
                     ^
compilation terminated.
Error compiling.
I went ahead and added a "variant.h" to my STM32F4 core...

-rick

[Edit: ... I missed that @Funsailor already mentioned this problem]
Last edited by Rick Kimball on Fri Jul 24, 2015 5:26 pm, edited 2 times in total.
-rick

Post Reply