DSU calc the CRC 32 only in the lower part of flash?

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

Hello,

 

I working with the SAMC21 and the DSU an have the Problem, that the calc of the CRC32 only work's in the lower part of the Flash.

 

#define BOOTLOADER_addr  0x00000000 //0     AreaSize 32kB

#define APPLICATION_addr 0x00008000 //8000  AreaSize 100kB

#define TEMP_AREA_addr   0x00021000 //21000 AreaSize 100kB

 

DSU->STATUSA.reg = 0x1F; //reset Errors

DSU->ADDR.reg = (uint32_t)((TEMP_AREA_addr / 2) << 2); //TEMP_AREA is a Byte Address --> Word --> / 2

DSU->LENGTH.reg = (uint32_t)(400 * 4 * NVMCTRL_PAGE_SIZE / 2); //400 Rows with 4 Pages with a size of 64 Byte --> Word --> / 2

DSU->DATA.reg = 0;

DSU->CTRL.reg = DSU_CTRL_CRC;

while(!DSU->STATUSA.reg & DSU_STATUSA_DONE) {} ; //wait till finish

 

Bootloader_SW_CRC_should = DSU->DATA.reg;

 

DSU->STATUSA.reg = 0x1F; //reset errors

DSU->ADDR.reg = (uint32_t)((APPLICATION_addr / 2) << 2); //TEMP_AREA is a Byte Address --> Word --> / 2

DSU->LENGTH.reg = (uint32_t)(400 * 4 * NVMCTRL_PAGE_SIZE / 2); //400 Rows with 4 Pages with a size of 64 Byte --> Word --> / 2

DSU->DATA.reg = 0;

DSU->CTRL.reg = DSU_CTRL_CRC;

 

while(!DSU->STATUSA.reg & DSU_STATUSA_DONE) {} ; //wait till finish

 

Bootloader_SW_CRC_is = DSU->DATA.reg;

 

The first part of this Code delivers allways a BUS-error in the StatusRegister.

 

In the first part the ADDRRegister is set to 0x00042000 and the LENGTH is 0x0000C800 ( this is 102400 Byte )

In the seconde part the ADDRRegister is set to 0x00010000 and the LENGTH is 0x0000C800 ( this is 102400 Byte )

 

The ADDR Register has the last to bit for the Setup the AreaMode of the function, which is in my case the ARRAY Mode for the Flash.

The first part of the Code should start at the Address 0x00021000 which is 135168 Byte and then moves up to 0x0003A000 which is 237568 Byte (I have the 256 kB Flash Version of this Chip)

 

The Problem is, that the first part of Code never work, the second part works fine, and I don't find the reason why this is the case.

No part of the Flash is protected at this time of testing...

 

May be you have a hint for me?

 

Best regards

Michael

 

 

 

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

How about:

DSU->ADDR.reg = TEMP_AREA_addr;
DSU->LENGTH.reg = 400 * 4 * NVMCTRL_PAGE_SIZE;
...
while ((DSU->STATUSA.reg & DSU_STATUSA_DONE) == 0);