FlashTool V6 Command Customization Guide

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

FlashTool V6 Command Customization

Guide
Version: 1.0
Release date: 07/02/2021

Specifications are subject to change without notice.

© 2014, 2015 MediaTek Inc.


This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction of this information in whole or in part is strictly prohibited.
FlashTool V6 Command Customization
Guide

Document Revision History

Revision Date Description


1.0 La0t0av32Ti73 Initial version.

© 2015 MediaTek Inc. Page 1 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

Table of contents

1. Purpose............................................................................................................................................... 4
2. General command format and execution flow......................................................................................5
2.1. Command Format.............................................................................................................................5
2.2. The command execution flow...........................................................................................................5
2.3. Security concern................................................................................................................................6
3. DA Implementation............................................................................................................................. 7
3.1. Command registration......................................................................................................................7
3.2. Function examples............................................................................................................................7

© 2015 MediaTek Inc. Page 2 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

Lists of tables

未找到图形项目表。

© 2015 MediaTek Inc. Page 3 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

1. Purpose

Flashtool library and Download Agent support customized commands.


The official supported commands are documented in “FlashTool V6 Library Developer's
Guide.docx”.
This document is the introduction of how to add OEM commands in Download Agent.

© 2015 MediaTek Inc. Page 4 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

2. General command format and execution flow

1.1. Command Format


The command string is XML use UTF-8 encoding.

1) Root node must be “<da>”

2) Have node “<da/version>”, version format: “major.minor”. “1.x” must compatible with early version. If
not, update to “2.x”.

3) Node “<command>” is a customized command string, max length is 64.

4) In “<arg>” node, can add any wanted node sending to DA.

<?xml version="1.0" encoding="utf-8"?>


<da>
<version>1.0</version>
<command>CMD:CUST1</command>
<arg>
<cust_node1>xx</cust_node1>
<cust_node2>xx</cust_node2>
</arg>
</da>

1.2. The command execution flow


The command string will be sent by this sequence:

1) Service send string to flash.dll library, and the library just send it directly to DA, do not modify and check it.

2) DA check whether this command is registered.

3) If command is registered, DA dispatcher will execute the command handler.

4) Command handler use protocol functions already implemented in DA to communicate with flash.dll.

5) DA can get/set these info:

a. Get value in command xml.

b. Read/Write file on host. File can be: memory buffer, host normal file, customized file type.

c. Some host file system operations: like mkdir, file-exist etc.

d. Report operation progress.

© 2015 MediaTek Inc. Page 5 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

1.3. Security concern


These commands must pass security check in DA.

© 2015 MediaTek Inc. Page 6 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

3. DA Implementation

1.4. Command registration


In file platform/<project>/flash/cmd_bootstrap2.c

 Call this API to register command handler:

register_major_command(“CMD:CUST1”, ver1_0, cmd_cust1);

//If command “CMD:CUST1” and version ver1_0 is received, “cmd_cust1” will handle
this.

 Implement command handler like this:

//parameter:
//channel: USB channel, must not be used directly to transfer data.
// or will cause protocol error.
//xml: the xml string sent by host.
int cmd_cust1(struct com_channel_struct *channel, const char *xml) {
clear_error_msg();
mxml_node_t *tree;
const char *info;
if ((tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK)) == NULL ||
(info = mxmlGetNodeText(tree, "da/arg/cust_node1")) == NULL) {
set_error_msg(“This error message will be reported to host.”);
return STATUS_ERR;
}

//do functions.

MXMLDELETE(tree);
return STATUS_OK;
}

1.5. Function examples


 read a host file to DA:

© 2015 MediaTek Inc. Page 7 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.


FlashTool V6 Command Customization
Guide

char *buffer = 0;

uint32_t data_length = 0;

status = fp_read_host_file(channel, “host-file-name”, &buffer, &data_length,

"cust-message");

//the file data will be in “buffer” and actual length in “data_length”

//after use, free buffer


fp_free_host_file_buffer(buffer);

 Doing a time consumption job and prevent host timeout and appear no response to user, need report
progress:

struct progress_cb progress;

progress.user_arg = (void *)channel;

progress.cb = cb_op_progress_report;

fp_progress_report_start(channel, part_info.name);

//do function and use this to report progress:

// progress.cb(cb.user_arg, progress_value_0_to_100, “message report to host”);

fp_progress_report_end(channel);

 More functions, refer to this header file: platform/flashc/boot/protocol_functions.h

© 2015 MediaTek Inc. Page 8 of 8


This document contains information that is proprietary to MediaTek Inc. Co

Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.

You might also like