Visible to Intel only — GUID: zwu1642635914613
Ixiasoft
Visible to Intel only — GUID: zwu1642635914613
Ixiasoft
7.10.3.3. alt_write_flash_block()
int alt_write_flash_block( alt_flash_fd* fd, int block_offset, int data_offset, const void *data, int length )
This function writes to the flash memory identified by the handle fd. It writes to the block located block_offset bytes from the start of the flash device. The function writes length bytes of data from the location pointed to by data to the location data_offset bytes from the start of the flash device.
Using the Fine-Grained Flash Access API Functions
#include <string.h> #include "sys/alt_flash.h" #include "stdtypes.h" #include "system.h" #define BUF_SIZE 100 int main (void) { flash_region* regions; alt_flash_fd* fd; int number_of_regions; int ret_code; char write_data[BUF_SIZE]; /* Set write_data to all 0xa */ memset(write_data, 0xA, BUF_SIZE); fd = alt_flash_open_dev(EXT_FLASH_NAME); if (fd) { ret_code = alt_get_flash_info(fd, ®ions, &number_of_regions); if (number_of_regions && (regions->offset == 0)) { /* Erase the first block */ ret_code = alt_erase_flash_block(fd, regions->offset, regions->block_size); if (ret_code == 0) { /* * Write BUF_SIZE bytes from write_data 100 bytes to * the first block of the flash */ ret_code = alt_write_flash_block ( fd, regions->offset, regions->offset+0x100, write_data, BUF_SIZE ); } } } return 0; }