MTK入门资料

MTK入门

有偿提供MTK技术支持(QQ85313653-请注明MTK

文档内容:
-》MTK软件架构
-》如何编译
-》开发目录结构解析
-》开发工具的了解
-》程序入口,程序导读
-》MMI的制作

1MTK软件构架
参考文档:MT6218_SW_ReleaseNote.pdf
MTK
MediaTek公司提供的GSM软件方案。它包含5个部分:
-》L1协议
-》设备驱动
-》协议栈
-》MMI
-》WAP应用
MediaTek
为用户提供3个工具:
-》Catcher
-》META
-》MCT
MTK
软件架构图:

<shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="bj_t" style="WIDTH: 5in; HEIGHT: 204.75pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1025"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1728470.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image001.gif"></imagedata></shape>

下面3个部分组成该软件方案:
1. MS Executable Software, which is the software running on the MS, includes the following modules
- OS: Nucleus OS.
- L1 Protocol Stack: GSM physical layer.
- Drivers: device driver, like SIM, UART, GPIO, etc.
- L2/L3 protocol stack: GSM protocol stack layer.
- MMI: man-machine interface.
- WAP: Wireless application protocol.
- JAVA: J2ME Software
2. The Mobile Engineering Testing Architecture, also known as META
3. Catcher
-》OS
MediaTek
采用Nucleus OS实时操作系统。KAL OS层为MediaTek’s软件和Nucleus操作系统的接口。它为任务提供许多系统服务函数,比如计时器,队列,内存管理,事件等等。
-》L1 Protocol Stack
The physical layer or Layer 1 supports the transfer of bit streams on the radio medium according to the Technical Specifications of the 05-series. It provides service to upper layers and control the mapping and scheduling between the logical and physical channels. The TDMA framing and radio control parts are also implemented.

<shape id="g.s4" style="WIDTH: 335.25pt; HEIGHT: 277.5pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1026"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1728471.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image002.gif"></imagedata></shape>

Layer 1 Asynchronous: handles the message request from upper layers and forward the result generated by layer 1 to upper layer.
Surrounding Cell Engine: handles the neighbor cell power measurement and neighbor cell synchronization information acquisition.
Layer 1 Control: handles the TDMA scheduling on the radio environment, including timing advance and power control command from serving base station.
Layer 1 Driver: handles the DSP and Radio control

-》Drivers
MCU外围设备的驱动,如下:
SIM: Subscriber Identity Module

UART: Universal Asynchronous Receiver/Transmitter

SPI: Serial Port Interface

LCD: Liquid Crystal Display

GPIO: General Purpose Input/Output

GPT: General Purpose Timer

RTC: Real Time Clock

WDT: Watch Dog Timer

PWM: Pulse Width Modulation

Alerter

Keypad

PMIC: Power Management IC

BMT: Battery Charging Management task

AUX task: Auxiliary task

ADC Sched.: Analog to Digital Converter Sch
eduler
USB task: The USB 1.1 protocol and
driver
IrDA task: The IrDA and driver
Camera: Camera driver for integrating with 3rd party camera module
MSDC: Memory card driver, supporting SD, MMC cards and Memory Stick
JPEG Decoder: Software for controlling hardware JPEG decoder

<shape id="q96i" style="WIDTH: 5in; HEIGHT: 206.25pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1027"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1720340.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image003.gif"></imagedata></shape>

-》L2/L3/L4 Protocol Stack
这部分包含大量的GSM/GPRS需求以及提供一个优秀的GSM/GPRS平台给应用程序。本地MMI和远程PC通过AT命令可以方便的使用该软件平台。详细的结构如下:
RMI:
远程MMI,比如PC端,可以使用AT命令通过串口与协议栈进行通讯。
FMI: Feature rich MMI, described in the
above section. This is the production co-worked with Pixtel.
L4: Layer 4. L4 is a task through which FMI and/or
RMI communicate with PS. L4 task includes several sub-modules.
ATCI: AT command interpreter. Interprets the AT
commands from PC side and commands the L4C to do the relative actions.
L4A: L4 adaptation layer for FMI. The SAP
between FMI and L4A is primitive base.
L4C: L4 control entity. Handles all applications request and response.

UEM: User equipments adaptation.
Adaptation for drivers, like Keypad, LED, GPIO, Audio…etc.
PHB: Phone book management. Handles the phone
books related processing, like: sorting…etc.
SMU: SIM management unit. Handle the security
management, and STK.
CSM: Circuit
switching protocol stack management.
RAC: Registration access control.

SMSAL: Short message service application layer.

TCM: Terminal context management.

NVRAM: Non-volatile RAM. This is adaptation layer
to flash memory.
SIM: Subscriber
identity module. Handle SIM behavior as ETSI 11.11 description.
DATA: Circuit switched data service. Data task
includes several sub-modules.
FAX:
Group 3 Facsimile.
TDT: Transparent
circuit switching data.
L2R: Layer 2
relay protocol for non-transparent circuit switching data.
RLP: Radio link protocol for non-transparent
circuit switching data.
CC:
Circuit-switched call control.
SS:
Supplementary service.
SMS: Short
message service.
SM: Session
management.
MM/GMM: Mobility
management/GPRS mobility management.
SNDCP: Subnetwork dependent convergence protocol.

LLC: Logical link control.

RR: Radio resource management. RR task includes
several sub-modules.
RRM: Handles cell
selection and PLMN selection.
RMPC:
Handles the procedures in Idle/Dedicated state including the surrounding cell scheme and measurement reporting.
LAPDM: Handles the procedure defined in GSM layer 2.

RLC: Radio link control protocol.

MAC: Medium access control protocol.

MPAL: Adaptation layer for RR and L1A.

PPP: Point to Point protocol layer. This is client PPP layer.

<shape id="xj_x003a_x" style="WIDTH: 5in; HEIGHT: 265.5pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1028"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1720341.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image004.gif"></imagedata></shape>

<shape id="ncq0" style="WIDTH: 5in; HEIGHT: 205.5pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1029"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1720342.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image005.gif"></imagedata></shape>

-》MMI
这部分包括用户的接口架构,应用以及和协议栈的通讯。

<shape id="hbzh" style="WIDTH: 5in; HEIGHT: 174.75pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1030"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1721330.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image006.gif"></imagedata></shape>

Framework: This covers that
OSL: OS adaptation layer

Task: communication with L4 task.

File system: communication with storage device.

GUI: This covers that

Theme

UI
component
Category screen

Font

Editor

T9 or Ezi input method.

Access LCD driver.

Customization tool.

Application

Phonebook

Messages (SMS, <place w:st="on">EMS</place> 4.0, CB)

Call
history
Setting. (Phone setting,
network setting, security setup)
5
kinds of user profiles
Fun and games

Organizers

Services

Shortcuts

In call management.

Interrupt events, like charging , alarm.

-》WAP
如何编译
参考文档:wcr-MTK_MakeBuild_Design_Customer_040930.pdf

-》编译环境
操作系统:Windows 2000, WinXP. 推荐Windows 2000 with SP2 or later.
编译器:ADS (Arm Developer Suite) v1.2.
Perl
解析:ActivePerl.推荐使用ActivePerl 5.6.1版本

-》make.bat
It will parse command line to determine project name, platform, and action. Meanwhile, checking /make directory exist or not and checking command line argument is legal or not. After checking, to execute build script GSM2.mak build script to perform action.
使用:
Usage: Make [custom=customername] <project> <platform> <action> [module]"
custom = Monza
project = GPRS (GSM only)
action = new (clean, scan, compile, link) (default)
= update (scan, compile, link)
= remake (compile, link)
= clean (clean)
module = component module name (nucleus, l1, ...)

Example:
To make/build new GPRS project, clean all old objects, libraries, and log files etc., the new action also creates necessary directories and removes all temporary files, and flushes log files automatically.
d:>/pvcs/maui/mcu/Make custom=Monza GPRS new
To update project dependency, and compile changed modules, link. Notice that, update and remake action won’t remove temporary files, and flush log file. Build results will be append after last log file.
d:>/pvcs/maui/mcu/Make custom=Monza GPRS update
To recompile changed files, and link
d:>/pvcs/maui/mcu/Make custom=Monza GPRS remake
To clean all objects, temporary files, libraries, and executable binaries. Meanwhile log file will also be flushed.
d:>/pvcs/maui/mcu/Make custom=Monza GPRS clean
To clean dedicated init modules’ objects libraries. Meanwhile log file will also be flushed.
d:>/pvcs/maui/mcu/Make custom=Monza GPRS clean init

-》how to customize your build environment
!!!To add some modules into or remove some modules from the building procedure.
To complete this kind of configuration, it is necessary to understand the following variables in the make file
Monza_GPRS.mak
COMPLIST: list all source code modules can be built to .lib. In initial custom release, COMPLIST
should be the sum of CUS_REL_SRC_COMP and CUS_REL_PAR_SRC_COMP. The following is the initial setting in custom release.
ifeq ($(strip $(CUSTOM_RELEASE)),TRUE)
COMPLIST = $(strip $(CUS_REL_SRC_COMP))
COMPLIST += $(strip $(CUS_REL_PAR_SRC_COMP))
endif
CUS_REL_MTK_COMP: list all modules provided with .lib only. These .lib are put in /mcu/mtk_libs.
If you want to add a source module
1
add the module "xyz" (in lower case) into COMPLIST.
ifeq ($(strip $(CUSTOM_RELEASE)),TRUE)
COMPLIST = $(strip $(CUS_REL_SRC_COMP))
COMPLIST += $(strip $(CUS_REL_PAR_SRC_COMP))
COMPLIST += xyz
endif
2
add a folder “mcu/make/xyz” for xyz.lis, xyz.inc, xyz.pth, xyz.def.

-》编译生成的文件以及log
1
.编译的log在目录C:/code_100/build/a100中的MT6218B.log。目录C:/code_100/build/a100/log下的log文件为各个模块编译时生成的log
2
.编译生成的binC:/code_100/build/a100下的a100_PCB01_gprs_MT6218B_FN.W05_12.bin
3
.编译生成的目标文件在C:/code_100/build/a100/gprs/MT6218Bo目录中。

3、开发目录结构解析
参考文档:wcr-MTK_MakeBuild_Design_Customer_040930.pdf
目录结构:

<shape id="wgs0" title="点击图片看全图" style="WIDTH: 5in; HEIGHT: 387.75pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1031" o:button="t"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1721331.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image007.gif"></imagedata></shape>


4.开发工具的了解
参考目录《工具》中的文件。
工具:
-》Catcher
Catcher is a PC-side tool for MTK GSM/GPRS Products. The main purpose of Catcher is for logging primitives and debug information. Engineers can use Catcher to analyze the behavior of mobile phones.

-》META
META (Mobile Engineering Testing Architecture) is designed to provide the functionality of RF testing, NVRAM access testing, speech related testing of advanced feature – melody and voice memo.

-》MCT
UI
制作工具,包括菜单制作,图片制作,字体制作等等。

<shape id="jxrx" style="WIDTH: 5in; HEIGHT: 212.25pt" alt="" type="#_x0000_t75" o:spid="_x0000_i1032"><imagedata o:href="http://www.kudev.net/kuimg/allimg/070603/1722500.gif" src="file:///C:/DOCUME~1/MCheng/LOCALS~1/Temp/msohtml1/01/clip_image008.gif"></imagedata></shape>

5.程序入口,程序导读

-》MMI任务入口:
C:/code_100/plutommi/mmi/Framework/Tasks/TasksSrc
中文件MMITask.c函数MMI_task

-》MMI任务的建立:
C:/code_100/plutommi/mmi/Framework/Osl/OslSrc
中文件pixtelMMI.c函数WinMain调用InitApplication函数,在该函数中建立MMI任务,建立任务的接口函数为:osl_create_task

-》MMI任务信息:
{"MMI TASK"(任务名称), "MMI Q"(队列名称), 127(优先级), 4096(堆栈大小),MAX_PRT_NODES(队列结点个数), MMI_task(任务入口)}

-》MMI模块入口:
目录C:/code_100/plutommi/mmi中为MMI各个模块的代码。比如闹钟模块,源代码在C:/code_100/plutommi/mmi/Alarm/AlarmSrc中,头文件在C:/code_100/plutommi/mmi/Alarm/AlarmInc中。首先找到初始化闹钟的函数AlmInit,该函数定义在选择闹钟菜单项时调用函数HighlightAlmMenu进入闹钟功能。

6MMI的制作
参考文档:

文件名

文件内容描述

API For Writing Applications Using Pixtel MMI Platform.pdf

各类窗口列表

Writing Applications Using Pixtel MMI Platform.pdf

如何写应用程序

MMI 2.0 Design DOCMMI Design Doc目录中对MMI中的各个模块进行描述,因此在研究某一模块时可以在这两个文件夹中找到该模块的介绍,通过这些文档可以加速对该模块编码的理解。
MMI
的模块在路径C:/code_100/plutommi中。
-》设计一个应用程序的流程如下: -
1. Write an Initialization function to register the various event handlers.
2. Write a populate function to register various string and image elements for the
application.
3. Write highlight handlers for function registered.
菜单项的功能,当用户选择菜单项后执行的函数。
4. Write the Entry functions
。入口函数
5. Write the Exit function
。出口函数
6. Write the business logic to call between various entry functions.


MTK平台入门

1 简介
1.1
目的及其应用范围
本文档介绍了mtk平台的一些基础应用和实现,适用于刚参加mtk软件开发人员
1.2
术语定义
MMI – Man-machine interface
,人机界面
FMI – Feature rich MMI
1.3
参考资料
[1] MMI High level design specification, pixtel
2
平台安装:
2.1
安装ads1.2
2.2
安装perl
2.3
安装usb 驱动,用于下载
3
编译命令:

通过 new, update, remake, clean all, clean modules, codegen. 来动作生成bin file (二进字文件)
类如:
假设项目是gsm项目,项目名称为m720,则有这些命令:
make custom=m720 gsm resgen
(修改了资源时用这个命令生成新资源)
make custom=m720 gsm remake
(用于生成bin档即可烧录到手机的文件)
make custom=m720 gsm cleancustom
(把custom模块生成的obj文件删除)
make custom=m720 gsm update custom
update custom 模块)
make custom=m720 gsm new
(等于执行了前三个步骤,即cleanresgenremake
make custom=m720 gsm update mmiresource
(更新了资源但不会更新代码)

4
添加一个字符串:
首先给该字符串起一个名字,即ID:如STR_GLOBAL_OK,这个即是一个字串的id也就是名字,而这个字串的具体内容(比如STR_GLOBAL_OK的内容是“Ok”),可以用下面的语句来添加,
ADD_APPLICATION_STRING2(STR_GLOBAL_OK, "Ok","Global String- OK");
如果有对应的中文字符,则应在ref_list.txt中按照固定的格式添加中文字串。如:
STR_GLOBAL_OK GLOBAL 6 Global String- OK Ok
確定 确定

5
添加一个菜单:
首先给这个菜单起一个名字,即ID:如ORGANIZER_CALENDER_MENU,这个即是一个菜单的id也就是名字,但要把这个菜单加入到某个父菜单之下,则须指定其父菜单,方式可以参照:ORGANIZER_CALENDER_MENU这个菜单的方法,在res_mainmenu.c里,
ADD_APPLICATION_MENUITEM((MAIN_MENU_ORGANIZER_MENUID,IDLE_SCREEN_MENU_ID,ORG_ENUM_TOTAL,
#if defined(__MMI_CALENDAR__)
ORGANIZER_CALENDER_MENU,
#endif
#if defined(__MMI_TODOLIST__)
ORGANIZER_TODOLIST_MENU,
#endif
ORGANIZER_ALARM_MENU,

#if defined (__MMI_WORLD_CLOCK__)
ORGANIZER_WORLDCLOCK_MENU,
#endif
#ifdef __MMI_MESSAGES_CLUB__
MAIN_MENU_SHORTCUTS_MENUID,
#endif
#ifdef __SLT_LONG_DISTANCE_DDD__
MENU_LONG_DISTANCE_DDD,
#endif
SHOW,MOVEABLEACROSSPARENT,DISP_LIST,
MAIN_MENU_ORGANIZER_TEXT,MAIN_MENU_ORGANIZER_ICON));
这个语句说明菜单ORGANIZER_CALENDER_MENU是菜单MAIN_MENU_ORGANIZER_MENUID的子菜单。而在res_organizer.c里,
ADD_APPLICATION_MENUITEM((ORGANIZER_CALENDER_MENU,MAIN_MENU_ORGANIZER_MENUID,
3,
MENU_GOTO_TASK_CAL,
MENU_ID_CLNDR_JUMP_TO_DATE,
MENU_CAL_TYPE,
SHOW,
MOVEABLETOSHORTCUT,DISP_LIST,
ORGANIZER_MENU_CALENDER_STRINGID,ORGANIZER_MENU_CALENDER_IMAGEID));
这个语句则声明了ORGANIZER_CALENDER_MENU菜单所拥有的子菜单。

1
关于宏ADD_APPLICATION_STRING2()ADD_APPLICATION_MENUITEM()可以参考文件Writing Applications Using Pixtel MMI Platform.pdf
更深入的了解可以查看文件夹Document/MMI Design Documents/Pixtel下的文件。
6
下载程序:
在当前工程build文件夹中找到对应的项目,打开项目文件夹,里面有*.bin文件就是我们要下载的文件。
7
编译错误信息查看:
如果在编译中某一模块编译不通过,我们可以在build/项目名称/log 中查看log信息
8
模拟器运行:
首先安装好VC,然后直接运行工程目录下的PLUTOMMI/mmi/PixtelMMI.dsw文件,先编译资源文件,然后执行运行就可以了。

9
修改铃声资源:
一般项目开发修改的铃声资源主要是来电铃声,开关机铃声,翻合盖提示音,信息提示音
9.1
.修改来电闹钟铃声资源:
修改的文件是custpack_audio.c
const custpack_audio_header custpack_audio =
{ 15,
{
{Y300Mid01_mp3, sizeof(Y300Mid01_mp3), 5},
{Y300Mid02_mid, sizeof(Y300Mid02_mid), 17},
{Y300Mid03_mid, sizeof(Y300Mid03_mid), 17},
{Y300Mid04_mid, sizeof(Y300Mid04_mid), 17},
{Y300Mid05_mid, sizeof(Y300Mid05_mid), 17},
{Y300Mid06_mid, sizeof(Y300Mid06_mid), 17},
{Y300Mid07_mid, sizeof(Y300Mid07_mid), 17},
{Y300Mid08_mid, sizeof(Y300Mid08_mid), 17},
{Y300Mid09_mid, sizeof(Y300Mid09_mid), 17},
{Y300Mid10_mid, sizeof(Y300Mid10_mid), 17},
{Y300Mid11_mid, sizeof(Y300Mid11_mid), 17},
{Y300Mid12_mid, sizeof(Y300Mid12_mid), 17},
{Y300Mid13_mid, sizeof(Y300Mid13_mid), 17},
{Y300Mid14_mid, sizeof(Y300Mid14_mid), 17},
{Y300Mid15_mp3, sizeof(Y300Mid15_mp3), 5},
}
custpack_audio
数组 第一个参数是铃声总数
第二个参数是铃声list ,其中包含铃声数据,大小,类型,
铃声数据可以用MCT 这个工具转换,然后代替各个数组的数据,提示最好不要修改数组名称
类型可以在mdi_audio.h 中查找,类如 这里的5 代表mp317代表mid

9.2
修改开关机铃声,翻合盖提示音,信息提示音
resource_audio.c---------------------
开关机铃声,翻合盖提示音,信息提示音
开关机铃声和翻合盖提示音对应的数组是一样的
const audio_resource_struct mtk_resource_sounds[]={
{resource01_mid, sizeof(resource01_mid), 17},
{resource02_mid, sizeof(resource02_mid), 17},
{resource03_mid, sizeof(resource03_mid), 17},
{resource04_mid, sizeof(resource04_mid), 17},
{resource05_mid, sizeof(resource05_mid), 17},
{resource06_mid, sizeof(resource06_mid), 17},
{resource07_mid, sizeof(resource07_mid), 17},
{resource08_mid, sizeof(resource08_mid), 17},



};

信息提示音对应的数组是:
const audio_resource_struct mtk_resource_message_sounds[]={
{message01_mp3, sizeof(message01_mp3), 5},
{message02_mp3, sizeof(message02_mp3), 5},
{message03_mid, sizeof(message03_mid), 17},
{message04_mid, sizeof(message04_mid), 17},
{message05_mid, sizeof(message05_mid), 17},
{message06_mid, sizeof(message06_mid), 17},
{message07_mid, sizeof(message07_mid), 17},
{message08_mid, sizeof(message08_mid), 17},
{message09_mid, sizeof(message09_mid), 17},
{message10_mid, sizeof(message10_mid), 17},
};

9.3
调整铃声总数和id
resource_audio.h--------------------
设置铃声id 和总数

铃声ID大小不需要调整,只是根据铃声总数变了,增加或者减少ID

10
修改图片资源:
添加图片资源一般用这个函数:ADD_APPLICATION_IMAGE2 它的参数分别是:图片ID,图片放置路径,图片用途描述。类如:

ADD_APPLICATION_IMAGE2( MAIN_MENU_SYSTEM_ICON , CUST_IMG_PATH"////MainLCD////MainMenu////BI_DEGREE////MM_ITEM.gif" , "Icon used for system in mainmenu" );

图片资源的修改主要分几种情况:
10.1
直接替换图片资源,不需要调整座标:类如开关机动画,墙纸,开关机mp4等,这种修改资源很简单,但是修改时要注意图片来名称和类型与代码中是否匹配。
10.2
修改需要调整座标的图片:如日历,计算器等,这些图片修改需要ID给出座标,然后我们在代码中修改。
10.3
修改用tools生成座标的图片:主要是MP3 MP4 FM,世界时钟,座标调整可以用mct tools 来做。关于这个工具的使用
10.4
主题的修改也可以mct tools 来做

(注:本人MTK平台、代码、资料属联发科所有,有偿提供支持QQ85313653请注明MTK

你可能感兴趣的:(MTK)