Commit 8f39fafb authored by Kevin Gillespie's avatar Kevin Gillespie Committed by Kevin
Browse files

Removing locking procedure from RAM algorithm.

Adding locking procedure on error case.

Change-Id: Iad232becedf73fdee2cc27395c4881b3a9242aa7
parent 87c03ca7
......@@ -151,9 +151,6 @@ void algo_write(uint8_t *work_start, uint8_t *work_end, uint32_t len, uint32_t a
enc_buffer[0] |= (temp8 << (i*8));
}
// Unlock the flash
MXC_FLC->cn = (MXC_FLC->cn & ~MXC_F_FLC_CN_UNLOCK) | MXC_S_FLC_CN_UNLOCK_UNLOCKED;
// 32-bit write
MXC_FLC->cn |= MXC_F_FLC_CN_WDTH;
......@@ -166,9 +163,6 @@ void algo_write(uint8_t *work_start, uint8_t *work_end, uint32_t len, uint32_t a
// Wait for the operation to complete
while(MXC_FLC->cn & MXC_F_FLC_CN_WR) {}
/* Lock flash */
MXC_FLC->cn &= ~MXC_F_FLC_CN_UNLOCK;
/* Check access violations */
if (MXC_FLC->intr & MXC_F_FLC_INTR_AF) {
MXC_FLC->intr &= ~MXC_F_FLC_INTR_AF;
......@@ -263,9 +257,6 @@ void algo_write(uint8_t *work_start, uint8_t *work_end, uint32_t len, uint32_t a
enc_buffer[3] = MXC_TPU->dout[3];
}
// Unlock the flash
MXC_FLC->cn = (MXC_FLC->cn & ~MXC_F_FLC_CN_UNLOCK) | MXC_S_FLC_CN_UNLOCK_UNLOCKED;
// 128-bit write
MXC_FLC->cn &= ~MXC_F_FLC_CN_WDTH;
......@@ -281,9 +272,6 @@ void algo_write(uint8_t *work_start, uint8_t *work_end, uint32_t len, uint32_t a
// Wait for the operation to complete
while(MXC_FLC->cn & MXC_F_FLC_CN_WR) {}
/* Lock flash */
MXC_FLC->cn &= ~MXC_F_FLC_CN_UNLOCK;
/* Check access violations */
if (MXC_FLC->intr & MXC_F_FLC_INTR_AF) {
MXC_FLC->intr &= ~MXC_F_FLC_INTR_AF;
......
......@@ -4,56 +4,54 @@
0x17,0xf0,0x40,0x0f,0x2f,0x68,0x14,0xbf,0x47,0xf4,0x00,0x17,0x27,0xf4,0x00,0x17,
0x2f,0x60,0x51,0xf8,0x88,0x5c,0xad,0x07,0x1e,0xd5,0x4f,0xf0,0x80,0x45,0xaf,0x68,
0x7b,0x03,0x5e,0xbf,0xaf,0x68,0x47,0xf4,0x80,0x27,0xaf,0x60,0x6f,0x6a,0x7f,0x04,
0x42,0xbf,0x6f,0x6a,0x27,0xf4,0x80,0x47,0x6f,0x62,0x40,0x4d,0x01,0x27,0x2f,0x60,
0x42,0xbf,0x6f,0x6a,0x27,0xf4,0x80,0x47,0x6f,0x62,0xc0,0x4d,0x01,0x27,0x2f,0x60,
0x2f,0x68,0x47,0xf4,0x80,0x47,0x2f,0x60,0x2f,0x68,0x47,0xf0,0x10,0x07,0x2f,0x60,
0x2f,0x68,0x47,0xf0,0x20,0x07,0x2f,0x60,0xa1,0xf5,0x86,0x75,0xa1,0xf5,0x82,0x77,
0x05,0x95,0x00,0xf1,0x08,0x05,0x02,0x95,0x03,0x97,0x34,0x4d,0xa1,0xf5,0x80,0x77,
0x05,0x95,0x00,0xf1,0x08,0x05,0x02,0x95,0x03,0x97,0xb4,0x4d,0xa1,0xf5,0x80,0x77,
0x04,0x97,0x1a,0xb9,0x00,0xbe,0x27,0xf4,0x80,0x17,0xc9,0xe7,0x51,0xf8,0x88,0x7c,
0x17,0xf0,0x01,0x0c,0x5c,0xd1,0xa7,0x68,0x47,0xf0,0x10,0x07,0xa7,0x60,0x01,0x9f,
0xc6,0xf8,0x00,0xc0,0x00,0x2a,0x4d,0xd0,0xd0,0xf8,0x04,0x80,0xd0,0xf8,0x00,0xe0,
0x17,0xf0,0x01,0x0c,0x4d,0xd1,0xa7,0x68,0x47,0xf0,0x10,0x07,0xa7,0x60,0x01,0x9f,
0xc6,0xf8,0x00,0xc0,0x00,0x2a,0x41,0xd0,0xd0,0xf8,0x04,0x80,0xd0,0xf8,0x00,0xe0,
0xf0,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0xe0,0xd0,0xf8,0x04,0x80,0x9e,0xf8,0x00,0xe0,
0x08,0xf1,0x01,0x08,0x46,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x80,0x02,0x9b,0x43,0x60,
0x08,0xf1,0x01,0x08,0x88,0xbf,0xc0,0xf8,0x04,0x80,0x01,0x3a,0x01,0x37,0x33,0x68,
0x0e,0xfa,0x0c,0xfe,0x0c,0xf1,0x08,0x0c,0x43,0xea,0x0e,0x0e,0xbc,0xf1,0x20,0x0f,
0xc6,0xf8,0x00,0xe0,0xd6,0xd1,0xd4,0xf8,0x08,0xc0,0x01,0x9b,0x2c,0xf0,0x70,0x4c,
0x4c,0xf0,0x00,0x5c,0xc4,0xf8,0x08,0xc0,0xd4,0xf8,0x08,0xc0,0x4c,0xf0,0x10,0x0c,
0xc6,0xf8,0x00,0xe0,0xd6,0xd1,0xd4,0xf8,0x08,0xc0,0x01,0x9b,0x4c,0xf0,0x10,0x0c,
0xc4,0xf8,0x08,0xc0,0x23,0x60,0x33,0x68,0x23,0x63,0xa3,0x68,0x43,0xf0,0x01,0x03,
0xa3,0x60,0xa3,0x68,0xdb,0x07,0xfc,0xd4,0xa3,0x68,0x23,0xf0,0x70,0x43,0xa3,0x60,
0x63,0x6a,0x9b,0x07,0x04,0xd5,0x63,0x6a,0x23,0xf0,0x02,0x03,0x63,0x62,0x00,0xbe,
0x01,0x97,0x9e,0xe7,0x4f,0xf0,0xff,0x0e,0xc9,0xe7,0x00,0xbf,0x00,0x10,0x00,0x40,
0xdd,0xf8,0x14,0xe0,0x01,0x9f,0xa1,0xf1,0xfc,0x0b,0xf4,0x46,0x00,0x23,0x4c,0xf8,
0x04,0x3f,0x00,0x2a,0x00,0xf0,0x06,0x81,0xd0,0xf8,0x04,0x90,0xd0,0xf8,0x00,0x80,
0xc1,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x80,0xd0,0xf8,0x04,0x90,0x98,0xf8,0x00,0x80,
0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x90,0x02,0x9b,0x43,0x60,
0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,0x01,0x3a,0x01,0x37,0xcc,0xf8,
0x00,0x80,0x00,0x2a,0x00,0xf0,0xe9,0x80,0xd0,0xf8,0x04,0xa0,0xd0,0xf8,0x00,0x90,
0xca,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x90,0x99,0xf8,0x00,0xa0,0xd0,0xf8,0x04,0x90,
0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x90,0x02,0x9b,0x43,0x60,
0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,0x01,0x3a,0x01,0x37,0x48,0xea,
0x0a,0x28,0xcc,0xf8,0x00,0x80,0x00,0x2a,0x00,0xf0,0xca,0x80,0xd0,0xf8,0x04,0xa0,
0xd0,0xf8,0x00,0x90,0xca,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x90,0x99,0xf8,0x00,0xa0,
0xd0,0xf8,0x04,0x90,0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x90,
0x02,0x9b,0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,0x01,0x3a,
0x01,0x37,0x48,0xea,0x0a,0x48,0xcc,0xf8,0x00,0x80,0x00,0x2a,0x00,0xf0,0xab,0x80,
0xd0,0xf8,0x04,0xa0,0xd0,0xf8,0x00,0x90,0xca,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x90,
0x99,0xf8,0x00,0xa0,0xd0,0xf8,0x04,0x90,0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,
0xd0,0xf8,0x04,0x90,0x02,0x9b,0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,
0x04,0x90,0x01,0x3a,0x01,0x37,0x48,0xea,0x0a,0x68,0xd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0x2c,0xf0,0x10,0x0c,0xc4,0xf8,0x08,0xc0,0x23,0x60,0x33,0x68,
0x23,0x63,0x03,0x9b,0x1b,0x68,0x63,0x63,0x04,0x9b,0x1b,0x68,0xa3,0x63,0x51,0xf8,
0xfc,0x3c,0xe3,0x63,0xa3,0x68,0x43,0xf0,0x01,0x03,0xa3,0x60,0xa3,0x68,0xdb,0x07,
0xfc,0xd4,0xd9,0xe6,0x4f,0xf0,0xff,0x08,0x11,0xe7,0x4f,0xf0,0xff,0x0a,0x2e,0xe7,
0x4f,0xf0,0xff,0x0a,0x4d,0xe7,0x4f,0xf0,0xff,0x0a,0x6c,0xe7,
0xa3,0x60,0xa3,0x68,0xdb,0x07,0xfc,0xd4,0x63,0x6a,0x9b,0x07,0x04,0xd5,0x63,0x6a,
0x23,0xf0,0x02,0x03,0x63,0x62,0x00,0xbe,0x01,0x97,0xaa,0xe7,0x4f,0xf0,0xff,0x0e,
0xd5,0xe7,0xdd,0xf8,0x14,0xe0,0x01,0x9f,0xa1,0xf1,0xfc,0x0b,0xf4,0x46,0x00,0x23,
0x4c,0xf8,0x04,0x3f,0x00,0x2a,0x00,0xf0,0xfe,0x80,0xd0,0xf8,0x04,0x90,0xd0,0xf8,
0x00,0x80,0xc1,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x80,0xd0,0xf8,0x04,0x90,0x98,0xf8,
0x00,0x80,0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x90,0x02,0x9b,
0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,0x01,0x3a,0x01,0x37,
0xcc,0xf8,0x00,0x80,0x00,0x2a,0x00,0xf0,0xe3,0x80,0xd0,0xf8,0x04,0xa0,0xd0,0xf8,
0x00,0x90,0xca,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x90,0x99,0xf8,0x00,0xa0,0xd0,0xf8,
0x04,0x90,0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,0x04,0x90,0x02,0x9b,
0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,0x01,0x3a,0x01,0x37,
0x48,0xea,0x0a,0x28,0xcc,0xf8,0x00,0x80,0x00,0x2a,0x00,0xf0,0xc4,0x80,0xd0,0xf8,
0x04,0xa0,0xd0,0xf8,0x00,0x90,0xca,0x45,0xf9,0xd0,0xd0,0xf8,0x04,0x90,0x99,0xf8,
0x00,0xa0,0xd0,0xf8,0x04,0x90,0x09,0xf1,0x01,0x09,0x4e,0x45,0x8d,0xbf,0xd0,0xf8,
0x04,0x90,0x02,0x9b,0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,0xc0,0xf8,0x04,0x90,
0x01,0x3a,0x01,0x37,0x48,0xea,0x0a,0x48,0xcc,0xf8,0x00,0x80,0x00,0x2a,0x00,0xf0,
0xa5,0x80,0xd0,0xf8,0x04,0xa0,0xd0,0xf8,0x00,0x90,0xca,0x45,0xf9,0xd0,0xd0,0xf8,
0x04,0x90,0x99,0xf8,0x00,0xa0,0xd0,0xf8,0x04,0x90,0x09,0xf1,0x01,0x09,0x4e,0x45,
0x8d,0xbf,0xd0,0xf8,0x04,0x90,0x02,0x9b,0x43,0x60,0x09,0xf1,0x01,0x09,0x88,0xbf,
0xc0,0xf8,0x04,0x90,0x01,0x3a,0x01,0x37,0x48,0xea,0x0a,0x68,0xdc,0x45,0xcc,0xf8,
0x00,0x80,0x7f,0xf4,0x74,0xaf,0x51,0xf8,0x88,0x3c,0x9b,0x07,0x58,0xd5,0x01,0x9b,
0x23,0xf0,0x7f,0x4a,0x51,0xf8,0x88,0x3c,0xde,0xf8,0x04,0x80,0x13,0xf0,0x20,0x0f,
0x0e,0xf5,0x86,0x7b,0x08,0xbf,0x01,0x9b,0xab,0xeb,0x01,0x0b,0x0e,0xf1,0x04,0x09,
0x14,0xbf,0xd3,0x44,0x9b,0x44,0x8b,0xea,0x08,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bf,
......@@ -508,8 +508,10 @@ static int max32xxx_write(struct flash_bank *bank, const uint8_t *buffer,
/* Prepare to issue flash operation */
retval = max32xxx_flash_op_pre(bank);
if (retval != ERROR_OK)
if (retval != ERROR_OK) {
max32xxx_flash_op_post(bank);
return retval;
}
if (remaining >= 4) {
/* try using a block write */
......@@ -554,6 +556,7 @@ static int max32xxx_write(struct flash_bank *bank, const uint8_t *buffer,
if (retry <= 0) {
LOG_ERROR("Timed out waiting for flash write @ 0x%08x", address);
max32xxx_flash_op_post(bank);
return ERROR_FLASH_OPERATION_FAILED;
}
......@@ -587,6 +590,7 @@ static int max32xxx_write(struct flash_bank *bank, const uint8_t *buffer,
if (retry <= 0) {
LOG_ERROR("Timed out waiting for flash write @ 0x%08x", address);
max32xxx_flash_op_post(bank);
return ERROR_FLASH_OPERATION_FAILED;
}
......@@ -625,6 +629,7 @@ static int max32xxx_write(struct flash_bank *bank, const uint8_t *buffer,
if (retry <= 0) {
LOG_ERROR("Timed out waiting for flash write @ 0x%08x", address);
max32xxx_flash_op_post(bank);
return ERROR_FLASH_OPERATION_FAILED;
}
}
......@@ -671,6 +676,7 @@ static int max32xxx_write(struct flash_bank *bank, const uint8_t *buffer,
if (retry <= 0) {
LOG_ERROR("Timed out waiting for flash write @ 0x%08x", address);
max32xxx_flash_op_post(bank);
return ERROR_FLASH_OPERATION_FAILED;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment