Preventing FLASH Erase

I have a customer with one of my products on his CNC machine. For whatever reason, his machine seems to have an unusually large amount of electrical noise. Three times now, this has resulted in the ProMini on my board having its FLASH at least partially erased or corrupted to the point it no longer functioned correctly. There has never been any actual damage to the chip itself, and re-FLASHing gets it going again. Ideally, we could figure out what is going on with his machine, but in reality, that is unlikely to happen. So I’m wondering if there is some way to make it more difficult for the FLASH to get corrupted, by setting a LOCK bit or something similar.

I realize this may be an exercise in futility, given that if the problem is caused purely by electrical noise, this may be purely a hardware phenomena. But, I have to at least try. So, I’m thinking I could prepare a replacement ProMini with no boot loader (eliminating the possibility that the boot loader FLASH programmer is somehow being activated), and setting any fuses, etc. that might at least make it more difficult for the FLASH to get erased or otherwise corrupted.

Any ideas? What fuse options are there that might be relevant, and how do I change them?

Regards,
Ray L.

That's a strange one Ray. I thought it was pretty difficult for the Flash to get overwritten by any software means by a user program.

I suspect that the root cause is something along the lines of transient over-voltages (due to electrical noise) on the external pins somehow emulating external programming.

I'd be looking at power supply and grounding first up. In a noisy environment it's good to have as close as possible to a single point ground where your system hooks up to the noisy machine in question.

Something often overlooked here is the "parasitic" high frequency coupling that you can get through a regular mains transformer. In other words, you want the ground on your MPU system as separated as possible from other machine, even including all possible parasitic paths to ground like capacitive coupling of transformer windings.

See the “Memory Programming” section of the data sheet, “Lock Bit Byte”. You need to change the Lock bits and if you eliminate the bootloader you should also change the BOOTRST fuse from 0 to 1 (unset). For changing the fuses (and loading the program without a bootloader) you will need an ISP/ICSP programmer or an Uno programmed to be an ISP/ICSP programmer. You will also need the documentation for Avrdude.

avrdude -c -P <PORT(if needed)> -b <BAUD(if needed)> -p m328p -s -U flash:w:YourProgram.hex:i -U hfuse:w:0x??:m -U lock:w:0x??:m

Use -s to disable safemode when writing fuses. Write the lock bits last. Chip erase command will clear lock bits.

stuart0: That's a strange one Ray. I thought it was pretty difficult for the Flash to get overwritten by any software means by a user program.

I suspect that the root cause is something along the lines of transient over-voltages (due to electrical noise) on the external pins somehow emulating external programming.

I'd be looking at power supply and grounding first up. In a noisy environment it's good to have as close as possible to a single point ground where your system hooks up to the noisy machine in question.

Something often overlooked here is the "parasitic" high frequency coupling that you can get through a regular mains transformer. In other words, you want the ground on your MPU system as separated as possible from other machine, even including all possible parasitic paths to ground like capacitive coupling of transformer windings.

I've been through all that already. It's powered by the PC power supply in the machine, and has a single +5V and a single GND connection. Noise has been a non-issue on all other machines customers have installed these things in.

I don't believe the FLASH is getting over-written by software - I think this is an electrical problem, but one I can't solve on my board. What I'm hoping for is a fuse or something that makes it near impossible to erase or otherwise alter the flash.

Regards, Ray L.

tf68:
See the “Memory Programming” section of the data sheet, “Lock Bit Byte”. You need to change the Lock bits and if you eliminate the bootloader you should also change the BOOTRST fuse from 0 to 1 (unset). For changing the fuses (and loading the program without a bootloader) you will need an ISP/ICSP programmer or an Uno programmed to be an ISP/ICSP programmer. You will also need the documentation for Avrdude.

avrdude -c -P <PORT(if needed)> -b <BAUD(if needed)> -p m328p -s -U flash:w:YourProgram.hex:i -U hfuse:w:0x??:m -U lock:w:0x??:m

Use -s to disable safemode when writing fuses. Write the lock bits last. Chip erase command will clear lock bits.

Thanks. I’ll see if I can make that work…

Regards,
Ray L.

Next time this happens, read out the flash and compare it to what you uploaded. I'm skeptical of the "corrupted flash" theory.

DrAzzy: Next time this happens, read out the flash and compare it to what you uploaded. I'm skeptical of the "corrupted flash" theory.

Well.... Twice, simply re-FLASHing has restored normal operation. What would you call it?

Regards, Ray L.