STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

xtream123
Posts: 22
Joined: Thu Dec 19, 2019 1:23 am

STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by xtream123 »

Hi there guys,
As the title implies, if I combine all the codes to run the six uart/s and USB Serial(CDC) the program hangs up and stop sending the debug message.
Please suggest any thing that I can do with the code or is it something to be changed in the core?
No error encountered during compilation.

Im Using:
OS: Windows 10
IDE : Arduino IDE 1.8.10
Core : StevStrong core (https://github.com/stevstrong/Arduino_STM32)

Board settings: Generic STM32f407V series
USB Configuration: USB Serial (CDC)
Upload method : ST link (im using jlink to upload the bin file)

Here is my sample code:

Code: Select all

void setup() {
  Serial.begin(115200);
  Serial1.begin(152000);
  Serial2.begin(152000);
  Serial3.begin(152000);
  Serial4.begin(152000);
  Serial5.begin(152000);
  Serial6.begin(152000);
  delay(1000);
  Serial.println("Start");
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {
    Serial.write(Serial.read());
  }
  delay(1000);
  Serial.println("USB Serial Test tx");
  // delay(10);
  Serial1.println("Serial1 Test tx");
  Serial2.println("Serial2 Test tx");
  Serial3.println("Serial3 Test tx");
  Serial4.println("Serial4 Test tx");
  Serial5.println("Serial5 Test tx");
  Serial6.println("Serial6 Test tx");

}

ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by ag123 »

try a debug?
or did you try commenting the serialX to see where the 'hang' occurs?
xtream123
Posts: 22
Joined: Thu Dec 19, 2019 1:23 am

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by xtream123 »

ag123 wrote: Thu Jan 02, 2020 4:22 am try a debug?
or did you try commenting the serialX to see where the 'hang' occurs?
Thanks for your suggestion :)

What I have tested is,
1. Use only the USB serial (Serial) --> result does not hang
2. Use USB Serial(Serial) and added Serial1 --> result does hang
3. I just added all the serial and USB Serial(Serial) --> result does hang
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by ag123 »

Code: Select all

  Serial1.begin(152000);
tried

Code: Select all

  Serial1.begin(115200);
instead?
152000 seemed quite odd a baud rate, but nevertheless, stm32's uart tend to still work with odd baud rates
i actually tried successfully to connect esp8266 at 74880 baud on stm32f103

to dig into the bottom of it one may need a debugger
some alternatives are to Serial.print() to the usb-serial console to try to figure out where it got stuck

it is quite possible to do that with gdb / openocd / st-link-v2
https://ardupilot.org/dev/docs/debuggin ... stm32.html
then there are 'full suite' setups patched into eclipse etc e.g.
https://www.openstm32.org/System%2BWork ... or%2BSTM32
https://github.com/stm32duino/wiki/wiki/How-to-debug

one other trick that i tend to use
are things like

Code: Select all

void blinks(int8 led_pin) {
	bool led = true;
	for(int i=0; i<10;i++) {
		digitalWrite(led_pin, led);
		led = ~led;
		delay(100);
	}
}	
then i called blinks deep into various codes to see where it reached, you could literally try different blinks() patterns and different leds
Last edited by ag123 on Thu Jan 02, 2020 7:21 am, edited 1 time in total.
xtream123
Posts: 22
Joined: Thu Dec 19, 2019 1:23 am

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by xtream123 »

ag123 wrote: Thu Jan 02, 2020 6:20 am

Code: Select all

  Serial1.begin(152000);
tried

Code: Select all

  Serial1.begin(115200);
instead?
152000 seemed quite odd a baud rate, but nevertheless, stm32's uart tend to still work with odd baud rates
i actually tried successfully to connect esp8266 at 74880 baud on stm32f103

to dig into the bottom of it one may need a debugger
some alternatives are to Serial.print() to the usb-serial console to try to figure out where it got stuck

it is quite possible to do that with gdb / openocd / st-link-v2
https://ardupilot.org/dev/docs/debuggin ... stm32.html
then there are 'full suite' setups patched into eclipse etc e.g.
https://www.openstm32.org/System%2BWork ... or%2BSTM32
https://github.com/stm32duino/wiki/wiki/How-to-debug
the baudrate is quite wrong, its my mistake to make it 152000, it should be 115200. Thanks

I tried to put debug message in each every line to see where it got stuck. It get stuck after sending from Serial then Serial1.

BTW, I got to make it work now, I downgraded my arduino IDE to 1.8.9 and it works perfectly.
I also created a test code. see below.

I'm just wondering why this code is not working in 1.8.10 and it works in 1.8.9.

