What is the address of the Program Once Field in the program flash IFR?

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

What is the address of the Program Once Field in the program flash IFR?

Jump to solution
974 Views
marlonsmith
Contributor IV

Hi everyone,

We're using the MK60DN512VLL10 in a product, and we plan to use the program once field to store a permanent MAC address.  We need to write this value in production using JTAG.

In the user guide, the address range for the program once field is 0xC0-0xFF, but I can't seem to find the base address.  Program flash starts at address 0 as far as I can tell, but the program once field can't be at address 0xC0 as that's in the middle of the initial vector table.

Does anyone know the actual address of the field?

Thanks!

Marlon

0 Kudos
1 Solution
605 Views
mjbcswitzerland
Specialist V

Marlon

Don't be mislead by the address of the program once field. It is not a memory mapped address such as program Flash.

The K60 has 8 "record Indexes" which are 8 byte phrases than can be written or read. This gives 8 x 8 bytes (64 bytes) in these indexes.

When reading or writing, the FCMD_PROGRAM_ONCE or FCMD_READ_ONCE commands are issued to the Flash controller, along with the record index in question and the flash controller either programs the record or returns its content.

The program once area cannot be addresses by a physical address so is not readable by using a pointer.

You can get program once interface code from the uTasker project which gives the following general program once interface:

extern int fnProgramOnce(int iCommand, unsigned long *ptrBuffer, unsigned char ucBlockNumber, unsigned char ucLength);

It supports programming and retrieving the MAC address from this area using the routines (showing how the interface is used):

Retrieval:

static void fnGetUserMAC(void)
{
    unsigned long ulTestBuffer[2];                                   // the MAC address is saved in two long words
    fnProgramOnce(PROGRAM_ONCE_READ, ulTestBuffer, 0, 2);            // read 2 long words from the start of the program-once area
    if (uMemcmp(ulTestBuffer, cucBroadcast, MAC_LENGTH) != 0) {      // if programmed
        uMemcpy(network[DEFAULT_NETWORK].ucOurMAC, ulTestBuffer, MAC_LENGTH); // use the stored value as MAC address
    }
}

Programming:

    unsigned long ulTestBuffer[2];
    ulTestBuffer[1] = 0xffffffff;
    uMemcpy(ulTestBuffer, temp_pars->temp_network[DEFAULT_NETWORK].ucOurMAC, MAC_LENGTH); // retrieve first MAC address from storage
    fnProgramOnce(PROGRAM_ONCE_WRITE, ulTestBuffer, 0, 2);       // save to the first 2 long words in the program once area

Note that all operations use an 8 byte phrase (buffer) and unused bytes are set to 0xff. The MAC thus occupies a single phrase (organised as 2 long words in the passing buffer). In the uTasker projet the first phrase is used as MAC address as convention when the option is enabled.

The uTasker Kinetis simulator also simulates the Program Once Memory (as well as all other Flash operation) to allow experimenting with code to ensure correct usage before moving to the HW (where any mistakes can't be deleted).

Regards

Mark

View solution in original post

0 Kudos
2 Replies
606 Views
mjbcswitzerland
Specialist V

Marlon

Don't be mislead by the address of the program once field. It is not a memory mapped address such as program Flash.

The K60 has 8 "record Indexes" which are 8 byte phrases than can be written or read. This gives 8 x 8 bytes (64 bytes) in these indexes.

When reading or writing, the FCMD_PROGRAM_ONCE or FCMD_READ_ONCE commands are issued to the Flash controller, along with the record index in question and the flash controller either programs the record or returns its content.

The program once area cannot be addresses by a physical address so is not readable by using a pointer.

You can get program once interface code from the uTasker project which gives the following general program once interface:

extern int fnProgramOnce(int iCommand, unsigned long *ptrBuffer, unsigned char ucBlockNumber, unsigned char ucLength);

It supports programming and retrieving the MAC address from this area using the routines (showing how the interface is used):

Retrieval:

static void fnGetUserMAC(void)
{
    unsigned long ulTestBuffer[2];                                   // the MAC address is saved in two long words
    fnProgramOnce(PROGRAM_ONCE_READ, ulTestBuffer, 0, 2);            // read 2 long words from the start of the program-once area
    if (uMemcmp(ulTestBuffer, cucBroadcast, MAC_LENGTH) != 0) {      // if programmed
        uMemcpy(network[DEFAULT_NETWORK].ucOurMAC, ulTestBuffer, MAC_LENGTH); // use the stored value as MAC address
    }
}

Programming:

    unsigned long ulTestBuffer[2];
    ulTestBuffer[1] = 0xffffffff;
    uMemcpy(ulTestBuffer, temp_pars->temp_network[DEFAULT_NETWORK].ucOurMAC, MAC_LENGTH); // retrieve first MAC address from storage
    fnProgramOnce(PROGRAM_ONCE_WRITE, ulTestBuffer, 0, 2);       // save to the first 2 long words in the program once area

Note that all operations use an 8 byte phrase (buffer) and unused bytes are set to 0xff. The MAC thus occupies a single phrase (organised as 2 long words in the passing buffer). In the uTasker projet the first phrase is used as MAC address as convention when the option is enabled.

The uTasker Kinetis simulator also simulates the Program Once Memory (as well as all other Flash operation) to allow experimenting with code to ensure correct usage before moving to the HW (where any mistakes can't be deleted).

Regards

Mark

0 Kudos
605 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Marlon,

You can find the IFR's definition in the reference manual.

2016-01-19_9-13-33.jpg2016-01-19_9-25-11.jpg


Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos