kv flash 读写都是正常的。初始化DB时,在读取 SIMPLE_FLASH_KEY_ADDR 这个地址后会报[simple_flash.c:479] key data is not matched magic(0x3a2d3e45),crc32(0xe2d8782c)这个错误。
自己试了试,SIMPLE_FLASH_KEY_ADDR区域前16个字节的内容不同,magic和crc32的值也会不同。SDK的程序从未对SIMPLE_FLASH_KEY_ADDR区域进行过写入。
接着程序报[simple_flash.c:493] flash is encrypted or empty。后续相关程序似乎都是因为这里失败报错。
接口的flash分配如下(与给的例程一致):
Code: Select all
#define PARTITION_SIZE (1 << 12) /* 4KB */
#define FLH_BLOCK_SZ PARTITION_SIZE
// flash map 0x0
#define SIMPLE_FLASH_START 0x0 //相对地址
#define SIMPLE_FLASH_SIZE 0x10000 // 64K
#define SIMPLE_FLASH_SWAP_START 0x20000
#define SIMPLE_FLASH_SWAP_SIZE 0x4000 // 16k
#define SIMPLE_FLASH_KEY_ADDR (SIMPLE_FLASH_SWAP_START + SIMPLE_FLASH_SWAP_SIZE)
#define SIMPLE_FLASH_KEY_SIZE 0x1000 // 4k
#define UF_FILE_FLASH_START_ADDR (SIMPLE_FLASH_START + SIMPLE_FLASH_SIZE)
#define UF_FILE_FLASH_SIZE 0x8000
以下是日志:
Code: Select all
[TOS_DBG]tuya_esp_flash_init ok, addr:0x3b0000, size:0x28000
xxxxxxxxxxxx flash read 0x011000 | 4096
xxxxxxxxxxxx flash read 0x010000 | 4096
xxxxxxxxxxxx flash read 0x010000 | 4096
[01-01 18:12:15 TUYA I][mqc_app.c:350] mqc app init ...
[01-01 18:12:15 TUYA I][uni_thread.c:220] thread_create name:sys_timer,stackDepth:4096,totalstackDepth:4096,priority:5
[01-01 18:12:15 TUYA D][uni_thread.c:247] Thread:sys_timer Exec Start. Set to Running Stat
[01-01 18:12:15 TUYA I][uni_thread.c:220] thread_create name:cmmod,stackDepth:4096,totalstackDepth:8192,priority:4
[01-01 18:12:15 TUYA D][uni_thread.c:247] Thread:cmmod Exec Start. Set to Running Stat
[01-01 18:12:15 TUYA D][mqc_app.c:144] mq_pro:5 cnt:1
[01-01 18:12:15 TUYA D][mqc_app.c:144] mq_pro:31 cnt:2
[01-01 18:12:15 TUYA D][svc_online_log.c:295] svc online log init success
xxxxxxxxxxxx flash read 0x010000 | 4096
xxxxxxxxxxxx flash read 0x010000 | 4096
[01-01 18:12:16 TUYA E][log_seq.c:871] logseq empty
[01-01 18:12:16 TUYA I][uni_thread.c:220] thread_create name:wk_th-0,stackDepth:5120,totalstackDepth:13312,priority:3
[01-01 18:12:16 TUYA D][uni_thread.c:247] Thread:wk_th-0 Exec Start. Set to Running Stat
[ 1980][D][tuya_main.cpp:219] tuya_init(): init param over
[01-01 18:12:16 TUYA D][tuya_ws_db.c:450] init fs. Path: /tuya
[01-01 18:12:16 TUYA D][kv_storge.c:46] *****************kvs_init.
[01-01 18:12:16 TUYA N][simple_flash.c:459] key_addr: 0x24000 block_sz 4096
xxxxxxxxxxxx flash read 0x024000 | 4096
[01-01 18:12:16 TUYA E][simple_flash.c:479] key data is not matched magic(0x3a2d3e45),crc32(0xe2d8782c)
xxxxxxxxxxxx flash read 00000000 | 4096
[01-01 18:12:16 TUYA E][simple_flash.c:493] flash is encrypted or empty
[01-01 18:12:16 TUYA E][simple_flash_app.c:306] create_flash_hand_and_init err 10
[01-01 18:12:16 TUYA E][tuya_ws_db.c:454] db init fails -1
[01-01 18:12:16 TUYA E][tuya_iot_com_api.c:454] db init fails -1
[01-01 18:12:16 TUYA E][tuya_main.cpp:222] ret:-1
[ 2430][D][tuya_main.cpp:223] tuya_init(): kv flash init over
[01-01 18:12:16 TUYA E][ws_db_gw.c:80] wd_protected_read fails gw_bi -1
[01-01 18:12:16 TUYA D][ws_db_gw.c:208] gw base read finish:-1
[01-01 18:12:16 TUYA D][ws_db_gw.c:61] write buf:
这里模糊处理了{"uuid":"xxxxxxxxxxx","psk_key":null,"auth_key":xxxxx","ap_ssid":"SmartLife_Ivy","ap_passwd":"xxxx","country_code":null,"prod_test":false,"fac_pin":null }
[01-01 18:12:16 TUYA E][ws_db_gw.c:66] wd_protected_write fails gw_bi -1
[01-01 18:12:16 TUYA E][ws_db_gw.c:145] gw base write fail:-1
[01-01 18:12:16 TUYA E][tuya_main.cpp:225] ret:-1
[ 2486][I][tuya_main.cpp:141] device_init(): device init start
这里模糊处理了
[01-01 18:12:16 TUYA N][tuya_iot_wifi_api.c:276] wifi soc init. pid:xxxxx5 firmwarekey:xxxx ver:1.1.3
[01-01 18:12:16 TUYA D][tuya_svc_upgrade.c:791] tuya svc upgrade init success!
[01-01 18:12:16 TUYA N][tuya_devos_entry.c:1752] Last reset reason: 0
[01-01 18:12:16 TUYA E][ws_db_gw.c:80] wd_protected_read fails gw_bi -1
[01-01 18:12:16 TUYA D][ws_db_gw.c:208] gw base read finish:-1
[01-01 18:12:16 TUYA E][tuya_devos_entry.c:1087] base read fail:-1
[01-01 18:12:16 TUYA E][tuya_devos_entry.c:1757] ret:-7171
[01-01 18:12:16 TUYA E][tuya_devos_entry.c:1808] ERR_EXIT is Jumped!
[ 2545][E][tuya_main.cpp:167] device_init(): tuya_iot_wf_soc_dev_init_param error,err_num:-7171