Loading [MathJax]/extensions/Safe.js

Author Topic: Preventing manufacturing service from copying hex code  (Read 9534 times)

0 Members and 1 Guest are viewing this topic.

Offline matbobTopic starter

  • Contributor
  • Posts: 23
  • Country: ca
Preventing manufacturing service from copying hex code
« on: December 06, 2019, 10:16:00 pm »
Hello All,

I have a product with a Microchip PIC microcontroller in it. The components and PCB will be sourced, assembled and tested by an EMS (Electronics Manufacturing Service) which is located far from my facility. I have to give them the hex code for programming the microcontroller, may be as a PIC kit "Programmer To Go".

I will be making all the legal agreements to prevent them from cloning my design but I know it is useless. Is there any way to prevent the EMS from copying my code and make clones of the product? I have the following constraints:

1) I cannot be physically there at the EMS facility to do the programming myself.

2) I cannot have the microcontrollers pre-programmed from Microchip because the EMS might have a preferred vendor.

3) I cannot have the micro controllers shipped to my facility and then program it and send it back because this is a volume manufacturing and the EMS might prefer tape and reel packaging (the microcontroller is in SOIC package). So if I take out the microcontroller for programming, I cannot re-pack it.

Is there a way out?

Thanks for your help.
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6617
  • Country: nl
Re: Preventing manufacturing service from copying hex code
« Reply #1 on: December 06, 2019, 10:23:37 pm »
Only with an indirect customer unfriendly activation scheme that also requires an interface to a gui or pc.  :(

What you would like to have and no cheap microcontroller has is a small secured area of rom where you can let the manufacturer custom program your special bootcode in. But alas that is expensive and some high iq hacker will eventually gain access to it anyway.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 16245
  • Country: fr
Re: Preventing manufacturing service from copying hex code
« Reply #2 on: December 06, 2019, 10:24:16 pm »
I don't see one. If you're giving them means of programming the chips, whatever means you choose, they'll be able to do the same behind your back.
So count on the legal agreements, and make sure you can defend them in case they are infringed.

One possibility would be to add a final step that only your company can handle, like an activation step of some kind. So just producing the device, even with the full firmware, would not be enough to make it function (unless of course the activation system is cracked, but that would be more than just copying...) Downside is, adding a service to handle activations would have a cost.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: dk
Re: Preventing manufacturing service from copying hex code
« Reply #3 on: December 06, 2019, 10:27:32 pm »
Hello All,

I have a product with a Microchip PIC microcontroller in it. The components and PCB will be sourced, assembled and tested by an EMS (Electronics Manufacturing Service) which is located far from my facility. I have to give them the hex code for programming the microcontroller, may be as a PIC kit "Programmer To Go".

I will be making all the legal agreements to prevent them from cloning my design but I know it is useless. Is there any way to prevent the EMS from copying my code and make clones of the product? I have the following constraints:

1) I cannot be physically there at the EMS facility to do the programming myself.

2) I cannot have the microcontrollers pre-programmed from Microchip because the EMS might have a preferred vendor.

3) I cannot have the micro controllers shipped to my facility and then program it and send it back because this is a volume manufacturing and the EMS might prefer tape and reel packaging (the microcontroller is in SOIC package). So if I take out the microcontroller for programming, I cannot re-pack it.

Is there a way out?

Thanks for your help.


since the part you want use (preprogrammed PIC) isn't available from their preferred vendor, you buy it and supply them?
 

Offline matbobTopic starter

  • Contributor
  • Posts: 23
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #4 on: December 06, 2019, 10:40:33 pm »
@Kjelt,
@SiliconWizard,

The microcontroller is a cheap one and unfortunately all the pins have been used and I am close to 98% flash memory usage.

@langwadt,

This seems to be the only option. But, what if I find a bug on my code and want to change the code in between the production run. And also, I will have to deduct the extra cost of the microcontroller from my profit margin.

Thanks for your replies.

 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6617
  • Country: nl
