Modifying board definitions corectly

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
aleskramzar
Posts: 2
Joined: Wed Sep 28, 2022 12:04 pm

Modifying board definitions corectly

Post by aleskramzar »

Hello,

I am developing a custom board based on stm32F030CCTx chip. I have generated a custom board variant in STM32duino and it works ok. My main goal is to use all 6 uarts that the chip offers. But due to an unrelated issue i can not use this board because a library does not play well with it.
Therefore i have opted to use the built in board stm32F030C8Tx , which is almost identical other then the fact that that chip only has 2 USARTS.
All my code is compatible between both of them (other then the USART part) and if i compile the code for this chip the library plays nicely.

So i am trying to modify the board definition files so that i can use all 6 USARTS on the chip, while still compiling for stm32F030C8Tx (since the library likes that better).
I have been modifying the files in \AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.3.0\variants\STM32F0xx\F030C8T

So far i have edited the ParipheralPins.c file so that it is the same as that of stm32F030CCTx, but the compiler still spews out errors:

error: 'USART3' undeclared here (not in a function); did you mean 'USART1'?

'GPIO_AF4_USART3' undeclared here (not in a function); did you mean 'GPIO_AF1_USART1'?


My question is how do i modify the files so that i can add more USARTS?

here is the simple code i am using to test usart functionality:

#include <HardwareSerial.h>

HardwareSerial Serial_MODBUS_S1(USART1);
HardwareSerial Serial_mbus_1(USART2);
HardwareSerial Serial_MODBUS_M2(USART3);
HardwareSerial Serial_MODBUS_S2(USART4);
HardwareSerial Serial_mbus_2(USART5);
HardwareSerial Serial_MODBUS_M1(USART6);

int BAUD1 = 9600;
int BAUD2 = 9600;
int BAUD3 = 9600;
int BAUD4 = 9600;
int BAUD5 = 9600;
int BAUD6 = 9600;

void setup() {
Serial_MODBUS_S1.begin(BAUD1);
Serial_MODBUS_S2.begin(BAUD2);
Serial_MODBUS_M1.begin(BAUD3);
Serial_MODBUS_M2.begin(BAUD4);
Serial_mbus_1.begin(BAUD5);
Serial_mbus_2.begin(BAUD6);

}

void loop() {
Serial_MODBUS_M1.println("Serial_MODBUS_M1:");
Serial_MODBUS_M2.println("Serial_MODBUS_M2:");
Serial_mbus_1.println("Serial_mbus_1:");
Serial_mbus_2.println("Serial_mbus_2");
Serial_MODBUS_S2.println("Serial_MODBUS_S2");
Serial_MODBUS_S1.println("Serial_MODBUS_S1");

delay(1000);
}

This works good when compiled for stm32F030CCTx board bot cant compile for stm32F030C8Tx
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Modifying board definitions corectly

Post by GonzoG »

F030C8 does not have 6 UARTS. It has only 2: USART1 and USART2.
USART3, 4, 5 and 6 are only on F030xC MCUs.
https://www.st.com/resource/en/datashee ... f030c8.pdf
aleskramzar
Posts: 2
Joined: Wed Sep 28, 2022 12:04 pm

Re: Modifying board definitions corectly

Post by aleskramzar »

GonzoG wrote: Wed Sep 28, 2022 12:47 pm F030C8 does not have 6 UARTS. It has only 2: USART1 and USART2.
USART3, 4, 5 and 6 are only on F030xC MCUs.
https://www.st.com/resource/en/datashee ... f030c8.pdf
Thats what i said in the post. i know 030C8 has onyl 2 USARTS. but i am using 030CC which has 6. I am trying to modify the board definition so that in the files it compiles for 6 USARTS. i know this code would never work on 030C8, but i dont plan to use one anyway.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Modifying board definitions corectly

Post by GonzoG »

Then you have to edit few other files as many functions depend on MCU definition (e.g. uart.c).
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Modifying board definitions corectly

Post by fpiSTM »

You have to use the F030CC variant, modifying C8 to get more IP is more difficult than declaring new generic which only require to add the linker script and declare it in the boards.txt.
AAdding new IP would require to modify the CMSIS device definintion, HAL drivers and review all define....
User avatar
Juraj
Posts: 47
Joined: Fri Jan 03, 2020 7:47 pm
Answers: 1
Location: Slovakia
Contact:

Re: Modifying board definitions corectly

Post by Juraj »

Post Reply

Return to “IDE's”