Is it possible to embed an Application DWL to the WPK File?

I think I have found the solution (need a bit more testing to confirm, but looks good so far!). I am using the DWLWin API in C# to download the firmware and application in one go, as well as starting the application automatically. Here is how I did it:

  1. Register the DWLWin API as explained in the user guide
  2. Create a new C# application
  3. Add a reference to dwlwin in the references section
  4. Use the following code snippet to perform the download (for a WMP100):
dwlwin.dwlwin dwl = new dwlwin.dwlwin();

string package = "project_name.wpb|";
string firmware = "R7.46.0.201108091301-cus-wmp-02.wpk";
string path = @"D:\DeveloperStudioWorkspace\project_name\[Target]_ARM_EABI_GCC_Debug\";

private void cmdStart_Click(object sender, EventArgs e)
{
    lblStatus.Text = "Starting download...";

    dwl.setDownloadOptions(13, 921600, path, firmware + "|" + package , "", "", 0, 0, 0, 0, 0, 0, 7, 0, "");

    string result = dwl.getPackageStrOptions(path + firmware);
    string result2 = dwl.getPackageIntOptions(path + firmware);

    dwl.setStrExtOption(13, "WCPU_TYPE", "wmp100");
    dwl.setIntExtOption(13, "NO_DOWNLOAD", 0);
    dwl.setIntExtOption(13, "START_APPLICATION", 1);

    dwl.start(13);

    Thread.Sleep(500);

    bool bConnected = false;

    while (dwl.isDownloadOver(13) == 0)
    {
        Thread.Sleep(100);

        if (!bConnected && (dwl.isBootOk(13) == 1))
        {
            lblStatus.Text = "Target Detected";
            bConnected = true;
         }

         try
         {
             progressBar1.Value = dwl.getProgress(13);
         }
         catch (Exception ex)
         {
             lblStatus.Text = ex.Message;
         }
    }

    try
    {
        int exitCode = dwl.getErrorCode(13);
        string exitMessage = dwl.translateErrCode(exitCode);

        lblStatus.Text = exitMessage;
     }
     catch
     {
     }
}

Some things to note:

  • The firmware wpk must be in the same directory as the application wpb.
  • You must select the CPU Type (WCPU_TYPE) or the application throws an error. This is because the firmware package contains files for more than one CPU type.
  • Here I am using COM13 at 921600 baud rate.

If anyone has a better solution, let us know!