STM32 DEPRECATED undefined reference to `Serial1'

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
imk
Posts: 31
Joined: Fri Sep 24, 2021 9:26 pm

STM32 DEPRECATED undefined reference to `Serial1'

Post by imk »

Hello,
I am working on a few STM32F411CEU6 projects, one of which i uses Serial1 port on default PA9/10
So i noticed in BoardMamager that STM32 was DEPRECATED and i should use the new library

So i replaced path https://github.com/stm32duino/BoardMana ... index.json
with new path https://github.com/stm32duino/boardmana ... index.json
and installed the new STM32 Libraries.

Recompiled the code and get compile error undefined reference to `Serial1'

Code is Serial1.begin(9600); // open serial port for ERIN tx/rx comms default PA9/10

Any ideas please, has Serial1 gone and what other to use please.

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

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by ag123 »

you'd need to select it (Serial) from the menu firsthand.
and if you didn't do that you could also try to define it like such
https://github.com/stm32duino/wiki/wiki ... wareserial
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by GonzoG »

There is only one "Serial" defined by default. If you use Serial for USB, then you need to define Serial1 by yourself.
It's all in the wiki: https://github.com/stm32duino/wiki/wiki ... wareserial
imk
Posts: 31
Joined: Fri Sep 24, 2021 9:26 pm

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by imk »

ag123 many thanks for reply,
I had set
Serial Enable Generic Serial and USB to CDC after i did the library update but got the missing serial1 error.

My BAD was i set Generic F411CEU not Black Pill F411CE, complies now.
But wondering why Generic F411CEU throws the error and not Black Pill F411CE when same chip?
imk
1201 Alarm
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by ag123 »

this is a little 'undocumented', generic variants normally has 'direct' pinmaps, i.e. PA1 is PA_1, PA2 is PA_2, Pyxx is Py_xx etc.
i.e. the pins are what they are based on stm32's definition in for the chip per the spec!
it is a 'good thing'

the other thing is, generic variants won't know what crystal you are running on, so it (normally) runs on HSI.
this is where u'd need to do some work to create a 'custom' variant, to use an external crystal i.e. HSE, u'd need to configure the PLL clocks.
This (RCC - reset and clocks control) difference alone could account for some differences in functionality.
imk
Posts: 31
Joined: Fri Sep 24, 2021 9:26 pm

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by imk »

ag123,

this is a little 'undocumented', generic variants normally has 'direct' pinmaps, i.e. PA1 is PA_1, PA2 is PA_2, Pyxx is Py_xx etc.
i.e. the pins are what they are based on stm32's definition in for the chip per the spec!
it is a 'good thing'

So are you saying I should use PA_1 as is more generic, makes code more portable across STM32 chips and maybe compile a little quicker?
If so "It is a Good Thing" :-)

I must admit I should be reading up on how Variant's works in Arduino as i think it maybe be key to my better upstanding.

BTW I notice Arduino Ver 2 IDE Release Candidate is out, i am currently testing with it and it is looks most interesting over 1.8.16
Pity STM32 compile times are longer than expected, i hope they will improve future, but all good for now.
Thanks again imk
1201 Alarm
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32 DEPRECATED undefined reference to `Serial1'

Post by ag123 »

There are about 2 main things in a 'variant', pin map.
Generally, i'd say it is better to just use stm32 definitions. STM core does it faithfully the 'Arduino way', using a pin map.
So STM core has functions that'd map the macro PA1 to PA_1, PA_1 is used 'internally', when using digitalRead(), digitalWrite(), analogRead(), analogWrite() and just about most 'Aduinoish' stuff, you should use PA1 rather than PA_1. i.e. the pinmap maps PA1 to PA_1.
using a pin map is occasionally useful as pin symbols like PA1 represents a physical ordering of the pins on the board. while PA_1 is the mcu pin spec sort of. Generic variants uses 'direct' pin maps, i.e. the physical ordering is same as mcu ordering (i think, mostly).

The use of a pinmap is interesting in the sense that you can swap things like uart1 to uart2 on the fly, dynamic, but in practice, the pinmap resides in flash. initializations etc are also complicating factors.

clock config, this is your PLL clock config to setup the system/cpu clock, and all the other pheriperial clocks.
for a 'custom' variant you'd need to define this, normally this is to use HSE the crystal on the board.
for generic variants, they would (normally) run off HSI, as it is unlikely it'd know what is your HSE crystal frequency.
Post Reply

Return to “IDE's”