cancel
Showing results for 
Search instead for 
Did you mean: 

Flashing STM32F030F4P6 from 32F0308DISCOVERY board

Ferdster
Associate II

I have a small project that coded and prototyped on a 32F0308DISCOVERY board (STM32F030R8T6). It works perfectly on the Discovery board.

I now want to switch over to using a STM32F030F4P6 programmed by the ST-Link that's on the Discovery board (CN2 jumpers removed). I made a new project in CubeMX with the new target (I am using Keil MDK5) and tried to flash the STM32F030F4P6, but had no success.

So, I went to what I think is the bare minimum and simply tried to do a full erase of the chip using ST-Link Utility and STM32CubeProgrammer and I could not get that to work either.

Here is what I have connected on the STM32F030F4P6:

Pin1 (BOOT0) connected to Discovery Ground

Pin4 (NRST) connected to Discovery CN3 Pin5

Pin5 (VDDA) connected to Pin16 (VDD) connected to Discovery 3volts

Pin15 (VSS) connected to Discovery Ground

Pin19 (SWDIO) connected to Discovery CN3 Pin4

Pin20 (SWCLK) connected to Discovery CN3 Pin2

I also have Discovery CN3 Pin1 connected to 3volts.

Both the ST-Link Utility and STM32CubeProgrammer can connect and identify the chip, but they won't program or do a full erase. 

I can erase individual sectors, but it gives the option to go all the way to sector 31, shouldn't it only go to 15 since this is a 16K chip? 

I can read the option bits (initially set to level 0 protection), but when I tried to write it fails, I didn't change any settings to what it initially read. Then the next time I connect the protection is set to level 1 (even though I never changed it to level 1). And now I can't change it back to level 0 since I never could write the option bits to begin with. This happened on two chips and I am not trying it again on a third.

I tried slowing down the speed of the SWD and it made no difference.

I am probably overlooking something simple and I hope you can tell me what that is.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Ferdster
Associate II

It was something simple...I needed to remove SB19 and SB22 from the Discovery board.

View solution in original post

5 REPLIES 5

Hi.

Do you use decoupling capacitors between pin 15 and 16 VSS-VDD? (as close as possible to pins)

Getting power from Discovery board, suggest to remove idd jumper from this board

Ferdster
Associate II

I just added a 220nF decoupling cap right at the pins and I already had the Idd jumper removed. Still can't do a full erase. It will actually only connect when SWD is set to 4000kHz, anything slower it gives the error that the target is being held under reset.

Here is the log from STM32CubeProgrammer:

17:10:54:070 : STLinkUSBDriver.dll loaded

17:10:54:071 : STLinkUSBDriver.dll loaded

17:10:54:071 : ST-LINK SN : 38FF6D064B46323629080843

17:10:54:071 : ST-LINK FW : V2J33S0

17:10:54:072 : Voltage : 2.93V

17:10:54:081 : SWD freq : 4000 KHz

17:10:54:081 : Connect mode: Normal

17:10:54:081 : Reset mode : Software reset

17:10:54:139 : Device ID : 0x444

17:10:54:247 : flash loader C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin/FlashLoader/0x444.stldr is loaded

17:10:54:428 : UPLOADING OPTION BYTES DATA ...

17:10:54:428 : Bank : 0x00

17:10:54:429 : Address : 0x1ffff800

17:10:54:429 : Size : 16 Bytes

17:10:54:429 : Reading data...

17:10:54:429 : r ap 0 @0x1FFFF800 0x00000010 bytes

17:10:54:429 : UPLOADING OPTION BYTES DATA ...

17:10:54:429 : Bank : 0x00

17:10:54:430 : Address : 0x1ffff800

17:10:54:430 : Size : 16 Bytes

17:10:54:430 : Reading data...

17:10:54:430 : r ap 0 @0x1FFFF800 0x00000010 bytes

17:10:54:458 : UPLOADING ...

17:10:54:458 : Size : 1024 Bytes

17:10:54:458 : Address : 0x8000000

17:10:54:458 : Read progress:

17:10:54:458 : Reading data...

17:10:54:471 : r ap 0 @0x08000000 0x00000400 bytes

17:10:54:472 : Data read successfully

17:10:54:472 : Time elapsed during the read operation is: 00:00:00.006

17:11:10:830 : MASS ERASE ...

17:11:10:830 : Flash erase...

17:11:10:836 : reset ap 0

17:11:10:836 : run ap 0

17:11:10:841 : halt ap 0

17:11:10:841 : w ap 0 reg 15 (0x20000000)

17:11:10:841 : w ap 0 reg 17 (0x20000500)

17:11:10:841 : w ap 0 reg 16 (0x01000000)

17:11:10:842 : w ap 0 @0x20000880 0x00000200 bytes

17:11:10:842 : w ap 0 @0x20000000 0x00000004 bytes

17:11:10:855 : w ap 0 @0x20000004 0x00000454 bytes

17:11:10:855 : Init flashloader...

17:11:10:855 : halt ap 0

17:11:10:856 : w ap 0 reg 0 0x00000001

17:11:10:856 : w ap 0 reg 1 0x00000000

17:11:10:856 : w ap 0 reg 2 0x00000000

17:11:10:856 : w ap 0 reg 3 0x00000000

17:11:10:856 : w ap 0 reg 4 0x00000000

17:11:10:857 : w ap 0 reg 5 0x00000000

17:11:10:857 : w ap 0 reg 6 0x00000000

17:11:10:857 : w ap 0 reg 7 0x00000000

17:11:10:857 : w ap 0 reg 8 0x00000000

17:11:10:857 : w ap 0 reg 9 0x00000000

17:11:10:857 : w ap 0 reg 10 0x00000000

17:11:10:858 : w ap 0 reg 11 0x00000000

17:11:10:858 : w ap 0 reg 12 0x00000000

17:11:10:858 : w ap 0 reg 13 0x00000000

17:11:10:858 : w ap 0 reg 14 0x20000001

17:11:10:858 : w ap 0 reg 15 0x20000005

17:11:10:858 : w ap 0 reg 16 0x01000000

17:11:10:859 : w ap 0 reg 17 0x20000854

17:11:10:859 : w ap 0 reg 18 0x00000000

17:11:10:859 : run ap 0

17:11:10:869 : halt ap 0

17:11:10:873 : r ap 0 reg 0 0x00000001

17:11:10:873 : Loader mass erase...

17:11:10:877 : w ap 0 reg 0 0x00000002

17:11:10:882 : w ap 0 reg 1 0x00000000

17:11:10:886 : w ap 0 reg 2 0x00000000

17:11:10:892 : w ap 0 reg 3 0x00000000

17:11:10:898 : w ap 0 reg 4 0x00000000

17:11:10:907 : w ap 0 reg 5 0x00000000

17:11:10:913 : w ap 0 reg 6 0x00000000

17:11:10:916 : w ap 0 reg 7 0x00000000

17:11:10:916 : w ap 0 reg 8 0x00000000

17:11:10:916 : w ap 0 reg 9 0x00000000

17:11:10:916 : w ap 0 reg 10 0x00000000

17:11:10:916 : w ap 0 reg 11 0x00000000

17:11:10:916 : w ap 0 reg 12 0x00000000

17:11:10:917 : w ap 0 reg 13 0x00000000

17:11:10:917 : w ap 0 reg 14 0x20000001

17:11:10:917 : w ap 0 reg 15 0x2000014D

17:11:10:917 : w ap 0 reg 16 0x01000000

17:11:10:917 : w ap 0 reg 17 0x20000854

17:11:10:917 : w ap 0 reg 18 0x00000000

17:11:10:918 : run ap 0

17:11:10:918 : halt ap 0

17:11:10:918 : r ap 0 reg 0 0xFFFFFFFF

17:11:10:918 : Error: Mass erase operation failed.Please verify flash protection

When I read the option bytes, it says that protection is set to level 0 (AA).

Thanks.

I just realized that if idd is open , "hardware reset" option is not functional since STLink RST is connected to a pin(NRST) of an unpowered mcu with all surrounded clamp diodes actually "grounded"

I believe this is taken care of by removing the CN2 jumpers on the Discovery board. I mean they advertise that the Discovery board can be used to flash external chips. I will need to double-check that SB19 and SB22 are not populated though.

Ferdster
Associate II

It was something simple...I needed to remove SB19 and SB22 from the Discovery board.