Re: Preventing manufacturing service from copying hex code
« Reply #5 on: December 06, 2019, 10:46:02 pm »
@Kjelt,
@SiliconWizard,

The microcontroller is a cheap one and unfortunately all the pins have been used and I am close to 98% flash memory usage.
Then you are out of options.
What you learned today is what I told professionals for years:
Security should be designed in from the start, it can (almost) never be added at the end.
 
The following users thanked this post: nctnico, I wanted a rude username

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4983
  • Country: dk
Re: Preventing manufacturing service from copying hex code
« Reply #6 on: December 06, 2019, 10:48:32 pm »
@Kjelt,
@SiliconWizard,

The microcontroller is a cheap one and unfortunately all the pins have been used and I am close to 98% flash memory usage.

@langwadt,

This seems to be the only option. But, what if I find a bug on my code and want to change the code in between the production run. And also, I will have to deduct the extra cost of the microcontroller from my profit margin.

Thanks for your replies.

can you give the EMS a software that only has what is needed to do the test and then reprogram them later yourself?
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 16245
  • Country: fr
Re: Preventing manufacturing service from copying hex code
« Reply #7 on: December 06, 2019, 10:57:34 pm »
One idea, close to the "activation" thing, but easier to deal with IMO, would be to write your own programming software and have EMS use it to program your devices instead of using Microchip tools. It's some work for sure, but definitely doable. There are open source projects for doing just that AFAIK that could serve as basis, and anyway, I think the programming protocols are documented.

Said software could contain the object code for the firmware itself, so you wouldn't need to provide a hex file, and retrieving the code could be made at least significantly harder than just copying a file.
Additionally, this software could add the functionality to generate (and program) a different serial number for each device. Make the software able to only generate unique serial numbers, and only for a predefined range. Once the total number of programmed devices has been reached, the software would not allow programming any further device, so you'd keep control over the number of "manufacturable" products.

In the firmware, you could just add a basic check that the SN has been programmed - probably just a few more bytes of code - (so even if someone manages to somehow extract the code from your programming software, they would still have to understand this additional thing with the SN.) That step would be optional, just a simple additional roadblock. Some PICs can be configured at program time to prevent reading back Flash content as well, so enable this in the config bits.

