MT2503使用笔记



此博文仅供自己备忘使用。


1、当需要把某些相关的数据,组织成一个结构体存到NV里的时候,为什么数组的size要在有效的最大长度上加1?

例如:

typedef struct
{
    kal_uint8        auth_len;
    kal_uint8        auth_code[IOT_LOCK_AUTHCOE_MAX_LEN+1]; //auth_code
}nvram_ef_auth_code_struct;

答:是因为需要给这个接头的变量赋值,赋值的时候,经常是用常量字符串给结构体中的数组赋值的,而常量字符串末尾是有个'\0'的。

static nvram_ef_auth_code_struct NVRAM_EF_IOT_AUTHCODE_DEFAULT =
{
    6,
    {"123456"},
};


2、在nvram_common_config.c 里的这段注释,基本说明了添加一个logical data item的步骤。

扫描二维码关注公众号,回复: 4889861 查看本文章

/**
 * Steps of defining logical data item:
 * 1> Define LID of new logical data item into `nvram_LID_cust_enum' in
 *    nvram_user_defs.h
 * 2> Define two constants: SIZE and TOTAL, in nvram_user_defs.h
 * 3> Define default value of that new logical data item in nvram_user_config.c
 * 4> Define attributes of that new logical data item into
 *    `logical_data_item_table_cust'
 * 5> Bypass.
 * 6> Change version number CODED_DATA_VERSION in nvram_user_config.c
 */
/**
 * The logical data item table.
 * Note:
 * Each logical data item must be:
 * 1> Size must be EVEN
 * 2> Size of default value must be equal to the logical data item's size.
 */
 /**
 * The rule for data item changes:
 * 1. To add a new data item, its name must be the next of the current last LID, for example,
 *     the last LID in the CT reign now is CT20, the new one must be CT21.
 * 2. Version must be increased if
 *    (a) Size is changed, or
 *    (b) Number of sections is changed, or
 *    (c) Attribute is changed, or
 *    (d) data structure is changed.
 */


3、代码走的分支是:__MTK_TARGET__



#if  defined(NVRAM_AUTO_GEN)

#define sgyouTest  1

#define ltable_entry_structnvram_ltable_entry_struct __attribute__((aligned(4)))__attribute__((__section__("_nvram_ltable")))

#define NVRAM_LIG_GRP_INIT(X)

#elif defined(__MTK_TARGET__)

#define sgyouTest  2

#define ltable_entry_structnvram_ltable_entry_struct __attribute__((section("_nvram_ltable")))

#define NVRAM_LIG_GRP_INIT(X)   {\

                                    externnvram_ltable_entry_struct X##[];\

                                    void *X##_p = (void *)&X;\

                                }

#else

#define sgyouTest  3

#define ltable_entry_struct__pragma(section("_nvram_ltable_content")) \

                           nvram_ltable_entry_struct __declspec(allocate("_nvram_ltable_content"))

#define NVRAM_LIG_GRP_INIT(X)   extern nvram_ltable_entry_struct X##[];\

                                static void*X##_p = (void *)&X;

#endif

#if  defined(NVRAM_AUTO_GEN)

#define sgyouTest  1

#define ltable_entry_structnvram_ltable_entry_struct __attribute__((aligned(4)))__attribute__((__section__("_nvram_ltable")))

#define NVRAM_LIG_GRP_INIT(X)

#elif defined(__MTK_TARGET__)

#define sgyouTest  2

#define ltable_entry_structnvram_ltable_entry_struct __attribute__((section("_nvram_ltable")))

#define NVRAM_LIG_GRP_INIT(X)   {\

                                    externnvram_ltable_entry_struct X##[];\

                                    void *X##_p = (void *)&X;\

                                }

#else

#define sgyouTest  3

#define ltable_entry_struct__pragma(section("_nvram_ltable_content")) \

                           nvram_ltable_entry_struct __declspec(allocate("_nvram_ltable_content"))

#define NVRAM_LIG_GRP_INIT(X)   extern nvram_ltable_entry_struct X##[];\

                                static void*X##_p = (void *)&X;

#endif

4、当编译MT2503的时候,出现下面的链接错误:\build\CORETEK2503A_3GTRACKER_11C\CORETEK2503A_3GTRACKER_11C_PCB01_gprs_MT6261_

00.elf is not existed! Please check link error.查看错误信息的时候。请查看根目录下的文件pl_error_normal.log,来定位错误信息。

5、2503的管脚名称,复用请看芯片手册的2.1.4章节。比如KROW1 可以复用那个gpio, 在这里就可以查到 配置成GPIO20


猜你喜欢

转载自blog.csdn.net/zhashuiguangzi/article/details/78700814
今日推荐