Thanks.

Code: Select all

/*
  file: generic_f407v.h
  #define BOARD_NR_USARTS         6
  #define BOARD_USART1_TX_PIN     PA9
  #define BOARD_USART1_RX_PIN     PA10
  #define BOARD_USART2_TX_PIN     PA2
  #define BOARD_USART2_RX_PIN     PA3
  #define BOARD_USART3_TX_PIN     PB10
  #define BOARD_USART3_RX_PIN     PB11
  #define BOARD_UART4_TX_PIN      PA0
  #define BOARD_UART4_RX_PIN      PA1
  #define BOARD_UART5_TX_PIN      PC12 // SDIO_CLK !!
  #define BOARD_UART5_RX_PIN      PD2  // SDIO_CMD
  #define BOARD_USART6_TX_PIN     PC6  // DCMI_D0 !!
  #define BOARD_USART6_RX_PIN     PC7  // DCMI_D1 !!
*/

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial1.begin(115200);
  Serial2.begin(115200);
  Serial3.begin(115200);
  Serial4.begin(115200);
  Serial5.begin(115200);
  Serial6.begin(115200);
  delay(1000);
  Serial.println("Start");
  pinMode(PA6, OUTPUT);

}

void loop() {
  static unsigned prevTime = 0;

  if (millis() - prevTime > 1000) {//send in every interval
    Serial.println("USBSerial");
    Serial1.println("Serial1");
    Serial2.println("Serial2");
    Serial3.println("Serial3");
    Serial4.println("Serial4");
    Serial5.println("Serial5");
    Serial6.println("Serial6");
    prevTime = millis();
  }

  //Rx test
  if (Serial.available() > 0) {
    Serial.write(Serial.read());
  }

  if (Serial1.available() > 0) {
    Serial.write(Serial1.read());
  }

  if (Serial2.available() > 0) {
    Serial.write(Serial2.read());
  }

  if (Serial3.available() > 0) {
    Serial.write(Serial3.read());
  }

  if (Serial4.available() > 0) {
    Serial.write(Serial4.read());
  }

  if (Serial5.available() > 0) {
    Serial.write(Serial5.read());
  }

  if (Serial6.available() > 0) {
    Serial.write(Serial6.read());
  }



  static unsigned long ptime = millis();
  static bool val = 1;
  if (millis() - ptime > 120) {//heart beat, built in LED
    if (val == 1) {
      val = 0;
      digitalWrite(PA6, LOW);
    } else if (val == 0) {
      val = 1;
      digitalWrite(PA6, HIGH);
    }
    ptime = millis();
  }

}
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by ag123 »

btw i tend to work in eclipse and used a makefile.
between the releases, the way it (Arduino IDE) reads platform.txt and boards.txt may have varied, if it fails to do like previous, it could have an impact

this is a recent makefile i used with f401 black pill
viewtopic.php?f=47&t=37&p=328#p327

this is an old makefile i used with f407
viewtopic.php?f=47&t=37&p=328#p328

if you work in windows, you probably need WSL to use the makefiles. u'd need the linux arm-none-eabi gcc stacks too installed in the linux environment
https://docs.microsoft.com/en-us/window ... tall-win10
Last edited by ag123 on Thu Jan 02, 2020 7:11 am, edited 3 times in total.
xtream123
Posts: 22
Joined: Thu Dec 19, 2019 1:23 am

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by xtream123 »

oh..good input :) I learned something new with you.
Well i dont know how to make a makefile as I have encountered it a lot of times.

Maybe @stevstrong should check this out so it will work on 1.8.10.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by ag123 »

working in eclipse has one thing i liked, it can search and jump from symbol to symbol / function referenced etc
so it is easy to do a 'deep dive' e.g. from Serial1.print() i can drill down into print etc to see where are the codes

the 'bad' thing about eclipse and possibly even Arduino IDE, is that the configs (defines, includes, sources, compiler flags and library paths) are set in the GUI. especially in eclipse (without nice plugins like sloeber https://eclipse.baeyens.it/), i've had to redo all my defines, includes, source paths, and flags with each new sketch/project. that is 'painful'.

in the end i used makefiles instead
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by stevestrong »

I can reproduce the issue, please wait for a solution I will post on Github.
xtream123
Posts: 22
Joined: Thu Dec 19, 2019 1:23 am

Re: STM32F407VE hang up using USB Serial(CDC) with 6 serial on.

Post by xtream123 »

stevestrong wrote: Thu Jan 02, 2020 3:16 pm I can reproduce the issue, please wait for a solution I will post on Github.
Thank you :)
Post Reply

Return to “STM32F4 based boards”