Other Parts Discussed in Thread: SYSCONFIG
Tool/software:
Hi
I need to read and write the external flash using memcpy for my application. Can you provide me an example where I can see the configs needed to achive this ?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi Dheeraj,
Thank you for the query.
Can you please let us know which flash part number is used? For a quick start we have the ospi_flash_io example in mcu_plus_sdk_am261x_10_00_01_10
Path: C:\ti\mcu_plus_sdk_am261x_10_00_01_10\examples\drivers\ospi\ospi_flash_io
Thanks & Regards,
Rijohn
Hi, I am using the onboard Flash i.e. IS25WX064
The flashio example for AM261 does not use memcpy for reading the flash content directly.
ospi_flash_io.c
Please check the following example. I am trying to use the memcpy to read the Flash. It goes into abort handler. I have also defined the region.


In my application, I need to use memcpy to read the flash and I am trying this in Flash IO example . I am commented the flash read statement and trying to read using memcpy.
Hi Dheeraj,
Apologies for the delay.
Sorry, looks like I gave path to am263px mcu_plus_sdk instead of AM261x
Correct Path: C:\ti\mcu_plus_sdk_am261x_10_00_01_10\examples\drivers\ospi\ospi_flash_io
Also,
Please add the below attached sysconfig file in this path C:\ti\mcu_plus_sdk_am261x_10_00_01_10\source\sysconfig\board\.meta\flash
{
"flashSize": 8388608,
"flashPageSize": 256,
"flashManfId": "0x9D",
"flashDeviceId": "0x5B17",
"flashBlockSize": 131072,
"flashSectorSize": 4096,
"cmdBlockErase3B": "0xD8",
"cmdBlockErase4B": "0xDC",
"cmdSectorErase3B": "0x20",
"cmdSectorErase4B": "0x21",
"protos": {
"p111": {
"isDtr": false,
"cmdRd": "0x03",
"cmdWr": "0x02",
"modeClksCmd": 0,
"modeClksRd": 0,
"dummyClksCmd": 0,
"dummyClksRd": 0,
"enableType": "0",
"enableSeq": "0x00",
"dummyCfg": null,
"protoCfg": null,
"strDtrCfg": null
},
"p112": null,
"p114": null,
"p118": {
"isDtr": false,
"cmdRd": "0x7C",
"cmdWr": "0x84",
"modeClksCmd": 0,
"modeClksRd": 0,
"dummyClksCmd": 0,
"dummyClksRd": 7,
"enableType": "0",
"enableSeq": "0x00",
"dummyCfg": null,
"protoCfg": null,
"strDtrCfg": null
},
"p444s": null,
"p444d": null,
"p888s": null,
"p888d": {
"isDtr": false,
"cmdRd": "0x7C",
"cmdWr": "0x84",
"modeClksCmd": 0,
"modeClksRd": 0,
"dummyClksCmd": 16,
"dummyClksRd": 16,
"enableType": "0",
"enableSeq": "0x00",
"dummyCfg": {
"isAddrReg": true,
"cmdRegRd":"0x85",
"cmdRegWr":"0x81",
"cfgReg": "1",
"shift":0,
"mask":"0xFF",
"bitP":16
},
"protoCfg": {
"isAddrReg": true,
"cmdRegRd": "0x85",
"cmdRegWr": "0x81",
"cfgReg": "0",
"shift": 0,
"mask": "0xff",
"bitP": 231
},
"strDtrCfg": {
"isAddrReg": true,
"cmdRegRd": "0x85",
"cmdRegWr": "0x81",
"cfgReg": "0x00000000",
"shift": 255,
"mask": 255,
"bitP": 0
}
},
"pCustom": {
"fxn": null
}
},
"addrByteSupport": "1",
"fourByteAddrEnSeq": "0xA1",
"cmdExtType": "REPEAT",
"resetType": "0x30",
"deviceBusyType": "0",
"cmdWren": "0x06",
"cmdRdsr": "0x05",
"srWip": 0,
"srWel": 1,
"cmdChipErase": "0xC7",
"rdIdSettings": {
"cmd": "0x9F",
"numBytes": 5,
"dummy4": 0,
"dummy8": 8,
"addressBytesSize": 0
},
"xspiWipRdCmd": "0x00",
"xspiWipReg": "0x00000000",
"xspiWipBit": 0,
"flashDeviceBusyTimeout": 72000000,
"flashPageProgTimeout": 120
}