This way, the object code itself is never provided directly. If you ever need to update the firmware, just send EMS a new version of your programming software; likewise if the predefined number of devices has been reached. It would take a reasonably skilled software guy to do this, but it seems largely doable, and many manufacturing plants will accept using client-provided tools and software (sometimes you don't even have a choice when you use very specific/custom parts.)

 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12009
  • Country: us
    • Personal site
Re: Preventing manufacturing service from copying hex code
« Reply #8 on: December 06, 2019, 11:09:00 pm »
There is no point in making a custom software. All they will have to do is put a logic analyzer on the programming pins and extract the firmware and any additional programming steps from that.
Alex
 
The following users thanked this post: I wanted a rude username

Offline coppice

  • Super Contributor
  • ***
  • Posts: 10289
  • Country: gb
Re: Preventing manufacturing service from copying hex code
« Reply #9 on: December 06, 2019, 11:27:13 pm »
Who is testing the completed boards? If its you, have you considered programming the parts after the board has been assembled?

A lot of big production runs at EMS places use pre-programmed MCUs, and its a huge pain. Not only is it messy unpacking parts, programming them in jigs, and then repacking them suitable for the PnP machines on the EMS line, you also get a higher defect rate if the device has legs. There will always be some rate of leg bending with all that extra handling. QFNs might be a boon here.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 16245
  • Country: fr
Re: Preventing manufacturing service from copying hex code
« Reply #10 on: December 06, 2019, 11:29:35 pm »
The whole point is to make things harder. Just like locking your door. Those manufacturing services must see hundreds of different products per year, they won't go into any effort getting to clone yours unless it's either VERY easy to do so (just copying a file for instance), or your device is hugely interesting and sells by the million.


 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Preventing manufacturing service from copying hex code
« Reply #11 on: December 06, 2019, 11:57:11 pm »
I'm of the opinion that unless it's doing something really, really unique, there's no point. If the widget is worth copying then someone will invest a bit of time in writing their own firmware that does the same thing. If someone releases a commercial product that is running your own firmware then there are ways you can find this out and go after them legally.

In the classic arcade game days it was common to implement easter eggs in the code that could be used to demonstrate that a competitor had copied it.
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3323
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #12 on: December 07, 2019, 12:06:15 am »
Given your constrains, there's absolutely no way you can prevent them from stealing your code.

The only way is to put an ICSP header on the board and program only after you receive them from your manufacturer.

You can give your manufacturer an alternative firmware which is only good for tests, but is harmless if stolen. They will do all the tests, and you will then re-program with real firmware in-house. Alternatively,  you can move testing (or part of it) in-house too.

At any rate, having an ability to re-program it at any time later is a good thing.

On the positive note, how much code can you really have in a small PIC which cannot be re-written with relatively small effort? So, what's the point of protecting it?
 
The following users thanked this post: kripton2035

Offline matbobTopic starter

  • Contributor
  • Posts: 23
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #13 on: December 07, 2019, 12:47:17 am »
@Kjelt,
@SiliconWizard,

The microcontroller is a cheap one and unfortunately all the pins have been used and I am close to 98% flash memory usage.
Then you are out of options.
What you learned today is what I told professionals for years:
Security should be designed in from the start, it can (almost) never be added at the end.

@Kjelt,
The initial plan was to do the production within our facility. So I did not think of any extra security measures other than setting the flash memory read lock bits. But now, our reseller/buyer wants a better quality and cost control and therefore we have to shift to their preferred EMS service.
 

Offline matbobTopic starter

  • Contributor
  • Posts: 23
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #14 on: December 07, 2019, 12:49:07 am »
There is no point in making a custom software. All they will have to do is put a logic analyzer on the programming pins and extract the firmware and any additional programming steps from that.

@ataradov

Yes, I agree to this. All you need is to monitor the programming pins.
 

Offline matbobTopic starter

  • Contributor
  • Posts: 23
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #15 on: December 07, 2019, 01:15:29 am »
@coppice
@NorthGuy

The testing has to be done by the EMS. If there are rejects, they are responsible. If the board comes to my facility and if I find rejects, the EMS could blame the transportation or handling at my facility. And again, the rejects have to be send back to EMS for repair which is too much work and money. Also, after testing, the boards have to go directly to a reseller instead of me.

@james_s

I did consult a lawyer regarding IP protection and stuff. Their advice is to do something technical to avoid the software getting leaked at the first place. In the part of the world I plan to sell this product, it is too difficult to get a favourable judgement from court.

 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7980
  • Country: ca
  • Non-expert
Re: Preventing manufacturing service from copying hex code
« Reply #16 on: December 07, 2019, 02:13:07 am »
A lot of big production runs at EMS places use pre-programmed MCUs, and its a huge pain. Not only is it messy unpacking parts, programming them in jigs, and then repacking them suitable for the PnP machines on the EMS line, you also get a higher defect rate if the device has legs. There will always be some rate of leg bending with all that extra handling. QFNs might be a boon here.

microchip programs the parts for you, they aren't going to screw anything up..

https://www.microchipdirect.com/programming/
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: Howardlong

Offline coppice

  • Super Contributor
  • ***
  • Posts: 10289
  • Country: gb
Re: Preventing manufacturing service from copying hex code
« Reply #17 on: December 07, 2019, 02:25:13 am »
A lot of big production runs at EMS places use pre-programmed MCUs, and its a huge pain. Not only is it messy unpacking parts, programming them in jigs, and then repacking them suitable for the PnP machines on the EMS line, you also get a higher defect rate if the device has legs. There will always be some rate of leg bending with all that extra handling. QFNs might be a boon here.

microchip programs the parts for you, they aren't going to screw anything up..

https://www.microchipdirect.com/programming/
Various vendors will do the programming for you at the factory, and mark the chips with a customer specific code. They don't all mention this. You have to talk to the sales people, and you may need to be buying in considerable volume. However, this usually requires considerable setup time, and most people are trying to churn out some boards the moment they are happy with the design. The time issues means programming before the chip leaves the factory is not for everyone.
 

Offline Bud

  • Super Contributor
  • ***
  • Posts: 7382
  • Country: ca
Re: Preventing manufacturing service from copying hex code
« Reply #18 on: December 07, 2019, 02:55:05 am »
Digikey does it. In fact i can see a note added right under the microcontroller line item when i add one to the shopping cart, offering custom programming.
« Last Edit: December 07, 2019, 02:57:07 am by Bud »
Facebook-free life and Rigol-free shack.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4084
  • Country: us
Re: Preventing manufacturing service from copying hex code
« Reply #19 on: December 07, 2019, 04:40:52 am »
This seems to be the only option. But, what if I find a bug on my code and want to change the code in between the production run. And also, I will have to deduct the extra cost of the microcontroller from my profit margin.

In volume, pre-programmed microcontrollers shouldn't cost much more.

If you only buy enough for one production run at a time you don't have to worry as much about having a reel of useless parts.  If the firmware changes during the manufacturing process then I guess you are screwed.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Preventing manufacturing service from copying hex code
« Reply #20 on: December 07, 2019, 05:30:41 am »
Like I said before, unless the code is doing something very clever and unique, if it's worth trying to steal then someone will either reverse engineer it and write new firmware that does the same thing, or they'll find a way to crack the chip and dump the code. If you use a reputable manufacture they're not going to risk stealing your code.
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 867
  • Country: us
    • AG6QR Blog
Re: Preventing manufacturing service from copying hex code
« Reply #21 on: December 07, 2019, 06:44:31 am »
Perhaps you could hide some form of Easter Egg in your code that does something like blink your name in Morse code when a certain sequence of buttons is pressed.  The idea is to make it easy to discover if a device in the field is using your pirated firmware, and make it so that nobody can plausibly claim that the firmware in question was not a copy but instead independently written to perform the same function as yours.

That doesn't prevent copying, but at least gives you some chance of detecting and proving it after the fact.  For whatever that's worth.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4084
  • Country: us
Re: Preventing manufacturing service from copying hex code
« Reply #22 on: December 07, 2019, 07:07:17 am »
Like I said before, unless the code is doing something very clever and unique, if it's worth trying to steal then someone will either reverse engineer it and write new firmware that does the same thing, or they'll find a way to crack the chip and dump the code. If you use a reputable manufacture they're not going to risk stealing your code.

That's a good point, although even a moderate cost to reverse engineer and replicate your software creates an upfront fixed cost which they have to expect on recouping via sales.  Whereas just producing extra units in exactly the same way and selling them has almost no fixed costs, so any margin they can get is essentially free money.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14179
  • Country: gb
    • Mike's Electric Stuff
Re: Preventing manufacturing service from copying hex code
« Reply #23 on: December 07, 2019, 09:11:15 am »
Get the parts preprogrammed by Microchipdirect & direct shipped to the EMS Usually only a few cents to program, mark and re-reel.

Also, put some hidden functionality in your code, to prove that a device is a copy and not a re-creation of the same functionality.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: Howardlong

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14179
  • Country: gb
    • Mike's Electric Stuff
Re: Preventing manufacturing service from copying hex code
« Reply #24 on: December 07, 2019, 09:12:20 am »
This seems to be the only option. But, what if I find a bug on my code and want to change the code in between the production run. And also, I will have to deduct the extra cost of the microcontroller from my profit margin.

In volume, pre-programmed microcontrollers shouldn't cost much more.

If you only buy enough for one production run at a time you don't have to worry as much about having a reel of useless parts.  If the firmware changes during the manufacturing process then I guess you are screwed.
Not necessarily - your code can include a bootloader to allow subsequent reprogramming.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: Howardlong


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf