>I designed a board for a client, who wants to contract out the assembly, but test in house. Is there a way for the customer to program and secure the parts without being able to read the files? I will be furnishing a test fixture with pogo pins and a BDM connector.
If I understand correctly, your main problem is how to avoid your client examining your file. The easiest and safest way to avoid unwanted examination of your files is to pre-load a bootloader that accepts encrypted images for loading. I use this method with a couple more measures and it hasn’t failed yet. Of course, it does require that you have pre-loaded the end boards with this bootloader. What’s the advantage then over pre-loading the whole firmware in the first place? You only have to do it once per MCU. Once the initial bootloader is loaded, you can send your client encrypted firmware updates that your client will have no use other than to load in the specific boards (MCUs) that you have pre-loaded with your bootloader. S/he can also never make more copies than you have pre-loaded as cloning is practically impossible.
AFAIK, there are no tools today that allow encrypted BDM programming. So, if you use standard BDM tools, you’re out of luck.
(But, if BDM is the only option, you can do very little. For example, you could come up with a small custom BDM programmer board to give your client that takes your encrypted files, decrypts them internally, and loads them to the target. Not quite as secure as the built-in bootloader method as it cannot prevent interception between the BDM programmer and the target MCU but, hopefully, the end client won’t go into such extremes trying to get the file. S/he would have to build a target BDM emulator to copy your now decrypted file as it passes from BDM to target MCU – or, at least, grab the security byte and change it to always no-security, then program a board without your security, and read back the whole file. It all depends on how much value your work has for them to want to ‘rip’ it. This method (with the exception the client being smart enough to bypass it as described above, can also control how many copies are made – you put a counter inside your custom BDM programmer to stop after so many successful ‘burns’.)