Skip to content

Storage Control (FLASH CTL)


1. Overview

In CI110X series chips, flash is used for a variety of functions, including firmware storage and user data storage. Generally, user data storage should be completed using the relevant APIs of NVdata components. If you need to quickly read and write flash data and develop bootload programs during the development and debugging process, you may need to directly read and write flash. However, since flash devices are accessed by the m4 core and the dnn hardware unit at the same time, you cannot directly read and write flash, Therefore, the FLASH control read-write interface is provided here, through which the bus control can be obtained safely and reliably, and then the flash can be read and written.


2. Instructions

Function Interface Description
post_ write_ flash Request to write flash
post_ read_ Flash Request to read flash
post_ erase_ Flash Request to erase flash
requset_ flash_ Ctl Request flash bus use
release_ flash_ Ctl Release flash bus for use

Warning

Generally, post is used_ write_ flash、post_ read_ flash、post_ erase_ The flash interface can be operated to complete the flash data related requirements, and requset is not recommended_ flash_ ctl、release_ flash_ The ctl interface controls flash, because long-term possession of flash control will affect the DNN and thus the recognition effect. Remember that if you want to save user nv data, please use the relevant API of NVdata component instead of this component.

3. Example of use (1)

#define WAVE_ ADDR  0x1000
char wav_ format_ head[44];

/*Read 44 bytes of flash 0x1000 address to wav_ format_ In head*/
post_ read_ flash(wav_format_head, WAVE_ADDR, sizeof(wav_format_head));

4. Example of use (2)

The following details how to add, package, and read the file content in FLASH.

  • (1) . Create a new file in the project directory (SDK sample internal sample_xxx irmware_ser_file ), for example ([0] text file. txt). The file content is “123456789”.

!! Note “Note” There are no restrictions on the file name, but [ID] should be marked in front of the file name. As long as it does not have the same name as the ID of [60000], this ID is used for program reading.

图-1

  • (2) . Double click (synthetic partition bin file. bat) under the running project directory (SDK sample internal sample_xxx firmware) to package the file to user_ In file.bin

  • (3) The program reading file content program is as follows:

#include "ci_flash_data_info.h"
#include "flash_rw_process.h"

char value[512] = {0};

void read_ txt_ file(void)
{
uint32_ t tabaddr1 = 0;
uint32_ t tabsize1 = 0;

if(get_userfile_addr(0, &tabaddr1, &tabsize1) !=  0)
{
ci_ loginfo(LOG_USER,"failed!\n");
}

ci_ loginfo(LOG_USER,"file addr[%x],file size[%x]!\n",tabaddr1,tabsize1);

post_ read_ flash(value, tabaddr1, tabsize1);
ci_ loginfo(LOG_USER,"file value[%s]",value);
}
  • (4) The operation results are as follows:
file addr[376020],file size[9]!
file value[123456789]