The aim of the LIBMEM loader library is to be an add on to the LIBMEM library that simplies the writing of loader applications.
To write a loader application all you need to do is register the LIBMEM drivers you require and then call the appropriate loader start function for the communication mechanism you wish to use.
For example the following code is an example of a LIMBMEM loader, it registers one LIBMEM FLASH driver and starts up a LIBMEM loader using direct remote procedure calls of the LIBMEM library:
static unsigned char buffer[256]; int main(void) { uint8_t *flash1_start = (uint8_t *)0x10000000; const int flash1_max_geometry_regions = 4; libmem_driver_handle_t flash1_handle; libmem_geometry_t flash1_geometry[flash1_max_geometry_regions]; libmem_flash_info_t flash1_info; // Register FLASH driver. libmem_register_cfi_driver(&flash1_handle, flash1_start, flash1_geometry, flash1_max_geometry_regions, &flash1_info); // Run the loader libmem_rpc_loader_start(buffer, buffer + sizeof(buffer) - 1); return 0; }
Essentially, a LIBMEM loader is just a standard RAM based application that registers the LIBMEM drivers required by the loader and then calls the appropriate loader start function for the communication mechanism being used.
The LIBMEM loader library currently supports three different loader communication mechanisms. You select which one to use by calling libmem_rpc_loader_start() , libmem_dcc_rpc_loader_start() or libmem_dcc_loader_start() to start the loader. The documentation for each of these functions describes how each of these communication mechanisms work.
A significant difference between LIBMEM loader applications and regular applications is that once the loader start function is called it is no longer possible to debug the application using the debugger. Therefore if you need to debug your loader application using the debugger you can do it by simply adding calls to the functions you wish to debug in place of the loader start call.