PMOS开关电路,很常见呀。不过要注意VGS数值不要超过12V
https://whycan.com/files/members/1798/屏幕截图_20240722_122744.png
感谢。
我刚才理解错了,Vgs和Vgs(th)不是一回事来着...
再请教,这个C3在这里起什么作用呢?让Q4开启和关断更慢一点?
经飞控群里二木仙人指点,去看了inav的代码:
455 uint16_t getVBatSample(void) {
1 // calculate battery voltage based on ADC reading
2 // result is Vbatt in 0.01V steps. 3.3V = ADC Vref, 0xFFF = 12bit adc, 1100 = 11:1 voltage divider (10k:1k)
3 return (uint64_t)adcGetChannel(ADC_BATTERY) * batteryMetersConfig()->voltage.scale * ADCVREF / (0xFFF * 1000);
4 }
这个就很容易理解了。
src/main/sensors/voltage.c中的函数:
159 STATIC_UNIT_TESTED uint16_t voltageAdcToVoltage(const uint16_t src, const voltageSensorADCConfig_t *config)
1 {
2 // calculate battery voltage based on ADC reading
3 // result is Vbatt in 0.01V steps. 3.3V = ADC Vref, 0xFFF = 12bit adc, 110 = 10:1 voltage divider (10k:1k) * 100 for 0.01V
4 return ((((uint32_t)src * config->vbatscale * getVrefMv() / 10 + (0xFFF * 5)) / (0xFFF * config->vbatresdivval)) / config->vbatresdivmultiplier);
5 }
getVreMv()函数,默认返回是3300,对应3300mV;
config->vbatscale,默认值是110;
config->vbatresdivval,默认值是10;
config->vbatresdivmultiplier,默认值是1.
找到个at32f435的原理图,可能不一定完全对应的上,原理图里只用了一个adc,用的10K:1K测量的电池电压。
按我的逻辑,(adc值/0xfff)*3300,得到测量的adc电压值,然后放大11倍,就是电池电压了。可看这个公式,对应不上。
-----------------------------------------------------------
如果把原式中的+(0xfff*5)去掉,精简下:
((((uint32_t)src * config->vbatscale * getVrefMv() / 10) / (0xFFF * config->vbatresdivval)) / config->vbatresdivmultiplier);
= src * 110 * 3300 / 10 / (0xFFF * 10) / 1
= src * 110 * 3300 / 0xFFF
这样看,就和我的逻辑计算公式差不多了,只是查了10倍, 那么原式中的+0xFFF*5,有什么作用呢?
-----------------------------------------------------------
单独把0xFFF*5部分拿出来再除以后续部分:
0xFFF*5 / (0xFFF * 10) / 1 = 0.5
这么看,这部分是为了四舍五入?
感觉这个转换函数写的好繁琐。
----------------------------------------------
算错,src * 110 * 3300 / 10 / (0xFFF * 10) / 1, 应该是:
= src * 110 * 3300 / 0xFFF * 10 * 10
= src * 11 * 3300 / 0xFFF * 10
可以看作将adc值转换为电压值后,按分压电阻放大11备得到mV单位的电池电压,再除以10得到0.01V单位的电池电压。
算是明白了,就是觉得这个公式好繁琐。
dlk /> sf probe qspi01
qspi0 freq (input): 99000000Hz
qspi0 freq ( bus ): 49500000Hz
01-01 10:14:57 I/NO_TAG: Flash ID: 0xef4018
01-01 10:14:57 I/NO_TAG: Find a Winbond flash chip. Size is 167772.
qspi0 freq (input): 99000000Hz
qspi0 freq ( bus ): 99000000Hz
01-01 10:14:57 I/NO_TAG: sf_cmd flash device is initialize success.
01-01 10:14:57 I/NO_TAG: Probe SPI flash sf_cmd by SPI device qspi.
16 MB sf_cmd is current selected device.
dlk /> sf status
The sf_cmd flash status register current value is 0x00.
早上给群里的朋友试我的固件,修改了配置,打开了芯片的内置1.8V LDO功能。当时现象依旧。
发现gitee上sdk更新了,就拉取了下来,编译并下载,现象依旧。
然后关闭了芯片的1.8V LDO功能,结果,能成功下载了,虽然我认为和LDO打开/关闭关系不大...
用的芯片是匠芯创的d133,该芯片程序只能存储在片外存储设备上,现用的是w25q128.
正常下载程序使用了一段时间后,发现烧录程序时,下载软件提示下载完成,但是实际没下载成功,程序还是运行的上次成功烧录的那个程序。
更换w25q128后,又可正常烧录。但是,使用一段时间后,仍有概率出现相同问题。
后来知道了spi nor flash有个状态寄存器,就用sfdu命令来查看状态寄存器的值:
sf status
The sf_cmd flash status register current value is 0xFC.
发现该值为0xFC,而另一块正常的板子,值为0。
查手册,得知为1的各位,其实是写保护位。
通过sf status 0 0,将该寄存器值恢复为0,可以正常烧写了。
过了大概有两三个月吧,问题又出现了,这次读取状态寄存器值,仍为0xFC, 我尝试用sf status 0 0清除该寄存器,结果程序就卡死了...
请教,还有什么办法,可以解除spi nor flash的写保护位吗?
用的d133 sdk,自带rtt,还有一些移植好了的本地软件包。
单用本地软件包里的lwip里的例程,能正常运行。
现在像运行libmodbus库,发现需要打开SAL组件,打开SAL组件,又会关联NETDEV组件,打开后发现好几个重复定义,比如ip4_addr。
搜了下,有如下多个定义:
grep -rnw "typedef struct ip4_addr"
packages/third-party/lwip/src/include/lwip/ip4_addr.h:57:typedef struct ip4_addr ip4_addr_t;
kernel/rt-thread/components/net/netdev/include/netdev_ipaddr.h:98:typedef struct ip4_addr
kernel/rt-thread/components/net/lwip/lwip-2.1.2/src/include/lwip/ip4_addr.h:57:typedef struct ip4_addr ip4_addr_t;
kernel/rt-thread/components/net/lwip/lwip-2.0.3/src/include/lwip/ip4_addr.h:57:typedef struct ip4_addr ip4_addr_t;
后两个应该没使能,应该没包含进去。
第一个是本地软件包里的lwip,第二个是rtt里的netdev组件。
俩文件还不一样,要是一样的话我就删除一个就行了...
我觉得应该是两个.h文件不能在同一个.c文件中被包含,但是,不知道如何去查找引起冲突的文件...
-------------------------------------
查看报错信息,找第一个报错时的.c文件:
In file included from kernel/rt-thread/components/net/netdev/include/arpa/inet.h:14,
from kernel/rt-thread/components/net/sal/include/sal_socket.h:15,
from kernel/rt-thread/components/net/sal/include/socket/sys_socket/sys/socket.h:16,
from application/rt-thread/can2eth/udpandtcp.c:5:
kernel/rt-thread/components/net/netdev/include/netdev_ipaddr.h:84: note: this is the location of the previous definition
84 | #define ntohl(x) (uint32_t)PP_NTOHL(x)
|
In file included from packages/third-party/lwip/src/include/lwip/ip_addr.h:43,
from packages/third-party/lwip/src/include/lwip/netif.h:46,
from application/rt-thread/can2eth/udpandtcp.c:9:
packages/third-party/lwip/src/include/lwip/ip4_addr.h:51:8: error: redefinition of 'struct ip4_addr'
51 | struct ip4_addr {
| ^~~~~~~~
In file included from kernel/rt-thread/components/net/netdev/include/arpa/inet.h:14,
from kernel/rt-thread/components/net/sal/include/sal_socket.h:15,
from kernel/rt-thread/components/net/sal/include/socket/sys_socket/sys/socket.h:16,
from application/rt-thread/can2eth/udpandtcp.c:5:
感觉是自己写的这个udpandtcp.c文件的问题?
tsdb方式存储的数据,每一条目里,存储的是数据偏移位值及数据长度,实际数据是从该扇区底部开始往上存储的。
hexdump log.fdb.0
0000000 ff3f ffff 5354 304c 0001 0000 ffff ffff
0000010 ffff ffff ffff ffff ffff ffff ffff ffff
0000020 ffff ffff ffff ffff ff1f ffff 0001 0000
0000030 0008 0000 0ff8 0000 ff1f ffff 0002 0000
0000040 0008 0000 0ff0 0000 ff1f ffff 0003 0000
0000050 0008 0000 0fe8 0000 ff1f ffff 0004 0000
0000060 0008 0000 0fe0 0000 ff1f ffff 0005 0000
0000070 0008 0000 0fd8 0000 ff1f ffff 0006 0000
0000080 0008 0000 0fd0 0000 ff1f ffff 0007 0000
0000090 0008 0000 0fc8 0000 ff1f ffff 0008 0000
00000a0 0008 0000 0fc0 0000 ff1f ffff 0009 0000
00000b0 0008 0000 0fb8 0000 ff1f ffff 000a 0000
00000c0 0008 0000 0fb0 0000 ff1f ffff 000b 0000
00000d0 0008 0000 0fa8 0000 ff1f ffff 000c 0000
00000e0 0008 0000 0fa0 0000 ffff ffff ffff ffff
00000f0 ffff ffff ffff ffff ffff ffff ffff ffff
*
0000fa0 0026 0000 005a 0000 0024 0000 0055 0000
*
0001000
FashDB目录下有fdb_cfg.h文件,里边有FDB_USING_FAL_MODE FDB_WRITE_GRAN FDB_USING_FILE_LIBC_MODE FDB_USING_FILE_POSIX_MODE等宏定义。而我用的luban-lite sdk里,menuconfig里也有对应选项,且生成到了rtconfig.h里。结果有些宏定义重复了,而以上MODE宏定义,只能三选一,由于有了两个地方都有定义,造成了同时使能了其中多个。
目前都改成使用FDB_USING_FILE_POSIX_MODE,貌似是成功了。
dlk /> test_flashdb
dlk /> [FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1784) The oldest addr is @0x00000000
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1800) KVDB size is 16384 bytes.
[FlashDB] FlashDB V2.1.0 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' value is 1
[FlashDB][sample][kvdb][basic] set the 'boot_count' value to 2
[FlashDB][sample][kvdb][basic] ===========================================================
[FlashDB][sample][kvdb][string] ==================== kvdb_type_string_sample ====================
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][sample][kvdb][string] get the 'temp' value is: 36C
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][sample][kvdb][blob] get the 'temp' value is: 36
[FlashDB][sample][kvdb][blob] set 'temp' value to 38
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB][tsl][log][/data] (packages/third-party/FlashDB/src/fdb_tsdb.c:978) TSDB (log) oldest sectors is 0x00000000, current using sector .
[FlashDB][sample][tsdb] ==================== tsdb_sample ====================
[FlashDB][sample][tsdb] append the new status.temp (36) and status.humi (85)
[FlashDB][sample][tsdb] append the new status.temp (38) and status.humi (90)
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 1, temp: 36, humi: 85
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 2, temp: 38, humi: 90
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 3, temp: 36, humi: 85
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 4, temp: 38, humi: 90
[FlashDB][sample][tsdb] [query_by_time_cb] queried a TSL: time: 1, temp: 36, humi: 85
[FlashDB][sample][tsdb] [query_by_time_cb] queried a TSL: time: 2, temp: 38, humi: 90
[FlashDB][sample][tsdb] [query_by_time_cb] queried a TSL: time: 3, temp: 36, humi: 85
[FlashDB][sample][tsdb] [query_by_time_cb] queried a TSL: time: 4, temp: 38, humi: 90
[FlashDB][sample][tsdb] query count is: 2
[FlashDB][sample][tsdb] set the TSL (time 1) status from 3 to 3
[FlashDB][sample][tsdb] set the TSL (time 2) status from 3 to 3
[FlashDB][sample][tsdb] set the TSL (time 3) status from 2 to 3
[FlashDB][sample][tsdb] set the TSL (time 4) status from 2 to 3
[FlashDB][sample][tsdb] ===========================================================
hexdump env.fdb.0
0000000 3f3f ffff 4446 3042 ffff ffff ffff ffff
0000010 ff3f ffff 564b 3030 0026 0000 c32c b664
0000020 ff08 ffff 0006 0000 7375 7265 616e 656d
0000030 7261 696d 6b6e ff3f ffff 564b 3030 0026
0000040 0000 4c95 83fc ff08 ffff 0006 0000 6170
0000050 7373 6f77 6472 3231 3433 3635 ff0f ffff
0000060 564b 3030 0026 0000 f64e efde ff0a ffff
0000070 0004 0000 6f62 746f 635f 756f 746e 0000
0000080 0000 ff3f ffff 564b 3030 0071 0000 1dce
0000090 135c ff09 ffff 0050 0000 6f62 746f 745f
00000a0 6d69 0065 0000 0000 0000 0100 0000 0000
00000b0 0000 0200 0000 0000 0000 0300 0000 0000
00000c0 0000 0000 0000 0000 0000 0000 0000 0000
*
00000f0 0000 3f00 ffff 4bff 3056 2730 0000 a700
0000100 d62e 0b29 ffff 04ff 0000 5f00 765f 7265
0000110 6e5f 6d75 5f5f 0000 0000 ff3f ffff 564b
0000120 3030 0026 0000 912b 5762 ff0a ffff 0004
0000130 0000 6f62 746f 635f 756f 746e 0001 0000
0000140 ff0f ffff 564b 3030 001f 0000 b630 fa55
0000150 ff04 ffff 0003 0000 6574 706d 3633 0f43
0000160 ffff 4bff 3056 1f30 0000 be00 d69b 0464
0000170 ffff 03ff 0000 7400 6d65 3370 4338 ff0f
0000180 ffff 564b 3030 0020 0000 89da b6c5 ff04
0000190 ffff 0004 0000 6574 706d 0024 0000 ff0f
00001a0 ffff 564b 3030 0020 0000 4151 1ccc ff04
00001b0 ffff 0004 0000 6574 706d 0026 0000 ffff
00001c0 ffff ffff ffff ffff ffff ffff ffff ffff
*
0001000
使用FDB_USING_FILE_POSIX_MODE模式时,我以为文件路径会是/dev/data呢,结果/data就行。
而使用FDB_USING_FILE_LIBC_MODE模式时,就是上边楼层最后追踪到的fwrite()函数,写入size是12,返回却是1。原因未知。
在两个地方都配置为FDB_USING_FAL_MODE模式,FDB_WRITE_GRAN配置为1或32,都是卡到这里:
dlk /> test_flashdb
dlk /> [FlashDB][kv][(null)
追踪最后的这个报错:
[FlashDB][tsl][log][/data] Error: write tsl failed (2)
是在fdb_tsdc.c
/* write the TSL node */
1 result = write_tsl(db, blob, cur_time);
2 if (result != FDB_NO_ERR) {
3 FDB_INFO("Error: write tsl failed (%d)", result);
4 return result;
5 }
检测write_tsl()这个函数的返回,如果不是0,则报错。
static fdb_err_t write_tsl(fdb_tsdb_t db, fdb_blob_t blob, fdb_time_t time)
1 {
2 fdb_err_t result = FDB_NO_ERR;
3 struct log_idx_data idx;
4 uint32_t idx_addr = db->cur_sec.empty_idx;
5
6 idx.log_len = blob->size;
7 idx.time = time;
8 idx.log_addr = db->cur_sec.empty_data - FDB_WG_ALIGN(idx.log_len);
9 /* write the status will by write granularity */
10 _FDB_WRITE_STATUS(db, idx_addr, idx.status_table, FDB_TSL_STATUS_NUM, FDB_TSL_PRE_WRITE, false);
11 /* write other index info */
12 FLASH_WRITE(db, idx_addr + LOG_IDX_TS_OFFSET, &idx.time, sizeof(struct log_idx_data) - LOG_IDX_TS_OFFSET, false);
13 /* write blob data */
14 FLASH_WRITE(db, idx.log_addr, blob->buf, blob->size, false);
15 /* write the status will by write granularity */
16 _FDB_WRITE_STATUS(db, idx_addr, idx.status_table, FDB_TSL_STATUS_NUM, FDB_TSL_WRITE, true);
17
18 return result;
19 }
可write_tsl()这个函数,里面声明了result,赋值为0,然后就是最后的return result了,其他地方没用到result。
奇怪这个result是什么时候被赋值为2的。
-------------------------------
懂了,在该函数里调用的几个宏里,有return result返回,如:
68 #define _FDB_WRITE_STATUS(db, addr, status_table, status_num, status_index, sync) \
1 do { \
2 result = _fdb_write_status((fdb_db_t)db, addr, status_table, status_num, status_index, sync);\
3 if (result != FDB_NO_ERR) return result; \
4 } while(0);
5
6 #define FLASH_WRITE(db, addr, buf, size, sync) \
7 do { \
8 result = _fdb_flash_write((fdb_db_t)db, addr, buf, size, sync); \
9 if (result != FDB_NO_ERR) return result; \
10 } while(0);
---------------------------------------------
修改FDB_WRITE_GRAN这个值,由32改为1,结果报错crc错误。
我用的spi nor flash,四线qspi,应该选1吧?
26 /* Using FAL storage mode */
1 // #define FDB_USING_FAL_MODE
2
3 #ifdef FDB_USING_FAL_MODE
4 /* the flash write granularity, unit: bit
5 * only support 1(nor flash)/ 8(stm32f2/f4)/ 32(stm32f1)/ 64(stm32f7)/ 128(stm32h5) */
6 #define FDB_WRITE_GRAN 1 /* @note you must define it for a value */
7 #endif
dlk /> test_flashdb
dlk /> [FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1784) The oldest addr is @0x00000000
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1800) KVDB size is 16384 bytes.
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00000000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00001000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00002000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00003000).
[FlashDB][kv][env][/data] All sector header is incorrect. Set it to default.
[FlashDB] FlashDB V2.1.0 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][string] ==================== kvdb_type_string_sample ====================
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][sample][kvdb][blob] set 'temp' value to 38
[FlashDB][kv][env][/data] Error: Read the KV (@0x00000010) CRC32 check failed!
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB][tsl][log][/data] Sector (0x00000000) header info is incorrect.
[FlashDB][tsl][log][/data] All sector format finished.
[FlashDB][tsl][log][/data] (packages/third-party/FlashDB/src/fdb_tsdb.c:978) TSDB (log) oldest sectors is 0x00000000, current using sector .
[FlashDB][sample][tsdb] ==================== tsdb_sample ====================
[FlashDB][tsl][log][/data] Error: update the sector status failed (2)[FlashDB][sample][tsdb] append the new status.temp (36) and status.hum )
[FlashDB][tsl][log][/data] Error: write tsl failed (2)[FlashDB][sample][tsdb] append the new status.temp (38) and status.humi (90)
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 0, temp: 40, humi: 805688500
[FlashDB][sample][tsdb] [query_by_time_cb] queried a TSL: time: 0, temp: 40, humi: 805688604
[FlashDB][sample][tsdb] query count is: 0
[FlashDB][sample][tsdb] set the TSL (time 0) status from 1 to 3
[FlashDB][sample][tsdb] ===========================================================
--------------------------------
定位到这里,fwrite写入的size是12,可函数返回值却是1.
if ((fseek(fp, addr, SEEK_SET) != 0) || (fwrite(buf, size, 1, fp) != size))
dlk /> test_flashdb
dlk /> [FlashDB][sample][kvdb][basic] ==================== kvdb_basic_sample ====================
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][basic] get the 'boot_count' value is 0
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][basic] set the 'boot_count' value to 1
[FlashDB][sample][kvdb][basic] ===========================================================
[FlashDB][sample][kvdb][string] ==================== kvdb_type_string_sample ====================
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][blob] get the 'temp' value is: 0
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][blob] set 'temp' value to 38
[FlashDB][kv][(null)][(null)] Error: KV ((null)) isn't initialize OK.
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB] Error: Partition (fdb_tsdb1) not found.
[FlashDB] Error: TSDB (log
今早发现FlashDB目录下不知道什么时候多了个文件,打开看貌似是些记录啥的。忘了名了,已经删了,再次编译也没再出现。
不过执行test_flashdb,出现以上信息。
--------------------------------------------
发现昨天保存时,不知道什么时候删除了个/,导致fdb_kvdb_init()这条语句被注释了。恢复后,还是昨天下午的那个报错。
lk /> test_flashdb
dlk /> [FlashDB] (db->sec_size != 0) has assert failed at _fdb_init_ex.
----------------------------------------------
照抄linux的demo,又增加了两个语句:
bool file_mode = true;
uint32_t sec_size = 4096, db_size = sec_size * 4;
/* set the sector and database max size */
fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_SEC_SIZE, &sec_size);
fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_MAX_SIZE, &db_size);
/* enable file mode */
fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_FILE_MODE, &file_mode);
编译后可以运行,但是/data目录下没有看到新增文件。
dlk /> test_flashdb
dlk /> [FlashDB][kv][env][/dev/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1784) The oldest addr is @0x00000000
[FlashDB][kv][env][/dev/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1800) KVDB size is 16384 bytes.
[FlashDB][kv][env][/dev/data] Sector header info is incorrect. Auto format this sector (0x00000000).
[FlashDB][file] Error: open (/dev/data/env.fdb.0) file failed.
[FlashDB][kv][env][/dev/data] Sector header info is incorrect. Auto format this sector (0x00001000).
[FlashDB][file] Error: open (/dev/data/env.fdb.1) file failed.
[FlashDB][kv][env][/dev/data] Sector header info is incorrect. Auto format this sector (0x00002000).
[FlashDB][file] Error: open (/dev/data/env.fdb.2) file failed.
[FlashDB][kv][env][/dev/data] Sector header info is incorrect. Auto format this sector (0x00003000).
[FlashDB][file] Error: open (/dev/data/env.fdb.3) file failed.
[FlashDB][kv][env][/dev/data] All sector header is incorrect. Set it to default.
[FlashDB][file] Error: open (/dev/data/env.fdb.0) file failed.
[FlashDB] FlashDB V2.1.0 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][string] ==================== kvdb_type_string_sample ====================
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][kv][env][/dev/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[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][/dev/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB][tsl][log][/dev/data] Sector (0x00000000) header info is incorrect.
[FlashDB][file] Error: open (/dev/data/log.fdb.0) file failed.
[FlashDB][file] Error: open (/dev/data/log.fdb.1) file failed.
[FlashDB][file] Error: open (/dev/data/log.fdb.2) file failed.
[FlashDB][file] Error: open (/dev/data/log.fdb.3) file failed.
[FlashDB][tsl][log][/dev/data] All sector format finished.
[FlashDB][tsl][log][/dev/data] (packages/third-party/FlashDB/src/fdb_tsdb.c:978) TSDB (log) oldest sectors is 0x00000000, current using sec .
[FlashDB][sample][tsdb] ==================== tsdb_sample ====================
[FlashDB][tsl][log][/dev/data] Error: write tsl failed (3)[FlashDB][sample][tsdb] append the new status.temp (36) and status.humi (85)
[FlashDB][tsl][log][/dev/data] Error: write tsl failed (3)[FlashDB][sample][tsdb] append the new status.temp (38) and status.humi (90)
[FlashDB][sample][tsdb] query count is: 0
[FlashDB][sample][tsdb] ===========================================================
---------------------------------------------
原来用的posix模式打开文件,修改为libc模式,貌似成功了。
35 /* Using file storage mode by LIBC file API, like fopen/fread/fwrte/fclose */
1 #define FDB_USING_FILE_LIBC_MODE
2
3 /* Using file storage mode by POSIX file API, like open/read/write/close */
4 // #define FDB_USING_FILE_POSIX_MODE
dlk /> test_flashdb
dlk /> [FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1784) The oldest addr is @0x00000000
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1800) KVDB size is 16384 bytes.
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00000000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00001000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00002000).
[FlashDB][kv][env][/data] Sector header info is incorrect. Auto format this sector (0x00003000).
[FlashDB][kv][env][/data] All sector header is incorrect. Set it to default.
[FlashDB] FlashDB V2.1.0 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][string] ==================== kvdb_type_string_sample ====================
[FlashDB][kv][env][/data] Error: The KV @0x00000024 length has an error.
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][kv][env][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[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][/data] (packages/third-party/FlashDB/src/fdb_kvdb.c:954) Not found 'temp' in KV.
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB][tsl][log][/data] Sector (0x00000000) header info is incorrect.
[FlashDB][tsl][log][/data] All sector format finished.
[FlashDB][tsl][log][/data] (packages/third-party/FlashDB/src/fdb_tsdb.c:978) TSDB (log) oldest sectors is 0x00000000, current using sector .
[FlashDB][sample][tsdb] ==================== tsdb_sample ====================
[FlashDB][tsl][log][/data] Error: write tsl failed (2)[FlashDB][sample][tsdb] append the new status.temp (36) and status.humi (85)
[FlashDB][tsl][log][/data] Error: write tsl failed (2)[FlashDB][sample][tsdb] append the new status.temp (38) and status.humi (90)
[FlashDB][sample][tsdb] query count is: 0
[FlashDB][sample][tsdb] ===========================================================
dlk /> cd /data
dlk /data> ls
Directory /data:
env.fdb.0 4096
env.fdb.1 4096
env.fdb.2 4096
env.fdb.3 4096
log.fdb.0 4096
log.fdb.1 4096
log.fdb.2 4096
log.fdb.3 4096
参考linux那个demo发现,要使用文件系统,除了使能那两个宏之一,还要增加个设置语句:
bool file_mode = true;
fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_FILE_MODE, &file_mode);
运行后,提示堆栈溢出,原来分配了1K,改成10k,不再报那个错误了,但是有如下报错,也不知道写入是否成功,明天再看。
dlk /> test_flashdb
dlk /> [FlashDB] (db->sec_size != 0) has assert failed at _fdb_init_ex.
板子是匠芯创的d133,片外spi nor flash。目前有两个分区用来存储数据,/rodata分区格式化为fat32文件系统,/data分区格式化为littlefs文件系统,两个分区都可读写。
luban-lite sdk里虽然有flashdb配置选项,但是没有flashdb库文件。手动下载下来放到packages/third-party/目录下,将src,inc,sample三个文件夹加到工程里,demo目录下有多个单片机的demo,照抄stm32f405-spi-flash那个,写了个test_demo.c文件放到了demo目录下并添加到工程里。
初始化时,有这个语句:
// result = fdb_kvdb_init(&kvdb, "env", "fdb_kvdb1", &default_kv, NULL);
result = fdb_kvdb_init(&kvdb, "env", "/dev/data", &default_kv, NULL);
板子没有叫fdb_kvdb1的分区,我改成"data",报错:
dlk /> fal probe qspi01
Device qspi01 NOT found. Probe failed.
No flash device or partition was probed.
Usage: fal probe [dev_name|part_name] - probe flash device or partition by given name.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name | flash_dev | offset | length |
[I/FAL] -------------------------------------------------------------
[I/FAL] | spl | norflash0 | 0x00000000 | 0x00040000 |
[I/FAL] | env | norflash0 | 0x00040000 | 0x00020000 |
[I/FAL] | env_r | norflash0 | 0x00060000 | 0x00020000 |
[I/FAL] | os | norflash0 | 0x00080000 | 0x00200000 |
[I/FAL] | os_r | norflash0 | 0x00280000 | 0x00000000 |
[I/FAL] | rodata | norflash0 | 0x00280000 | 0x00500000 |
[I/FAL] | rodata_r | norflash0 | 0x00780000 | 0x00100000 |
[I/FAL] | data | norflash0 | 0x00880000 | 0x00700000 |
[I/FAL] =============================================================
dlk /> test_flashdb
dlk /> [FlashDB][kv][env][data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1784) The oldest addr is @0x00000000
[FlashDB][kv][env][data] (packages/third-party/FlashDB/src/fdb_kvdb.c:1800) KVDB size is 7340032 bytes.
[FlashDB][kv][env][data] Sector header info is incorrect. Auto format this sector (0x00000000).
改成"/data"或"/dev/data",使能FDB_USING_FILE_LIBC_MODE或FDB_USING_FILE_POSIX_MODE, 报错找不到分区:
dlk /> test_flashdb
dlk /> [FlashDB] Error: Partition (/data) not found.
[FlashDB] Error: KVDB (env
@温柔的猪 之前回复过你,还没搞定吗。在rtconfig.py 里添加 -fdiagnostics-color=always 就会有颜色提示了
不好意思,一直没尝试,后来忘了。今天编译时又找不到报错在哪一行,于是就发了这个帖子。
我找到了rtconfig.py,但是不知道该加到哪里。
直接加到末尾新行,不符合语法。
写成这样又没效果:
SCONSFLAGS="-fdiagnostics-color=always"
-----------------------------------------------
0 BUILD = 'release'
1 if BUILD == 'debug':
2 CFLAGS_DBG = ' -O0 -gdwarf-2 -fdiagnostics-color=always'
3 AFLAGS_DBG = ' -gdwarf-2'
4 else:
5 CFLAGS_DBG = ' -O2 -g2 -fdiagnostics-color=always'
6 AFLAGS_DBG = ''
7
不知道该加到哪个flags里,就加到CFLAGS_DBG里了,我看下面还有CFLAGS和M_CFLAGS,也都用到了这个变量。
反正是起作用了。
感谢。
忘了之前的过程了...
2.0的sdk是从mango的github上下载的,现在好像仓库移除了。
2.1的sdk是从全志官网下载的,当时注册就能下载,现在貌似不行了,得签nda。
不过t113s3官方的sdk已经是tina5.x了吧。tina2.x是基于openwrt的,tina5.x是直接基于buildroot的了,好像是这样子。
之前用tina2.0时,make menuconfig里有qt选项,于是就想尽量用官方自带的,觉得可能更好,于是就折腾了一阵子。
而到tina2.1时,sdk里已经没有qt库了,也就死心了,安心单独编译qt。
cp: cannot stat '/home/embedfire/workspace/tina-t113/Tina_Linux_2022/Tina-Linux/out/t113-evb1/compile_dir/target/qt-everywhere-src-5.12.9/ipkg-install/usr/lib/libQt5MultimediaQuick.so*': No such file or directory
无论自己单独编译,还是用sdk自带的,编译qt都有个配置选项,里边配置编译哪些库。你可以看下是应该选这个库还是不该选。
编译qt库也挺费时间的。
https://club.rt-thread.org/ask/question/9faea7447d375649.html
看这篇文章,发现需要打开SAL选项,估计是
enable bsd socket operated by file system api.
但是我搜目前的rtt组件,没搜到这个,目前打开的是:
│ │ [*] SAL: socket abstraction layer ---> │ │
│ │ -*- Enable network interface device --->
而且,和local package里的lwip寸在冲突。
现在不用local lwip时,sqlite功能正常了。
-----------------------------------------------
一次插入8000条数据,可以成功,插入9000条,就卡住了,重启后发现目录下多了个journel.db。
删掉数据库,创新创建,多次插入8000调数据,可以成功,但发现插入一条数据的时间比插入8000调数据的时间还长。
比如,插入一条数据要16秒,插入8000调要12秒。
多次插入后,就出错了,用stu score再也无法查询出某范围的条数。复制数据到到pc,用db brower查看,也看到数据内容。
此时文件系统没有被占满,分配了7M空间,数据库才700多k。
------------------------------
删掉数据库,重新创建,然后每次只插入一条数据,发现时间大概话非1秒,有点难受啊。
用stu命令可以看到列出数据,看数据库最大条数是8564, 再新增也是这个数字。那么,数据库最大容量是8564?但实际不是,用stu score m n,可列出score值巍在m和n范围内的数据条,可以看的id有超过8664的。
莫名奇妙的例程能正常运行了。
dlk /data> create_student_tbl
/data/stu_info.dbdlk /data>
dlk /data> ls
Directory /data:
stu_info.db 12288
dlk /data> stu add 10
Insert 10 record(s): 1166ms, speed: 116ms/record
dlk /data> stu
test get all students
id:1 name:Student44408 score:40
id:2 name:Student44409 score:41
id:3 name:Student44411 score:43
id:4 name:Student44414 score:46
id:5 name:Student44418 score:50
id:6 name:Student44423 score:55
id:7 name:Student44429 score:61
id:8 name:Student44436 score:68
id:9 name:Student44444 score:76
id:10 name:Student44453 score:85
record(s):10
dlk /data> stu score 40 60
-------------------------------------
创建数据库,新增数据、删除、按分数范围查找,都能执行。
执行stu score时有个坑,按说stu score 40 60,就可以查找40-60分数的数据,结果本来是4个参数,有个可选的第5个参数,程序里只判断参数大于4个的情况下,也会去读取第5个参数,结果就卡住了。加个条件即可,参数大于5时才读第5个参数。
msh线程分配了10k空间,占用率85%。
-------------------------------------
上午发现stu add命令可以成功执行后,觉得之前尝试给msh分配的空间太大了,就由512k逐渐减下去,减到10k后sqlite例程的几个命令还可以使用,以为没事了。
下午切到win下,又试着重新编译sdk里的sqlite,结果又出现了上次的问题,create_student_tbl命令可以成功创建数据库,但是stu add命令就会失败,仍报错:
bind failed errmsg:database disk image is malformed
msh线程空间也改大了,无效。怀疑是spi速度的原因影响spi nor flash里的littlefs分区的读写,降低spi速度,无效。
又切回到ubuntu下,由于下午想尝试libmodbus,重新编译过。发现ubuntu下编译烧录后,stu add命令也是报错。
https://club.rt-thread.org/ask/question/9faea7447d375649.html
这个sqlite在spi和sd卡上没法用,慢到无法忍受.归根结底是文件系统速度太慢.我有在uffs和yaffs文件系统上测,文件系统速度是上去了。但是数据量增加到一定量数据库就报SQL error: database disk image is malformed。不知道什么鬼。
但是在SD卡文件系统上测试就不会
在rtt论坛搜到同样报错的帖子,我还是放弃单片机上跑sqlite吧,或者等artinchip来解决。
话说,artinchip的lunban-lite sdk里带的这个sqlite,也许是给d21x这类片子运行的吧。
还是得看readme.
358 ## 注意事项
1 - SQLite资源占用:RAM:250KB+,ROM:310KB+,所以需要有较充足的硬件资源。
2 - 根据应用场景创建合理的表结构,会提高操作效率。
3 - 根据应用场合理使用SQL语句,如查询条件,插入方式等。
4 - 如涉及到多表操作或联表查询,最好使用PowerDesigner等工具合理设计表。
我是在msh里执行create_student_tbl命令的,应该是需要比较大的内存,而msh默认分配了4k内存,改成40k后,可以创建数据库成功了。使用stu add xxx命令来增加数据条出错了,还在解决:
dlk />
dlk /> cd data
dlk /data> ls
Directory /data:
123 4
stu_info.db 12288
ui_font_Big.c 102408
dlk /data> stu add 1
01-01 08:31:52 E/app.dbhelper: bind failed errmsg:database disk image is malformed
01-01 08:31:52 E/app.dbhelper: db operator failed,rc=1
01-01 08:31:52 E/app.student_dao: add failed!
dlk /data>
dbhelper.c文件里,该行报错:
268 sqlite3_finalize(stmt);
1 if ((rc != SQLITE_OK) && (rc != SQLITE_DONE))
2 {
3 LOG_E("bind failed errmsg:%s", sqlite3_errmsg(db));
4 goto __db_exec_fail;
5 }
-------------------------------
msh栈空间改为400k,结果仍一样。
尝试改为1M,结果上电后,不运行了...
---------------------------------
student_dao.c里,执行stu add命令后,会调用到这个函数。
int student_add(rt_list_t *h)
{
return db_nonquery_operator("insert into student(name,score) values (?,?);", student_insert_bind, h);
}
db_nonquery_operator()执行一系列操作后,调用的是如下函数。
static int student_insert_bind(sqlite3_stmt *stmt, int index, void *arg)
{
int rc = 0;
rt_list_t *h = arg, *pos, *n;
student_t *s = RT_NULL;
rt_list_for_each_safe(pos, n, h)
{
s = rt_list_entry(pos, student_t, list);
sqlite3_reset(stmt); //reset the stmt
sqlite3_bind_text(stmt, 1, s->name, strlen(s->name), NULL); //bind the 1st data,is a string
sqlite3_bind_int(stmt, 2, s->score); //bind the 1st data,is a int
rc = sqlite3_step(stmt); //execute the stmt by step
}
if (rc != SQLITE_DONE)
return rc;
return SQLITE_OK;
}
感觉是这个函数执行后返回的值rc,根据rc值执行了报错输出。
@Gentlepig
写一大串没用的,难道你就没有怀疑是你输入的命令有问题?写了一大串也没有把重要细节show出来!
输入命令如下:
dlk /> df /rodata
disk free: 4.8 MB [ 9968 block, 512 bytes per block ]
dlk /> df /data
disk free: 6.8 MB [ 1764 block, 4096 bytes per block ]
dlk /> create_student_tbl
/rodata/stu_info.db
对应函数如下,无参数,目的是创建数据库:
static int create_student_tbl(void)
{
int fd = 0;
db_set_name("/data/stu_info.db");
fd = open(db_get_name(), O_RDONLY);
rt_kprintf(db_get_name());
if (fd < 0)
{
/* there is not the .db file.create db and table */
const char *sql = "CREATE TABLE student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);";
return db_create_database(sql);
}
else if (db_table_is_exist("student") > 0)
{
/* there is the table int db.close the db. */
close(fd);
LOG_I("The table has already existed!\n");
return RT_EOK;
}
else
{
/* there is not the table int db.create the table */
const char *sql = "CREATE TABLE student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);";
return db_create_database(sql);
}
}
MSH_CMD_EXPORT(create_student_tbl, create sqlite db);
详细文件见:
https://gitee.com/artinchip/luban-lite/blob/master/packages/third-party/sqlite/student_dao.c
手头的板子没焊接sd相关,打算先用spi nor flash存储做个尝试。
rtt配置里勾选了littlefs和sqlte,sqlite里勾选了example。
/rodata配置为fatfs,分配了5M;/data配置为littlefs,分配了7M。
student_dao.c里默认数据库存在/data/stu_info.db。
编译后烧录到板子上,执行crate_student_tbl命令,按说应该在/data目录下生成stu_info.db数据库,可串口终端一直卡在这个命令这里,不过光标还是闪烁的。
等了几分钟后,仍是这个效果,就重启板子,发现/data下有stu_info.db文件,虽然大小为0。
执行stu命令,应该显示数据库所有数据,结果仍是卡住且光标正常闪烁。
以为是文件系统的问题,将student_dao.c里创建数据库的位值改为/rodata,这个是fatfs格式的。
结果执行create_student_tbl命令后,还是卡住,重启后,在/rodata目录下,并没有db数据库文件生成。
目前用d133定时采集can总线上的数据,然后在rgb屏幕上的lvgl界面上显示出来。
但是想保存采集到的数据,方便其他设备查询历史记录,或者在lvgl界面上查询历史记录。
请教,有什么好的办法?
问了几个群里,有推荐sqlite3和flashdb的。想知道,使用数据库有什么好处?
还有就是目前使用的spi nor flash,如果用fatfs,好想说并不适合频繁擦写。
目前有两种需求:
1, 采集can总线上定时发送过来的数据,每次保存,或几次采集后保存一次,可能保存频率很高;
2, 采集can总线上不定时发送过来的,一般是系统出现问题时才发送过来,保存频率较低。
更新1.0.5版本的sdk后,上电时can容易进错误中断的现象消除了。
对比新旧两版test_can例程,发现新例程在打开并配置好can后,增加了句打开can中断的语句。
//enable CAN TX interrupt
rt_device_control(can_tx_dev, RT_DEVICE_CTRL_SET_INT, NULL);
上一版的例程里没这么一句,但是却能进can中断。奇怪。
另,新版的sdk,lvgl的rtp使能后正常了,但是旋转屏幕却变得不正常了。
在lv_port_disp.c里的lv_port_disp_init()函数里,增加这一句:
// disp_drv.rotated = LV_DISP_ROT_180;
画面视觉效果没有旋转,但是点击按钮没反映,而按旋转后的位值虚空点击,却出现了点击效果。
感觉是,画面貌似旋转了,但是呈现没旋转。
--------------------------------------------------------
比较下了,两版sdk,打开can时,参数里都带有中断方式参数,新版的,在设置完波特率等后,又通过ctrl命令打开中断。
于是对比了两版sdk里rtt_kernel里的can驱动部分,的rt_can_open(),发现给的参数里有中断方式,那么就在函数结尾处直接调用contrl命令打开中断。而新版里注释了这部分。
那么问题应该就是就板过早的打开了can接收中断,波特率还未配置,滤波器组也未配置,结果总线上有信息,于是就报错进错误中断了。
----------------------
lvgl屏幕旋转的问题是,忘了使能USE_DRAW_BUF这个宏定义。
win10下,sdk应该是1.0.4, 之前编译通过了。今天尝试再次编译,结果报错找不到stddef.h这个文件。
编译d133默认工程也是报这个错误。
搜了下,在rtdef.h里有:
#include <rtconfig.h>
#ifdef RT_USING_LIBC
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#endif /* RT_USING_LIBC */
又搜到:
在开启了 RT_USING_LIBC 后,GCC 编译使用 newlib
未开启 RT_USING_LIBC 时,GCC 编译使用 minilibc
dlib 是 RT-Thread 针对 IAR 编译器的移植适配(使用标准库接口时注意开启 RT_USING_LIBC)
armlibc 是 RT-Thread 针对 MDK 编译器的移植适配
https://blog.csdn.net/wandersky0822/article/details/120130059
但是,我印象中我没做啥设置修改啊。
-----------------------------
在me菜单里,搜了下RT_USING_LIBC,看其依赖关系,现在没处于选中状态啊。
-----------------------------
> m
scons: Reading SConscript files ...
args.outfile: F:\MCU\ArtinChip\luban-lite/partition_table.h
cc1.exe: warning: is shorter than expected
Newlib version:3.2.0
F:\MCU\ArtinChip\luban-lite\kernel\rt-thread
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: output\d13x_kunlunpi88-nor_rt-thread_helloworld
CC application\rt-thread\helloworld\main.c
CC bsp\artinchip\drv\audio\drv_audio.c
In file included from kernel\rt-thread\include/rtthread.h:27,
from application\rt-thread\helloworld\main.c:9:
kernel\rt-thread\include/rtdef.h:55:10: fatal error: stddef.h: No such file or directory
55 | #include <stddef.h>
| ^~~~~~~~~~
compilation terminated . CC bsp\artinchip\drv\audio\drv_dmic.c
我用的这个就是功率电感吧
功率电感一般是那种绕线的,比如4030封装之类的。
1、打开 USE_DRAW_BUF;
2、设置变量 disp_drv.rotated = LV_DISP_ROT_90;
3.由于LVGL的旋转方向和触摸定义的旋转方向反了,1.0.3的SDK需要手动对调下90,270。后续SDK会更新掉这个问题。
LV_DISP_ROT_90
这是设置LVGL的旋转。
看sdk菜单里有frame旋转功能,但是我总是设置不成功。我设置旋转180度,结果rgb屏幕就变成雪花点了。
> Board options > Display Parameter ────────────────────────────────
┌───────────────── framebuffer rotation degree ─────────────────┐
│ Use the arrow keys to navigate this window or press the │
│ hotkey of the item you wish to select followed by the <SPACE │
│ BAR>. Press <?> for additional information about this │
│ ┌───────────────────────────────────────────────────────────┐ │
│ │ (X) 0 │ │
│ │ ( ) 90 │ │
│ │ ( ) 180 │ │
│ │ ( ) 270 │ │
│ │ │ │
│ │ │ │
│ └───────────────────────────────────────────────────────────┘ │
├───────────────────────────────────────────────────────────────┤
│ <Select> < Help > │
└───────────────────────────────────────────────────────────────┘
bit4 R/W 0x0 SLEEP_MOD:Sleep Mode,休眠模式,只在复位模式可写
0x0:正常操作。控制器唤醒。
0x1:休眠模式。CAN无总线活动和无中断发生。
bit3 R/W 0x0 FILTER_MOD:Acceptance Filter Mode,接收过滤器模式
0x0:双过滤模式。使用两个过滤器。
0x1:单过滤模式。使用一个4字节过滤器。
bit2 R/W 0x0 SELFTEST_MOD:Self Test Mode,自测模式
0x0:正常操作。发送成功需有应答。
0x1:自测模式。在SELF_REQ自接收请求指令下,无需其它节点
参与也能完成整个节点测试,发送成功无需应答。
bit1 R/W 0x0 LISTEN_MOD:Listen Only Mode,只听模式
0x0:正常操作。错误计数停止于当前值 。
0x1:只听模式。只接收总线上数据,不产生应答信号,
也不更新接收错误计数。
bit0 R/W 0x1 RST_MOD:Reset Mode,复位模式
0x0:正常操作。控制器返回正常操作模式。
0x1:复位模式。发送或接收中止,控制器处于可配置状态。
这是can状态寄存器的描述。
程序里出错时打印了状态寄存器的值,我看是0xA2和0xF3差不多交替出现。这么看,像是在自动切换复位模式和正常模式。
[E] hal_can_bus_error_msg()340 0xA2
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Stuff Error, [E] hal_can_bus_error_msg()335 ID28~21
[E] hal_can_bus_error_msg()340 0xF3
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Other Error, [E] hal_can_bus_error_msg()335 Tolerate dominant bits
[E] hal_can_bus_error_msg()340 0xA2
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Other Error, [E] hal_can_bus_error_msg()335 Tolerate dominant bits
[E] hal_can_bus_error_msg()340 0xF3
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Other Error, [E] hal_can_bus_error_msg()335 Tolerate dominant bits
[E] hal_can_bus_error_msg()340 0xA2
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Stuff Error, [E] hal_can_bus_error_msg()335 ID28~21
[E] hal_can_bus_error_msg()340 0xA2
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Other Error, [E] hal_can_bus_error_msg()335 Tolerate dominant bits
[E] hal_can_bus_error_msg()340 0xF3
[E] hal_can_bus_error_msg()303 error in RX direction, [E] hal_can_bus_error_msg()314 Stuff Error, [E] hal_can_bus_error_msg()335 ID28~21
这是can错误处理函数,直接CAN_INTR_ERRB错误,进hal_can_bus_error_msg()函数。
看到里边有对发送错误计数寄存器的读取staus.txerr,超过阈值后,将can设置为复位模式。
虽然有对接收错误计数寄存器stauts.rxerr的读取,但是没看到有其它地方调用到。
另有对溢出错误的累加计数。
而看错误提示,应该是:
ERRB_INT:Bus Error Interrupt,总线错误中断(节点检测到总线上发生了错误)。
错误信息里提到的是,接收方向错误,Tolerate dominant bits错误。
static void hal_can_error_handle(can_handle *phandle, u32 err_status)
{
u32 can_status;
u8 errcode;
errcode = readb(phandle->can_base + CAN_ERRCODE_REG) &
CAN_ERRCODE_SEGCODE_MASK;
can_status = readl(phandle->can_base + CAN_STAT_REG);
phandle->status.rxerr = readl(phandle->can_base + CAN_RXERR_REG);
phandle->status.txerr = readl(phandle->can_base + CAN_TXERR_REG);
if (err_status & CAN_INTR_ERRB) {
hal_can_bus_error_msg(phandle);
}
if (err_status & CAN_INTR_ARBLOST) {
hal_can_arblost_msg(phandle);
}
if (err_status & CAN_INTR_ERRP) {
if (phandle->status.current_state == PASSIVE_STATUS)
phandle->status.current_state = WARNING_STATUS;
else
phandle->status.current_state = PASSIVE_STATUS;
}
if (err_status & CAN_INTR_OVF) {
phandle->status.othererrcnt++;
phandle->status.recverrcnt++;
hal_can_set_mode(phandle, CAN_MODE_RST);
hal_can_mode_release(phandle, CAN_MODE_RST);
if (phandle->callback)
phandle->callback(phandle, (void *)CAN_EVENT_RXOF_IND);
/* clear bit */
writel(CAN_MCR_CLR_OVF, phandle->can_base + CAN_MCR_REG);
}
if (err_status & CAN_INTR_ERRW) {
if (can_status & CAN_STAT_BUS)
phandle->status.current_state = BUS_OFF;
else if (can_status & CAN_STAT_ERR)
phandle->status.current_state = WARNING_STATUS;
else
phandle->status.current_state = ACTIVE_STATUS;
}
if (phandle->status.current_state == BUS_OFF)
hal_can_mode_release(phandle, CAN_MODE_RST);
if (phandle->status.txerr > CAN_ERRP_THRESHOLD &&
errcode == CAN_ERRCODE_ACK_SLOT)
{
writel(CAN_MCR_ABORTREQ, phandle->can_base + CAN_MCR_REG);
hal_can_set_mode(phandle, CAN_MODE_RST);
hal_can_mode_release(phandle, CAN_MODE_RST);
}
}
hal_can_bus_error_msg()函数里,打印出了错误的方向、错误的类型、在哪个阶段出的错。
static void hal_can_bus_error_msg(can_handle *phandle)
{
u8 i;
u8 errinfo = readb(phandle->can_base + CAN_ERRCODE_REG);
u8 errtype = (errinfo & CAN_ERRCODE_ERRTYPE_MASK) >> 6;
u8 errdir = (errinfo & CAN_ERRCODE_DIR) >> 5;
u8 errcode = errinfo & CAN_ERRCODE_SEGCODE_MASK;
for (i = 0; i < ARRAY_SIZE(bus_err_dir); i++) {
if (errdir == bus_err_dir[i].code) {
hal_log_err("%s, ", bus_err_dir[i].msg);
if (i)
phandle->status.recverrcnt++;
else
phandle->status.snderrcnt++;
break;
}
}
for (i = 0; i < ARRAY_SIZE(bus_err_type); i++) {
if (errtype == bus_err_type[i].code) {
hal_log_err("%s, ", bus_err_type[i].msg);
switch (i) {
case 0:
phandle->status.biterrcnt++;
break;
case 1:
phandle->status.formaterrcnt++;
break;
case 2:
phandle->status.stufferrcnt++;
break;
default:
phandle->status.othererrcnt++;
break;
}
break;
}
}
for (i = 0; i < ARRAY_SIZE(bus_err_code); i++) {
if (errcode == bus_err_code[i].code) {
hal_log_err("%s\n", bus_err_code[i].msg);
break;
}
}
}
翻了手册,看到这么一段话:
错误报警阈值ERRWT将作为报警功能提示当前发生的总线错误,且在控制器进入被动错误状态之前被触发。在复位模式下,ERRWT数值可在错误报警阈值寄存器(CAN_ERRWT)中进行配置。当TEC和/或REC数值大于等于ERRWT时,ERR_STAT 被置1。当TEC 和REC 数值都小于ERRWT时, ERR_STAT被复位0。只要ERR_STAT或BUS_STAT位值发生变化,便会触发错误报警中断ERRW_INT。
当TEC和/或REC数值大于127 时,节点进入被动错误状态。当TEC和REC数值都小于等于127时,节点重新变为主动错误状态。节点在主动错误和被动错误状态之间切换时,都将触发被动错误中断ERRP_INT。
当TEC 数值大于255 时,节点进入总线关闭离线状态。此时,控制器将REC数值置为0、TEC数值置为127、BUS_STAT位置1、产生错误报警中断ERRW_INT、控制器进入复位模式。
为了返回主动错误状态,必须进行离线恢复。首先需要退出复位模式,进入正常操作模式;然后要求节点在总线上检测到128 次11 个连续隐性位。每一次检测到11 个连续隐性位时,TEC 数值都将减1,当离线恢复完成后(TEC 数值从127 减小到0),BUS_STAT位复位为0,从而触发错误报警中断ERRW_INT。
看can相关寄存器,有个CAN_MODE寄存器,0为复位模式,3为接收过滤。
irqreturn_t hal_can_isr_handler(int irq_num, void *arg)
{
u32 int_status;
can_handle *phandle = (can_handle *)arg;
int_status = readl(phandle->can_base + CAN_INTR_REG);
if (int_status & (CAN_INTR_ERRB | CAN_INTR_ARBLOST | CAN_INTR_ERRP |
CAN_INTR_WAKEUP | CAN_INTR_OVF | CAN_INTR_ERRW))
hal_can_error_handle(phandle, int_status);
if (int_status & CAN_INTR_TX) {
phandle->status.sndpkgcnt++;
if (phandle->callback)
phandle->callback(phandle, (void *)CAN_EVENT_TX_DONE);
}
if ((int_status & CAN_INTR_RX) && !(int_status & CAN_INTR_OVF)) {
hal_can_rx_frame(phandle->can_base, &phandle->msg);
if (phandle->callback)
phandle->callback(phandle, (void *)CAN_EVENT_RX_IND);
}
writel(int_status, phandle->can_base + CAN_INTR_REG);
return IRQ_HANDLED;
}
aic_hal_can.c文件里,can中断函数中,是先看状态寄存器,一旦出现错误,就先去进行错误处理。
如果d133先上电,而总线上其它设备还没上电,则也会报can发送错误,这是可以理解的,can总线上没有其它can设备是发送不成功的。但其它can设备一上电,这个发送错误就会立刻消除了。
而接收错误这里,大部分情况下会一直错下去。
烧录镜像选择分区就可以了,rodata属于只读分区,如果是需要读写的文件,放在data分区就可以了
靠群里朋友的帮助解决了。
menuconfig里,file system image0,设置的fatfs文件系统,名字是rodata.fatfs,挂载到了/rodata分区。但还有个额外选项 FATFS enable write func in spinor 需要选中,fatfs文件系统才能可写。
----------------------------------------------------------
物理分区、文件系统分区,我还是有点晕乎。
partition_tab.h里应该定义的是物理分区吧,分成了4个部分。spl分区应该是存放boot程序。os分区应该是存放编译的可执行程序。另两个应该是存放资源文件。
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WORD, "spl",FAL_USING_NOR_FLASH_DEV_NAME, 0,262144,0}, \
{FAL_PART_MAGIC_WORD, "os",FAL_USING_NOR_FLASH_DEV_NAME, 262144,2097152,0}, \
{FAL_PART_MAGIC_WORD, "rodata",FAL_USING_NOR_FLASH_DEV_NAME, 2359296,6291456,0}, \
{FAL_PART_MAGIC_WORD, "data",FAL_USING_NOR_FLASH_DEV_NAME, 8650752,7340032,0}, \
}
#endif
board.c里是文件系统分区,其中有名为/data和/rodata的文件系统分区,/rodata分区挂载的是fatfs格式的blk_rodata类型的设备,/data分区挂载的是littlefs格式的data类型的设备。
这里最糊涂了,blk_rodata怎么来的?物理分区是如何挂载到/rodata的?
#ifdef RT_USING_DFS_ROMFS
#include "dfs_romfs.h"
static const struct romfs_dirent _mountpoint_root[] =
{
{ROMFS_DIRENT_DIR, "ram", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "data", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "rodata", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "udisk", RT_NULL, 0},
};
const struct romfs_dirent romfs_root =
{
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_mountpoint_root, ARRAY_SIZE(_mountpoint_root)
};
#endif
const struct dfs_mount_tbl mount_table[] = {
#ifdef RT_USING_DFS_ROMFS
{RT_NULL, "/", "rom", 0, &romfs_root, 0},
#endif
#ifdef LPKG_RAMDISK_TYPE_INITDATA
{"ramdisk0", "/ram", "elm", 0, 0, 0},
#endif
#if (defined(AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_0) || defined(AIC_USING_FS_IMAGE_TYPE_FATFS_FOR_1))
{"blk_rodata", "/rodata", "elm", 0, 0, 0},
#endif
#ifdef LPKG_USING_LITTLEFS
{"data", "/data", "lfs", 0, 0, 0},
#endif
#ifdef LPKG_USING_DFS_UFFS
{"data", "/data", "uffs", 0, 0, 1},
#endif
#ifdef AIC_USING_SDMC1
{"sd0", "/sdcard", "elm", 0, 0, 0},
#endif
#if (defined(AIC_USING_USB0_HOST) || defined(AIC_USING_USB1_HOST))
{"udisk", "/udisk", "elm", 0, 0, 0xFF},
#endif
{0}
};
#endif
望清楚的朋友帮解惑。
比如有些图片,想传到板子上。不想把这些文件打包进烧录镜像里的话,能不能通过usb传到板子上?
使能了usb device,然后选了usb msc device,然后里面有个两个选项,ram template和storage template。
选了ram template后,win10上弹出个500k的盘符,提示要格式化,格式化后,做个修改,再重启,还提示要格式化...
选storage template模式,默认挂载路径是/sdcard,我没接sd接口,而且,想存到spi nor flash里。我看/rodata目录也是fat格式,就设置了这个目录,结果烧录后运行,提示:
[E/FAL] (blk_dev_write:106) This config only supports read!
请教,有什么办法,通过usb口,直接读写板子上spi nor flash的数据?
/* when define USE_DRAW_BUF, disp_drv.rotated can be
LV_DISP_ROT_90/LV_DISP_ROT_180/LV_DISP_ROT_270
*/
// disp_drv.rotated = LV_DISP_ROT_90;
留意注释,USE_DRAW_BUF也要使能
这个是lvgl软件旋转吧。
看 配置菜单里的 Graphics Support,应该是可以直接硬件支持旋转的吧,我想要的是这个效果。
默认的开机彩色方格,是没有使用lvgl的吧。
----------------------------------------
配置菜单里旋转180后,因为是花屏,盲点rtp校准,然后盲点屏幕上的按钮,发现调试串口发现这个警告出现了很多次。
[W] hal_ge_control()549 Invailid ioctl: 00004703
----------------------------------------
配置菜单里不旋转,lvgl里使能USR_DRAW_BUF, disp_drv.rotated = LV_DISP_ROT_180;确实能旋转了。
好奇这种旋转,有没有额外的性能开销?
但配置菜单里有这个旋转功能,还是想使用这个功能。
比如 netif_list 为空?甚至还没初始化,是个脏值。
不检查就直接访问么?
确实是这个问题,lvgl线程和lwip_test_example优先级相同,改成lwip线程优先级更高一点就没事了。
请教,netif_list没初始化时,lvgl线程调用netif_list->ip_addr为什么会卡死?因为该指针是个不正常的位置值,进行读取造成程序无法运行?
另,如何检查呢?不懂指针的检查方法?
-------------------------------
搜了下,说是c语言指针未初始化时为NULL,也就是0.
那么netif_list为0时,调用netif_list->ip_addr为什么程序会卡死?
-------------------------------
gpt回答的:
在C语言中,如果一个指针未初始化,那么访问该指针所指向的结构体变量会导致未定义的行为。这可能会导致程序崩溃、产生奇怪的结果,或者其他不可预测的行为。
未初始化的指针会包含一个未知的内存地址,当你尝试通过这个指针去访问结构体的成员时,实际上是在尝试读取一个未知内存地址的内容,这是非常危险的行为。这种行为可能导致程序崩溃,或者读取到不可预测的数据,因为该内存区域可能被其他数据所覆盖,或者根本不存在有效数据。
因此,在使用指针之前,一定要确保将其初始化为合适的值,比如将其设置为一个有效的内存地址,或者使用NULL来表示空指针。
目前用的1.0.4sdk,不旋转的话,lvgl, awtk都能运行,rtp也正常。开机默认有个彩色方格显示。
我想将屏幕旋转180,按d133-doc教程:
┌─────────────────────────────────────────────── Display Parameter ───────────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ [*] Display Support │ │
│ │ [ ] Ai PQ Tool Support │ │
│ │ select Display interface (Display RGB interface) ---> │ │
│ │ RGB interface options ---> │ │
│ │ select framebuffer format (argb8888) ---> │ │
│ │ [*] Support double framebuffer │ │
│ │ [*] Display color block │ │
│ │ framebuffer rotation degree (180) ---> │ │
│ │ Display Panels ---> │ │
│ │ panel backlight control (gpio) ---> │ │
│ │ (PE.13) panel backlight enable pin │ │
│ │ [ ] panel backlight enable pin low active │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
结果,开机的彩色放个都编程灰色混乱的了。
想在屏幕上显示本机ip,查看ifconfig命令的实现,看到是读取了全局变量netif_list或netif_default。
于是在Lvgl界面初始化里加了个label,初始化值为netif_list->ip_addr,按钮回调函数里,也更新这个label值为netif_list->ip_addr.
结果下载后第一次运行,能正常显示本机地址。但是重启后,就进不到应用程序了,串口中断也卡住不更新了。
后来发现在设置lalbe值为netif_list->ip_addr之前,加个rt_thread_mdelay(),不管多小。界面就又正常了。
请教,这是为什么?
void test_ui_init()
{
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 50, 50); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "get ip address"); /*Set the labels text*/
lv_obj_center(label);
rt_thread_mdelay(1);
labelIpaddr = lv_label_create(lv_scr_act());
lv_label_set_text_fmt(labelIpaddr, "local ip addr:0x%X", 0xaa55);
lv_label_set_text_fmt(labelIpaddr, "local ip addr: %s", ip4addr_ntoa(&netif_list->ip_addr));
lv_obj_set_pos(labelIpaddr, 200, 50);
lv_obj_set_size(labelIpaddr, 400, 50);
}
前面是dap的主控 后面是目标的主控 为了拖着烧录用的 好像是这样
我现在用的合宙的air32f103cbt6开发板,烧写的是air32f103xb_air32f103rb_if.hex。但是不光可以给ari32f103cb烧写程序,还可以给stm32f103cb, ve烧写程序,还可以给gd32f103cb, ve烧写程序。
-----------------------------
打开src/board目录下可以看到各对应的.c文件,比如stm32f072rb.c:
#include "target_family.h"
#include "target_board.h"
const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0720",
.family_id = kStub_HWReset_FamilyID,
.target_cfg = &target_device,
.board_vendor = "STMicroelectronics",
.board_name = "NUCLEO-F072RB",
};
stm32f103rb.c:
#include "target_family.h"
#include "target_board.h"
const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0001",
.family_id = kStub_HWReset_FamilyID,
.target_cfg = &target_device,
.board_vendor = "LuatOS",
.board_name = "Air32 MINI DAPLink",
};
感觉是这样的,这几个是给对应nucleo板上的stlink更新成dapllink用的。
各种nucleo板,虽然板载给用户使用的mcu有各种各样的,m3,m4,m0,l0,l4等,但上边都板载了个stm32f103cb作为stlink。
--------------------------------------
stm32f103xb_if这个工程,没有指定特定目标板,编译时报错,对比了下工程,没有包含类似stm32f103cb.c这样的目标板配置文件,算是少个参数。
MDK: CMSIS-DAP Cortex-M Target Driver Setup中的Download Function选中Erase Full Chip
试了下,不行。erase full chip可能不会擦除option bytes部分吧。
---------------------------------------------------------------------------
https://gitee.com/delbertz/openocd-toolbox
找到这么个工具,可惜不支持gd系列的。
d133,跑lvgl例程,硬件上是画了rgb888接口到lcd。然后sdk里菜单配置lcd也是rgb888, 顺序是bgr。
lvgl配置里,有个色深,只有16和32可选,我就选了32。
结果运行后,屏幕有些区域有些闪,字体看不到,或者放大发虚。
按群友配置,rgb565,色深16,就正常了。我又改成argb8888,色深32,也正常了。
rgb888的话,我的理解是正好通过24条信号线传到了屏里。那么argb8888呢?这是怎么传输的啊?lcd颜色信号线只有24条啊。
另,lcd配置里还有个data mirror选项,这个是干什么用的?
│ │ rgb mode (PRGB) ---> │ │
│ │ interface format (PRGB 24 BIT) ---> │ │
│ │ data order (BGR) ---> │ │
│ │ clock phase select (0 degree) ---> │ │
│ │ [ ] data mirror │ │
│ │
看test_rtp_draw程序,有两处xy交换,一处是校准是,画出十字光标后,获取测试点坐标,获取后,进行了次xy转换。
然后画线程序画线时,将获取的触控坐标进行xy转换,再瞄点。
按这个,在lvgl_rtp相关部分加入这两个xy交换,就可以了。
lv_tpc_rtp.c
if (data->x_coordinate > 0 || data->y_coordinate > 0) {
press_flag = 1;
rt_device_control(rtp_dev, RT_TOUCH_CTRL_SET_X_TO_Y, (void *)data);
lv_tpc_run.c
#ifdef AIC_USING_RTP
extern void lv_convert_adc_to_coord(struct rt_touch_data *data);
rt_device_control(dev, RT_TOUCH_CTRL_SET_X_TO_Y, (void *)(&(read_data[i])));
lv_convert_adc_to_coord(&read_data[i]);
#endif
请教,这里为什么要进行xy坐标交换?
Pre-Boot Program ... (24-03-28 14:17 853acea)
SPINOR
cs=0, phase=3
cs=1, phase=2
Psram_init done.
goto run SPL
tinySPL [Built on May 6 2024 15:16:22]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()133 Not find udisk.
qspi0 freq (input): 99000000Hz
qspi0 freq ( bus ): 49500000Hz
qspi0 freq ( bus ): 99000000Hz
Selecting default config 'Luban-lite firmware'
spl read: 631304 byte, 13254 us -> 46514 KB/s
spl read: 235968 byte, 5011 us -> 45986 KB/s
spl read: 8924 byte, 494 us -> 17640 KB/s
169281 : Run APP
_ _ ___ ___ _ _
/ \ _ __| |_|_ _|_ __ / __| |__ (_)_ __
/ _ \ | '__| __|| || '_ \| | | '_ \| | '_ \
/ ___ \| | | |_ | || | | | |__| | | | | |_) |
/_/ \_\_| \__|___|_| |_|\___|_| |_|_| .__/
|_|
Welcome to ArtInChip Luban-Lite 1.0 [Built on May 10 2024 11:41:54]
qspi0 freq (input): 99000000Hz
qspi0 freq ( bus ): 49500000Hz
01-01 12:13:24 I/NO_TAG: Flash ID: 0xef4018
01-01 12:13:24 I/NO_TAG: Find a Winbond flash chip. Size is 16777216 bytes.
qspi0 freq (input): 99000000Hz
qspi0 freq ( bus ): 99000000Hz
01-01 12:13:24 I/NO_TAG: norflash0 flash device is initialize success.
01-01 12:13:24 I/NO_TAG: Probe SPI flash norflash0 by SPI device qspi01 success.
[I] aic_find_panel()62 find panel driver : panel-rgb
[I] aicfb_probe()950 fb0 allocated at 0x40045920
[I] hal_ge_init()342 cmd queue hal, cmdq buffer size = 2048
[I] hal_ge_init()400 dither line phys: 0x40334180
01-01 12:13:24 I/RTP: x_plate 235 y_plate 665
01-01 12:13:24 I/touch: rt_touch init success
01-01 12:13:24 I/RTP: ArtInChip RTP loaded
01-01 12:13:24 I/WDT: ArtInChip WDT loaded
Reboot action: Watchdog-Reset, reason: Command-Reboot
Startup time: 0.473 sec
info: cmd ring buf size:1920
info: cmd ring buf size:1920
[I] rtp_get_fb_info()97 Screen width: 800, height: 480
dlk /> 01-01 12:13:39 I/RTP: Unsupported cmd: 0x1501
01-01 12:13:39 I/RTP: Unsupported cmd: 0x150b
电阻屏触控不准。
不运行lvgl程序,运行test_rtp_draw校准,然后画线,看着还算跟手,没有啥偏移。
lvgl例程里,也有触控校准部分,运行lvgl后,先执行了校准,然后进lvgl界面,但是触控偏移很大。可以左右滑动、上下滑动总是失败。
看串口信息,有两个关于rtp的警告:
Unsupported cmd: 0x1501
Unsupported cmd: 0x150b
报错如下。
bsp\artinchip\hal\syscfg\hal_syscfg.c: In function 'syscfg_gmac_init':
bsp\artinchip\hal\syscfg\hal_syscfg.c:408:42: error: 'SYSCFG_GMAC_RXDLY_SEL_SHIFT' undeclared (first use in this function); did you mean 'SYSCFG_GMAC_TXDLY_SEL_SHIFT'?
408 | cfg |= (AIC_DEV_GMAC0_RXDELAY << SYSCFG_GMAC_RXDLY_SEL_SHIFT);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| CC bsp\artinchip\sys\d13x\time.c
SYSCFG_GMAC_TXDLY_SEL_SHIFT
bsp\artinchip\hal\syscfg\hal_syscfg.c:408:42: note: each undeclared identifier is reported only once for each function it appears in
CC bsp\artinchip\sys\d13x\trap_c.c
scons: *** [output\d13x_cbs-nor_rt-thread_can2eth\bsp\artinchip\hal\syscfg\hal_syscfg.o] Error 1
scons: building terminated because of errors.
之前遇到过这个问题,忘了是怎么解决的了,好像是自己加了个这个定义。
今天更新到1.0.4后,再次编译,又遇到这个错误了。
请教,该如何解决?
Windows
请先安装 python(64 位系统要安装 64 位版本的 python),scons 和 Visual Studio C++(版本 >=2017)
如果没有安装 pywin32,请 pip 安装:
pip install pywin32
如果没有安装nodejs,请到 nodejs下载并安装。
编译运行 (在命令行模式下,进入 awtk 所在的目录,并运行下列命令):
scons
bin\demoui
---------------------------------
以上是readme里的,已安装了vsc++。
3rd\cjson\cJSON.c(40): fatal error C1083: 无法打开包括文件: “string.h”: No such file or directory
参考官方原理图画的板子,用的rtp,目前测量rtp四线,1-3间电阻值约为683欧,2-4间电阻约为210欧。宽边出线。
按如下设置。
┌──────────────────────────────────────────── RTP touch panel options ────────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ [*] Using touch panel RTP │ │
│ │ (15) The sample period of RTP(in cycle mode) │ │
│ │ (3800) The pressure threshold of RTP │ │
│ │ (683) The x-plate value of RTP touchscreen │ │
│ │ (210) The Y-plate value of RTP touchscreen │ │
│ │ (0xffff) The press detect enable debounce │ │
│ │ (0x4f00004f) The precharge delay of RTP │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
按这个配置来,校准后,任意画线只能在屏幕对角线上出现点。
如果AIC_RTP_Y_PLATE值设为0的话,在屏幕画线的画,屏幕上的点就会很分散,类似满天星。
另,AIC_RTP_MAX_PRESSURE值该如何选取?
https://blog.csdn.net/awangdea99/article/details/107227193
服务端使用tcplistener接收连接请求。客户端使用tcpclient.connect主动连接。
在一对一的情况下(1个服务端只连接1个客户端时),服务端调用client.Close()主动关闭连接后,客户端接收函数(revString = br.ReadString();)立马报异常,因此可通过捕获此异常来进行重连操作。
但是,当一对多的情况下(1个服务端同时连接多个客户端),服务端对所有的client调用client.Close()主动关闭连接后,经常有少数(一般是一个)客户端无法捕获上面的异常,因此就无法通过捕获异常来重连。
为了解决上述问题,我试了网上很多方法,都不能解决此问题:
这是通病吗?
现在感觉是我对tcp的连接/断开理解不正确。
尝试只用一个板子当作tcp client连接pc的tcp server,建立tcp连接后,pc端断开tcp server或直接关掉tcp server软件,板子作为tcp client的send()函数,都能返回-1,这和预想的一样。试验了很多次,都是这个结果。
但是当用两个板子都作为tcp client去连接pc的tcp server时,断开tcp server,两个板子的send()函数,至少有一个能返回-1。有时候两个都返回-1,有时候一个返回-1,另一个仍然返回发送的数据长度。
感觉tcp server端,不能保证和所有的tcp client实现完整的断开操作。
那么,tcp client端,就适合用send()返回值来判断tcp的连接状态。
还有其他办法来判断tcp连接状态吗?tcp client这里,我需要判断tcp连接状态退出tcp while循环,进行下一次重连操作。
list_sem看到的信号量列表里,sem加数字的这4个信号量,应该都是lwip建立的。但是不知道对应的哪几个。
src/api/tcpip.c:485: err_t err = sys_sem_new(&call->sem, 0);
src/api/sockets.c:2026: if (sys_sem_new(&API_SELECT_CB_VAR_REF(select_cb).sem, 0) != ERR_OK) {
src/api/sockets.c:2371: if (sys_sem_new(&API_SELECT_CB_VAR_REF(select_cb).sem, 0) != ERR_OK) {
src/api/api_lib.c:1318: err = sys_sem_new(API_EXPR_REF(API_VAR_REF(msg).sem), 0);
src/api/api_msg.c:752: if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) {
src/core/sys.c:139: err_t err = sys_sem_new(&delaysem, 0);
-------------------------------------
今天试验,发现断开tcp server后,板子继续tcp send()能返回发送数据长度时,不一定有信号量阻塞tcp线程。
/> list_sem
semaphore v suspend thread
---------------- --- --------------
sem126 000 1:lwip_test_exampl
sem53 000 0
sem6 000 0
sem3 000 0
can data sem 000 1:udp and tcp thre
rxSem 000 1:canRxThread
can0tl 001 0
shrx 000 0
sem0 000 1:ping_thread
qspi0_s 000 0
heap_cma 001 0
heap_sys 001 0
是这样持续了几分钟后,tcp线程才被一个信号量阻塞。
----------------------------------------------
这是sdk里网络驱动里,发送数据的底层函数:
static err_t low_level_output(struct netif *netif, struct pbuf *p)
{
aicmac_netif_t *aic_netif = (aicmac_netif_t *)netif;
struct pbuf *q;
aicmac_dma_desc_t *pdesc;
int ret = ERR_OK;
#ifndef CONFIG_MAC_ZERO_COPY_TXBUF
u8 *buffer;
uint16_t framelength = 0;
uint32_t bufferoffset = 0;
uint32_t byteslefttocopy = 0;
uint32_t payloadoffset = 0;
#else
uint32_t p_cnt = 0;
uint32_t p_type = 0;
uint32_t empty_desc_cnt = 0;
uint32_t index;
uint32_t tmpreg = 0;
uint32_t i = 0;
#endif
pr_debug("%s\n", __func__);
if ((netif == NULL) || (p == NULL)){
pr_err("%s invalid parameter.\n", __func__);
return ERR_MEM;
}
aicos_mutex_take(eth_tx_mutex, AICOS_WAIT_FOREVER);
pdesc = dctl[aic_netif->port].tx_desc_p;
/* before read: invalid cache */
aicmac_dcache_invalid((uintptr_t)pdesc, sizeof(aicmac_dma_desc_t));
#ifndef CONFIG_MAC_ZERO_COPY_TXBUF
buffer = (u8 *)(unsigned long)(pdesc->buff1_addr);
bufferoffset = 0;
for (q = p; q != NULL; q = q->next) {
if ((pdesc->control & ETH_DMATxDesc_OWN) != (u32)RESET) {
pr_err("%s no enough desc for transmit.(len = %u)\n", __func__, q->len);
ret = ERR_MEM;
goto error;
}
/* Get bytes in current lwIP buffer */
byteslefttocopy = q->len;
payloadoffset = 0;
/* Check if the length of data to copy is bigger than Tx buffer size*/
while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE) {
/* Copy data to Tx buffer*/
memcpy((u8_t *)((u8_t *)buffer + bufferoffset),
(u8_t *)((u8_t *)q->payload + payloadoffset),
(ETH_TX_BUF_SIZE - bufferoffset));
/* after write: flush cache */
aicmac_dcache_clean((uintptr_t)((u8_t *)buffer + bufferoffset),
(ETH_TX_BUF_SIZE - bufferoffset));
/* Point to next descriptor */
pdesc = (aicmac_dma_desc_t *)(unsigned long)(pdesc->buff2_addr);
/* before read: invalid cache */
aicmac_dcache_invalid((uintptr_t)pdesc, sizeof(aicmac_dma_desc_t));
/* Check if the buffer is available */
if ((pdesc->control & ETH_DMATxDesc_OWN) != (u32)RESET) {
pr_err("%s no enough desc for transmit.(len = %u)\n", __func__, q->len);
ret = ERR_MEM;
goto error;
}
buffer = (u8 *)(unsigned long)(pdesc->buff1_addr);
byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
payloadoffset = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
framelength = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
bufferoffset = 0;
}
/* Copy the remaining bytes */
memcpy((u8_t *)((u8_t *)buffer + bufferoffset),
(u8_t *)((u8_t *)q->payload + payloadoffset), byteslefttocopy);
/* after write: flush cache */
aicmac_dcache_clean((uintptr_t)((u8_t *)buffer + bufferoffset),
byteslefttocopy);
bufferoffset = bufferoffset + byteslefttocopy;
framelength = framelength + byteslefttocopy;
}
/* Prepare transmit descriptors to give to DMA*/
aicmac_submit_tx_frame(aic_netif->port, framelength);
#else
/* Count number of pbufs in a chain */
q = p;
while (q != NULL) {
if (q->len > ETH_DMATxDesc_TBS1){
pr_err("%s too large pbuf.(len = %d)\n", __func__, q->len);
ret = ERR_MEM;
goto error;
}
p_cnt++;
q = q->next;
}
/* Scan empty descriptor for DMA tx */
while (((pdesc->control & ETH_DMATxDesc_OWN) == (uint32_t)RESET) &&
(empty_desc_cnt < ETH_RXBUFNB)) {
empty_desc_cnt++;
if (empty_desc_cnt >= p_cnt)
break;
/* Point to next descriptor */
pdesc = (aicmac_dma_desc_t *)(unsigned long)(pdesc->buff2_addr);
if (pdesc == dctl[aic_netif->port].tx_desc_unconfirm_p){
pr_info("%s don't overwrite unconfirm area.\n", __func__);
break;
}
/* before read: invalid cache */
aicmac_dcache_invalid((uintptr_t)pdesc, sizeof(aicmac_dma_desc_t));
}
if (p_cnt > empty_desc_cnt){
pr_err("%s no enough desc for transmit pbuf.(pbuf_cnt = %d, empty_desc = %d)\n",
__func__, p_cnt, empty_desc_cnt);
ret = ERR_MEM;
goto error;
}
pbuf_ref(p);
q = p;
p_type = p->type_internal;
for(i=0; i<p_cnt; i++){
index = pdesc->reserved1;
if (index >= ETH_RXBUFNB){
pr_err("%s get dma desc index err.\n", __func__);
pbuf_free(p);
ret = ERR_MEM;
goto error;
}
if (i == (p_cnt-1)){
dctl[aic_netif->port].tx_buff[index] = p;
}else{
dctl[aic_netif->port].tx_buff[index] = NULL;
}
/* flush data cache */
if (p_type == PBUF_POOL){
aicmac_dcache_clean((uintptr_t)q->payload, q->len);
}else{
aicos_dcache_clean_range((unsigned long *)q->payload, q->len);
}
/* Set Buffer1 address pointer */
pdesc->buff1_addr =
(uint32_t)(unsigned long)(q->payload);
/* Set frame size */
pdesc->buff_size = (q->len & ETH_DMATxDesc_TBS1);
/* after write: flush cache */
aicmac_dcache_clean((uintptr_t)&pdesc->buff_size, 2*sizeof(uint32_t));
/*set LAST and FIRST segment */
tmpreg = ETH_DMATxDesc_TCH;
if (i == 0)
tmpreg |= ETH_DMATxDesc_FS;
if (i == (p_cnt-1))
tmpreg |= ETH_DMATxDesc_LS | ETH_DMATxDesc_IC;
/* TCP/IP Tx Checksum Insertion */
if (mac_config[aic_netif->port].coe_tx)
tmpreg |= ETH_DMATxDesc_CIC_TCPUDPICMP_Full;
/* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */
tmpreg |= ETH_DMATxDesc_OWN;
pdesc->control = tmpreg;
/* after write: flush cache */
aicmac_dcache_clean((uintptr_t)&pdesc->control, sizeof(uint32_t));
/* Point to next descriptor */
pdesc = (aicmac_dma_desc_t *)(unsigned long)(pdesc->buff2_addr);
q = q->next;
}
dctl[aic_netif->port].tx_desc_p = pdesc;
/* Resume DMA transmission */
aicmac_resume_dma_tx(aic_netif->port);
#endif
error:
/* Give semaphore and exit */
aicos_mutex_give(eth_tx_mutex);
return ret;
}
看代码,用rtt+lwip,建了两个线程,eth_rx和eth_phy_poll。
大概是这样的:
eth_phy_poll线程,检查phy状态,连上或没连上。个人感觉这里指的不是socket连接状态,可能是网线是否连通。
eth_rx线程,等待网口中断发送来的信号,根据其值,判断是接收中断,还是发送完成中断。然后进行响应处理。
实在想不出,tcp socket的连接状态,由哪里判断的。
本来两个线程,can线程和tcp线程。有时候,会发现tcp线程不再打印信息,感觉像是阻塞了。
用list_sem看,多了个sem87这个信号量,阻塞了tcp线程。但我没建这个信号量啊。
semaphore v suspend thread
---------------- --- --------------
sem220 000 1:lwip_test_exampl
sem87 000 1:udp and tcp thre
sem6 000 0
sem3 000 0
can data sem 042 0
rxSem 000 1:canRxThread
can0tl 001 0
shrx 000 0
sem0 000 1:ping_thread
qspi0_s 000 0
heap_cma 001 0
heap_sys 001 0
--------------------------------
https://club.rt-thread.org/ask/question/822103778869d33f.html
在rtt论坛也搜到了类似问题,但没找到解决办法。
貌似就是lwip创建了个信号量,阻塞住了创建socket的这个线程。
Gentlepig 说:楼主电阻屏调通了吗?我校准后总是不符,手画了个圆,结果在屏上却是个斜线。
我的电阻触摸还没调好,就算校准了也是偏差很大。
大概直到电阻触控总是校准不好的原因了。
我基本上是参考官方开发板原理图画的,rtp和ctp用的是同样4根线,官方板把两个接口都保留了。注意,ctp这里其实是i2c信号线,原理图里有4个4.7K的上拉电阻。感觉rtp不需要上拉。
我将这4个上拉电阻去掉了,在屏幕上画图形,不再是缩小或变形的图形了,但是位移很大,应该需要重新校准。
但是我执行test_rtp_draw -c,出现校准光标后,按下屏幕却不再有任何反应,像是卡死了一样...
我看楼主板子上也有这4个上拉电阻,可以考虑去掉试试。
------------------------------------------
最终还是没校准成功,暂时放弃rtp校准。
打算增加cjson软件包,结果pkgs --update报错,甚至执行pkgs --list也报错。
取消勾选cjson软件包,还是一样的报错。
> pkgs --list
Traceback (most recent call last):
File "F:\MCU\ArtinChip\luban-lite\tools\env\tools\ConEmu\ConEmu\..\..\..\tools\scripts\env.py", line 126, in <module>
main()
File "F:\MCU\ArtinChip\luban-lite\tools\env\tools\ConEmu\ConEmu\..\..\..\tools\scripts\env.py", line 122, in main
args.func(args)
File "F:\MCU\ArtinChip\luban-lite\tools\env\tools\scripts\cmds\cmd_package\__init__.py", line 45, in run_env_cmd
list_packages()
File "F:\MCU\ArtinChip\luban-lite\tools\env\tools\scripts\cmds\cmd_package\cmd_package_list.py", line 59, in list_packages
pkg_path = pkg['path']
KeyError: 'path'
看了下,是littlefs相关。是去env目录下找这个目录了,而实际目录是在sdk根目录下的/packages/third-party目录下。
请教下,这个问题该如何解决?
另,还是想找个linux下的烧录工具,不想在win下办公了。
@Gentlepig
一条斜线问题 我开始也遇到了,是x y 坐标反了造成的。我在rtp里面把 xy交换就可以了
是指x-plate值吗?我搜了下,说是电阻屏x方向上的电阻值。文档里给了个800*480电阻屏的这两个值,235、902,我试过并对换过这两个值,都没成功。
好一点的时候,是在屏幕上画个大圆,屏幕上隐约能显示出个极小的类似圆的轨迹点。
┌──────────────────────────────────────────── RTP touch panel options ────────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ [*] Using touch panel RTP │ │
│ │ (15) The sample period of RTP(in cycle mode) │ │
│ │ (800) The pressure threshold of RTP │ │
│ │ (235) The x-plate value of RTP touchscreen │ │
│ │ (0) The Y-plate value of RTP touchscreen │ │
│ │ (0xffffffff) The press detect enable debounce │ │
│ │ (0x4f00004f) The precharge delay of RTP │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
又遇到了两个问题。
连接网络后,ping局域网地址成功,ping域名失败,打开了dns功能,同样失败。这是为什么呢?
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ --- LwIP: light weight TCP/IP stack │ │
│ │ lwIP version (lwIP v2.1.3) ---> │ │
│ │ [ ] IPV6 protocol │ │
│ │ [*] LwIP Examples │ │
│ │ [ ] IGMP protocol │ │
│ │ -*- ICMP protocol │ │
│ │ [ ] SNMP protocol │ │
│ │ [*] Enble DNS for name resolution │ │
│ │ [*] Enable alloc ip address through DHCP │ │
│ │ (1) SOF broadcast │ │
│ │ (1) SOF broadcast recv │ │
│ │ -*- UDP protocol │ │
│ │ [*] TCP protocol │ │
│ └───────────────────↓(+)──────────────────────────────────────────────────────────────────────────────────────┘ │
aic /> ping www.baidu.com
Ping request could not find host www.baidu.com. Please check the name and try again
aic />
luban-lite sdk, 在ubuntu下,执行了tools/onestep.sh命令,有个ab的命令,可以直接增加个自定义的配置。
在win下,用了win_env.bat,无法执行tools/onestep.sh命令,也没有ab这个命令了,如何新增自定义配置呢?
---------------------------------
win下试了git bash,可以运行onestep.sh然后ab新增个配置。
----------------------------------
win_env.bat环境里,用scons -h可以查看更多命令,里面又--addboard命令。
-----------------------------------
用scons --add-board命令遇到了个坑,之前sdk有个这样的目录:
luban-lite\application\os\helloworld
更新又,这里变成了:
luban-lite\application\rt-thread\helloworld
luban-lite\application\freertos\helloworld
tools/scripts/aic_build.py里有个命令复制应用文件目录,就报错找不到之前的os目录。修改该.py文件,将app_os由'os'改为'rt-thread',就能正常添加自定义配置了。
----------------------------------
新增了个自定义配置后,同时打开lvgl例程和lwip例程,结果下载到板子上跳不到app。
Pre-Boot Program ... (24-01-26 17:26 a87e5e1 dirty)
SPINOR
cs=0, phase=2
cs=1, phase=1
Psram_init done.
goto run SPL
tinySPL [Built on Feb 1 2024 07:52:04]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()133 Not find udisk.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Selecting default config 'Luban-lite firmware'
spl read: 750332 byte, 15396 us -> 47592 KB/s
151172 : Run APP
关掉lvgl例程后,lwip例程才正常。
这是ram不够?或flash不够?编译时,没注意到有什么 提示。
不翻墙v2ex打不开了。
D121bav d121bbv
晕,我糊涂了。
d12x, d13x,我记错了...
我的d133板子调试遇到了问题,给点建议吧,不知道怎么搞了。
rtp屏幕校准后,画线没有跟手指。
网口部分,总是ping不通pc。
aic /> ping 192.168.1.69
aic /> ip4_output_if: ai0
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 60 | (v, hl, tos, len)
+-------------------------------+
| 0 |000| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 1 | 0x3763 | (ttl, proto, chksum)
+-------------------------------+
| 192 | 168 | 1 | 200 | (src)
+-------------------------------+
| 192 | 168 | 1 | 69 | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
[D] low_level_output()191 low_level_output
[D] low_level_output()191 low_level_output
Request timed out
---------------------------------
网口问题解决了,ping通了。
问题比较低级,rtl8201的rxdv管脚,是选焊拉高或拉低,我这里两个都焊接了,结果没配置成rmii模式。
test_rtp.c里,打开rtp这里,从中断方式改成轮询方式,就可以正常运行校准程序了。
// ret = rt_device_open(g_rtp_dev, RT_DEVICE_FLAG_INT_RX);
ret = rt_device_open(g_rtp_dev, RT_DEVICE_FLAG_RDONLY);
但是还有问题,较准时,会有这么个提示:
The RTP parameter (press detect enable debounce) is inaccurate
我将滤波时间改小了,可以完成校准设置,但是执行test_rtp_draw -d,画线时,屏幕上只在一条斜线上描点。
设置还是有问题。
-----------------------------------------
看test_rtp.c程序,应该是按中断方式设计的,设置中断回调函数。就是不知道为什么我这里设置为中断方式,总是卡死。
没看到要开adc中断啥的...
-----------------------------------------
rt-thread设置里,device driver里,使能touce device driver,并且,不要使能touch irq use pin irq。这样,编译后,test_rtp.c的device_open就正常了。
但是校准完,有个文件打不开的提示,而且,校准完画线,还是只在一条斜线上显示。
aic /> test_rtp_draw -c
[I] rtp_get_fb_info()98 Screen width: 800, height: 480
g_opened aic-rtp device
rtp calibrate start.
Top left : X = 50 Y = 50
01-01 08:00:56 I/RTP: PDEB should be configured as 0xff57ff57
Calibration: X = 463, Y = 320
Top right : X = 750 Y = 50
01-01 08:00:58 I/RTP: PDEB should be configured as 0xff57ff57
Calibration: X = 446, Y = 91
Bot right : X = 750 Y = 430
01-01 08:00:59 I/RTP: PDEB should be configured as 0xff57ff57
Calibration: X = 92, Y = 26
Bot left : X = 50 Y = 430
01-01 08:01:00 I/RTP: PDEB should be configured as 0xff57ff57
Calibration: X = 47, Y = 226
Center : X = 400 Y = 240
01-01 08:01:01 I/RTP: PDEB should be configured as 0xff57ff57
Calibration: X = 259, Y = 196
open file failed!
aic /> Try to read 1000 points from RTP ...
01-01 08:01:02 I/RTP: PDEB should be configured as 0xff57ff57
@Gentlepig
另外要看下 好像官方SDK默认是LVDS还是mipi 没有把RGB管脚全部配成RGB模式功能 需要自己加一下
屏幕点亮了。
spi flash的问题,通过将spi flash的状态寄存器清零也解决了。
rtp触摸屏没搞定,同事运行test_rtp_draw和lvgl程序,界面会闪。
然后关掉lvgl,调用test_rtp_draw -c,出现类似ts_calibrate的界面,有个小光标,但是点击没反应,调试口貌似也卡住了。
aic /> test_rtp_draw
Usage: test_rtp_draw [options]
-c, --calibrate Platform the screen calibration
-p, --points Set the points for drawing, defalut is 1000
-d, --draw Draw the shape
-h, --help
Example: test_rtp_draw -c
aic /> test_rtp_draw -h
[I] rtp_get_fb_info()98 Screen width: 800, height: 480
运行rtp_status应该是正常:
aic /> rtp_status
In RTP controller V1.00:
Mode hw 2/ sw 2, RTP enale 1, Press detect enable 1
Pressure enable 1, max 800, x-plate 235, y-plate 902
Sample period: 15 ms, Fuzz: 0
aic />
-----------------------------------------
应该是rtp设备打开这里出了问题,一直卡在这里。
if (!g_opened) {
ret = rt_device_open(g_rtp_dev, RT_DEVICE_FLAG_INT_RX);
if (ret != RT_EOK) {
rt_kprintf("Failed to open %s device\n", AIC_RTP_NAME);
return;
}
g_opened = 1;
rt_kprintf("g_opened %s device\n", AIC_RTP_NAME);
}
用list_devices命令,可以看到有aic_rtp设备的,不知道为什么会卡在rt_device_open(aic_rtp, xxx)这里。
而且,虽然卡在这里了,我在后面添加的rt_kprint语句,都不能打印出来,但是屏幕绘制还是能执行的,挺奇怪的,屏幕绘制十字光标或栅格,都是在这个rt_device_open()语句后边才开始调用的。
发现昆仑派这个板子用的是rgb接口,就编译了这个配置,下载倒板子上,屏幕有图像,就是乱的。找商家要了屏幕的资料,确定了front-porch, back-porch, sync_len这些参数,修改menuconfig里de选项的分辨率以及这些参数。屏幕显示正常了。
这里好奇,为什么之前用tina linux,uboot及内核设备树里的这些参数,和我从厂家要的都不一样,但是却能正常驱动这个屏幕?
我又按这些参数,修改nor-rtt这个配置,结果编译后,屏幕还是没有输出,rgb的clk也没信号。
我试过将昆仑派的配置参数,复制到nor-rtt这个配置里,结果问题依旧。
-------------------------------------------------
对比了下target目录下的两个配置目录下的pinmux.c文件。发现nor-rtt这边没有AIC_PRGB_16BIT_LD这个宏定义,另一边多出来些引脚配置。这些,看样子是需要自己添加了。
target目录下,分几个子目录,其实是两种,一种是官方299的那个开发板,另一个就是139的昆仑派。
299板子有lvds接口,没rgb接口,故除了target/kunlun88-nor这个目录下的pinmux.c里有rgb引脚配置,其他几个目录下的pinmux.c没有rgb引脚配置。即使在menuconfie里配置了rgb功能,而因为实际上没有初始化rgb引脚,故屏幕始终点不亮。
另今天lubanlite更新了,有了68脚的配置了,还有d12x的配置。
看了target目录下68脚的pinmux.c,里边还是比较全的,rgb24bit,rgb16bit都有。而d13x的还是之前那样...
示波器测量spi的cs管脚,发现一直有波形,而另一块板子,spc_cs一直是高电平的。
之前下载的是nor_xip程序?
------------------------------------
发现另一块可以正常烧录程序的板子,spi flash状态寄存器是:0x00
aic /> sf probe qspi01
01-01 08:01:09 I/SFUD: Flash ID: 0xef4018
01-01 08:01:09 I/SFUD: Find a Winbond flash chip. Size is 16777216 bytes.
01-01 08:01:09 I/SFUD: sf_cmd flash device is initialize success.
01-01 08:01:09 I/SFUD: Probe SPI flash sf_cmd by SPI device qspi01 success.
16 MB sf_cmd is current selected device.
aic /> sf status
The sf_cmd flash status register current value is 0x00.
aic />
通过sf status 0 0这个命令,将问题板的spi flash状态寄存器也修改为0x00,就可以继续烧录了。
问题原因不明,rtt环境下可以通过这个方法解决。裸机环境下就不知道怎么解决了。
既然这个板子无法烧录成功,就打算用rtt的sf命令擦除flash。结果没成功:
aic /> sf bench yes
Erasing the sf_cmd 16777216 bytes data, waiting...
Erase benchmark success, total time: 0.000S.
Writing the sf_cmd 16777216 bytes data, waiting...
Write benchmark success, total time: 5.279S.
Reading the sf_cmd 16777216 bytes data, waiting...
Data check ERROR! Please check you flash by other command.
Read sf_cmd failed, already rd for 0 bytes, read 256 each time
Read benchmark has an error. Error code: 3.
This flash operate has an error. Error code: 3.
aic />
查看flash状态寄存器:
aic /> sf status
The sf_cmd flash status register current value is 0xFC.
aic />
查手册,倒数第二位是写保护位,目前是0,未开启写保护。
通过sf read可以读flash内容:
Read the sf_cmd flash data success. Start from 0x00000000, size is 1000. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00000000] 41 49 43 20 45 3C 01 11 01 00 01 00 10 3B 00 00 AIC E<.......;..
[00000010] 00 00 00 00 00 00 00 00 00 00 10 30 00 01 10 30 ...........0...0
[00000020] 00 00 00 00 00 00 00 00 00 3B 00 00 10 00 00 00 .........;......
[00000030] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[00000040] C0 39 00 00 B0 00 00 00 00 01 00 00 B0 38 00 00 .9...........8..
[00000050] 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .<..............
[00000060] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[00000070] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[00000080] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[00000090] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000A0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000B0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000C0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000D0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000E0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[000000F0] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[00000100] 50 42 50 20 98 D1 9D DD 97 02 00 00 93 82 82 0F PBP ............
[00000110] 23 A0 82 00 23 A2 92 00 23 A4 22 01 23 A6 32 01 #...#...#.".#.2.
[00000120] 23 A8 42 01 23 AA 52 01 23 AC 62 01 23 AE 72 01 #.B.#.R.#.b.#.r.
[00000130] 23 A0 82 03 23 A2 92 03 23 A4 A2 03 23 A6 B2 03 #...#...#...#...
[00000140] 23 A8 22 02 23 AA 12 02 23 AC A2 02 23 AE B2 02 #.".#...#...#...
通过sf write写,写0或者写0xff,再读出来,还是上边这些数据。
写不成功,但又没开启写保护,奇怪了。
---------------------------------------------------
有问题的这个板子,通过rtt的sf status命令,可以读spi flash的状态寄存器,是0xFC,而另一个正常的板子,读出来是0x00.
通过sf status 0 0 将状态寄存器也改为0x00,然后就可以正常烧录了。
这是解决办法,问题的原因不明。另,如果烧录的不是rtt版本的程序,不知道该用什么办法来解决了。
@sjshe3326
我用的nor-flash-rtt那个,在win下是lunch 6。
找到了t113的tina sdk里的uboot和内核的设备树,看了下800*480屏幕的配置参数。因为t113-s3能点亮这个7寸屏,就参照这个了。
&lcd0 {
lcd_used = <1>;
lcd_driver_name = "default_lcd";
lcd_if = <0>;
lcd_x = <800>;
lcd_y = <480>;
lcd_width = <150>;
lcd_height = <94>;
lcd_dclk_freq = <48>;
lcd_pwm_used = <1>;
lcd_pwm_ch = <7>;
lcd_pwm_freq = <10000>;
lcd_pwm_pol = <1>;
lcd_hbp = <55>;
lcd_ht = <1240>;
lcd_hspw = <20>;
lcd_vbp = <35>;
lcd_vt = <650>;
lcd_vspw = <10>;
lcd_lvds_if = <0>;
lcd_lvds_colordepth = <1>;
lcd_lvds_mode = <0>;
lcd_frm = <0>;
lcd_io_phase = <0x0000>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
屏幕配置这里,估计裸机和os没区别吧,目前menuconfig里这么配置:
┌──────────────────────────────────────── display timing of simple panel ─────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ (48) pixelclock in MHZ │ │
│ │ (800) hactive │ │
│ │ (480) vactive │ │
│ │ (55) hback-porch │ │
│ │ (1240) hfront-porch │ │
│ │ (20) hsync-len │ │
│ │ (35) vback-porch │ │
│ │ (650) vfront-porch │ │
│ │ (10) vsync-len │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌───────────────────────────────────────────── RGB interface options ─────────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ rgb mode (PRGB) ---> │ │
│ │ interface format (PRGB 24 BIT) ---> │ │
│ │ data order (RGB) ---> │ │
│ │ clock phase select (0 degree) ---> │ │
│ │ [*] data mirror │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────── Display Parameter ───────────────────────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters │
│ are hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> │
│ for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > module capable │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ [*] Display Support │ │
│ │ select Display interface (Display RGB interface) ---> │ │
│ │ RGB interface options ---> │ │
│ │ select framebuffer format (rgb888) ---> │ │
│ │ [*] Support double framebuffer │ │
│ │ [*] Display color block │ │
│ │ framebuffer rotation degree (0) ---> │ │
│ │ Display Panels ---> │ │
│ │ panel backlight control (gpio) ---> │ │
│ │ (PE.13) panel backlight enable pin │ │
│ │ [ ] panel backlight enable pin low active │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
通过示波器,测量lcd屏幕的40pin接口,各引脚均无发现变化的波形。据说clk应该有波形才对。
另,我目前更换spi flash的那块板,又出现了2秒烧录的问题了。更换回之前换下的那个spi flash,问题依旧。总不能出现了,就换个新的spi flash。
能否通过QQ请教下?我在群主的别墅群里,也在芒果的群里。
之前有问题的第一块板,昨天和其他一块单片机板调换了w25q128,调换后,d133可以正常烧录了,另一块单片机板,也可以通过命令读取flash型号,可以擦除flash。
然后这块d133板,昨天又调试lcd和can功能,反复烧录了很多次。今天上午也能烧录来着,临近中午,突然不能烧录了,和之前一样,2秒下载完成,显示成功,实际未烧录进去。
因为之前换下来的那个w25q128可以在其他板子上正常工作,就把该w25q128整片擦除后,又换回到这个板子上了。结果,还是2秒烧录...
------------------------------------------
目前手头两块板,第一块板:来回换过2次w25q128,目前无法正常烧录。
1.2V纹波较大,400mV, 3.3V纹波也比较大,但是看频率没1.2V那么多尖刺。1.8V纹波很小,100mV多些。
第二块板,始终未更换过w25q128,一直可以正常烧录。
3路电压都有较大纹波,大概400mV左右,只是1.2V纹波的尖刺更频繁,1.8V和3.3V尖刺明显少很多。
两块板应该烧录的都是相同的镜像文件。
记录一下,另一块板子,第一次烧录,用了26秒,烧录时也有上边那两个报错,看样子这两个报错不影响烧录。
[debug] Software Version: "1.3.6"
[debug] Machine Name: "DESKTOP-HQF1R40"
[debug] System Name: "Windows 10 (10.0)"
[debug] CPU Architecture: "x86_64"
[debug] Parse the image header from "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img"
[debug] Soc type: "d13x"
[debug] Board type: "demo88-nor"
[debug] Image version: "1.0.0"
[debug] Storage type: "spi-nor"
[debug] Storage ID: ""
[debug] Meta count: "5"
[debug] Refresh the partition tree ...
[debug] Part name: image.target.spl , size: 130320
[debug] Part name: image.target.os , size: 699868
[debug] Part name: image.target.rodata , size: 2093056
[debug] Current connect type: 0
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some device arrival or removed 32768
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] Current file path: "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img"
[debug] Parse the image header from "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img"
[debug] Soc type: "d13x"
[debug] Board type: "demo88-nor"
[debug] Image version: "1.0.0"
[debug] Storage type: "spi-nor"
[debug] Storage ID: ""
[debug] Meta count: "5"
[debug] Refresh the partition tree ...
[debug] Part name: image.target.spl , size: 130320
[debug] Part name: image.target.os , size: 699740
[debug] Part name: image.target.rodata , size: 2093056
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to connect the ArtInChip device "1:3-2" ...
[debug] Try to get Usb device hd info...
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Get Usb device hd info success
[debug] The status of ArtInChip device: true
[debug] Start burn online ...
[debug] Progress range: 0 ~ 3055616
[debug] Burn Image file "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img" ...
[debug] Meta 0 image.updater.spl , size 130320 ...
[debug] Blocksize 4 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 4608 Size: 130320
[debug] Dev "1:3-2" Send the rest data 130320
[error] aicupg_trans_recv_pkt()208: CSW size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_final()777: Recv resp failed, expect 16, got 0
[debug] Don't check the result of image.updater.spl
[debug] Meta 1 image.info , size 2048 ...
[error] aicupg_trans_send_pkt()80: CBW tag 0x51, size 0, Pipe error(-9)
[error] aicupg_cmd_get_hwinfo()106: Send command failed. ret = 0, siz = 16
[debug] Wait to reconnect dev "1:3-2"
[debug] WinEvent: Some devnode changed
[debug] QTime("07:28:38.930") Wait for Dev "1:3-2" ready
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[warn ] Set upg work mode: 0
[debug] Blocksize 1 , chunk 1048576 * 0 , rest 2048
[debug] Offset: 0 Size: 2048
[debug] Dev "1:3-2" Send the rest data 2048
[debug] Meta 2 image.target.spl , size 130320 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 135680 Size: 130320
[debug] Dev "1:3-2" Send the rest data 130320
[debug] Meta 3 image.target.os , size 699740 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 699740
[debug] Offset: 266752 Size: 699740
[debug] Dev "1:3-2" Send the rest data 699740
[debug] Meta 4 image.target.rodata , size 2093056 ...
[debug] Blocksize 2048 , chunk 1048576 * 1 , rest 1044480
[debug] Offset: 967168 Size: 2093056
[debug] Dev "1:3-2" Send chunk 0 ...
[debug] Dev "1:3-2" Send the rest data 1044480
[error] aicupg_trans_send_pkt()104: CSW tag 0xaa, size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_update()741: Send out data length is not expected. ret = 0
[error] Dev "1:3-2" Failed to send data 1044480
[error] Dev "1:3-2" Failed to send 1044480
[debug] Update "fail_cnt" of "2024-01-24"
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
-----------------------------------------
第一次下载的程序里,main函数里我加入了while循环里面定时打印信息,在串口可以看到。
修改了程序,把这部分注释掉,编译,再次下载,花费了38秒,显示烧录成功。
但是调试口这里,启动后,无法输入命令。
烧录信息:
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to connect the ArtInChip device "1:3-2" ...
[debug] Try to get Usb device hd info...
[debug] Get Usb device hd info success
[debug] The status of ArtInChip device: true
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Start burn online ...
[debug] Progress range: 0 ~ 3055616
[debug] Burn Image file "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img" ...
[debug] Meta 0 image.updater.spl , size 130320 ...
[debug] Blocksize 4 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 4608 Size: 130320
[debug] Dev "1:3-2" Send the rest data 130320
[error] aicupg_trans_recv_pkt()208: CSW size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_final()777: Recv resp failed, expect 16, got 0
[debug] Don't check the result of image.updater.spl
[debug] Meta 1 image.info , size 2048 ...
[error] aicupg_trans_send_pkt()80: CBW tag 0xfc, size 0, Pipe error(-9)
[error] aicupg_cmd_get_hwinfo()106: Send command failed. ret = 0, siz = 16
[debug] Wait to reconnect dev "1:3-2"
[debug] QTime("07:34:42.769") Wait for Dev "1:3-2" ready
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[warn ] Set upg work mode: 0
[debug] Blocksize 1 , chunk 1048576 * 0 , rest 2048
[debug] Offset: 0 Size: 2048
[debug] Dev "1:3-2" Send the rest data 2048
[debug] Meta 2 image.target.spl , size 130320 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 135680 Size: 130320
[debug] Dev "1:3-2" Send the rest data 130320
[debug] Meta 3 image.target.os , size 699804 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 699804
[debug] Offset: 266752 Size: 699804
[debug] Dev "1:3-2" Send the rest data 699804
[debug] Meta 4 image.target.rodata , size 2093056 ...
[debug] Blocksize 2048 , chunk 1048576 * 1 , rest 1044480
[debug] Offset: 967168 Size: 2093056
[debug] Dev "1:3-2" Send chunk 0 ...
[debug] Dev "1:3-2" Send the rest data 1044480
[debug] Burn online successfully!
[debug] Update "success_cnt" of "2024-01-24"
[debug] Reboot the device ...
[debug] WinEvent: Some devnode changed
[debug] No device available
[error] aicupg_trans_send_pkt()104: CSW tag 0x169, size 0, Pipe error(-9)
启动信息:
Pre-Boot Program ... (2023-11-14 13:46:14)
SPINOR
tinySPL [Built on Jan 24 2024 07:25:45]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()137 Not find udisk.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Selecting default config 'Luban-lite firmware'
spl read: 699248 byte, 32788 us -> 20826 KB/s
151691 : Run APP
_ _ ___ ___ _ _
/ \ _ __| |_|_ _|_ __ / __| |__ (_)_ __
/ _ \ | '__| __|| || '_ \| | | '_ \| | '_ \
/ ___ \| | | |_ | || | | | |__| | | | | |_) |
/_/ \_\_| \__|___|_| |_|\___|_| |_|_| .__/
|_|
Welcome to ArtInChip Luban-Lite 1.0 [Built on Jan 24 2024 07:26:41]
qspi0 freq (input): 1000000Hz
qspi0 freq ( bus ): 50000000Hz
01-01 08:05:25 I/SFUD: Flash ID: 0xef4018
01-01 08:05:25 I/SFUD: Find a Winbond flash chip. Size is 16777216 bytes.
qspi0 freq (input): 1000000Hz
qspi0 freq ( bus ): 1000000Hz
01-01 08:05:25 I/SFUD: norflash0 flash device is initialize success.
01-01 08:05:25 I/SFUD: Probe SPI flash norflash0 by SPI device qspi01 success.
[I] aic_find_panel()56 find panel driver : panel-lvds
[I] aicfb_probe()809 fb0 allocated at 0x40010360
[I] hal_ge_init()320 cmd queue hal, cmdq buffer size = 2048
[I] hal_ge_init()377 dither line phys :0X040268c00
[I] hal_ge_init()385 hal_ge_init() end
[I] aic_sdmc_clk_init()543 SDMC1 sclk: 49500 KHz, parent clk 792000 KHz
01-01 08:05:25 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
[I] aic_sdmc_probe()636 SDMC1 driver loaded
01-01 08:05:25 I/WDT: ArtInChip WDT loaded
packages\third-party\littlefs\lfs.c:1210:error: Corrupted dir pair at {0x0, 0x1}
01-01 08:05:25 E/DFS: mount fs[lfs] on /data failed.
01-01 08:05:25 E/DFS: mount fs[elm] on /sdcard failed.
01-01 08:05:25 E/DFS: mount fs[elm] on /sdcard failed.
Reboot action: Warm-Reset, reason: External-Reset
Startup time: 0.366 sec
info: cmd ring buf size:1920
info: cmd ring buf size:1920
can't find device:gt911
aic /> 01-01 08:05:25 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
-----------------------------------
又反复烧录了几次,这个第二块板,均能正常烧录,烧录时间一般在38秒左右。
板子有3路dc/dc供电,boot及app配置里,均关掉了ldo1x和ldo18的输出。
usb供电,测量3.3V,1.8V, 1.1V,纹波都有点大,在400mV左右,这次画板dc/dc电路部分没处理好。
--------------------------------------
第一块板,更换两个w25q128,又可以正常烧录了,反复烧录了几个img文件,都能成功每次烧录也大都时30多秒。
不知道之前失败的原因了。
换下来的w25q128, 换到了个另一个单片机板上,可以正常擦除。
还有个问题,我用putty连的板子的调试口,如果打开putty串口的情况下,重启板子,比如reboot命令,或烧写程序,有很大机率putty串口无法输入。重新插拔usb转ttl则大概率变回可能输入的状态。而且,当插拔usb转ttl时,aiburn调试记录有信息:
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some device arrival or removed 32772
[debug] WinEvent: Some device arrival or removed 32772
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some device arrival or removed 32768
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some device arrival or removed 32768
我将1.1V dc/dc的使能管脚的电阻去掉,此时dc/dc应该不工作了,测量1.1V这里,测试出1.2V电压,但是不稳定,应该是启动后按配置关闭ldo1x输出,然后反复重启。
让芯片进入boot状态,此时1.2V稳定了,那么怀疑是boot状态,默认ldo1x输出1.2V。而我的dc/dc供电是1.1V,这样上电时,dc/dc输出有1.2V电压,让dc/dc没稳定工作,造成了很大的纹波?
另,几个默认配置,都是关闭LDO1X,打开LDO18,而且LDO18配置为7,查手册,7对应是1.92V,3才是1.80V。
另,虽然LDO1X默认没打开,但是打开后,默认配置为6,6对应1.20V, 4才对应1.10V.
猜测,boot状态下,ldo1x和ldo18都是打开的,而且电压是1.20V和1.92V,都比推荐的外部供电电压值高。
----------------------------------------------------------
我将dc/dc1.1V使能,更改电阻使输出变为1.2V。结果上电后,虽然能进系统,但是示波器测量1.2V还是有很大的纹波。
烧录功能虽然显示success,但实际运行的还是之前的程序。
------------------------------------------------------
3.3V 纹波410mV
1.8V 纹波170mV
1.2V 纹波410mV
dc/dc电路布局有问题?我测量了下之前画的t113-s3板子,3路dc/dc电路输出纹波大概在130mV左右。都没这么高。
两个板子的dc/dc部分,都是用的sy8088,布局基本没变。
以上情况,是两个板子都用同一个usb供电时测得的。
@Gentlepig
不知道我买的SY8088iaac 有问题还是怎么的 有两片1.8V有问题,之前3.3V 好好的,也坏掉了均出现烧录失败的问题 都是供电导致的
你遇到的烧录失败,是烧录时就提示失败?还是烧录提示成功,运行其实还是之前程序?
我用的也是sy8088,嘉立创贴的。我这部分dc/dc电路,和其他板子上的布局差不多。其他板子都能正常运行的。
这个d133板子到手后,我也是先测量了各路电压正常后,才开始烧录程序的。
---------------------------------------
用示波器测量了下,dc/dc 1.1V纹波相当的大,是负载太重或者太轻?。目前关闭了芯片自身的ldo18和ldo1x输出。
usb烧录时,会有这两个报错:
[debug] Meta 0 image.updater.spl , size 130320 ...
[debug] Blocksize 4 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 4608 Size: 130320
[debug] Dev "1:3-1" Send the rest data 130320
[error] aicupg_trans_recv_pkt()208: CSW size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_final()777: Recv resp failed, expect 16, got 0
[debug] Don't check the result of image.updater.spl
[debug] Meta 1 image.info , size 2048 ...
[error] aicupg_trans_send_pkt()80: CBW tag 0x654, size 0, Pipe error(-9)
[error] aicupg_cmd_get_hwinfo()106: Send command failed. ret = 0, siz = 16
[debug] Wait to reconnect dev "1:3-1"
[debug] QTime("06:35:22.073") Wait for Dev "1:3-1" ready
-------------------------------
怀疑是spi的问题。
看了下,spi0的cs,wp,hold三个管脚各接10k电阻上拉到3.3V。spi线没有走灯长,不过spi flash离d133很近,线走的不长。
我以为是spi0设置速度的问题,看了下,默认是100M最大速度,我修改成了1M最大速度,没效果。
-------------------------------
怀疑是ldo电压的问题。
又看论坛其他网友又通过配置ldo1x和ldo18解决的,看了下默认配置,默认打开ldo18(7)关闭ldo1x的。
修改为,打开ldo1x(4),打开ldo18(3),没效果。
修改为,关闭ldo1x,打开ldo18(3),没效果。
修改为,关闭ldo1x,关闭ldo18,无没效果。
我板子是有独立的dc/dc电路提供1.8V和1.1V的,基本是参考官方的那个图纸画的。
我也遇到了类似问题,gitee上下载的1.36,板子是d133cbs, w25q128, 编译时,lunch 4, m, lunch6, m.
第一次烧录需要39s。
现在每次烧录是2s,显示成功了,但是我修改源码,在application/os/helloword/main.c,加入了while(1)循环,里面加了些rt_kprintf()语句,然后调用rt_thread_delay(1000),觉得应该是每秒打印信息,结果烧录后却没有。
感觉只是执行了第一次烧录的程序,后来的烧录显示成功,但实际上没烧录进去...
int main(void)
{
#ifdef AIC_AB_SYSTEM_INTERFACE
char target[32] = { 0 };
aic_ota_status_update();
aic_get_rodata_to_mount(target);
printf("Mount APP in blk %s\n", target);
if (dfs_mount(target, "/rodata", "elm", 0, 0) < 0)
printf("Failed to mount elm\n");
#endif
while(1)
{
// rt_kprintf("-------------------");
// rt_kprintf("app started.");
// rt_kprintf("-------------------");
printf("-------------------");
printf("app started.");
printf("-------------------");
rt_thread_delay(1000);
rt_thread_delay(1000);
}
return 0;
}
ps显示线程列表,看到有gt911和alarmsvc线程,找到这两个的启动相关注释掉:
// INIT_DEVICE_EXPORT(rt_hw_gt911_port);
// INIT_PREV_EXPORT(rt_alarm_system_init);
结果烧录后,ps里还能看到这两个.
启动信息如下:
tinySPL [Built on Jan 22 2024 08:57:26]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()137 Not find udisk.
Reboot action: Warm-Reset, reason: External-Reset
Firmware Component:
name: image.info
partition:
attr: required
Media: RAM(0)
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Firmware Component:
name: image.target.spl
partition: spl
attr: mtd;required
Media: SPI_NOR(3)
Firmware Component:
name: image.target.os
partition: os
attr: mtd;required
Media: SPI_NOR(3)
Firmware Component:
name: image.target.rodata
partition: rodata
attr: mtd;optional
Media: SPI_NOR(3)
Going to reboot ...
Pre-Boot Program ... (2023-11-14 13:46:14)
SPINOR
tinySPL [Built on Jan 20 2024 14:53:02]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()137 Not find udisk.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Selecting default config 'Luban-lite firmware'
spl read: 691324 byte, 32423 us -> 20822 KB/s
153713 : Run APP
_ _ ___ ___ _ _
/ \ _ __| |_|_ _|_ __ / __| |__ (_)_ __
/ _ \ | '__| __|| || '_ \| | | '_ \| | '_ \
/ ___ \| | | |_ | || | | | |__| | | | | |_) |
/_/ \_\_| \__|___|_| |_|\___|_| |_|_| .__/
|_|
Welcome to ArtInChip Luban-Lite 1.0 [Built on Jan 20 2024 14:53:25]
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
01-01 09:03:50 I/SFUD: Flash ID: 0xef4018
01-01 09:03:50 I/SFUD: Find a Winbond flash chip. Size is 16777216 bytes.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 100000000Hz
01-01 09:03:50 I/SFUD: norflash0 flash device is initialize success.
01-01 09:03:50 I/SFUD: Probe SPI flash norflash0 by SPI device qspi01 success.
01-01 09:03:50 I/touch: rt_touch init success
01-01 09:03:50 I/gt911: touch device gt911 init success
[I] aic_find_panel()56 find panel driver : panel-lvds
[I] aicfb_probe()809 fb0 allocated at 0x40010360
[I] hal_ge_init()320 cmd queue hal, cmdq buffer size = 2048
[I] hal_ge_init()377 dither line phys :0X040268c00
[I] hal_ge_init()385 hal_ge_init() end
[I] aic_sdmc_clk_init()543 SDMC1 sclk: 49500 KHz, parent clk 792000 KHz
01-01 09:03:50 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
[I] aic_sdmc_probe()636 SDMC1 driver loaded
01-01 09:03:50 I/WDT: ArtInChip WDT loaded
packages/third-party/littlefs/lfs.c:1210:error: Corrupted dir pair at {0x0, 0x1}
01-01 09:03:50 E/DFS: mount fs[lfs] on /data failed.
01-01 09:03:50 E/DFS: mount fs[elm] on /sdcard failed.
01-01 09:03:50 E/DFS: mount fs[elm] on /sdcard failed.
Reboot action: Watchdog-Reset, reason: Command-Reboot
Startup time: 0.442 sec
info: cmd ring buf size:1920
info: cmd ring buf size:1920
01-01 09:03:50 E/gt911: read id failed
id = GT526753
01-01 09:03:50 E/gt911: read info failed
range_x = 0
range_y = 0
point_num = 101
aic /> 01-01 09:03:50 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
01-01 09:03:51 E/gt911: read info failed
aic /> ps
thread pri status sp stack size max used left tick error
---------------- --- ------- ---------- ---------- ------ ---------- ---
gt911 25 suspend 0x000001d8 0x00001000 17% 0x00000004 OK
LVGL 20 ready 0x000003a8 0x00008000 09% 0xfffff88f OK
tshell 20 running 0x000003b8 0x00001000 23% 0x00000009 OK
mmcsd_detect 22 suspend 0x00000218 0x00002000 10% 0x0000000d OK
alarmsvc 10 suspend 0x000001d8 0x00000800 23% 0x00000005 OK
tidle0 31 ready 0x000001b8 0x00000400 46% 0x00000002 OK
timer 4 suspend 0x00000198 0x00000200 79% 0x00000008 OK
aic />
RT-Thread shell commands:
list_fd - list file descriptor
ulog_filter - Show ulog filter settings
ulog_kw - Set ulog global filter keyword
ulog_tag - Set ulog global filter tag
ulog_lvl - Set ulog global filter level.
ulog_tag_lvl - Set ulog filter level by different tag.
ulog_be_lvl - Set ulog filter level by different backend.
sensor - sensor test function
sensor_polling - Sensor polling mode test function
sensor_int - Sensor interrupt mode test function
sensor_fifo - Sensor fifo mode test function
fal - FAL (Flash Abstraction Layer) operate.
tail - print the last N - lines data of the given file
echo - echo string to file
df - disk free
umount - Unmount device from file system
mount - mount <device> <mountpoint> <fstype>
mkfs - format disk with file system
mkdir - Create the DIRECTORY.
pwd - Print the name of the current working directory.
cd - Change the shell working directory.
rm - Remove(unlink) the FILE(s).
cat - Concatenate FILE(s)
mv - Rename SOURCE to DEST.
cp - Copy SOURCE to DEST.
ls - List information about the FILEs.
free - Show the memory usage in the system.
ps - List threads in the system.
help - RT-Thread shell help.
list - list objects
list_device - list device in system
list_timer - list timer in system
list_mempool - list memory pool in system
list_memheap - list memory heap in system
list_msgqueue - list message queue in system
list_mailbox - list mail box in system
list_mutex - list mutex in system
list_event - list event in system
list_sem - list semaphore in system
list_thread - list thread
version - show RT-Thread version information
clear - clear the terminal screen
mem_test - memory test: mem_test address_hex size_hex
reboot - Reboot the system
f - run a function
m - modify memory
p - print memory
arecord - record voice to a wav file
aplay - play wav file
top - cpu usage
dma_dump - Dump DMA register. Argument: channel_num
efuse - efuse command
wdt_status - Show the status of Watchdog
aicupg - Reboot to the upgrade mode
list_irq - list system irq
adc - adc [option]
pin - pin [option]
pwm - pwm [option]
lptimer_dump - soft lptimer dump
pm_dump - dump power management status
pm_run - switch power management run mode
pm_module_delay - module request delay sleep
pm_module_reques - request power management mode
pm_module_releas - release power management mode count
pm_module_releas - release module power mode
pm_request - request power management mode
pm_release_all - release power management mode count
pm_release - release power management mode
list_alarm - list alarm info
date - get date and time or set (local timezone) [year month day hour min sec]
sf - SPI Flash operate
ge_format - ge format test
ge_fill - ge fill test
ge_bitblt - ge bitblit test
ge_rotate - ge rotate test
pic_test - picture decode test
ge_dither - ge dithe test
ge_scan_order - ge scan test
ge_alpha_blendin - ge alpha test
ge_scale - ge scale test
pic_crop_test - pic crop test
aic />
烧录信息如下:
[debug] Software Version: "1.3.6"
[debug] Machine Name: "DESKTOP-HQF1R40"
[debug] System Name: "Windows 10 (10.0)"
[debug] CPU Architecture: "x86_64"
[debug] Parse the image header from "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img"
[debug] Soc type: "d13x"
[debug] Board type: "demo88-nor"
[debug] Image version: "1.0.0"
[debug] Storage type: "spi-nor"
[debug] Storage ID: ""
[debug] Meta count: "5"
[debug] Refresh the partition tree ...
[debug] Part name: image.target.spl , size: 130320
[debug] Part name: image.target.os , size: 698716
[debug] Part name: image.target.rodata , size: 2093056
[debug] Current connect type: 0
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to connect the ArtInChip device "1:3-1" ...
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to get Usb device hd info...
[debug] Get Usb device hd info success
[debug] The status of ArtInChip device: true
[debug] Start burn online ...
[debug] Progress range: 0 ~ 3055616
[debug] Burn Image file "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img" ...
[debug] Meta 0 image.updater.spl , size 130320 ...
[debug] Blocksize 4 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 4608 Size: 130320
[debug] Dev "1:3-1" Send the rest data 130320
[error] aicupg_trans_recv_pkt()208: CSW size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_final()777: Recv resp failed, expect 16, got 0
[debug] Don't check the result of image.updater.spl
[debug] Meta 1 image.info , size 2048 ...
[error] aicupg_trans_send_pkt()80: CBW tag 0x51, size 0, Pipe error(-9)
[error] aicupg_cmd_get_hwinfo()106: Send command failed. ret = 0, siz = 16
[debug] Wait to reconnect dev "1:3-1"
[debug] QTime("02:21:30.613") Wait for Dev "1:3-1" ready
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[warn ] Set upg work mode: 0
[debug] Blocksize 1 , chunk 1048576 * 0 , rest 2048
[debug] Offset: 0 Size: 2048
[debug] Dev "1:3-1" Send the rest data 2048
[debug] Meta 2 image.target.spl , size 130320 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 135680 Size: 130320
[debug] Dev "1:3-1" Send the rest data 130320
[debug] Meta 3 image.target.os , size 698716 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 698716
[debug] Offset: 266752 Size: 698716
[debug] Dev "1:3-1" Send the rest data 698716
[debug] Meta 4 image.target.rodata , size 2093056 ...
[debug] Blocksize 2048 , chunk 1048576 * 1 , rest 1044480
[debug] Offset: 967168 Size: 2093056
[debug] Dev "1:3-1" Send chunk 0 ...
[debug] Dev "1:3-1" Send the rest data 1044480
[debug] Burn online successfully!
[debug] Insert statistic of "2024-01-23"
[debug] Reboot the device ...
[error] aicupg_trans_send_pkt()104: CSW tag 0xbe, size 0, Pipe error(-9)
[debug] WinEvent: Some devnode changed
[debug] No device available
d133cbs + w25q128.
忘了第一次烧录需要多久时间了,现在每次烧录是2s,显示成功了,但是我修改源码,在application/os/helloword/main.c,加入了while(1)循环,里面加了些rt_kprintf()语句,然后调用rt_thread_delay(1000),觉得应该是每秒打印信息,结果烧录后却没有。
int main(void)
{
#ifdef AIC_AB_SYSTEM_INTERFACE
char target[32] = { 0 };
aic_ota_status_update();
aic_get_rodata_to_mount(target);
printf("Mount APP in blk %s\n", target);
if (dfs_mount(target, "/rodata", "elm", 0, 0) < 0)
printf("Failed to mount elm\n");
#endif
while(1)
{
// rt_kprintf("-------------------");
// rt_kprintf("app started.");
// rt_kprintf("-------------------");
printf("-------------------");
printf("app started.");
printf("-------------------");
rt_thread_delay(1000);
rt_thread_delay(1000);
}
return 0;
}
ps显示线程列表,看到有gt911和alarmsvc线程,找到这两个的启动相关注释掉:
// INIT_DEVICE_EXPORT(rt_hw_gt911_port);
// INIT_PREV_EXPORT(rt_alarm_system_init);
结果烧录后,ps里还能看到这两个.
启动信息如下:
tinySPL [Built on Jan 22 2024 08:57:26]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()137 Not find udisk.
Reboot action: Warm-Reset, reason: External-Reset
Firmware Component:
name: image.info
partition:
attr: required
Media: RAM(0)
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Firmware Component:
name: image.target.spl
partition: spl
attr: mtd;required
Media: SPI_NOR(3)
Firmware Component:
name: image.target.os
partition: os
attr: mtd;required
Media: SPI_NOR(3)
Firmware Component:
name: image.target.rodata
partition: rodata
attr: mtd;optional
Media: SPI_NOR(3)
Going to reboot ...
Pre-Boot Program ... (2023-11-14 13:46:14)
SPINOR
tinySPL [Built on Jan 20 2024 14:53:02]
[W] usbh_get_connect_id()107 usb 0 port change wait failed.
[E] main()137 Not find udisk.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
qspi0 freq ( bus ): 100000000Hz
Selecting default config 'Luban-lite firmware'
spl read: 691324 byte, 32423 us -> 20822 KB/s
153713 : Run APP
_ _ ___ ___ _ _
/ \ _ __| |_|_ _|_ __ / __| |__ (_)_ __
/ _ \ | '__| __|| || '_ \| | | '_ \| | '_ \
/ ___ \| | | |_ | || | | | |__| | | | | |_) |
/_/ \_\_| \__|___|_| |_|\___|_| |_|_| .__/
|_|
Welcome to ArtInChip Luban-Lite 1.0 [Built on Jan 20 2024 14:53:25]
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 50000000Hz
01-01 09:03:50 I/SFUD: Flash ID: 0xef4018
01-01 09:03:50 I/SFUD: Find a Winbond flash chip. Size is 16777216 bytes.
qspi0 freq (input): 100000000Hz
qspi0 freq ( bus ): 100000000Hz
01-01 09:03:50 I/SFUD: norflash0 flash device is initialize success.
01-01 09:03:50 I/SFUD: Probe SPI flash norflash0 by SPI device qspi01 success.
01-01 09:03:50 I/touch: rt_touch init success
01-01 09:03:50 I/gt911: touch device gt911 init success
[I] aic_find_panel()56 find panel driver : panel-lvds
[I] aicfb_probe()809 fb0 allocated at 0x40010360
[I] hal_ge_init()320 cmd queue hal, cmdq buffer size = 2048
[I] hal_ge_init()377 dither line phys :0X040268c00
[I] hal_ge_init()385 hal_ge_init() end
[I] aic_sdmc_clk_init()543 SDMC1 sclk: 49500 KHz, parent clk 792000 KHz
01-01 09:03:50 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
[I] aic_sdmc_probe()636 SDMC1 driver loaded
01-01 09:03:50 I/WDT: ArtInChip WDT loaded
packages/third-party/littlefs/lfs.c:1210:error: Corrupted dir pair at {0x0, 0x1}
01-01 09:03:50 E/DFS: mount fs[lfs] on /data failed.
01-01 09:03:50 E/DFS: mount fs[elm] on /sdcard failed.
01-01 09:03:50 E/DFS: mount fs[elm] on /sdcard failed.
Reboot action: Watchdog-Reset, reason: Command-Reboot
Startup time: 0.442 sec
info: cmd ring buf size:1920
info: cmd ring buf size:1920
01-01 09:03:50 E/gt911: read id failed
id = GT526753
01-01 09:03:50 E/gt911: read info failed
range_x = 0
range_y = 0
point_num = 101
aic /> 01-01 09:03:50 I/SDMC: SDMC1 BW 1, sclk 49500 KHz, clk 400 KHz(399 KHz), div 2-62
01-01 09:03:51 E/gt911: read info failed
aic /> ps
thread pri status sp stack size max used left tick error
---------------- --- ------- ---------- ---------- ------ ---------- ---
gt911 25 suspend 0x000001d8 0x00001000 17% 0x00000004 OK
LVGL 20 ready 0x000003a8 0x00008000 09% 0xfffff88f OK
tshell 20 running 0x000003b8 0x00001000 23% 0x00000009 OK
mmcsd_detect 22 suspend 0x00000218 0x00002000 10% 0x0000000d OK
alarmsvc 10 suspend 0x000001d8 0x00000800 23% 0x00000005 OK
tidle0 31 ready 0x000001b8 0x00000400 46% 0x00000002 OK
timer 4 suspend 0x00000198 0x00000200 79% 0x00000008 OK
aic />
RT-Thread shell commands:
list_fd - list file descriptor
ulog_filter - Show ulog filter settings
ulog_kw - Set ulog global filter keyword
ulog_tag - Set ulog global filter tag
ulog_lvl - Set ulog global filter level.
ulog_tag_lvl - Set ulog filter level by different tag.
ulog_be_lvl - Set ulog filter level by different backend.
sensor - sensor test function
sensor_polling - Sensor polling mode test function
sensor_int - Sensor interrupt mode test function
sensor_fifo - Sensor fifo mode test function
fal - FAL (Flash Abstraction Layer) operate.
tail - print the last N - lines data of the given file
echo - echo string to file
df - disk free
umount - Unmount device from file system
mount - mount <device> <mountpoint> <fstype>
mkfs - format disk with file system
mkdir - Create the DIRECTORY.
pwd - Print the name of the current working directory.
cd - Change the shell working directory.
rm - Remove(unlink) the FILE(s).
cat - Concatenate FILE(s)
mv - Rename SOURCE to DEST.
cp - Copy SOURCE to DEST.
ls - List information about the FILEs.
free - Show the memory usage in the system.
ps - List threads in the system.
help - RT-Thread shell help.
list - list objects
list_device - list device in system
list_timer - list timer in system
list_mempool - list memory pool in system
list_memheap - list memory heap in system
list_msgqueue - list message queue in system
list_mailbox - list mail box in system
list_mutex - list mutex in system
list_event - list event in system
list_sem - list semaphore in system
list_thread - list thread
version - show RT-Thread version information
clear - clear the terminal screen
mem_test - memory test: mem_test address_hex size_hex
reboot - Reboot the system
f - run a function
m - modify memory
p - print memory
arecord - record voice to a wav file
aplay - play wav file
top - cpu usage
dma_dump - Dump DMA register. Argument: channel_num
efuse - efuse command
wdt_status - Show the status of Watchdog
aicupg - Reboot to the upgrade mode
list_irq - list system irq
adc - adc [option]
pin - pin [option]
pwm - pwm [option]
lptimer_dump - soft lptimer dump
pm_dump - dump power management status
pm_run - switch power management run mode
pm_module_delay - module request delay sleep
pm_module_reques - request power management mode
pm_module_releas - release power management mode count
pm_module_releas - release module power mode
pm_request - request power management mode
pm_release_all - release power management mode count
pm_release - release power management mode
list_alarm - list alarm info
date - get date and time or set (local timezone) [year month day hour min sec]
sf - SPI Flash operate
ge_format - ge format test
ge_fill - ge fill test
ge_bitblt - ge bitblit test
ge_rotate - ge rotate test
pic_test - picture decode test
ge_dither - ge dithe test
ge_scan_order - ge scan test
ge_alpha_blendin - ge alpha test
ge_scale - ge scale test
pic_crop_test - pic crop test
aic />
烧录信息如下:
[debug] Software Version: "1.3.6"
[debug] Machine Name: "DESKTOP-HQF1R40"
[debug] System Name: "Windows 10 (10.0)"
[debug] CPU Architecture: "x86_64"
[debug] Parse the image header from "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img"
[debug] Soc type: "d13x"
[debug] Board type: "demo88-nor"
[debug] Image version: "1.0.0"
[debug] Storage type: "spi-nor"
[debug] Storage ID: ""
[debug] Meta count: "5"
[debug] Refresh the partition tree ...
[debug] Part name: image.target.spl , size: 130320
[debug] Part name: image.target.os , size: 698716
[debug] Part name: image.target.rodata , size: 2093056
[debug] Current connect type: 0
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] No device available
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to connect the ArtInChip device "1:3-1" ...
[debug] WinEvent: Some devnode changed
[debug] There are "1" device available
[debug] Try to get Usb device hd info...
[debug] Get Usb device hd info success
[debug] The status of ArtInChip device: true
[debug] Start burn online ...
[debug] Progress range: 0 ~ 3055616
[debug] Burn Image file "F:/MCU/ArtinChip/luban-lite/output/d13x_demo88-nor_rt-thread_helloworld/images/d13x_demo88-nor_v1.0.0.img" ...
[debug] Meta 0 image.updater.spl , size 130320 ...
[debug] Blocksize 4 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 4608 Size: 130320
[debug] Dev "1:3-1" Send the rest data 130320
[error] aicupg_trans_recv_pkt()208: CSW size 0, Pipe error(-9)
[error] aicupg_cmd_send_fwc_data_final()777: Recv resp failed, expect 16, got 0
[debug] Don't check the result of image.updater.spl
[debug] Meta 1 image.info , size 2048 ...
[error] aicupg_trans_send_pkt()80: CBW tag 0x51, size 0, Pipe error(-9)
[error] aicupg_cmd_get_hwinfo()106: Send command failed. ret = 0, siz = 16
[debug] Wait to reconnect dev "1:3-1"
[debug] QTime("02:21:30.613") Wait for Dev "1:3-1" ready
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[debug] WinEvent: Some devnode changed
[warn ] Set upg work mode: 0
[debug] Blocksize 1 , chunk 1048576 * 0 , rest 2048
[debug] Offset: 0 Size: 2048
[debug] Dev "1:3-1" Send the rest data 2048
[debug] Meta 2 image.target.spl , size 130320 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 130320
[debug] Offset: 135680 Size: 130320
[debug] Dev "1:3-1" Send the rest data 130320
[debug] Meta 3 image.target.os , size 698716 ...
[debug] Blocksize 2048 , chunk 1048576 * 0 , rest 698716
[debug] Offset: 266752 Size: 698716
[debug] Dev "1:3-1" Send the rest data 698716
[debug] Meta 4 image.target.rodata , size 2093056 ...
[debug] Blocksize 2048 , chunk 1048576 * 1 , rest 1044480
[debug] Offset: 967168 Size: 2093056
[debug] Dev "1:3-1" Send chunk 0 ...
[debug] Dev "1:3-1" Send the rest data 1044480
[debug] Burn online successfully!
[debug] Insert statistic of "2024-01-23"
[debug] Reboot the device ...
[error] aicupg_trans_send_pkt()104: CSW tag 0xbe, size 0, Pipe error(-9)
[debug] WinEvent: Some devnode changed
[debug] No device available
------------------------------------
找到第一次烧写的截图了,39s。现在每次烧录都是2s,我怀疑我是不是只有第一次烧录成功了...
后来烧写显示成功了,但是仍执行的第一次烧写的程序...
ubuntu22.04下,用python3.10,执行onesetp.sh后,打算用addboard新增加个设置,结果报错:
addboard 0
scons: Reading SConscript files ...
Chip list:
0: d13x
1: d21x
NameError: name 'raw_input' is not defined:
File "/home/any/Mcu/artinchip/luban-lite/SConstruct", line 12:
PRJ_CHIP,PRJ_BOARD,PRJ_KERNEL,PRJ_APP,PRJ_DEFCONFIG_NAME,PRJ_CUSTOM_LDS,MKIMAGE_POST_ACTION = get_prj_config(AIC_ROOT)
File "/home/any/Mcu/artinchip/luban-lite/tools/scripts/aic_build.py", line 1135:
add_board_cmd(aic_root, PRJ_CHIP, PRJ_BOARD, PRJ_KERNEL, PRJ_APP, PRJ_DEFCONFIG_NAME)
File "/home/any/Mcu/artinchip/luban-lite/tools/scripts/aic_build.py", line 247:
i = raw_input("Select chip for new board(number):")
搜了下,raw_input是python2语法,python3改成Input了。但看文档里介绍,luban-lite是支持python3的吧?
-----------------------------------------------------------------
将对应pyton文件里的raw_input,全部改成input,ab命令通过。
不过有个疑问,app工程是如何指定bootloader版本的?靠名称前缀?
触控这里,是使用原先非旋转情况下的坐标吗?
我现在g2d旋转成功了,qt5界面旋转了180度。想用ts_calibrate校准,结果显示不出界面来,这里估计也得修改tslib源码吧?
--------------------------------------------
#export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=$QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS:rotate=180
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0:rotate=180
尝试了以上两句,都没效果,现在触控和画面是差180度的。
/etc/ts.conf 中加入module linear rot=2
也没效果。
@wwwlll
感谢,我还看到个,按qt5.4的一个patch,修改qt的framebuffer插件的源码,使其支持旋转功能。
https://blog.csdn.net/qq_15725099/article/details/102717970
另,为什么方法2 cpu占用率高?
我试过方法2,没效果:
export QT_QPA_PLATFORM=linuxfb:rotation=180
-------------------------------------------------------------
仔细看了下,
qt源码打patch,这种,也是修改qtbase/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp这个文件,需要添加的内容稍多些,但是不用打开内核的g2d功能了。
那么现在可行的方案就两种:
1,内核打开g2d,修改qlinuxfbscreen.cpp,增加某个接口函数。
2,内核不动,修改qlinuxfbscreen.cpp,修改部分函数,增加旋转部分。
这两种都需要重新编译qt源码,头疼...
【FAQ】全志F133(D1s)芯片 如何在Tina下进行显示旋转?
https://bbs.aw-ol.com/topic/2600
想将t113-s3的屏幕旋转180度,搜了下,大都是这个帖子的内容。启动g2d功能,设备树里设置下旋转方向。
然后lvgl里手动调用某个函数。
5.旋转后framebuffer编程是需要注意,旋转后的buffer不会直接显示到屏幕上, 需要在应用刷屏的地方调用FBIOPAN_DISPLAY接口.同步旋转后的buffer到LCD上.
但是我想用的是qt,在qt程序中的什么位值调用这个函数呢?
在aw-ol论坛上看到过,好像默认是用某个流控管脚控制收发的,但是有问题,那个帖子里给出了修改后的驱动函数,可以自己指定管脚。
--------------------------------------------
目前的实现是,嵌入式linux上电后发送下udp广播,表明自己是tcp client,pc收到后自动返回udp信息,表明自己是tcp server,此时双方都知道了对方的ip地址。然后就开始tcp连接。当嵌入式板发现tcp断开时,启动个定时器,定时再发送udp广播信息。
但又遇到了个问题,现场最后是一台pc多个嵌入式linux设备,如何区分这几个嵌入式linux设备呢?
pc端可以用ip地址来区分,但是实际嵌入式设备是哪个地址,可能不好看出来。
想实现的是,设备区分为 01, 02, 03....这样的若干个设备。
但是,这样问题就又来了,如何配置设备的名称?
之前这么实现过,pc向t113-s3的usb的虚拟串口,发送个固定格式的数据,t113-s3这里,写个串口接收处理程序,将收到的数据存为一个配置文件。
不过觉得也不是很方便,t113-s3的usb口一般用来烧录程序,或adb push文件。
有什么更好的办法吗?求推荐。
带NAPI的中断轮询数据接收模式
中断接收数据模式在数据频繁情况下,中断触发负载过大,系统性能受到影响,为此基于轮询的接收模式被开发,称为New API,即NAPI。
NAPI仍然需要首次数据包接收中断来触发poll过程,第一次接收中断发生后,中断处理程序禁止设备的接收中断,通过poll方式读取设备的接收缓冲区后,再次使能中断。
https://www.cnblogs.com/tureno/articles/6350137.html
搜到了这个。
既然用qt,那我就尽量用QSocketNotifier吧。
---------------------------------------------------------------
发现,如果用qt5的can类的话,已经有个收到can数据这个信号了:
connect(m_canDevice.get(), &QCanBusDevice::framesReceived,
this, &MainWindow::processReceivedFrames);
之前编写过一个t113-s3的qt程序,当时用到了can部分。
当时是这么实现的,将socketcan接收部分放到了一个线程里,收到数据后,通过信号将数据发送出去。没收到数据,则继续不停的接收。
现在gpt不是方便了么,问了gpt,结果给的例子是,利用QSocketNotifier:
QSocketNotifier notifier(s, QSocketNotifier::Read);
QObject::connect(¬ifier, &QSocketNotifier::activated, &receiveCanData);
这样貌似一旦收到数据后,就会触发 QSocketNotifier::activated信号,这样,貌似就不用线程了。
群里问了网友,又给了另一个方案,用poll, epoll, select。网上搜了下,这种貌似是在c++下的处理办法。
这下晕头了,不知道该怎么搞好了。求大家给意见。
另,我好奇,socketcan是如何知道收到数据了呢?
对于单片机来说,一般是打开can接收中断。而嵌入式linux这里是怎么知道收到数据了呢?
因为不明白这里,所以我之前用子线程不停的读这种方案,觉得也很合理。
但是QSocketNotifier和poll,感觉都是知道收到数据才去处理...
----------------------------------------------------------------------------------------
看了下can驱动文件,有中断函数...
642242855 说:我也搞个板子测试下,看如何:D
https://whycan.com/files/members/2275/微信截图_20231222165548.jpgboot 按键? 两路电源? rst 按键跟排针有阻碍
那个sot23-3的估计是个ldo。
好奇J13是什么?
另,群友画的几个板子,都没有看到引出网口的...
感谢分享,昨天刚想找D133原厂设计,就看到楼主发出来了。
借楼把从群里下载的D213原厂设计参考也放上来。
匠心创D213原厂硬件设计参考.zip
这两个板子,就是官方的两个开发板。应该都是candence设计的,然后又转出了ad和pads格式的。
两个板子布局很相似,都没引出rgb接口,而引出了lvds接口。
板子接口稍微有点少,我画的板子,基本接口都接出来了。
https://whycan.com/files/members/739/D133CBS.png
这个芯片不支持电阻屏吧?没看到你板子上放电容触控接口。
-------------------------------------------------------------------------------------------------
下载手册看了下,集成rtp的,PA8-11。