-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
variant(g4): Add WeActStudio.STM32G474CoreBoard support #2615
Conversation
I use Arduino 2 Theia IDE on Linux and Windows. I don't have Sloeber (yet), but installing that is preferred to VSCode. |
Hi @ALTracer |
Thanks. If some maintainer approves CI, then I can look at any failing checks (like astyle) and fix the simpler errors. It'll be my first time in this repo, so I don't know what's enforced here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess keeping pins numbering like the generic one is not an issue as it seems it exists 2 form factors for this board.
variants/STM32G4xx/G473C(B-C-E)U_G474C(B-C-E)U_G483CEU_G484CEU/generic_clock.c
Outdated
Show resolved
Hide resolved
https://github.com/stm32duino/Arduino_Core_STM32/wiki/Using-git-repository |
17504db
to
f267322
Compare
I've updated your branch. |
Thanks. Are the 8 Generic boards/chips autogenerated from CubeMX_DB? |
LPUART1 is already managed. Specific peripheral not. |
* UFQFN48 (U) boards were missing from selection, only LQFP48 were available (T) * Copy missing linkerscript from G474CET * Copy missing SystemClock_Config and readjust for HSI16 into PLL150 and HSI48 CRS (for USB FS Device)
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
f267322
to
59ed28d
Compare
Hello fpistm, ALTracer I started IDE 2.3.4 and can see the new WeAct G474CE in the board menu as expected. When I build this testing app for the WeAct G474 it runs at approximately one third the expected speed. So it seems that I have either jumped the gun and implemented what is not completed, or I messed up the G474 merg, or the clock definition is incorrect. Measured by Timer One interrupt or delay in main loop both run at about 1/3 expected when built as G474 Hope this help many thanks imk #define TEST_PIN_1 PB2 HardwareTimer *MyTim; void SetupOneMSIntTimer( void ); // -------------------------------------- setup() --------------------------------- SetupOneMSIntTimer(); // put this last as drive interrupt test pin. MyTim->setOverflow( 1000 , HERTZ_FORMAT); // 1000 Hz |
I did not verify the clock config. I assumer it was tested by @ALTracer anyway will chech it next week. |
many thanks fpistm have a good weekend.. imk |
Couldn't sleep thinking about this slow clock so had another look. // Add this define to force it to build clock config in generic_clock.c #if defined(ARDUINO_GENERIC_G473CBUX) || defined(ARDUINO_GENERIC_G473CCUX) || etc etc etc |
@imk2021 |
Hello Frederic, |
I see in boards_db.cmake ARDUINO_WEACT_G474CE I am just searching and guessing, so forgive if rubbish idea |
Ok. So no link with the generic . The clock config used is defined here: Line 96 in 65677a2
|
in variant_WEACT_G474CE.cpp I made edit to cause a build error to prove it is been called, see below: This caused a build error so it proves it is been called so maybe the clock speed issue is in WEAK void SystemClock_Config(void) I am unfamiliar territory so just guessing |
The generic should not be used. You use it because you add manually the define. |
Hello Frederic, Also will this not be confusing for other that use this board variant and expect it to run at full speed. Maybe ALTracer should comment please? again Frederic, many many thanks for your help. IMK |
Right, in general case , board clock configuration set it at max speed. |
So I have just built my main robot app for WeAct G474CE with the generic clock hack on my test bed (not production machine) and it seems to be working as expect, some 70% or more quickly :-) I have more testing to do but the only thing that looks a bit odd is PB2 as I think it maps to an analog port input port. What I will say is ALTracer many thanks for the big job you have done here with this variant and many thanks Frederic for your support. BTW is there some credit I can make/set against your avatars for this project? |
@imk2021 While your expectations are valid, it's not always possible to reach max clocks. On single PLL devices like F411 and G474, USB48 constrains VCO to an integer multiple of it like 96, 192, 288, even though rated clocks are 100 and 150/170 -- hence I left the DIVQ to 6 which can provide 144/6=48MHz; but using CRS HSI48 is preferable. @fpistm It is possible I misplaced some define/macro because I'm not familiar with this buildsystem; however I finally managed to set up bleeding edge (downloads of xPack and STM32_SVD from Github/Amazon/AWS are terribly slow, Still, note that this board gets the correct clock.c implementation TU, not generic. There is a HSE8 we can use. It is not 24 or 25 MHz. Where do I set HSE speed, gcc cmdline or headers? Hardware watchpoint 1: SystemCoreClock
Old value = 16000000
New value = 255000000
0x08000fc8 in HAL_RCC_ClockConfig (RCC_ClkInitStruct=0x2001ff84, FLatency=4)
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/system/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c:939
939 return HAL_InitTick(uwTickPrio);
(gdb) bt
#0 0x08000fc8 in HAL_RCC_ClockConfig (RCC_ClkInitStruct=0x2001ff84, FLatency=4)
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/system/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c:939
#1 0x080043a0 in SystemClock_Config ()
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/variants/STM32G4xx/G473C(B-C-E)U_G474C(B-C-E)U_G483CEU_G484CEU/variant_WEACT_G474CE.cpp:131
#2 0x0800314a in hw_config_init ()
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/libraries/SrcWrapper/src/stm32/hw_config.c:73
#3 0x0800462e in init ()
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/cores/arduino/board.c:11
#4 0x080043f4 in premain ()
at /home/altracer/.arduino15/packages/STMicroelectronics/hardware/stm32/2.10.0/cores/arduino/main.cpp:42
#5 0x080056c8 in __libc_init_array ()
#6 0x0800443e in Reset_Handler () GCC and linker two lines from Arduino 2.3.4 console
|
Hello ALTracer, again many thanks for the contribution you are making re bringing this board into Arduino, I for one really appreciate it. Re this clock matter, I have been using Arduino AVR for years for all sorts of little projects, however these AVR chips do lack speed. So when I embarked on this currently now 3 year mission robotics project I knew I need more speed so I went for STM32 arm chips using ST's HAL and found it a steep learning curve, then I discovered STM32Duino so I abandoned HAL and have been STM32Duino committed ever since. Hence you have my admiration using the STM32 HAL clock generator which from my experience is not easy, hence I thank you again. As for your question to fpistm re clock speed option command line or header, remember many of the Arduino users are not deeply experienced in micro-controls hence it is why we have Arduino. So my input would be whatever fits the keep it simple Arduino philosophy, which I think might be some header macros eg WEACT_G747_CLOCK_100_MHZ or WEACT_G747_CLOCK_150_MHZ or WEACT_G747_CLOCK_170_MHZ etc. I look forward to your clock updates. All best IMK |
@imk2021 There is more to performance than Cortex-M4F clock speed -- e.g. 90nm ST NVM Flash is only 30 MHz, anything faster requires multiple wait states, luckily ST also added ART that is effectively I-cache and D-cache outside of CM4F. Using I-bus fetch from CCM SRAM is not exactly easy in Arduino paradigm -- there is @fpistm I've added and tested a couple changes to WeAct variant. Basically it got HSE_VALUE from Advanced users can always bring their own SystemClock_Config to override the weak impl in variant.cpp. I also value the benefits of G4, like analog domain peripherals and CORDIC and proper DMAMUX and HRTIM, but I guess top clock speed is more important than working USB fsdev (G4 cannot be a USB Host or OTG/DRD). |
I've planned to check if |
Hello ALTracer and fpistm and many thanks for the clock update I am checking it at this time and it seems to be as expected. void setup() void loop() |
Could you test this example: Simply install the library and example will be available |
fpistm, |
hello fpistm |
Don't understand, Is the example run? what is the result ? 2.10.0 not planned before end of February (at least) |
Moreover, your code is not correct: |
hello fpistm and thanks for the update. Test one: Test two: void loop() |
Hello fpistm |
No clue to have, this is correct.
|
Looking at the shematics and the mcu errata sheets. I see no issue. I lock the conversation to no pollute more this PR. |
Summary
This PR implements support for the following feature
This PR solves the existing problem of e.g. inaccessible GPIO PC6 LED on UFQFN48 (U) when using other variants on this board. Now you can use either the correct generic variant or the dedicated board variant with LED and button and HSE clock config.
There's no onboard SWD+VCP debugger/bridge, only USB-C to FSDev PHY and two double rows of pinheaders (and SWD). There's no SPI Flash on the bottom side of my boards, but two other revisions exist, one with such flash, one is just a Long PCB (for single row pinheaders and breadboard compatibility probably).
I'll need further assistance in adding other important changes (like CMake chores, or LPUART1 instead of USART2, or Readme 2.9.0/2.10.0 targeting tag and links, or digitalPin/analogInputPin arrays -- ADC?). I don't think this board needs a custom
PeripheralPins_xxx.c
.Validation
Code formatting
Plain astyle 3.1 produces a lot of noise changes, it would be nice to have a git hook for formatter script for changed files only.
Closing issues