woodygb wrote:The "problem" you have explaining things to the majority of us is ...
We mostly have a mechanical bent / engineering background. ... Electrickery and electronics are black magic and voodoo.
I myself am self taught in coding and electronics and have a VERY NARROW / INCOMPLETE understanding of what everything does.
OK, my bad.
Let's assume these devices (motor controllers, joystick modules,
etc.) are inexpensive and compact enough to preclude using "computers" (in the sense of "PCs") in their implementations. Yet, they would obviously benefit from having computer-IZED electronics (instead of a mess of discrete electronics).
So, its reasonable to expect microcontrollers (MCU's) to provide the "smarts". Each is essentially a microprocessor (MPU) with "permanent" program and "alterable" data memory contained entirely within (instead of as external components like in a PC).
Somehow, the "program memory" has to be "programmed" with the software ("firmware") to give the microcontroller the functionality desired.
E.g., the MCU in the joystick module needs to have a "program" installed inside it that makes it act like a "joystick module" (whatever THAT is!).
You can purchase MCU's that have been preprogrammed (by the MCU manufacturer) to contain "your" program. The MCU manufacturer will typically mark these components with a "house number" (part number) of your choosing -- to make it easier for your manufacturing guys to assemble them into "joystick modules". This might be the
only part number marking on the component -- which
obfuscates your choice of components to your competitors (or, folks like us!). To a casual observer, the MCU looks like a "custom" chip -- one that can only be purchased from you, the joystick manufacturer IF you even offer it as a "spare part" (doubtful... you'll just sell completed joysticks!).
For most MCU customers, they purchase "blank" MCU's from the MCU manufacturer and "program" them on the assembly line as whatever product USING THEM is being manufactured (
e.g., joystick modules). This takes time (labor) and a bit of kit (the "programmer"). If your quantities are high enough, you might opt to just let the MCU manufacturer do this FOR you and sell you "preprogrammed" MCU's.
The down-side of a preprogrammed MCU is that it deprives you of some flexibility -- you have to decide how many of each "program" you want ahead of time; an MCU programmed for a joystick module won't work in a motor controller module (even if they use the exact same MCU!). Also, you can't make changes to your software (program) as easily as those changes have to be shipped off to the MCU manufacturer to be incorporated into the next batch of preprogrammed MCUs that you'll purchase (and they may charge you a fee to make the change). Of course, any MCU's that you have with the "old" software preprogrammed into them are now of dubious value (if you are making a change to the program, that suggests that there is something "wrong" with the current version!).
So, most devices manufactured with MCU's inside are designed for the device manufacturer to do the programming (NOT the MCU manufacturer).
You can design the circuit board to install a "chip socket" for the MCU so that the board can be built and the MCU installed AFTER it has been programmed. This lets you manufacture the boards and postpone adding the MCU until the last minute. But, this adds the cost of a socket to the design. OTOH, you can install a special MCU that has been programmed with a "test program" that allows folks on the assembly line to verify the proper operation of the
circuit board. Once the operation has been verified, you can remove the "special" MCU and be reasonably certain that the
tested board will function properly when the
real MCU is installed.
You can also design the circuit so that you can program the
BLANK MCU
after it has been soldered onto the circuit board! You can still postpone the (final!) programming until the last moment (
e.g., just before you ship the device to your customer so you can be sure to have the latest and greatest software available!) You'll still want some way of testing the circuit board to verify proper assembly, no defective components,
etc. You can do this by programming a "test program" into the MCU, performing the "manufacturing test procedures" to verify proper operation, then replacing the "test program" with the "real" program. Or, you can build the test program into your "real program" and activate it via some magical sequence of events (that likely won't be encountered by the normal user).
E.g., ground pin X on component Y while applying power (especially if pin X is not normally accessible to the end user!)
Given that you can program the MCU "in circuit", you need a way of verifying that the "program" (firmware) that you've installed is actually present in the device. So, you want a way to "read back" the contents of that "program memory" as part of the verification phase of the programming operation.
I.e., "Location 0000 is supposed to have a '27' stored in it. Does it? If so, let's move on and check location 0001. If not, then this MCU is obviously not going to perform as we'd intended cuz that 'instruction' is incorrect!"
Well, if
I can "dump" the contents of
your MCU, then I can decode the instructions that are represented by all of those bits of data. I can, effectively, recover your original software (firmware). I can then look through it and discover EVERYTHING that it could ever do! Even if I never witnessed it doing any of these things!
Imagine having a transmission for a car that is sealed. You never see the car drive backwards so don't even imagine that it has that capability! OTOH, if you could disassemble the transmission, you'd probably notice mechanisms that appeared to allow it to "run backwards". And, you'd trace linkages to discover how those mechanisms were activated.
Looking at the DISASSEMBLED software for the MCU lets me see what messages it might transfer to other modules. And, identify the conditions that would cause those messages to be transmitted -- even if I never observed them "in the wild". In addition, it lets me see what the components of each of those messages are and what they "mean". This gives me clues as to what other modules receiving those messages might be doing (why would I need to convey this piece of information to another module? and, which module is it intended for??)
Because this is so easy to do, MCU manufacturers have been tasked (by their customers) with making it "impossible" for folks to "dump" the contents of programmed MCU's. Usually, this is done by adding a step to the programming sequence that allows the
device (
e.g., joystick module) manufacture to "lock" the MCU after verifying that the program has been installed correctly. Like sealing up that transmission with "special" fasteners (hoping that folks don't have the correct tools to remove them) or even "one way" screws. Or,
welding the case shut!
But, most of these locking mechanisms have flaws in their implementation. So, even a locked MCU can often be "dumped". And, sometimes the locks aren't even "set"!
If the item in question is costly to repair/replace, you might be discouraged from tinkering (one product that I worked on sold "spare" components for $2,000 EACH; you didn't casually screw with that component cuz of the cost of replacing it if you broke it). OTOH, if you're a
business (competitor), you might think nothing of buying several "units" with the intent of destroying them as you try to "evaluate" them (a competitor of one of the firms I worked with bought ten $5K units with the full intent of "making them valueless" after sorting out how they work).