MEM

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.

Details

define MEM_VERSION

define MEM_IOC_IDENT_CHAR

define I_MEM_GETVERSION

define I_MEM_GETINFO

define I_MEM_SETATTR

define I_MEM_SETACTION

define I_MEM_ERASEPAGE

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

Example:

ioctl(mem_fd, I_MEM_ERASEPAGE, 3); //erase page 3

This function has no effect for pages that are not flash pages.


define I_MEM_ERASE_PAGE

define I_MEM_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:

mem_pageinfo_t pageinfo;
pageinfo.type = MEM_PAGEINO_TYPE_FLASH;
paginfo.num = 0;
//This will get the size and address of flash page 0
ioctl(mem_fd, I_MEM_GET_PAGEINFO, &pageinfo );

Or to lookup based on the address:

mem_pageinfo_t pageinfo;
pageinfo.type = MEM_PAGEINFO_TYPE_QUERY;
paginfo.addr = 0x00001000;
//This will get the size and address of flash page 0
ioctl(mem_fd, I_MEM_GETPAGEINFO, &pageinfo );

The type, num, and size parameters will then be populated.


define I_MEM_WRITEPAGE

This request writes a page to flash memory.


define I_MEM_TOTAL

enum @20
  • MEM_FLAG_IS_QUERY Query the page type. This is used when the address is known but the page number, size, and type are not known
  • MEM_FLAG_IS_RAM RAM
  • MEM_FLAG_IS_FLASH Flash
  • MEM_FLAG_IS_TIGHTLY_COUPLED Tightly coupled memory (OR with RAM or FLASH)
  • MEM_FLAG_IS_EXTERNAL External memory chip (OR with RAM or FLASH)

This lists each type of page.


struct::mem_info_t

u32 flash_pages

The total number of flash pages

u32 flash_size

The total size of the flash memory

u32 ram_pages

The total number of RAM pages

u32 ram_size

The total size of the RAM

u32 system_ram_page

First page for system shared RAM

u32 usage_size

u32 * usage

u32 external_ram_pages

The total number of external RAM pages

u32 external_ram_size

The total size of external RAM

u32 tightlycoupled_ram_pages

The total number of external RAM pages

u32 tightlycoupled_ram_size

The total size of external RAM

u32 resd

struct::mem_attr_t

This defines the attributes of the memory.

It is used with I_MEM_GETINFO. The attributes are read-only so I_MEM_SETATTR has no effect.

u32 o_flags

u32 resd

struct::mem_pageinfo_t

This structure contains the details for a page of memory.

s32 num

u32 o_flags

u32 addr

u32 size

struct::mem_writepage_t

u32 addr

The address to write to

u32 nbyte

The number of bytes to write

u8 buf

A buffer for writing to the flash


X

Thanks for Coming!

Subscribe to news and updates