Reading or Writing a Block Takes a Long Time with MICROSAR Standard Fee
In most cases a block is written many times before a sector switch has to be executed. That means there is more than one instance of a block in the data flash. If you want to read or write a block which already has more instances in the data flash, the first task of the Fee is to find the last (valid in case of reading) instance of the block. Searching begins with finding the newer sector. After that, the Fee reads the first address of the first chunk of the block, it checks if the management information of the first chunk is valid and if the first chunk has a chunk link. A chunk link is a pointer to the successor chunk, comparable to a linked list. If the chunk has a link to a successor chunk, the Fee checks the management information of this chunk and again checks whether this chunk has a successor chunk. The Fee must do this as long as a chunk is found without successor. For each step, checking management information or checking the link, an asynchronous read request to Fls is necessary.
If the Fee has found the last chunk without successor, it searches in this chunk for the last (valid in case of reading) instance. Searching in a chunk is done with a binary search algorithm. This is much faster than the cost intensive search by following the chunk links.
Many customer configurations did not change the configuration of the parameter Number Of Instances In Chunk (/MICROSAR/Fee/FeeBlockConfiguration/FeeNumberOfChunkInstances). The default value of this parameter is one. If a block has to be written, the searching of the last (valid) block is only done with the cost intensive search by following the chunk links. If the block is written many times since the last sector switch, the Fee must follow many links and that takes the long time. If the sector switch was executed, the number of links is reduced, often only the last valid chunk exists any more. Search time is much lower and will increase again to the next sector switch.
(Y-axis: time for each single write request. X-axis: number of write requests)
The picture above shows, how the time for writing a block increases due to the increased search effort for the last instance/next new empty instance to write to. After the sector switch, the time starts level again at the lowest.
To optimize the search time, DaVinci Configurator Pro offers an optimization assistant for configuring the optimum Number Of Instances In Chunk for each Fee block. Optimization is done for each partition. As input, the assistant uses the Number of Write Cycles (/MICROSAR/Fee/FeeBlockConfiguration/FeeNumberOfWriteCycles) of each Fee block. Do not forget to configure the probable number of write cycles for each block during the lifetime of the ECU before starting the assistant.