STM32G474CEU6 supported?

Post here first, or if you can't find a relevant section!
Repwoc
Posts: 3
Joined: Mon Jun 24, 2024 11:02 am

STM32G474CEU6 supported?

Post by Repwoc »

Trying to program a board that has a STM32G474CEU6 chip. I can't find this specific chip in the Arduino IDE. I've selected 'Generic STM32G4 series' in Tools/Board/STM32 MCU based boards, then the nearest I can see under 'Board part number' is G474CETx. If I select this and build my sketch it gives a:

Error: Target device not found
Establishing connection with the device failed

The board is in DFU mode and the 'STM Device in DFU Mode' is displayed under Universal Serial Bus controllers in device manager.

Is there something I need to do / install for the G474CEU6?

Thanks!
paul
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: STM32G474CEU6 supported?

Post by GonzoG »

G474CEUx hasn't been added.
You can add it yourself: https://github.com/stm32duino/Arduino_C ... 28board%29
Repwoc
Posts: 3
Joined: Mon Jun 24, 2024 11:02 am

Re: STM32G474CEU6 supported?

Post by Repwoc »

OK thanks. I have followed the procedure in the link provided. The chip now shows up in the board part number list; however I still get the "Target device not found" error when uploading the sketch.

I can program the board using a mini STLink dongle if I set the upload method to STM32CubeProgrammer (SWD) in Arduino IDE but then I can't get the serial monitor to work.

Any ideas?
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: STM32G474CEU6 supported?

Post by GonzoG »

Repwoc wrote: Sat Aug 31, 2024 7:24 am OK thanks. I have followed the procedure in the link provided. The chip now shows up in the board part number list; however I still get the "Target device not found" error when uploading the sketch.

I can program the board using a mini STLink dongle if I set the upload method to STM32CubeProgrammer (SWD) in Arduino IDE but then I can't get the serial monitor to work.

Any ideas?
USB needs 48MHz clock. If you haven't enabled USB in CubeMX and set 48MHz source for USB (eg. HSI48), it won't work.
Repwoc
Posts: 3
Joined: Mon Jun 24, 2024 11:02 am

Re: STM32G474CEU6 supported?

Post by Repwoc »

USB is enabled and clock is 48 MHz.

Do I need two USB cables - one to the STLink and one to the USB connector on the board?
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32G474CEU6 supported?

Post by STM32ardui »

Repwoc wrote: Sat Aug 31, 2024 2:32 pm Do I need two USB cables - one to the STLink and one to the USB connector on the board?
Yes.
STLink is not for output to Serial Monitor.

But be careful not to power board by USB and STLink at the same time.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32G474CEU6 supported?

Post by STM32ardui »

GonzoG wrote: Fri Aug 30, 2024 10:09 pm G474CEUx hasn't been added.
You can add it yourself: https://github.com/stm32duino/Arduino_C ... 28board%29
May I ask about this?

I see inside variants-folder a subfolder:
STM32G4xx/G473C(B-C-E)U_G474C(B-C-E)U_G483CEU_G484CEU

So I the middle part is valid for:
STM32G474CBUx
STM32G474CCUx
STM32G474CEUx
---> Part 1 "Find the MCU folder" is already made ...

Inside that variants-subfolder is a file generic_clock.c
---> Part 3 "Generic System Clock configuration" is also made ...
(OK, it's empty, but it should work with default values)

Inside that variants-subfolder is a file boards_entry.txt
And there I find a section

Code: Select all

# Generic G473CEUx
GenG4.menu.pnum.GENERIC_G473CEUX=Generic G473CEUx
GenG4.menu.pnum.GENERIC_G473CEUX.upload.maximum_size=524288
GenG4.menu.pnum.GENERIC_G473CEUX.upload.maximum_data_size=131072
GenG4.menu.pnum.GENERIC_G473CEUX.build.board=GENERIC_G473CEUX
GenG4.menu.pnum.GENERIC_G473CEUX.build.product_line=STM32G473xx
GenG4.menu.pnum.GENERIC_G473CEUX.build.variant=STM32G4xx/G473C(B-C-E)U_G474C(B-C-E)U_G483CEU_G484CEU
GenG4.menu.pnum.GENERIC_G473CEUX.debug.svd_file={runtime.tools.STM32_SVD.path}/svd/STM32G4xx/STM32G473.svd
After copying this section into boards.txt in   \Arduino15\packages\STMicroelectronics\hardware\stm32\2.8.1\   Part 4 " Declare the variant" is finished and ArduinoIDE (after a restart) should show this MCU in tool-menu?

So only Part 2 "Add the default linker script" I have to do and change two lines?


What will happen, when a new version 2.8.2 etc. comes out?
Will it overwrite boards.txt?
Will it delete ldscript.ld ?
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: STM32G474CEU6 supported?

Post by GonzoG »

You have to generate default clock config and paste it into generic_clock.c. Default (hardware) clocks are very slow. If I'm not mistaken, G474 will run @16MHz.

If your board has HSE, you need to create a variant specific to this board and also generate clock setup. I've used F411 black pill as an example.

All will be erased in case of update. But after you make changes and verify that everything works you can submit a PR so the changes can be included in next update.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32G474CEU6 supported?

Post by STM32ardui »

GonzoG wrote: Mon Sep 02, 2024 8:19 am You have to generate default clock config and paste it into generic_clock.c. Default (hardware) clocks are very slow. If I'm not mistaken, G474 will run @16MHz.

If your board has HSE, you need to create a variant specific to this board and also generate clock setup. I've used F411 black pill as an example.
In my case it is a board with STM32H562RGT6 from WeActStudio
(https://github.com/WeActStudio/WeActStu ... ree/master).

Yes it has LSE and HSE crystal, but I set PLL for HSI.
If I want to use HSE later, I can add a different generic_clock-function in a sketch.
With input divider 8, multiplier 125 and output divider 2 clock is at maximum of 250 MHz - nothing red marked in STM32CubeIDE.
GonzoG wrote: Mon Sep 02, 2024 8:19 am All will be erased in case of update. But after you make changes and verify that everything works you can submit a PR so the changes can be included in next update.
First I made a simple blink sketch with some output to Serial Monitor.
Board has 2x4pin 90° angled pinheader for SWD and RX/TX. RX/TX are connected to PA9/PA10 - not PA0/PA1 like defined in variant_generic.h. So I used Set.serialRx() and Set.serialTx() before Serial.begin().
HAL_RCC_GetSysClockFreq() etc. reported correct 250 MHz.

Next I tried CheckVariant.ino - with some addaption I got results, that's ok.

One small thing is, that boards are not sorted in alphabetical order.
I guess, ArduinoIDE shows boards in the order, wher it finds them inside boards.txt?
H562.jpg
H562.jpg (33.64 KiB) Viewed 2965 times
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: STM32G474CEU6 supported?

Post by GonzoG »

Arduino list boards in order as they are in boards.txt.

I've got 2 of those board. Have added them to Arduino IDE (generic and WeAct variant). Everything work, just the program does not start after flashing using DFU. Board needs to be manually reset.
Post Reply

Return to “General discussion”