Electronics > Microcontrollers

STM32G030K6T6TR problem re-programming

(1/2) > >>

amwales:
I am have been having limited success with an STM32G030K6T6TR, I purchased the part from lcsc and am confident that its not a clone.
I started out with a STM32CubeIDE 1.16.1 thinking that getting a LED blinky would be trivial using the tools provided by ST.
I created a new project selecting the appropriate chip from the pinout & configuration panel I double clicked PA0 and set it to GPIO_Output.
I then generated the code and made the following changes to the while loop inside main.

The while loop inside main


--- Code: ---  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);
  HAL_Delay(500);


    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */

--- End code ---

I built the target it compiled with All good so far, I got the following output.


--- Code: ---arm-none-eabi-size  simpletest1.elf
arm-none-eabi-objdump -h -S simpletest1.elf  > "simpletest1.list"
   text    data     bss     dec     hex filename
   5252      12    1572    6836    1ab4 simpletest1.elf
Finished building: default.size.stdout
 
Finished building: simpletest1.list
 

10:40:35 Build Finished. 0 errors, 0 warnings. (took 924ms)

--- End code ---

I was hoping I could program my chip from the IDE but after a fruitless search for a program or download button in the IDE I instead downloaded and install the STM32CubeProgrammer.

I had the chip installed in a breadboard, using a breadboarded ch340k and running at 3.3v powered externally I connected to the ch340k to the USART2_RX pin 10 PA3 and USART2_TX pin 9 PA2 ( I added a 1.8k resistor pullup on the RX pin ).

The STM32G030K6T6TR was connected to 3.3v/VDD pin 4 and GND/VSS pin 5.

I added an LED to PA0 pin 7.

Connecting this up to a USB cable on my PC the COM port appeared as I expected.

Using the STM32CubeProgrammer I selected the UART and clicked connect ( NOT change any of the default settings ).
unfortunately I did not collect the output, but it all looked good to me.

I then browsed for the file simpletest1.elf that was generated from the IDE and clicked on the download button.

At this point I cannot remember if I had added a jumper to the boot0 pin but since I was able to connect through the programmer I knew I was inside the bootloader.

I then pressed removed and reapplied power to the chip and the LED started blinking, success.

From this point on I have not been able to reprogram the chip.

I am beginning to believe that somehow the chip has been configured as read protected?

Things I have tried

combinations of pulling the boot0 pin low and high along with resetting the chip, then attempting to reconnect via the uart.

changing all the wires on the breadboard after find out some where steel.

using a cloned j-link to attempt to program with that while in reset, not in reset.

using j-link commander to connect

connected the nrst/pin 6 on the chip to the reset output on the j-link

using the j-link stm32 unlocker

whatever I do when I re-apply power the led starts blinking again.

I have a genuine j-link edu that I have never used but haven't tried that yet as I don't have a header for the teeny-tiny pins.

The more I read online the more I am convinced I have activated the chips read protection mechanism, I assume that the default setting within the IDE/Programmer would not have been set to do this.

Ideas?

elektryk:

--- Quote ---The more I read online the more I am convinced I have activated the chips read protection mechanism, I assume that the default setting within the IDE/Programmer would not have been set to do this.
--- End quote ---

Unfortunately default setting in Cube IDE is SWD disabled, but it shouldn't prevent you from using bootloader.

amwales:
Ok, I think I found the issue, it looks like the default for a virgin STM32G030 ( empty flash ) is to boot from the boot loader.
The production value of the option byte is set such that

nBoot0 = nBoot1 = nBOOT_SEL = 1 and empty flash

During programming of the virgin device you must set the nBOOT_SEL = 0 or it will no longer enter the bootloader,
regardless of the value of Boot0 pin. I guess this must be done through OB in the STM32CubeProgrammer, what a palava.

Explained by Peter BENSCH in https://community.st.com/t5/stm32-mcus-embedded-software/stm32g030-does-not-enter-bootloader-when-boot0-is-3-3v-what-is/td-p/222450

He also references

https://www.st.com/resource/en/application_note/cd00167594.pdf
https://www.st.com/resource/en/reference_manual/dm00463896.pdf

Still trying to understand why it cannot be programmed with SWD while held in reset, maybe its my j-link?
I'll solder another chip onto a breakout and breadboard but this time I'll look at the option byte.
Maybe I should buy a genuine st-link?
Maybe try the j-link edu....

voltsandjolts:

--- Quote from: amwales on January 22, 2025, 02:52:07 pm ---Still trying to understand why it cannot be programmed with SWD while held in reset, maybe its my j-link?

--- End quote ---

Held in reset? Trying to program it while reset is asserted the whole time?

amwales:
https://www.eevblog.com/forum/microcontrollers/stm32-programming-with-st-link-problem/

@rolo mentions it here in reply #2 "Try setting the programmer options to "connect under reset". Then press reset on the target controller, keep it pressed while klicking on connect in the programmertool, release reset on controller. Programmer should connect to the controller now."

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod