frdmk64 internal flash write problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

frdmk64 internal flash write problem

1,093 Views
sudhakarp
Contributor V

hi,

i am working on FRDMK64 controller. i am using KDS3.0 and KSDK1.2.0 example. my controller have 1MB flash and 256kb RAM.i am working on internal data flash read/write example.

i have some doubts in following function

1)what is the use of CACHE_DISABLE

2) g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)ramFunc , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);

in this function can i increase LAUNCH_CMD_SIZE  to 0x200. and also what is the use of above function and LAUNCH_CMD_SIZE  .

3)in my application code i am trying to write data from 0x8000 to 0xFA000 address but its not working correctly. upto 0x80000 address only its working fine.  i mean upto(512kb).

can you give some solution for this.

regards,

sudhakar p

0 Kudos
5 Replies

551 Views
DavidS
NXP Employee
NXP Employee

Hi Sudhakar p,

I do not see where CACHE_DISABLE is implemented.  Can you point me to that?

I general the Flash Controller has 4-way, 4-set cache enabled.  Please review the FMC chapter of the Reference Manual.

If you think the cache is getting corrupted than after your code re-programs the flash invalidate the cache.  Reference:

28.6 Initialization and application information

The FMC does not require user initialization. Flash acceleration features are enabled by default.

The FMC has no visibility into flash memory erase and program cycles because the Flash

Memory module manages them directly. As a result, if an application is executing flash

memory commands, the FMC's cache might need to be disabled and/or flushed to prevent

the possibility of returning stale data. Use the PFB0CR[CINV_WAY] field to invalidate

the cache in this manner.

The g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction() is copying code from Flash to SRAM.  The code to execute flash commands needs to run outside of flash space (it must run from SRAM for Kinetis K devices).  The LAUNCH_CMD_SIZE is just a size that is bigger than the flash code size that gets copied to SRAM (i.e. it is the size of SRAM reserved and then used to run Flash commands).  Increasing it is not needed unless you have modified the code to be bigger.

Attached is my main.c from the project C:\Freescale\KSDK_1.2.0\examples\frdmk64f\driver_examples\flash\kds .

This code setup to erase 0x80000-0x100000, and then program the beginning 0x80 bytes of each sector that can be viewed in the memory window when debugger is halted.

Regards,

David

551 Views
sudhakarp
Contributor V

hi david,

     i did boot loader code. my application code less than 512KB its working fine. but when i try more than 512kb(application code) its not working. i mean some functionality missing. ex:uart rx not working or uart txt not working like that. but when i load PE programmer its working fine.

what could be the issue. end of SREC file address i want to write any data..? please give some suggestion. i checked my application address and data  all are fine but i dnt know why some functionality was not working. give some suggestion.

regards,

sudhakar p

0 Kudos

551 Views
DavidS
NXP Employee
NXP Employee

Hi Sudhakar,

Not sure why you have the problem.

I tested my code to erase and program across the flash block boundary successfully.

Do you have interrupts enabled?  If yes, try disabling interrupts during flash command execution.

Do you have watchdog enabled?

Regards,

David

0 Kudos

551 Views
sudhakarp
Contributor V

Hi david,

i am not using any interrupt and watchdog (all disabled). can you tel is possible to write byte by byte character in internal data flash? if yes how to do..?example i want to erase and write 0x8000 address only remaining address should not effect. is possible.?address      data

0x8000      0xaa

0x8001         0xff  like that i want to erase and write.

why i need like that mean in .SREC motorola S record format some time i want to write only 4 byte or 2 byte char only . if possible to write single byte mean i can easily program depends on Moto S record Address.

S2080FD0000017850478     -MOTO S record example,  here 00178504 only data so 0xFD000 adress i want to write that data. how to do this one..? give some suggestion.

Actually i need this one for bootloader purpose only. i dnt need mbed bootloader.i need .MOTOrola S record format bootloader.

regards,

sudhakar p

0 Kudos

551 Views
DavidS
NXP Employee
NXP Employee

Hi Sudhakar,

Best to review the K64 Reference Manual Flash Memory Module (FTFE) chapter.

Simple rules of thumb are:

- smallest erase size is a sector (4096 bytes for K64).

- smallest programming/flashing size is 32-bits (4 bytes).

- code should not try to re-program/flash the same 32-bits without first having erased the sector first.  Otherwise flash may be damaged.

Attached is linker file example of adding user defined BYTE values to flash space near end of flash.

C:\Freescale\KSDK_1.2.0\platform\devices\MK64F12\linker\gcc\MK64FN1M0xxx12_flash.ld

  flash_done             (R)  : ORIGIN = 0x000FFFE0, LENGTH = 0x00000010

  .flash_written :
{
BYTE(0x00)
BYTE(0xBF)
BYTE(0x00)
BYTE(0xBF)
BYTE(0x00)
BYTE(0xBF)
BYTE(0x00)
BYTE(0xBF)
BYTE(0x00)
BYTE(0xBF)
} > flash_done

Regards,

David

0 Kudos