FLASH

The flash memory software module allows the user code to read memory in the flash program space. Reading the flash is portable across all supported MCU’s. However, writing the flash is dependent on the MCU page size.

This interface is typically only used with the bootloader. The preferred way to access the flash is using the Memory (RAM/Flash) interface.

Details

define FLASH_VERSION

define FLASH_IOC_IDENT_CHAR

define FLASH_MIN_WRITE_SIZE

This defines the MCU specific value for the minimum write size. This is also the minimum step and alignment size for writing the flash.


define FLASH_MAX_WRITE_SIZE

This defines the MCU specific value for the maximum write size for a flash operation.


define I_FLASH_GETVERSION

define I_FLASH_GETINFO

define I_FLASH_SETATTR

define I_FLASH_SETACTION

define I_FLASH_ERASEADDR

This request erases the page containing the specified address. The address is specified as the ctl argument.

ioctl(flash_fd, I_FLASH_ERASEADDR, (void*)0x00001000 );

define I_FLASH_ERASE_ADDR

define I_FLASH_ERASEPAGE

This request erases the page number specified by the ctl argument.

Example:

ioctl(flash_fd, I_FLASH_ERASEPAGE, 3); //erase page 3

define I_FLASH_ERASE_PAGE

define I_FLASH_GETPAGE

This request gets the page number for the specified address. The ctl argument is the address and the return value is the page.

Example:

int page;
page = ioctl(flash_fd, I_FLASH_GETPAGE, (void*)0x00001000 );

define I_FLASH_GET_PAGE

define I_FLASH_GETSIZE

This request gets the page number for the specified address. The ctl argument is the address and the return value is the page.

Example:

int page;
size = ioctl(flash_fd, I_FLASH_GET_PAGE);

define I_FLASH_GET_SIZE

define I_FLASH_GETPAGEINFO

This request gets the page number for the specified address. The ctl argument is the address and the return value is the page.

Example:

flash_pageinfo_t pageinfo;
page = ioctl(flash_fd, I_FLASH_GETPAGEINFO, &pageinfo );

define I_FLASH_GET_PAGEINFO

define I_FLASH_WRITEPAGE

This request is used to write a page to the flash memory.

flash_writepage_t pwrite;
pwrite.addr = 0x1000; //this should be on a boundary for the minimum page size
pwrite.nbyte = 256;  //This has to be a valid page write value for the architecture
memcpy(pwrite.buf, my_data, pwrite.nbyte);
ioctl(flash_fd, I_FLASH_WRITEPAGE, &pwrite);

define I_FLASH_TOTAL

struct::flash_info_t

u32 o_flags

u32 o_events

u32 resd

struct::flash_attr_t

u32 o_flags

u32 resd

struct::flash_pageinfo_t

This data structure holds the details of a flash page.

u32 page

u32 addr

u32 size

struct::flash_writepage_t

This structure is used to write data to the flash using I_FLASH_WRITEPAGE.

u32 addr

The address to write to

u32 nbyte

The number of bytes to write

u8 buf

X

Thanks for Coming!

Subscribe to news and updates