Disable programming lines - Page 1
Forum section: electronics / projects

author: vini_i
author_rank: Regular Contributor
timestamp: December 26, 2017, 08:44:32 pm
content: I'm designing a microcontroller based project. (PIC16F) The project will be battery powered and have a micro USB port for charging only. With an eye for production and testing, I had the idea that I could extend the D+, D- and ID pin to icspdat, icspclk, and Vpp, making a custom board to do so interfacing with a PicKit or whatever. This would allow me to program and test the device while it is completely closed.After the product is tested and ready to ship I would like to disable the programming lines.Is there a novel way to disable the programming lines?The best I could come up with is having some type of fuses in the two programming lines and zeners to ground downstream of them. Then using a constant current source to drive enough current into the pins and through the zeners to pop the fuses.

author: bkucenski
author_rank: Contributor
timestamp: December 27, 2017, 01:07:53 am
content: https://books.google.com/books?id=CB9GaAU1dwsC&pg=PA755&lpg=PA755&dq=eeprom+disable+write&source=bl&ots=Hib9A0ty8c&sig=v_qQ89AK8Db-327-dIbOHkhzq5Q&hl=en&sa=X&ved=0ahUKEwj35eGh_6jYAhXljlQKHbEEBPcQ6AEIajAI#v=onepage&q=eeprom%20disable%20write&f=falseThat's something that's done in the micro-controller to prevent program data from getting in or out of it. You'd have to check with the datasheet for your specific controller.Any sort of shenanigans done outside of the micro-controller could be easily defeated. The end user could simply replace the fuses or just run a wire around them.

author: ataradov
author_rank: Super Contributor
timestamp: December 27, 2017, 01:10:14 am
content: The question is more about disconnecting USB pins, so they don't interact in a bad way with the real USB hosts, not actually enforcing the access.I'm not sure if there is an easy way to do this, most likely it will not be worth it in the end.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 27, 2017, 01:57:18 am
content: It would probably be much less hassle in the end not to connect the USB data lines at all and program your PIC with some internal small connector on your board.As you can see here:http://www.littelfuse.com/products/fuses/surface-mount-fuses/nano-2-fuses.aspx, very small smd fuses like this, even for the lowest current model, would still need a pretty high current to blow up. Your diodes would have to be able to withstand this current and still be small enough (assuming this is a small device)... you may not find any that fit. Maybe with the smallest fuse in the 448 Series (62 mA).

author: bkucenski
author_rank: Contributor
timestamp: December 27, 2017, 02:09:41 am
content: If all you want is to connect and disconnect the data lines for the USB, you may be able to work a 4 small holes into your product casing that you can slip jumper wires into to complete the path between contact pads.

author: Nusa
author_rank: Super Contributor
timestamp: December 27, 2017, 02:34:42 am
content: How about a normally-open magnetic reed switch? They can be had in ultra-minature sizes.Programming would only be possible if you place a magnet in the proper spot outside the case.

author: ajb
author_rank: Super Contributor
timestamp: December 27, 2017, 05:03:50 am
content: If this is only for development, then use a couple of series resistors, and either remove them or don't fit them on the production articles. Or bring out a UART and use a bootloader. Optionally send a command to disable the bootloader after production testing. High impedance or softly pulled down IOs shouldn't cause any issues on the USB side.

author: MarkF
author_rank: Super Contributor
timestamp: December 27, 2017, 12:53:18 pm
content: Maybe do something in software. Like disable the USB interface after the unit has been powered up 10 times. Of course you would need to protect the program space from being read.Or just initially enable the test mode until you send a disable command on the USB interface that can not be re-enabled.

author: vini_i
author_rank: Regular Contributor
timestamp: December 27, 2017, 01:01:47 pm
content: Disabling the programming lines is not meant to be any kind of tamper resistance. This is just to prevent any accidental or unintended interactions.I had another idea. A set of diodes from the programming lines to the reset line. The reset lines should never be pulled low. It is either held high or taken to 12v to enable programming. This way the diodes will always be reverse biased. Then, when you're ready to blow the fuses pull the reset line low and supply power to the programming lines. This way the diode only sees forward current and its power dissipation is very low.

author: ataradov
author_rank: Super Contributor
timestamp: December 27, 2017, 05:23:58 pm
content: Quote from: vini_i on December 27, 2017, 01:01:47 pmCan you draw a schematic?

author: Mechatrommer
author_rank: Super Contributor
timestamp: December 27, 2017, 07:20:41 pm
content: Quote from: vini_i on December 26, 2017, 08:44:32 pmooh there are many novel ways a single page wont fit, its just the question of are they economical or not compared to what is already practices (not novel as bkucenski has suggested in reply #4), or the question of are you going to accept it or not? which 99.999% of the suggestions will be pointless anyway. one of the (worst) novel idea is using 40A SSRs 2" wide and length dimension along the lines.

author: KL27x
author_rank: Super Contributor
timestamp: December 27, 2017, 11:43:46 pm
content: Instead of disabling them after you are done, perhaps you could enable those lines when you want to use them. By detecting the presence of high/programming voltage (say >10V) on one of those lines, the other two lines are temporarily closed. A zener and a cap and a couple of solid state relays.The SSR's are the expensive part. Maybe the clock and/or data line can be switched in/out with just a transistor, unidirectionally, if you do some research on USB, and depending on if your device uses those pins for anything else.

author: Ian.M
author_rank: Super Contributor
timestamp: December 27, 2017, 11:57:24 pm
content: If your PIC16 supports high voltage programming, and you disable LVP in its CONFIG and set the ICSP pins as inputs and don't otherwise use them, they'll be inactive anyway unless VPP is applied. No USB host or device will ever apply more than 5.5V to those pins. Disabling them totally is pointless as no PIC16 is sufficiently secure for any application that absolutely must be tamper-proof.

author: Leo Bodnar
author_rank: Frequent Contributor
timestamp: December 28, 2017, 12:03:59 am
content: Why not use one of gazzilions of "secure" bootloaders?Sooner or later you will find yourslef trying to hack into your own device to fix a bug, make a custom mod or perform failure analysis and cursing yourself for locking yourself out.

author: ajb
author_rank: Super Contributor
timestamp: December 28, 2017, 02:34:13 am
content: Quote from: vini_i on December 27, 2017, 01:01:47 pmHigh impedance IO lines or weak pulldowns won't cause any improper interactions with USB ports as long as your MCU ignores them. A USB device signals its attachment (and speed) to a host by pulling either D+ or D- to 3.3V. So just don't pull either one high and a host port won't even notice it's connected. You might want to read the voltage on those lines to detect a charging port, but otherwise just have the MCU ignore them entirely. Using high voltage programming is a good idea, otherwise use a UART and a bootloader that waits for a particular activation sequence or something.

author: bson
author_rank: Unknown
timestamp: December 28, 2017, 04:47:59 am
content: I'd use something other than the USB connector to program it, basically equip your special programming board with pogo pins instead, or use an existing connector like TagConnect's legless TC-2030-NL. It basically does that plus has three guide pins. Then leave the USB connector solely to charging.