Update code to ArduinoDue via ethernetShield

Hallo everybody, I'm trying to make mechanism which allow me to upload code via ethernetShild. I looked into SAM3X8E datasheet and read this Arduino Playground - HomePage

and I found that SAM3X8E support boot from flash0 and flash1 by setting/clear GPNVM bit

So in short, there is three boot start points - SAM-BA, Flash 0 and Flash 1, this can be controlled by tweaking the GPNVM bits in EEFC0.

I tryed that using this library DueFlashStorage/DueFlashStorage.h at master · collin80/DueFlashStorage · GitHub but it works fine on flash0 but it doesn't work with flash1/

I don't know what to writte to flash1 so to accomplish dual boot. I tryed to copy all files from flash0 to flash1, but it doesn't works with switching boot mode.

Does anyone know how to help me?

Thank you in advance :slight_smile:

Hello Bojana,

I'd recommend you to use SAM-BA. Upload each bootloader at the beginning of flash0 and flash1 respectively, then, you can switch between flash banks as if there were totally separated devices by playing with the GPNVM bits.

-p

Thank you,

I'm already using SAM-BA and Atmel Studio. How to upload both bootloader in flash0 and flash1, because every time I upload new code, flash is erased?

@Bojana

It seems that this document details what is described in chap. 18.5.2 of sam 3X datasheet with examples for dual flash0 and flash1 uses:

http://www.atmel.com/images/atmel-42141-sam-at02333-safe-and-secure-bootloader-implementation-for-sam3-4_application-note.pdf

Having to adjust the DueFlashBootloader - thinking it was for some reason wired to only write to FLASH1:

  if ((uint32_t)FLASH_START+address < IFLASH1_ADDR) {
    _FLASH_DEBUG("Flash write address too low\n");
    return false;
  }

Will keep you posted.