Hi Francois,
ECC check is enabled in CR57 (reg32_write(DDR_CR057, 0x03000000); ) not in DDR_CR058.
I tried also to allow corruption after correct memory initiation by reg32_write(DDR_CR058, 0x00000000);
No issue found. Data are correctly stored in the memory and there are no EEC errors in DDR_CR80. Code and dis-assembly below.
My program (compiler) uses STRB, STBH and STB instructions for store 8,16 and 32 bits data, LDR,LDRH, LDRB for load. Exact work of STMIA, you use, can be find in ARM documentation, but ECC_DIS_WCRER bit is here especially in the case of CPU access to ECC protected SDRAM memory.
Confirm that you see no issues when line reg32_write(DDR_CR058, 0x00000000); is removed. Maybe you can try to use STR instructions also.
/Jiri

/* init of ECC check in SDRAM function */
void ecc_sdram_init(void)
{
uint32 memStart = 0x80000000;
uint32 memSize = 0x1000000;
uint32 i;
/* Clear ECC errors in IN_STAT DDRMC_CR80 */
reg32_write(DDR_CR081, 0x00000078);
/* Re-configure the DDR controller for an 8-bit port width; reduc = 1*/
reg32_write(DDR_CR078, 0x0000010c);
//reg32_write(DDR_CR078, 0x0700010c); // q_fullness reduc
/* Enable ECC - reporting and correcting on; ctrl_raw = 11 */
reg32_write(DDR_CR057, 0x03000000);
/* Need to disable checking on partial writes to get test to pass */
reg32_write(DDR_CR058, 0x01000000);
printf("Writing initial values to SDRAM\n");
for (i = 0; i < memSize; i = i + 4)
{
//*(uint32 *) (memStart + i) = memStart + i;
*(uint32 *) (memStart + i) = 0x0;
}
printf("SDRAM Initialization Complete!\n");
/* Allow the ECC codes for the entire user word to be corrupted */
reg32_write(DDR_CR058, 0x00000000);
}
void ecc_sdram_test(void)
{
uint32 memStart = 0x80000000;
uint32 memEnd = 0x81000000;
uint32 memIncrement = 0x0100;
uint32 i;
for (i = memStart; i < memEnd; i = i + memIncrement)
{
printf("Testing SDRAM memory \n");
mem8_write(i, (uint8_t) pattern);
mem16_write(i+2, (uint16_t) pattern);
mem32_write(i+4, (uint32_t) pattern);
printf("Adress:%08x i8:%02x i16:%04x i32: %08x \n", i, mem8_read(i), mem16_read(i+2), mem32_read(i+4));
mem8_write(i, (uint8_t) antipattern);
mem16_write(i+2, (uint16_t) antipattern);
mem32_write(i+4, (uint32_t) antipattern);
printf("Adress:%08x i8:%02x i16:%04x i32: %08x \n", i, mem8_read(i), mem16_read(i+2), mem32_read(i+4));
}
}