Copying stm32 chip

Post here first, or if you can't find a relevant section!
Jateu01
Posts: 8
Joined: Sun Mar 05, 2017 2:09 pm

Re: Copying stm32 chip

Postby Jateu01 » Mon Mar 06, 2017 2:29 am

I don't have stlink just a standard usb converter. The manufacturer will not respond to me. Ddrown am I correct in thinking I can just connect converter up to the tx, rx and ground to get demo software you see bootloader?

Many thanks

James

User avatar
RogerClark
Posts: 5577
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Copying stm32 chip

Postby RogerClark » Mon Mar 06, 2017 6:03 am

Pull pin Boot0 high
Pull pin Boot1 low
Connect TX and RX on your USB to Serial to PA9 and PA10
(Note you may need to swap the order if that does work for you as different USB to Serial have different labels on the pins)

See my video, which covers connecting a USB to Serial , and ignore the stuff about the Arduino IDE

https://www.youtube.com/watch?v=G_RF0a0hrak

Download STM's "Flash Loader Demonstrator"
http://www.st.com/en/development-tools/ ... stm32.html

Install and run that.

If it doesnt work first time, swap TX and RX around

If it still doesnt connect, try a few more times, with TX and RX around different ways, Because it doesnt always connect.
You can also try changing the speed settings if it doesnt connect, some USB to Serial adaptors work best slow some work better going faster

Once you have connected.

Make sure you don't overwrite what's in the chip, Look very carefully about what they call Uploading and what they call Downloading, as these can be counter-intuitive.

victor_pv
Posts: 1248
Joined: Mon Apr 27, 2015 12:12 pm

Re: Copying stm32 chip

Postby victor_pv » Mon Mar 06, 2017 6:34 am

Jateu01 wrote:I don't think it is protected. The esc can be upgraded with new firmware at any time. The thing is I have limited knowledge of this but whst I do know is the that the esc's board has 5 desitict areas where links have been made. I have back tracked and here are a list of pins on the stm32f051k6t6.

Reset pad links to pin 4 reset.
DIO pad links to pin 23 SWDIO.
TX pad links to pin 24 SWCLK.
RX pad links to pin 25
BT pad links to pin 31 Boot.
TLM pad links to pin 24 SWCLK.
PWM pad links to pin 26 SPI1_SCK.

Which of these do I need to read the chip. Because this is what looks like the manufacturer us to program with.

Many thanks again

James


You need some debug probe, either J-link, or St-Link, or something else compatible. ST-link clones are very cheap in ebay and aliexpress, so that's probably the best route.
Then you need to connect the probe pins SWCLK and SWDIO to the board, to those pins you identified, and GND in the probe to some GND point in the board.
If using st-link, you need to download the stlink utility (free download from STM). Open that tool, and select connect to target.
That will try to connect to the MCU. If has functions to read and to write the flash. It is read protected it will tell you right away.
If it is not read protected, you can read the flash (you likely need to enter the start address and size, which you can get from the mcu reference manual).
Once you read the flash, save the bin file. Check also the Option bytes.

Then repeat the connection to the new chip, and write the flash from the bin you saved, and set the option bytes in the same way as the original MCU.

If the original MCU is read protected, then you can not read the flash, and you will need to obtain it from the vendor, or get a programmed mcu from them.

Jateu01
Posts: 8
Joined: Sun Mar 05, 2017 2:09 pm

Re: Copying stm32 chip

Postby Jateu01 » Mon Mar 06, 2017 7:56 am

Roger and Victor. Thank you for your responses.

Roger there is only boot0 on the stm32f051k6t6! I will try the tx and rx connections the other way around and see what happens.

Victor I will get my self a stlink and see where to go from there.

Many thanks to you both for your help. I will try both ideas and see what happens but I will be sure to post a reply how everything goes.

Thanks again

James

User avatar
RogerClark
Posts: 5577
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Copying stm32 chip

Postby RogerClark » Mon Mar 06, 2017 9:09 am

OK

on the F103 boot1 controls whether the bootloader interacts with Flash or the RAM, but I guess the F051 bootloader will only interact with flash

Also, getting a cheap STLink e.g. eBay or Aliexpress is a good idea, they are not extensive, and work better than USB to Serial

Nutsy
Posts: 214
Joined: Sun Jul 24, 2016 4:26 pm

Re: Copying stm32 chip

Postby Nutsy » Mon Mar 06, 2017 10:42 am

I agree about the StLink, its a more fool proof way of uploading and reading the flash... Ive managed to unbrick a chip or two with it as well where the serial bootloader was totally knackerd for some odd reason...

While I applaud you for getting into SMT32 stuff and this is an interesting way to get into learning about it... But wouldnt it be easier to just buy a new motor? Or are these motors really expensive? I guess were not talking about your average PC case fan or hobby motor?

As for read protection, i didnt even know that was a thing... Good to be aware of it. So i can lock down some of my stuff if i decide to sell it so it doesnt get cloned by some Chinese factory :p Which is funny as Ill be getting a chinese factory to mass produce things if I did that :p

But also as some one else mentioned. Could you get the firmware hex file off the manufacturer? Maybe if you even asked really nicely in an email. They might give it to you

User avatar
Squonk42
Posts: 57
Joined: Thu Dec 29, 2016 9:25 am
Location: Bordeaux, France

Re: Copying stm32 chip

Postby Squonk42 » Mon Mar 06, 2017 5:18 pm

Nutsy wrote:As for read protection, i didnt even know that was a thing... Good to be aware of it. So i can lock down some of my stuff if i decide to sell it so it doesnt get cloned by some Chinese factory :p Which is funny as Ill be getting a chinese factory to mass produce things if I did that :p

I wouldn't count on it if your life depends on it...

Jateu01
Posts: 8
Joined: Sun Mar 05, 2017 2:09 pm

Re: Copying stm32 chip

Postby Jateu01 » Mon Mar 06, 2017 7:08 pm

Nutsy the motor control boards are £40 a pop and ive fried 4 of them well the stm32 at least. I'm pretty handy with a soldering iron so I've managed to extract of chips and replaced with a new one for £1.65. Yes granted it's a silly way to get around the problem. But the way I look at it is that if this happens again then it's only an hours work and £1.65. I have manged to get the demo software to recognise the new chip I just have to get a good board see if I can copy a good chips contents and then copy across. Fingers crossed it will work. I have a stlink on order but going to give the basic process ago while I wait. Than you all again for your advice and guidance.

James

Nutsy
Posts: 214
Joined: Sun Jul 24, 2016 4:26 pm

Re: Copying stm32 chip

Postby Nutsy » Tue Mar 07, 2017 10:36 am

Ohhhh... is this like a control board for a 3d printer or cnc machine?


Return to “General discussion”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest