SW equivalent to ERASE pin

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

Hi,

Is it possible to do the SW equivalency to setting the ERASE-pin?

 

I.e. reset flash and force factory bootloader.

 

Primary need is not clearing flash but activating primary bootloader without accessing the PCB.

 

As sam-ba can clear the flash for us, I.e. if both features can't be satisfied, reactivating factory boot-loader from MCU SW would be good enough.

 

Thanks!

 

This topic has a solution.
Last Edited: Thu. Oct 15, 2020 - 08:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In some of my applications, I have a jump to bootloader function that can be called/activated by the software. This does not erase the flash, but the bootloader can do that under control of whatever is driving the bootloader.

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks David,

I assume you mean the primary bootloader (I'll refer to it as PBL from now on) i.e. at adress 0x0 something like below snippet: 

 

#define EXCEPTION_TABLE_START 0X0

 

void (*pFct)(void) = NULL;

__set_MSP(*(uint32_t *)EXCEPTION_TABLE_START);

pFct = (void (*)(void))(*(uint32_t *)(EXCEPTION_TABLE_START + 4));

pFct(); 

 

 

That would work but has the drawback of not entering PBL (or any bootloader) with a known state and I'm not certain how PBL would react to that. I.e. side effect wrt to pre-scaler registers, TCM etc.and if PBL will take care of that.

 

I can enforce a SW induced HW reset by setting the WDT to a short time-out then entering while(1). I was looking for is perhaps if setting gpnvm:0 from within SW is possible. Datasheet refers to it in "11.1.5.5 Security Bit Feature" using EFFC but I don't know if gpnvm can be both set and reset whence altered once.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mambrus wrote:

I was looking for is perhaps if setting gpnvm:0 from within SW is possible. Datasheet refers to it in "11.1.5.5 Security Bit Feature" using EFFC but I don't know if gpnvm can be both set and reset whence altered once.

 

You haven't mentioned which SAM device you're using, but I'm going to assume SAM4S (since that's one I've used before). You absolutely can set/clear GPNVM bits in software, using either of two EEFC commands "SGPB" and "CGPB". So just issue CGPB for GPNVM#1, then force a reset.

 

From my understanding of the data sheet, GPNVM#0 (Security bit) will not prevent SAM-BA being used to read/write Flash. You might want to consider the security implications of this if you need to protect your firmware IP.

 

Steve

Maverick Embedded Technologies Ltd. Home of Maven and wAVR.

Maven: WiFi ARM Cortex-M Debugger/Programmer

wAVR: WiFi AVR ISP/PDI/uPDI Programmer

https://www.maverick-embedded.co...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The device is a SAME70J21. I assumed the GPNVM SW ability would be the same for all ARM based devices.

 

Thanks for the reply, this answers my question.

 

Will implement a security protocol in between target and host to prevent unauthorised entering of the boot-loader. Thanks for the advise.

 

Michael