Currently in PC remote access device Flash, which is the deployment of TINYCLR and download applications. In a previously written "Nandflash Drive Development" article, we know that Flash is divided into six areas, typically structured as follows (take the Sam9261_ek Development Board as an example):
const BlockRange g_K9F2G_8_BlockStatus[] =
{
{ BlockRange::BLOCKTYPE_BOOTSTRAP , 0, 1 },
{ BlockRange::BLOCKTYPE_CONFIG , 2, 2 },
{ BlockRange::BLOCKTYPE_CODE , 3, 24 },
{ BlockRange::BLOCKTYPE_DEPLOYMENT, 25, 29 },
{ BlockRange::BLOCKTYPE_DEPLOYMENT, 30, 34 },
{ BlockRange::BLOCKTYPE_DEPLOYMENT, 35, 39 },
{ BlockRange::BLOCKTYPE_DEPLOYMENT, 40, 48 },
{ BlockRange::BLOCKTYPE_STORAGE_A , 49, 49 },
{ BlockRange::BLOCKTYPE_STORAGE_B , 50, 50 },
{BlockRange::BLOCKTYPE_FILESYSTEM, 51, FLASH_BLOCK_COUNT - 1 }
};
Can we read and write directly to all the areas on the flash?
The benefits of implementing this feature are easy to see, and there is no longer a need to start a relatively large VS2008 to download an application, and not be limited by the need to open MF Engineering to download. In our development of TI DM355 Development Board encountered similar problems, we give off-site development board providers to demonstrate the relevant program features, must require the other side to install VS2008, but also must send our project source code, otherwise it will not be able to be on the other Development Board for demonstration.
A closer look at the Mfdeploy program, which is a typical C # program that works directly on Vista and Windows7, and the need to install the. Net Framework runtime on WinXP and previous systems, and discovers that a plug-in can be developed for it to achieve the functionality we require.
The Mfdeploy program can access. Net MF devices, serial ports, ports, and USB in three ways, and can deploy TINYCLR to devices (which require the Development Board to run Tinybooter) or empty the application area. So we just have to extend this part of the function to be able to.
The plug-in class must inherit from the Mfpluginmenuitem class, and the relevant code is as follows:
public class PlugInHandle : MFPlugInMenuItem
{
public override string Name { get { return "Read/Write Flash"; } }
public override void OnAction(IMFDeployForm form, MFDevice device)
{
if (form == null || device == null) return;
(new frmRWFlash(form, device)).ShowDialog ();
}
}
The form and device that are passed by the host are very important, the form is for the Mfdeploy main form, mainly provides the Dumptooutput function, displays the message to the information area, but device provides the correlation function which communicates with the device, such as Ping, Deploy, Erase, execute and so on.
Plug-in implementation of the first step, to read and write the Flash area, the first to obtain flash memory image table, through the following code can be obtained:
_dbg.wireprotocol.commands.monitor_flashsectormap.reply Reply = engine. Getflashsectormap ();
if (reply!= null)
{
for (int i = 0; i < Reply.m_map. Length; i++)
{
_dbg.wireprotocol.commands.monitor_flashsectormap.flashsectordata FSD = Reply.m_map[i];
String usage = "";
Switch (Fsd.m_flags & _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_mask)
{
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_applic ATION:
Usage = "Application";
Break
Case _DBG.WIREPROTOCOL.COMMANDS.MONITOR_FLASHSECTORMAP.C_MEMORY_USAGE_BOOTST RAP:
Usage = "Bootstrap";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_code:< br> USAGE = "CODE";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_config:
Usage = "Configuration";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_deploy ment:
Usage = "Deployment";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_jitter:
Usage = "jitter";
Break
Case _DBG.WIREPROTOCOL.COMMANDS.MONITOR_FLASHSECTORMAP.C_MEMORY_USAGE_FS:
Usage = "File System";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_reserv ED:
Usage = "Reserved";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_storag E_a:
Usage = "Storage";
Break
Case _dbg.wireprotocol.commands.monitor_flashsectormap.c_memory_usage_storag E_b:
Usage = "Storage";
Break
Case 0XA0:
Usage = "Custom";
Break
}
Flashmap.add (flashmaps, usage, fsd.m_address, fsd.m_size);
}
}