This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC1310:在 NVS 运行期间挂起

Guru**** 2482105 points
Other Parts Discussed in Thread: CC1310, SYSBIOS, UNIFLASH

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1252854/cc1310-hanging-during-nvs-operation

器件型号:CC1310
Thread 中讨论的其他器件: SYSBIOSUNIFLASH

您好、我正在尝试使用 CC1310上的 NVS 驱动程序来存储和回读由 uint16和 uint8 (具有多个条目)构成的结构列表。 我已经尝试修改 nvsinternal 示例以适合这一点、但当我运行它时、它几乎每隔一次在尝试写入或擦除 NVS 时挂起一次。  

我测试的结构:

/*测试结构以查看 NVS 写入是否会加载 uints*/
#define MAXNODES 4
结构 node_t{
uint16_t 节点地址;
uint8_t 类型;
}节点[MAXNODES];
静态 uint16_t buff[16];

修改了 nvsinternal 示例的主线程:

void *mainThread (void *arg0)
{
NVS_Handle nvsHandle;
NVS_Attrs regionAttrs;
NVS_Params nvsParams;

Display_Handle displayHandle;

display_init();
NVS_init();

displayHandle = Display_open (Display_Type_、空值);
if (displayHandle == NULL){
/* Display_open()失败*/
while (1);

uint8_t i;
for (i = 0;i < 4;i++){
node[i].nodeAddress = 16+I;
node[i].type = 1;

NVS_PARAMS_INIT (&nvsPARAMS);
nvsHandle = NVS_OPEN (Board_NVSINTERNAL、&nvsParams);

if (nvsHandle == NULL){
display_printf (displayHandle、0、0、"NVS_open () failed.");

返回(NULL);

display_printf (displayHandle、0、0、"\n");

/*
*这将填充具有特定属性的 NVS_Attrs 结构
*到 NVS_Handle、例如区域基地址、区域大小、
*和扇区大小。
*/
NVS_getAttrs (nvsHandle、&regionAttrs);

/*显示 NVS 区属性*/
Display_printf (displayHandle、0、0、"区域基地址:0x%x"、
regionAttrs.regionBase);
display_printf (displayHandle、0、0、"扇区大小:0x%x"、
regionAttrs.sectorSize);
display_printf (displayHandle、0、0、"区域大小:0x%x\n"、
attrs.regionSize);


/*
*从 NVS 区域基地址将"sizeof (signature)"字节复制到
*缓冲区。 偏移量为0表示相对于区域基地址的偏移量。
*因此、这些字节将从 regionAttrs.regionBase 复制。
*/
NVS_READ (nvsHandle、0、buff、sizeof (buff));
//NVS_Read (nvsHandle、2、(void *) temptype、1);

for (i = 0;i < 8;i += 2){
display_printf (displayHandle、0、0、"%u、%u"、buff[i]、 (uint8_t) buff[i+1]);

/*
*确定 NVS 区域是否包含签名字符串。
*将字符串与复制到缓冲区的内容进行比较。
*/
if (buff[0]== node[0].nodeAddress){
//if (strcmp ((char *) buffer、(char *) signature)== 0){

/*将签名直接从 NVS 区域写入 UART 控制台。 */
//Display_printf (displayHandle、0、0、"%u"、regionAttrs.regionBase);
display_printf (displayHandle、0、0、"擦除闪存扇区...");

/*擦除整个闪存扇区。 */
NVS_ERASE (nvsHandle、0、regionAttrs.regionSize);

否则{

/*在 NVS 区域中未找到签名。 */
// Display_printf (displayHandle、0、0、"将签名写入闪存……");
display_printf (displayHandle、0、0、"尝试向闪存写入节点");
/*将签名写入存储器。 闪存扇区在
*执行写入操作。 此函数为
* NVS_WRITE_ERASE。
*/
//NVS_WRITE (nvsHandle、0、(void *)签名、sizeof (签名)、
// NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
NVS_WRITE (nvsHandle、0、&node、sizeof (node)、NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);

display_printf (displayHandle、0、0、"复位设备");
display_printf (displayHandle、0、0、footer);

返回(NULL);

所以我想我的问题是:我试图用这个做什么会导致这种行为吗?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!

    当您说 NVS 操作挂起时、请检查它的状态。  

    此致、

    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Sid:

    在寻找 NVS 状态时、我确实了解了一些东西。 它不会挂起*在* NVS 操作上,这是导致在 NVS_READ 操作之后出现下一个 Display_printf 的原因。 此外、它每隔第二次运行它都会发生;即进入调试模式、运行它、复位器件(不退出调试模式)、然后再次运行它。  

    当我遇到问题后暂停程序时、收到以下消息:

    在 C:/ti\ccs1110\ccs\ccs_base\emulation\gel\image\cc26xx\cc13x0_rtos_rom_syms.out:{3}0x1001bbd2{4}"下、"ti_sysbios_family_arm_m3_Hwi_exchandler__i ()无可用源。  


    我从读取操作返回的状态代码是0、这应该是成功的。 因此、我不确定在 printf 之后会出现什么情况使其挂起/恐慌。

    谢谢。

    布莱斯

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!

    如果您在调试模式下运行、您能否单步执行 display_printf 并准确地检查其在何处发生问题?

    此致、
    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    似乎是在 UARTCC26XX.c 中的 startTxFifoEmptyClk 函数期间解决了问题、尤其是在调用时钟从 ClockP_tirtos.c 启动时

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!  

    我不知道会出什么问题。  我在代码中看不到它。 我将在星期一对其进行调试、并会回来与您联系。

    此致、
    SID  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!

    我刚刚复制了您的代码、并将其替换为 NVS_internal.c 源文件中的代码。  

    我在对器件进行复位几次后在终端上得到此输出。 似乎工作正常。  

     。 是预期的输出吗?

    此致、

    SID

    PS:我已经附上了我测试过的 nvsinternal.c 的代码。 它显示了两个有关不使用签名字符串的次要警告、以及由于使用您在结构中描述的缓冲区而默认定义的缓冲区。

    /*
     * Copyright (c) 2017-2019, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    /*
     *  ======== nvsinternal.c ========
     */
    
    #include <string.h>
    #include <stdlib.h>
    #include <stdint.h>
    
    /* Driver Header files */
    #include <ti/display/Display.h>
    #include <ti/drivers/NVS.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define FOOTER "=================================================="
    
    /* Buffer placed in RAM to hold bytes read from non-volatile storage. */
    static char buffer[64];
    
    /*
     * Some devices have a minimum FLASH write size of 4-bytes (1 word). Trying
     * to write a non-multiple of 4 amount of data will fail. This array is
     * rounded up (to next multiple of 4) to meet this requirement. Refer to NVS
     * driver documentation for more details.
     */
    static const char signature[52] =
        {"SimpleLink SDK Non-Volatile Storage (NVS) Example."};
    
    /*
     *  ======== mainThread ========
     */
    /* Test Structure to see if nvs write will load a struct of uints*/
    #define MAXNODES 4
    struct node_t{
    uint16_t nodeAddress;
    uint8_t type;
    } node [MAXNODES];
    static uint16_t buff[16];
    
    void *mainThread(void *arg0)
    {
        NVS_Handle nvsHandle;
        NVS_Attrs regionAttrs;
        NVS_Params nvsParams;
    
        Display_Handle displayHandle;
    
        Display_init();
        NVS_init();
    
        displayHandle = Display_open(Display_Type_UART, NULL);
        if (displayHandle == NULL) {
        /* Display_open() failed */
            while (1);
        }
        uint8_t i;
        for(i = 0; i < 4; i++){
            node[i].nodeAddress = 16+i;
            node[i].type = 1;
        }
    
        NVS_Params_init(&nvsParams);
        nvsHandle = NVS_open(Board_NVSINTERNAL, &nvsParams);
    
        if (nvsHandle == NULL) {
            Display_printf(displayHandle, 0, 0, "NVS_open() failed.");
            return (NULL);
        }
    
        Display_printf(displayHandle, 0, 0, "\n");
    
        /*
        * This will populate a NVS_Attrs structure with properties specific
        * to a NVS_Handle such as region base address, region size,
        * and sector size.
        */
        NVS_getAttrs(nvsHandle, &regionAttrs);
    
        /* Display the NVS region attributes */
        Display_printf(displayHandle, 0, 0, "Region Base Address: 0x%x",
        regionAttrs.regionBase);
        Display_printf(displayHandle, 0, 0, "Sector Size: 0x%x",
        regionAttrs.sectorSize);
        Display_printf(displayHandle, 0, 0, "Region Size: 0x%x\n",
        regionAttrs.regionSize);
    
    
        /*
        * Copy "sizeof(signature)" bytes from the NVS region base address into
        * buffer. An offset of 0 specifies the offset from region base address.
        * Therefore, the bytes are copied from regionAttrs.regionBase.
        */
        NVS_read(nvsHandle, 0, buff, sizeof(buff));
        //NVS_read(nvsHandle, 2, (void *) temptype, 1);
    
        for(i = 0; i < 8; i += 2){
            Display_printf(displayHandle, 0, 0, "%u,%u", buff[i], (uint8_t)buff[i+1]);
        }
        /*
        * Determine if the NVS region contains the signature string.
        * Compare the string with the contents copied into buffer.
        */
        if(buff[0] == node[0].nodeAddress){
        //if (strcmp((char *) buffer, (char *) signature) == 0) {
    
        /* Write signature directly from the NVS region to the UART console. */
        //Display_printf(displayHandle, 0, 0, "%u", regionAttrs.regionBase);
        Display_printf(displayHandle, 0, 0, "Erasing flash sector...");
    
        /* Erase the entire flash sector. */
        NVS_erase(nvsHandle, 0, regionAttrs.regionSize);
        }
    
        else {
    
        /* The signature was not found in the NVS region. */
        //Display_printf(displayHandle, 0, 0, "Writing signature to flash...");
        Display_printf(displayHandle, 0, 0, "Attempting to write node to flash");
        /* Write signature to memory. The flash sector is erased prior
        * to performing the write operation. This is specified by
        * NVS_WRITE_ERASE.
        */
        //NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),
        // NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
        NVS_write(nvsHandle, 0, &node, sizeof(node), NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
        }
    
        Display_printf(displayHandle, 0, 0, "Reset the device.");
        Display_printf(displayHandle, 0, 0, FOOTER);
    
        return (NULL);
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Sid:

    这是预期的输出、但它不是我得到的输出。 我得到的结果是这样的:

    我还注意到、当我终端未通过 CCS 进入调试模式时、它无法与终端连接通信。 我在几个不同的 Launchpad 上尝试过它、它们具有相同的行为、因此其中一个应该不会有问题。  

    我可以尝试从全新的 CCS 安装中将其重新设置、但我认为我没有更改任何会影响这一点的地方。 (在另一台计算机上进行设置也需要一点时间)

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!

    1.您在使用哪种 SDK? 我在 e2e 上向您发送了申请。 您可以试试我在 launchpad 上使用的映像。

    2.另外,为消除一个不太可能但看似合理的问题而进行的更快速的测试是更换电缆并尝试另一个 USB 端口。 以确保没有硬件错误。

    此致、

    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我目前正在使用 simplelink_cc13x0_sdk_4_20_01_03。 我刷写了您发送的映像、该映像在我的硬件上工作、因此我怀疑它是硬件问题。

    谢谢。
    布莱斯

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!

    我还将我用于生成图像的整个项目添加到了同一文件夹中。 您是否能够将您的项目与之进行比较?

    我刚导入了 NVS_internal 工程、并更改了源文件 NVS_internal.c 以添加您的内容。  

    此致、

    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    SID、

    我想您给我发送的有关该图像的链接只是到.out 文件、或者至少我无法看到文件夹中的其余部分。  

    我已经尝试了几件事情、为我当前使用的 SDK 重新导入了 nvsinternal 示例。 这是在做与我所看到的相同的事情。 然后、我下载了最新的 SDK 版本4_20_02_07、以及该 SDK 的 nvsinternal 示例。 这给出了一些奇怪的结果。 在调试模式期间、它给出了我看到的相同结果、但是在退出调试模式后、它能够在电路板上正常工作;与终端仿真器通信、并在重新启动时正确操作。 所以我尝试重定向我修改的版本以使用新的 SDK;但它没有改变这一个的行为。

    所以,我想我只是成功地让自己变得更加困惑。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!  

    请尝试使用 Uniflash 来执行完全的闪存擦除、然后刷写项目、这样您就知道从空白的 NVS 开始。

    我还给您发送了一个新的链接、它应该包含整个项目。  

    此致、
    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Sid:

    事先执行闪存擦除似乎没有影响。 我将项目文件下载并导入到了工作区中、它的行为与我在最后构建项目文件后看到的行为类似。 因此、我在另一台计算机上进行了 CCS 的全新安装(和版本更新)。 Re 在那个示例上导入了示例、按照我需要的内容修改了 nvsinternal.c、并使其正常工作。 所以、我不确定修复的问题是不是全新安装、还是更新 CCS 版本、但有一个修复了。 在之前的机器上、我的 CCS 版本是11.1.0。

    谢谢。

    布莱斯

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    布莱斯、您好!  

    我最终无法重现此问题。 我会将该问题标记为已解决。 如果问题再次发生、请回复此主题。

    此致、
    SID