Lock R/W from ISP programmer, but not from bootloader code

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I wonder if there is possibility to lock the application flash for R/W from an ISP interface, but still read eep/flash sections by a custom (or not) bootloader (and send the data over USB).

My goal is to protect my code and still be able to get some data, stored in flash/eep, extracted via the bootloader.

Using external flash would solve that problem, but that hardware change is not an option, no pins available and too little time.

 

Also, is there a way to lock FLASH but not EEP. I think there isn't, I thing it was possible for the Mega family, but not for the XMega?

 

Thanks in advance!

Last Edited: Thu. Apr 21, 2016 - 01:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems to be possible. LB in the Lock Bits should be set to RW lock. Thus when reading via ISP, we get only "0" for each address.

The reading I do via Atmel Studio.

 

When I try to read the mem via Atmel Flip, I get "Device protection is set", so I cannot get anything out if it either.

This lock is forced by the bootloader, though and it can easily be surpased - there is no actual lock on the flash and eep, besides for the ISP interface.

There is a function, which forces that "lock" and if we remove that lock,

udi_dfu_atmel_mem_b_protected = true;

we can read freely eeprom and flash via FLIP ()

static void udi_dfu_atmel_sel_mem( uint8_t mem_num )
{
#if (FLIP_PROTOCOL_VERSION == FLIP_PROTOCOL_VERSION_2)
	if((mem_num!=ISP_MEM_CONFIGURATION)
	&&(mem_num!=ISP_MEM_SECURITY)
	&&(mem_num!=ISP_MEM_BOOTLOADER)
	&&(mem_num!=ISP_MEM_SIGNATURE)) {
		udi_dfu_atmel_mem_b_protected = true;
	}else{
		udi_dfu_atmel_mem_b_protected = false;
	}
#endif
	udi_dfu_atmel_mem_sel = *isp_memories.mem[mem_num];
}

 

So, by it self this is pointless, since there is no actual protection for the flash and eep reading, but it gives the possibility to customize the bootloader furher, unlocking only specific addresses, for example, or implementing secret unlock sequences.

 

I wonder why Atmel would enforce such software lock on that reading, since they MCUs provide possibility to lock that using Lock Bits and yet, they lock it in bootloader even if the corresponding Lock Bits are not set.

 

P.S. Locking application section, without locking application TABLE section will also come in hadny, it seems.

Last Edited: Thu. Apr 21, 2016 - 02:58 PM