Protect pyboard from reading the code

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Protect pyboard from reading the code

Post by kamikaze » Sun Sep 11, 2016 10:27 pm

Is it possible to protect python code from being read via USB or any other way?

markxr
Posts: 62
Joined: Wed Jun 01, 2016 3:41 pm

Re: Protect pyboard from reading the code

Post by markxr » Sun Sep 11, 2016 10:40 pm

If you ship the python modules already compiled, then people won' t be able to access the source.

A Micropython decompiler is probably feasible.

In general, you should not waste time trying to prevent reverse engineering, although it depends what the exact application is (and hence motivation).

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Protect pyboard from reading the code

Post by dhylands » Mon Sep 12, 2016 4:07 am

In order to do this you should read up on "read protection" in the datasheet.

If the device is not read-protected, then its trivial to read the entire contents of flash using DFU. With read-protection enabled, you can't.

Disabling read-protection does a complete erase of flash.

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: Protect pyboard from reading the code

Post by kamikaze » Mon Sep 12, 2016 3:19 pm

dhylands wrote:In order to do this you should read up on "read protection" in the datasheet.

If the device is not read-protected, then its trivial to read the entire contents of flash using DFU. With read-protection enabled, you can't.

Disabling read-protection does a complete erase of flash.
Thanks, that's what I'm looking for )

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: Protect pyboard from reading the code

Post by kamikaze » Mon Oct 10, 2016 5:23 pm

in case of someone is interested in such protection: https://github.com/xyb/upy-stm-flash/blob/master/rdp.py

The only question I have - if I will set Level 2 - will micropython and my code work on such system?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Protect pyboard from reading the code

Post by dhylands » Mon Oct 10, 2016 6:38 pm

If you choose to use level 2 then DFU and JTAG are both disabled, which means that your code will need to provide a mechanism to reflash should you ever wish to change the onboard firmware for any reason.

Post Reply