Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inc/fdb_low_lvl] fix An error occurred in FDB_ALIGN(size, align) whe…
…n align is not 2 to the nth power (#233)
- Loading branch information
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个更新后我原来正常使用的程序初始化后,读取数据报错了。
�[32;22m[I/FAL] Flash Abstraction Layer (V0.5.99) initialize success.�[0m
[FlashDB] FlashDB V2.0.0 is initialize success.
[FlashDB] You can get the latest version on https://github.com/armink/FlashDB .
fdb_kvdb_init: 0
[FlashDB][kv][env][kvdb] Error: The KV (@0x00000014) CRC32 check failed!
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit cause macro expansion errors, stm32f405 demo will be stuck in CRC32 check. I use the following code to workground
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hsSam @guoweilkd 你们的 FDB_WRITE_GRAN 都是配置的多大的呀?
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我用的就是stm32f405的demo, FDB_WRITE_GRAN = 8, 直接跑demo会陷入到crc死循环中,具体代码在create_kv_blob()函数中的如下位置:
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guoweilkd
FDB_WG_ALIGN(10)
在 FDB_WRITE_GRAN = 8 时,结果应该是 10 吧模拟器测试下,结果也是 10
你方便方便把整个宏展开步骤拆一下嘛?看看具体哪个环节出的问题
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你测试的不是最新代码?最新代码的这两个宏是
后面的
((size + align -1) % align)
展开后%
和/
的完整性会被打乱FDB_WG_ALIGN(10)的展开结果如下: 10 + 0 % 15 / 8 = 10 /8 = 1, (size + align - 1) = 10, 所以 ((size + align - 1) - ((size + align -1) % align)) = 9
3e441f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 感谢反馈,确实是这个问题,给 入参 都加上括号就没问题了,类似下面这样
方便的话,可以帮忙提交个 PR 修正下哈