genericSTM32F405RG serial print output

Post here all questions related to STM32 core if you can't find a relevant section!
Jye
Posts: 7
Joined: Thu Dec 19, 2019 8:38 pm

genericSTM32F405RG serial print output

Post by Jye »

Hi,

I am having problems getting serial.print to work on the genericSTM32F405RG. My hardware is a flight controller, but otherwise just a normal F405. Below is the PFIO .ini and main. The LED blinks fine, but no matter what I try to do with serial and setting pins I cant get an output. Serial upload works so I know the uart is ok.

Is someone able to confirm the genericSTM32F405RG target is working, or point out if Ive made a silly mistake :(

Cheers

Code: Select all

[env:genericSTM32F405RG]
platform = ststm32@14.0.1
framework = arduino
board = genericSTM32F405RG
upload_protocol = serial

Code: Select all

#include <Arduino.h>

#define LEDPIN PA8

void setup()
{
  Serial.setTx(PA9);
  Serial.setRx(PA10);
  Serial.begin(9600);

  pinMode(LEDPIN, OUTPUT);
}

void loop()
{
  Serial.println("loop");

  digitalWrite(LEDPIN, HIGH);
  delay(250);
  digitalWrite(LEDPIN, LOW);
  delay(250);
}
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

Out of curiosity I tested a F405RG board I never used before as blue pill suffices all my needs.
I could not get the serial working not even blink test although the download via serial or STlink was successful.

Then I switched to Roger's core and programmed it as a F407V, both serial and blink worked fine.
I afterwards re-tried the STM32 core but programmed as F407VE and it worked perfectly.
Jye
Posts: 7
Joined: Thu Dec 19, 2019 8:38 pm

Re: genericSTM32F405RG serial print output

Post by Jye »

Thanks for testing. I just tried a couple of f407 targets and they blink an led but still no serial :(

Code: Select all

; board = genericSTM32F407VET6
; board = genericSTM32F407VGT6
board = black_f407ve
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

My setup:
Arduino IDE v1.8.12
STM32 core v1.9
USART Enabled Generic Serial
USB support No
Board Generic F407VE

I used exactly your sketch and both Blink/Serial worked. My board has a 8MHz crystal . Change the HSE if you use a different value, e.g.
#define HSE_VALUE 12000000U

I do not know why selecting the board as Generic F405RG did not work but the workaround above seemed fine with me. Good luck.
Jye
Posts: 7
Joined: Thu Dec 19, 2019 8:38 pm

Re: genericSTM32F405RG serial print output

Post by Jye »

Thanks for the info. I gave it a try with the arduino IDE, but still not luck :(

I might open an issue later considering you also couldn't get it working with the 405 target.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: genericSTM32F405RG serial print output

Post by fpiSTM »

Under arduino it works.
Jye
Posts: 7
Joined: Thu Dec 19, 2019 8:38 pm

Re: genericSTM32F405RG serial print output

Post by Jye »

hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

I retried by setting my board as Adafruit Feather STM32F405, both the blink (PC1) and Serial3 worked fine. I just needed to set the baud rate to 14400 to match the 8MHz clock on my board as the default for Feather is 12MHz.

However it did not work at all when I set the board back to Generic F405RG. There were no compilation errors but no blink and no serial. I noticed that you got progress by using other serial ports yet that would not work for me.
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: genericSTM32F405RG serial print output

Post by hobbya »

Some more observations.

Set board as Feather F405
Complied and programmed by Arduino IDE via SWD
Blink and serial worked
Device flash size detected by ST-link Utility = 1 MBytes

Set board as Generic F405RG
Complied and programmed by Arduino IDE via SWD
Blink and serial failed
Device flash size detected by ST-link Utility = 2 KBytes

My set up:
Windows 7 x64
Arduino 1.8.15
STM32 Core 1.9.0

I removed the STM core and re-installed but results did not change. Generic F405RG did not work for me.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: genericSTM32F405RG serial print output

Post by ag123 »

if you are using linux, do check out this faq here. modem manager can interfere with usb-serial lines treating them as modems.
https://github.com/stm32duino/wiki/wiki ... itor-fails

for windows i'm not too sure, but then i'd hope someone update the faq for windows part as well.
among the things i can think of:
- missing 'drivers'. accordingly windows has usb cdc built-in, but that you may still need to 'register' the driver against the vid : pid codes.
- windows may try to treat it as a modem just like linux if vid : pid is not found

if it does not blink, things to try are to flash that binary manually to make sure that it is after all correctly installed.
if that doesn't work, things to check are if some other 'download methods' or boot loaders are selected which can change the start address of the sketch firmware. stm32f405 doesn't need a boot loader, it has a built in dfu boot loader, but that u'd need to set boot0
Post Reply

Return to “General discussion”