Once these steps are done import the ospi_flash_io example and verify that seeing the default value of Flash in example.sysconfig file in ospi_flash_io example.
Regards,
Rijohn
After removing the project and reimporting then flash name is not changing but Device ID changes
Following are the changes done in json 
I changed the flash name manually to IS25WX064 and built the project. The generated code is as follows.
/*
* FLASH
*/
/* FLASH Object - initialized during Flash_open() */
Flash_NorOspiObject gFlashObject_IS25WX064;
/* FLASH Driver handles - opened during Board_flashOpen() */
Flash_Handle gFlashHandle[CONFIG_FLASH_NUM_INSTANCES];
/* FLASH Attrs */
Flash_Attrs gFlashAttrs_IS25WX064 =
{
.flashName = "IS25WX064",
.deviceId = 0x5B17,
.manufacturerId = 0x9D,
.flashSize = 8388608,
.blockCount = 64,
.blockSize = 131072,
.pageCount = 512,
.pageSize = 256,
.sectorCount = 2048,
.sectorSize = 4096,
.phyTuningOffset = 8388608/2,
};
/* FLASH DevConfig */
Flash_DevConfig gFlashDevCfg_IS25WX064 =
{
.cmdExtType = OSPI_CMD_EXT_TYPE_REPEAT,
.enable4BAddr = TRUE,
.addrByteSupport = 1,
.fourByteAddrEnSeq = 0,
.cmdWren = 0x06,
.cmdRdsr = 0x05,
.srWip = (1 << 0),
.srWel = (1 << 1),
.xspiWipRdCmd = 0x05,
.xspiWipReg = 0x00000000,
.xspiWipBit = (1 << 0),
.resetType = 0x30,
.eraseCfg = {
.blockSize = 131072,
.sectorSize = 4096,
.cmdBlockErase3B = 0xD8,
.cmdBlockErase4B = 0xDC,
.cmdSectorErase3B = 0x20,
.cmdSectorErase4B = 0x21,
.cmdChipErase = 0xC7,
},
.idCfg = {
.cmd = 0x9F, /* Constant */
.numBytes = 3,
.dummy4 = 0,
.dummy8 = 8,
.addrSize = 0
},
.protocolCfg = {
.protocol = FLASH_CFG_PROTO_8D_8D_8D,
.isDtr = TRUE,
.cmdRd = 0x7C,
.cmdWr = 0x84,
.modeClksCmd = 0,
.modeClksRd = 0,
.dummyClksCmd = 16,
.dummyClksRd = 16,
.enableType = 0,
.enableSeq = 0x00,
.protoCfg = {
.isAddrReg = TRUE,
.cmdRegRd = 0x85,
.cmdRegWr = 0x81,
.cfgReg = 0,
.shift = 0,
.mask = 0xff,
.cfgRegBitP = 231,
},
.strDtrCfg = {
.isAddrReg = TRUE,
.cmdRegRd = 0x85,
.cmdRegWr = 0x81,
.cfgReg = 0x00000000,
.shift = 255,
.mask = 255,
.cfgRegBitP = 0,
},
.dummyCfg = {
.isAddrReg = TRUE,
.cmdRegRd = 0x85,
.cmdRegWr = 0x81,
.cfgReg = 1,
.shift = 0,
.mask = 0xFF,
.cfgRegBitP = 16,
},
},
.flashWriteTimeout = 120,
.flashBusyTimeout = 72000000,
};
/* FLASH Config */
Flash_Config gFlashConfig[CONFIG_FLASH_NUM_INSTANCES] =
{
{
.attrs = &gFlashAttrs_IS25WX064,
.fxns = &gFlashNorOspiFxns,
.skipHwInit = FALSE,
.devConfig = &gFlashDevCfg_IS25WX064,
.object = (void *)&gFlashObject_IS25WX064,
.rwOffset = 0,
},
};
On running the code with the changes mentioned below in the example project(Flash IO), I am still running into abort handler.

Hi Dheeraj,
Thank you for the reply.
Can you please help me understand why you commented it out?
Can you try uncommenting it and running.
Regards,
Rijohn
Hello,
I did it because in my application, i need to use memcpy to read the flash.
Hi Dheeraj,
I did it because in my application, i need to use memcpy to read the flash
Can you check if DMA is enabled in Sysconfig setting of OSPI?
If yes, then please disable it. Also revert the driver as before. If DMA is not enabled, then the driver itself does use memcpy.
Regards,
Rijohn
HI
If I uncomment the code then it works using the Flash_read api but In my application code(higher layers), we are using memcpy to cpy data from flash so I will have to use memcpy statement only.
The memcpy statement is not working irrespective of DMA enabled or disabled.....
Hi Dheeraj,
Please see the below code/steps to get the memcopy working:
1. use the ospi_io example
// status = Flash_read(gFlashHandle[CONFIG_FLASH0], offset, gOspiRxBuf, APP_OSPI_DATA_SIZE);
status = OSPI_enableDacMode(gOspiHandle[0]);
uint8_t *pSrc = (uint8_t *)(0x60200000);
uint8_t *pDst = (uint8_t *)gOspiRxBuf_cpy;
memcpy(pDst, pSrc, 0x800);
We have tested this and it is working.