Start up a LIBMEM loader that uses remote procedure calls via the ARM's debug comms channel.
-
Parameters:
-
|
comm_buffer_start
|
A pointer to the start of an area of RAM that can be used by the host to store data passed to the remotely called libmem functions. |
|
comm_buffer_end
|
A pointer to the last byte of the of an area of RAM that can be used by the host to store data passed to the remotely called libmem functions. |
Example:
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;
libmem_register_cfi_driver(&flash1_handle,
flash1_start,
flash1_geometry,
flash1_max_geometry_regions,
&flash1_info);
libmem_dcc_rpc_loader_start(buffer, buffer + sizeof(buffer) - 1);
return 0;
}
This function starts up a LIBMEM loader that uses remote procedure calls of the LIBMEM library executed via the ARM's debug comms channel. This form of loader will only run on ARM7 and ARM9s with the debug comms channel. It offers some performance advantage over the direct RPC loader.
The advantage of this loader mechanism is that it can be quicker than the direct RPC loader as it uses the ARM debug comms channel for memory access rather tham accessing the memory directly reducing significantly the number of JTAG operations required to carry out each operation. It works by the host locating the addresses of the LIBMEM functions in memory by examining the symbols in the loader's binary file and then calling them directly via a simple server handling commands over the ARM debug comms channel.
A communication buffer is required to store the parameters passed to the LIBMEM functions, this buffer is specified using the comm_buffer_start and anf comm_buffer_end parameters. The buffer must be at least 8 bytes in length, however you will find the bigger the buffer is the more performant the loader will be as less RPC calls will required.
The host loader application adapts how it carries out the download by the set of LIBMEM functions that are linked into the loader application. The only two required functions are libmem_write() and libmem_erase(), libmem_unlock() is only required if the erase or write functions return a LIBMEM_STATUS_LOCKED result. Everything else can be done by accessing memory directly however you will get a performance increase when verifying if you link in libmem_crc32(). If any of the memory programmed by the LIBMEM drivers cannot be accessed directly you will also need to link in libmem_read(), note that if all memory can be accessed directly you should not link this in as using this function will reduce performance.
As the loader application usually makes no direct calls to the LIBMEM functions they will by default be discarded by the linker, you therefore need to make sure the required LIBMEM functions are linked into your loader using the "Linker | Keep Symbols" project property.
To use this form of loader the "Target | Loader File Type" project property must be set to "LIBMEM RPC Loader".
Optional parameters can be passed to the loader using CrossStudio's "Target | Loader Parameter" project property which holds a 32 bit integer value. When using an RPC loader this value is passed in register R0 as the loader starts up.
|