Hello! I need help with programing stspin32g4 (stm32g431)
I’m basing on GitHub - runger1101001/simplefoc_funqi_example project
I’m using nucleo l476RG as stlink (connection i guess it’s ok, because STM32CubeProgrammer detects my stm)
when im trying to upload my code i got error:
No DFU capable USB device available
*** [upload] Error 74
i also tried to change upload_protocol = dfu to upload_protocol = stlink
then i get
my stlink works property, because if i open project with nucleo there is no problem to upload any sketch i want, please help me
it’s clear it’s not trying to use the STlink… sorry, too quick to write…
The error in your first post is an issue with libusb. Are you on an M1 mac? I had (a similar) issue and can help you fix it if so.
Are you trying to program a STSPING4 nucleo, or are you meaning you’re using a nucleo as an stlink, connected to a different MCU? Have you broken it off or are you just hanging wires off the jumpers?
Using a nucleo is fine, but I have never tried it personally.
I take it you are using a custom board. If you were using one of the eval board (EVSPIN32G4NH or EVSPIN32G4-DUAL), they have an onboard stlink so you wouldn’t need the nucleo.
It may be that the ST tools are smart enough to check for every device on the SWD chain, but that whatever PIO is doing does not check for multiple devices on chain. IN that case, you may be getting responses from the nucleo mixed in with responses from your intended board. I think if you want to use the STlink from the nucleo, you need to break it off to run the headers to your stsping4 board.
Note the lack of usb build flags. I’m using a seperate usb/fdti for serial. Perhaps the upload part can work with nucleo but the serial bit is not working.
Also I’ve specified HSE - oscillator speed. If you are using runger’s clock.c - I think it is for a 24MHz clock, whereas I’m using an 8MHz (with different clock config). I presume you are using 24Mhz so might not need it.
I’m programming it with an stlink clone (looks like this one), which can also provide power to the board. I typically connect gnd, swdio, swdclk and 3.3v).
i resolded IC and bought stlink, now it programms everytime stm32cubeide and platformIO
but when I upload via platformIO it looks like code is not executed - led is not blinking, using STM32CubeProgrammer i see there is some code uploaded, when i set breakpoint, it doesn’t stop
doing same in stm32cubeIDE it ends with 100% succes
#include <Arduino.h>
// #include "SimpleFOC.h"
// #include "SimpleFOCDrivers.h"
// #include "drivers/stspin32g4/STSPIN32G4.h"
// STSPIN32G4 driver = STSPIN32G4();
// BLDCMotor motor = BLDCMotor(7);
void setup() {
// driver.voltage_power_supply = 12.0f;
// driver.init();
// motor.voltage_limit = driver.voltage_limit / 2.0f;
// motor.controller = MotionControlType::velocity_openloop;
// motor.linkDriver(&driver);
// motor.init();
pinMode(PC2, OUTPUT);
}
void loop(){
digitalWrite(PC2, 1);
delay(500);
digitalWrite(PC2, 0);
delay(500);
// motor.move(5.0f); // 5 rad/s open loop
// delayMicroseconds(100); // STM32G4 is very fast, add a delay in open loop if we do nothing else
}
If it’s working in STM32CubeIDE this is a good sign!
I can’t say why its not working for you - your hardware is probably different from the “Field Stack” board I was testing it on.
One thing to check is the clock setup. Did you make your own? The setup I created is for the field stack board, and enables the HSE (external oscillator) with the configuration that is right for that board. Depending on your board’s oscillator, you’d need a different clock setup function?