大家好,请教一下,我使用rtthread studio 使用软件包flashDB时,一直都不能正常工作,整了一整天也不知道哪里问题,所以上来求助一下。
使用的芯片是兆易GD32F303, fal操作读写分区已经正常, flashD使用例程存在问题,读不出键值boot_count变量失败,也保存不了,使用kvdb show也没有数据出来。打印如图下:
\ | /
RT - Thread Operating System
/ | \ 4.1.0 build Apr 4 2022 09:18:47
2006 - 2022 Copyright by RT-Thread team
[D/FAL] (fal_flash_init:49) Flash device | gd32f3_onchip | addr: 0x08000000 | len: 0x00080000 | blk_size: 0x00000800 |initialized finish.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name | flash_dev | offset | length |
[I/FAL] -------------------------------------------------------------
[I/FAL] | bl | gd32f3_onchip | 0x00000000 | 0x00008000 |
[I/FAL] | app | gd32f3_onchip | 0x00008000 | 0x00038000 |
[I/FAL] | flashDB | gd32f3_onchip | 0x00038000 | 0x00040000 |
[I/FAL] =============================================================
[I/FAL] RT-Thread Flash Abstraction Layer initialize success.
[FlashDB][kv][env] (../packages/FlashDB-v1.1.2/src/fdb_kvdb.c:1638) KVDB size is 262144 bytes.
[FlashDB] FlashDB V1.1.2 is initialize success.
[FlashDB] You can get the latest version on https://github.com/armink/FlashDB .
[FlashDB][sample][kvdb][basic] ==================== kvdb_basic_sample ====================
[FlashDB][sample][kvdb][basic] get the 'boot_count' failed
[FlashDB][sample][kvdb][basic] set the 'boot_count' value to 1
[FlashDB][sample][kvdb][basic] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][sample][kvdb][blob] set 'temp' value to 38
[FlashDB][kv][env] (../packages/FlashDB-v1.1.2/src/fdb_kvdb.c:866) Not found 'temp' in KV.
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
msh >kvdb probe flashDB
[FlashDB][kv][flashDB] (../packages/FlashDB-v1.1.2/src/fdb_kvdb.c:1638) KVDB size is 262144 bytes.
Probed a KVDB | flashDB | part_name: flashDB | sec_size: 2048 | max_size: 262144 |.
msh >kvdb show
Read data success. The KV data is:
mode: next generation
size: 2032/260096 bytes.
main函数如下:
int main(void)
{
int count = 1, tmp = 0xaa;
rt_device_t slave_serial;
struct rt_device_pwm tim3_pwm_dev;
struct fdb_default_kv default_kv;
slave_serial = rt_device_find("uart3");
rt_device_open(slave_serial, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
tim3_pwm_dev = (struct rt_device_pwm)rt_device_find("pwm3");
bsp_pin_init();
rt_pin_write(CPU_M1, PIN_HIGH);
rt_pin_write(CPU_M2, PIN_HIGH);
rt_pin_write(CPU_M3, PIN_HIGH);
rcu_periph_clock_enable(RCU_TIMER3);
timer3_pwm_init(0, 60000, 0);
/* rt_pwm_set(tim3_pwm_dev, 1, 1000, 300);
rt_pwm_set(tim3_pwm_dev, 3, 1000, 0);
rt_pwm_enable(tim3_pwm_dev, 1);
rt_pwm_enable(tim3_pwm_dev, 3);*/
// TIMER_CH0CV(TIMER3) = 1000; // SD2
// TIMER_CH1CV(TIMER3) = 0; // pwm2
//
// TIMER_CH2CV(TIMER3) = 1000; // SD1
// TIMER_CH3CV(TIMER3) = 50000; // PWM1
rt_pin_write(CPU_SD1, PIN_HIGH);
rt_pin_write(CPU_SD2, PIN_HIGH);
fal_init();
fdb_kvdb_init(&kvdb, "env", "flashDB", &default_kv, NULL);
extern void kvdb_basic_sample(fdb_kvdb_t kvdb);
extern void kvdb_type_blob_sample(fdb_kvdb_t kvdb);
kvdb_basic_sample(&kvdb);
kvdb_type_blob_sample(&kvdb);
while (1)
{
rt_pin_write(LED_RUN, PIN_HIGH);
TIMER_CH3CV(TIMER3) = 50000; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(5000);
rt_pin_write(LED_RUN, PIN_LOW);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(1000);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 50000; // pwm2
rt_thread_mdelay(5000);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(1000);
rt_pin_write(LED_RUN, PIN_HIGH);
TIMER_CH3CV(TIMER3) = 10000; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(5000);
rt_pin_write(LED_RUN, PIN_LOW);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(1000);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 10000; // pwm2
rt_thread_mdelay(5000);
TIMER_CH3CV(TIMER3) = 0; // PWM1
TIMER_CH1CV(TIMER3) = 0; // pwm2
rt_thread_mdelay(1000);
test();
rt_pin_write(CPU_UT_EN1, PIN_HIGH);
rt_device_write(slave_serial, 0,&tmp, 1);
}
return RT_EOK;
}
仔细的看了例程,没见有差异的地方,百思不得解。。