"Thread:SysConfig"中讨论的其他器件
嗯,这似乎是我的前一篇文章被删除。
无论如何、Code Composer Studio 版本12.2.0.00009提供的 tiarmclang 似乎存在代码生成错误
NVS_OPEN 始终返回 NULL、因为位于 if (0 < 1)- if (index < NVS_COUNT) never executed 后的块。
O0或-Oz 时的结果相同
参见屏幕截图。
是否有关于如何编译和执行 NVS 驱动程序的任何建议?
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.
嗯,这似乎是我的前一篇文章被删除。
无论如何、Code Composer Studio 版本12.2.0.00009提供的 tiarmclang 似乎存在代码生成错误
NVS_OPEN 始终返回 NULL、因为位于 if (0 < 1)- if (index < NVS_COUNT) never executed 后的块。
O0或-Oz 时的结果相同
参见屏幕截图。
是否有关于如何编译和执行 NVS 驱动程序的任何建议?
更新:似乎实际上存在代码生成错误。 通过将1而不是0作为对 NVS_OPEN 的索引传递可以支持 NVS。
因此、我在索引0处向 NVS 添加了一个虚拟8k 块。
ti_drivers_config.h 和.c 中的相关部分。
我们当然不希望浪费8k、从而欺骗编译器/NVS 来工作。 如果您有任何建议或更新有效、请告诉我
/*
* ======== NVS ========
*/
extern const uint_least8_t DUMMY_TO_FOOL_COMPILER_CONST;
#define DUMMY_TO_FOOL_COMPILER 0
extern const uint_least8_t FLASH_SETTINGS_16K_CONST;
#define FLASH_SETTINGS_16K 1
#define CONFIG_TI_DRIVERS_NVS_COUNT 2
/*
* =============================== NVS ===============================
*/
#include <ti/drivers/NVS.h>
#include <ti/drivers/nvs/NVSCC26XX.h>
/*
* NVSCC26XX Internal NVS flash region definitions
*
* Place uninitialized char arrays at addresses
* corresponding to the 'regionBase' addresses defined in
* the configured NVS regions. These arrays are used as
* place holders so that the linker will not place other
* content there.
*
* For GCC targets, the char arrays are each placed into
* the shared ".nvs" section. The user must add content to
* their GCC linker command file to place the .nvs section
* at the lowest 'regionBase' address specified in their NVS
* regions.
*/
#if defined(__TI_COMPILER_VERSION__) || defined(__clang__)
static char flashBuf0[0x2000] __attribute__ ((retain, noinit, location(0xa0000)));
static char flashBuf1[0x4000] __attribute__ ((retain, noinit, location(0xa2000)));
#elif defined(__IAR_SYSTEMS_ICC__)
__no_init static char flashBuf0[0x2000] @ 0xa0000;
__no_init static char flashBuf1[0x4000] @ 0xa2000;
#elif defined(__GNUC__)
__attribute__ ((section (".nvs")))
static char flashBuf0[0x2000];
__attribute__ ((section (".nvs")))
static char flashBuf1[0x4000];
#endif
NVSCC26XX_Object nvsCC26XXObjects[2];
static const NVSCC26XX_HWAttrs nvsCC26XXHWAttrs[2] = {
/* DUMMY_TO_FOOL_COMPILER */
{
.regionBase = (void *) flashBuf0,
.regionSize = 0x2000
},
/* FLASH_SETTINGS_16K */
{
.regionBase = (void *) flashBuf1,
.regionSize = 0x4000
},
};
#define CONFIG_NVS_COUNT 2
const NVS_Config NVS_config[CONFIG_NVS_COUNT] = {
/* DUMMY_TO_FOOL_COMPILER */
{
.fxnTablePtr = &NVSCC26XX_fxnTable,
.object = &nvsCC26XXObjects[0],
.hwAttrs = &nvsCC26XXHWAttrs[0],
},
/* FLASH_SETTINGS_16K */
{
.fxnTablePtr = &NVSCC26XX_fxnTable,
.object = &nvsCC26XXObjects[1],
.hwAttrs = &nvsCC26XXHWAttrs[1],
},
};
const uint_least8_t DUMMY_TO_FOOL_COMPILER_CONST = DUMMY_TO_FOOL_COMPILER;
const uint_least8_t FLASH_SETTINGS_16K_CONST = FLASH_SETTINGS_16K;
const uint_least8_t NVS_count = CONFIG_NVS_COUNT;
大家好、
您是否直接修改了 ti_drivers_config.h 和.c?
您的 SysConfig 文件可能已经定义了 NVS 实例、因为某些堆栈可能正在使用它。
如果在已打开的 NVS 实例上尝试 NVS_open、则返回 null 句柄。
1.请检查您的代码是否有 NVS_OPEN()正在使用的其他位置。
2.检查默认的 Wisun 示例。 它已经有一个 NVS 实例、供项目中的 nvocmp.c 文件使用。
您需要在 SysConfig 上添加第二个 NVS 实例并为该实例使用 NVS_OPEN ()。
此致、
SID