Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:40 04 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Read-protecting the MM chip...

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 02:39pm 14 Jan 2015
Copy link to clipboard 
Print this post

Hi all.

One thing I really did like about the PICAXE, was that you could program it as much as you wanted, but you could NOT read the device back with the likes of PK3 and IPE etc.

I am guessing that the PICAXE firmware has one of the config bits set so that you can write to it, but not read from it.

Can something like that be done with the MM series of chips?
Probably hidden somewhere in the IPE or IDE...
Smoke makes things work. When the smoke gets out, it stops!
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 03:32pm 14 Jan 2015
Copy link to clipboard 
Print this post

G

PIC32 chips have the Code Protect, "CP", bit which will prevent reading/modifying of the Flash using ICSP/JTAG. CP is a configuration bit, DEVCFG0: DEVICE CONFIGURATION WORD 0, bit 28, Page 226 of DS60001168F.

Peter
The only Konstant is Change
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2949
Posted: 03:57pm 14 Jan 2015
Copy link to clipboard 
Print this post

Hmm,

That is interesting..

Can it be ERASED if CP is set?

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 04:59pm 14 Jan 2015
Copy link to clipboard 
Print this post

Yes, you can protect all memory from being read. jimbotron showed how it could be done in this thread: http://www.thebackshed.com/forum/forum_posts.asp?TID=7148

As far as I know, the flash can still be erased if protected but not read.

Geoff
Geoff Graham - http://geoffg.net
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2949
Posted: 05:18pm 14 Jan 2015
Copy link to clipboard 
Print this post

Thanks Geoff,

I have a spare '150 sitting around somewhere.. I might give it a try..

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 05:21pm 14 Jan 2015
Copy link to clipboard 
Print this post

Cool, thanks for those replies.

I have a feeling that is the same bit that must be set with PICAXE chips, as you can re-program them, but you cannot read them back. This is not to say that someone who is very good at hacking etc, could not find a way to get into it somehow, but for the most part, it prevents all but the most intense people from being able to download your code from the chip.
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 05:28pm 14 Jan 2015
Copy link to clipboard 
Print this post

Doesn't the PIN give enough security?

Together with autorun on and break disabled will make it difficult to see the code.

Put it through Hugh's crunch will make reverse engineering anything that can be seen by reading the flash rather like gobblygook.

Jim

Edit:
Or do you want to prevent cloning?
Edited by TassyJim 2015-01-16
VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 05:43pm 14 Jan 2015
Copy link to clipboard 
Print this post

Hi Jim - Yes, you're on to it. I want to prevent anyone just reading the device - MMBASIC, code and all, into a HEX file saved locally, then cloning from that.

I realize nothing is infallible, but you can at least make it as hard as possible for the blighters!
Smoke makes things work. When the smoke gets out, it stops!
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 12:01am 15 Jan 2015
Copy link to clipboard 
Print this post

  GeoffG said  As far as I know, the flash can still be erased if protected but not read.


What I found while developing MMProg32RPC is that if CP is set, then MMProg32RPC can't get into Serial Execution Mode which is the required state for device programming - see Page 22 of DS60001145N - http://ww1.microchip.com/downloads/en/DeviceDoc/60001145N.pd f

In MMProg32RPC, if CP is SET, then before one can program a new .hex file into a PIC32, MMProg32RPC puts up a message box informing the user that the target chip MUST be erased (using the h/w erase method rather than the Programming Executive method), and displays an Erase button which invokes the MCHP_ERASE ICSP/JTAG command.

Peter
The only Konstant is Change
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 12:16am 15 Jan 2015
Copy link to clipboard 
Print this post

So, am I correct in my understanding of that, that once CP is set, you can't read the code back or program the device, BUT - you can erase the device(which would wipe out anyone's code), and then reprogram it as a default device?
Smoke makes things work. When the smoke gets out, it stops!
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 12:47am 15 Jan 2015
Copy link to clipboard 
Print this post

Yes indeed.

I don't have PK3+IPE, but I would expect the IPE to provide the facility to set CPEdited by G8JCF 2015-01-16
The only Konstant is Change
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4033
Posted: 02:35am 15 Jan 2015
Copy link to clipboard 
Print this post

Same here - about all you can do apart from using a protected chip as intended is erase it. That clears everything, the CP bits as well, so you can reflash it.

Oh, as I recall when protected you can at least identify what chip it is, with a view to erasing it :)

JohnEdited by JohnS 2015-01-16
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9586
Posted: 02:24pm 15 Jan 2015
Copy link to clipboard 
Print this post

Cool, thanks guys. I will hook up a PIC32 and run some tests along those lines.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025