Modified Sector Erase for AT91SAM4S
[fw/openocd] / src / flash / nor / at91sam4.c
index fd98b7f0da850370e77d91add82cb5ce4d0e78f4..ce3c1d137d2380fea494e9c9a60438841da87799 100644 (file)
@@ -722,10 +722,17 @@ static int FLASHD_ErasePages(struct sam4_bank_private *pPrivate,
                        break;
        }
 
+       /* AT91C_EFC_FCMD_EPA
+        * According to the datasheet FARG[15:2] defines the page from which
+        * the erase will start.This page must be modulo 4, 8, 16 or 32
+        * according to the number of pages to erase. FARG[1:0] defines the
+        * number of pages to be erased. Previously (firstpage << 2) was used
+        * to conform to this, seems it should not be shifted...
+        */
        return EFC_PerformCommand(pPrivate,
                /* send Erase Page */
                AT91C_EFC_FCMD_EPA,
-               (firstPage << 2) | erasePages,
+               (firstPage) | erasePages,
                status);
 }