Clarification on "ONCE" Flash fields

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

Clarification on "ONCE" Flash fields

1,040 Views
Catosh
Contributor IV

The mapping and functionality of the "once" flash flieds is not very clear for me. 

Program once (PO): read freely, no erase and limited program capability.

the PO IFR has 16bytes of XACC, 16bytes for SACC, 64bytes for ID Field. 
According to the Datasheet, "The Program Once Field in the program flash IFR provides 96 bytes of user data storage
separate from the program flash main array".
1) 32bytes are for access and supervisor control, 64bytes are for program ID field. Where is the user data storage located? 
2) the XACC and SACC are related to what? To the regular flash or the program once filed? what and where am I going to store/execute that code? 

Program Flash Erasable IFR Map:
16bytes x 2 total.
x20:x23 Programmed using Program Once, CANNOT be read with Read Once. How do I read this? Should I use the Read Resource Command?
x30:x33 Programmed using Program Once, READ with Read Once.

Then the commands: {
[...]The Read Once command provides read access to special 96-byte fields located in the
program flash 0 IFR (see
Program Flash IFR Map and Program Once Field). Access to
the Program Once ID field is via 16 records (index values 0x00 - 0x0F), each 4 bytes
long. Access to the Program Once XACC and SACC fields are via 4 records (index
values 0x10 - 0x13), each of which is 8 bytes long.
The Read Once command also provides read access to special 4-byte records (index
values 0x30 - 0x33) located in the program flash erasable IFR (see
Program Flash
Erasable IFR Map
and Erasable Program Once Field). These fields are programmed
using the Program Once command
 }


According to my understanding,there is no way to read feld x20:x23 from the erasable fields, unless I am going to read them with the Read Resource Command. Am I right?

Again on the Program Once Command: {

[...]The Program Once command enables programming to special 96-byte fields in the
program flash 0 IFR (see
Program Flash IFR Map and Program Once Field). Access to
the Program Once ID field is via 16 records (index values 0x00 - 0x0F), each 4 bytes
long. Access to the Program Once XACC and SACC fields are via 4 records (index
values 0x10 - 0x13), each of which is 8 bytes long. These records can be read using the
Read Once command (see
Read Once Command) or using the Read Resource command
(see
Read Resource Command). }

Summarising my doubts: 

The fields I can program using the Program Once are not "User data storge" fields but special byte fields?
Why the command is called Read Once if I can read more than once that field? 

The XACC and SACC on IFR are related to what? Are the same to what the FMC refers to as FAC? If so, what's the meaning of the Default Flash Protection bytes area (0x0_408 - 0x0_040B) ?

Any hit would be gladly appreciated. 

B.R.

L.

Labels (1)
0 Kudos
7 Replies

729 Views
mjbcswitzerland
Specialist V

Hi

the area you are referring to is called the "Program Once" area. Each 4 or 8 byte groups (depending on processor type - either using long word or 8 byte phrase programming) of its 64 byte can be programmed once and never changed/deleted. It can be read as many times as you like so the "read once" command is not referring to the ability to read it only once but to the fact that it is in the Program once area.
The program once area is not memory mapped (like program/data Flash) and can only be read by using the the FCMD_READ_ONCE command. It is programmed using the FCMD_PROGRAM_ONCE command.

I have attached the uTasker flash driver (suitable for any Kinetis part) which includes program once interface (search for SUPPORT_PROGRAM_ONCE for all relevant code).

Use its open source project from http://www.utasker.com/kinetis.html to test this and also to simulate it so that you can see what happens inside (useful also for testing without writing to the real HW so that application errors can be solved before setting the final memory)

Regards

Mark

0 Kudos

729 Views
Catosh
Contributor IV

Hello Mark, 

thanks for your quick reply, you helped me in clarify some aspects of the Program Once. 

BTW, a major doubt is on fields of the program once. Those 96 bytes are not "user data storage", but are already splitted and defined as ID field and XACC/SCAA fields, isn't it? And the XACC and SCAA (Execute only and Supervisor Only) are those loaded in the FTFA_XACCn and FTFA_SACCn registers during the reset sequence. 
The 64 bytes in the program once ID field are referred to what? 


Then:

Read Resource can access only the IFR and VersionID field 4 bytes at time, while ReadOnce can read also the 4byte records in Program Flash Erasabe IFR MAP? So the data written in 0x20 - 0x23 is not accessible but writable? 

The size of the fields is still not clear to me:

Table 34-10. Read Resource Select Codes

Resource
Select Code
Description Resource Size Local Address Range
0x00 Program Flash 0 IFR 256 Bytes 0x00_0000–0x00_00FF
0x011 Version ID 8 Bytes 0x00_0000–0x00_0007


bu according to the IFR table:
The program flash IFR is located within the program flash 0 memory block .

Address Range Size (Bytes) Field Description
0x00 – 0x9F 160 Reserved
0xA0 – 0xA3 4 Program Once XACCH-1 Field
(index = 0x10)
0xA4 – 0xA7 4 Program Once XACCL-1 Field
(index = 0x10)
0xA8 – 0xAB 4 Program Once XACCH-2 Field
(index = 0x11)
0xAC – 0xAF 4 Program Once XACCL-2 Field
(index = 0x11)
0xB0 – 0xB3 4 Program Once SACCH-1 Field
(index = 0x12)
0xB4 – 0xB7 4 Program Once SACCL-1 Field
(index = 0x12)
0xB8 – 0xBB 4 Program Once SACCH-2 Field
(index = 0x13)
0xBC – 0xBF 4 Program Once SACCL-2 Field
(index = 0x13)
0xC0 – 0xFF 64Program Once ID Field
(index = 0x00 - 0x0F)


Which one is correct? 

Thanks and best regards, 

L.T.

0 Kudos

729 Views
mjbcswitzerland
Specialist V

Hi

I think that you are using the KL82, which has additional capabilities in its flash memory module.

It may be best to first read the description of the module in a different part - such as the KL28 - which only has the basic user program once area.

At the moment you are mixing you the user program once area with additional ones. At the end of the day the module still has the standard 64 bytes of user area (can be programmed once but not erased) plus various new stuff which is in addition to that and makes it rather confusing.

From a programmer's point of view you can think of it as 64 bytes, which an be individually programmed (once) as long words. This is done using the "Program Once Command - 0x43". A parameter (record index) of 0..15 is passed with it to identify which of the 16 long words is to be programmed. Just where this is actually stored is another question but not that relevant for the programmer.

The extended capabilities add further record indexes to specify that the value to be programmed in other special areas (like the XACC, SACC fields and more) that are beyond the basic user program once capability.

Once you have used the basic programming area you can then move on the extended capabilities, if needed. Remember that most Kinetis parts with program once do not have the extended stuff.

Regards

Mark

729 Views
Catosh
Contributor IV

Hello Mark,
sorry for the long delay. I took a look to the KL28 and still I have a couple of doubts.

Basically:
address range 0x00 - 0x9F reserved
range 0xA0 - 0xBF index 0x10 - 0x13 is related to the XACC and SACC control (ProgramOnce, ReadOnce)
range 0xC0 - 0xFF index 0x00 - 0x0F user data ProgramOnce, ReadOnce.
range 0xC0 - 0xCF index 0x30 - 0x33 ProgramOnce, ReadOnce, Erasable.


Question 0: What does "address range" refer to? I read that program once fields are not memory mapped... with a debugger I should not be able to read this area, am I right?  

Question 1: the address range of "program once ID field" and of the "program Flash Erasabe IFR Map" overlap.
is the "program Flash Erasabe IFR Map" part of the "program once ID field" or do I misunderstand the "address range" meaning?

Question 2: The read resource reads the entire space of the program flash 0 IFR (or the version ID), while the ReadOnce reads only 4 bytes?

B.R.

Luca

0 Kudos

729 Views
mjbcswitzerland
Specialist V

Luca

Question 0: The area is not memory mapped (not visible using debugger and only accessible using codes and indexes) and I assume that the mapping shown is more an implementation detail and has little relevance for its programming model. Therefore I wouldn't worry too much about the details: basically use the command and index since that determines the data accessed and don't think about the (theoretical) implementation details.

Question 1: Again I wouldn't worry too much about the fact that address ranges overlap - it may be a documentation error or it may be that the area has two banks (the addresses given are only valid for specific instructions). The accesses are controlled by the command and index and the programmer can ignore the internal implementation details.

Question 3: All command transfer 4 bytes at a time but the Read Resource Command looks to use the Flash address, which is passed together with the command, to identify the byte that are involved (in this case the programmer can indeed consider the address range to be in a "virtual" memory mapped area (0..0xff) and an additional "Resource Select Code) switches this like a bank to determine whether the 0..0x7 range is read form the Version ID bank or the Program Flash 0 IFR.
This command is not needed for normal operation but could be used to experiment and get to better understand the internal workings/implementation if you are still curious.

Regards

Mark

0 Kudos

729 Views
Catosh
Contributor IV

Hi Mark, 
Thanks for your patience and support. 

Let me briefly recap to check if I understood correctly.. 
indexes 0x10 -  0x13 - Related to flash exec and access. 
indexes 0x00 - 0x0F   - empty area for the user. "ID Field" has no "identifier" meaning: 64Bytes for user data. 
Both areas are Not erasable, ponce to write, ronce to read. Not memory mapped, address range used only together with ReadResource. Address range 0x00-0x9F is reserved (not programmable and not erasable; read has no meaning for the coder here ). 
Other indexes (0x20, 0x30, etc) are related to additional features of the MCU that are configured using the program once flash command. These fields can be erased and read using the appropriate commands. 
The Address Range has no meaning from the programmer perspective so overlaps are not relevant (Data in 0x80 or in 0xC0 are not present in the same address range of the Program Once ID Field).  

In a simple table, 

Address rangeField indexDescriptionWriteReadErase
0x00 - 0x9FReservedNORead Once, Read ResourceNO
0xA0 - 0xA30x10XACCH-1Program once
0xA4 - 0xA70x10XACCL-1
0xA8 - 0xAB0x11XACCH-2
0xAC - 0xAF0x11XACCL-2
0xB0 - 0xB30x12SACCH-1
0xB4 - 0xB70x12SACCL-1
0xB8 - 0xBB0x13SACCH-2
0xBC - 0xBF0x13SACCL-2
0xC0 - 0xFF 0x00 - 0x0FProgram Once ID Field
0x80 - 0x830x20Program OnceNOErase ALL Blocks, Erase All Blocks Unsecure, mass Erase
0x80 - 0x830x21
0x80 - 0x830x22
0x80 - 0x830x23
0xC0 - 0xC30x30Key for SB firmware to upload wiht KBLProgram Once (4 Bytes)Read Once (4 Bytes)Erase ALL Blocks, Erase All Blocks Unsecure, mass Erase
0xC4 - 0xC70x31
0xC8 - 0xCB0x32
0xCC - 0xCF0x33

This should be correct - At least I hope. 

0 Kudos

729 Views
mjbcswitzerland
Specialist V

Luca

I don't know whether all details are perfectly accurate but I would go with that and do some practical tests/experiments. Then you can confirm and possibly iterate accordingly.

Regards

Mark

0 Kudos