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。
@Gentlepig
不需要知道,只要PC和多个嵌入式设备都在同一网段就行了。比如server为[192.168.1.10],client为[192.168.1.55]和[192.168.1.86]等等,这样一般服务器起来后,client会自动连接到server
https://blog.csdn.net/weixin_45062087/article/details/118946561
对于APUE网络socket,我们需要了解就是server和client之间的通信建立过程。首先我们需要知道两台不同网段的pc是怎么通信的,当一台pc通过应用程序发一段消息过来给另一台pc时,pc获取到数据包之后就行拆包解析,这些都是操作系统内核的工作,对于server而言,需要告诉内核使用什么ip和端口来建立起服务,当有client接入时,内核先进行解析,得到client的ip和访问端口之后再给server(对应的应用程序),最后完成通信建立;对于client而言,需要知道server的ip和端口,获取ip来源主要是通过dns解析和人为获取,然后通过获取的ip和端口进行发送连接请求,最后完成通信。
我搜到的这个文章,我的理解是client连接server,需要知道对方地址。
不要以自己的立场感受为常识。比如,从事Linux底层的人对nuttx就会很熟悉并觉得freertos功能太少。
像小米就选nuttx作为他们产品的RTOS,明显是因为他们的团队以前是搞手机系统的,众所周知,手机系统内核是Linux。
确实,自己了解的还是太少太片面了。nuttx之前只是见到过这个名字,chibios是第一次见到...
是不是不少rtos也兼容posix? rtt好像支持吧,微软的threadx是不是也兼容呢?
------------------------------------------------------------
搜到了这个:
为什么选择NuttX?
市场上开源或商业的RTOS非常多,为什么我们最终选择NuttX作为Xiaomi Vela的基础?主要有以下几个原因:
NuttX对POSIX标准有原生兼容:NuttX是可商用化RTOS中唯一一个对POSIX API有原生支持的实时操作系统,所以很多Linux社区的开源软件可以很方便的移植到NuttX上,这样可以极大的简化开源软件移植,方便代码复用,降低学习曲线,其它RTOS需要适配层把POSIX API转成内部API,而且通常只兼容一小部分的POSIX接口。
完成度高:NuttX集成了文件系统、网络协议栈、图形库和驱动框架,减少开发成本。
模块化设计:所有组件甚至组件内部特性,都可以通过配置Kconfig来调整或关闭,可按需对系统进行裁剪,适用于不同产品形态。
代码精简:所有组件都是从头编码,专门对代码和数据做了优化设计。
轻量级:虽然NuttX实现了传统操作系统的所有功能,但是最终生成的代码尺寸还是可以很小(最小配置不到32KB,最大配置不超过256KB)。
和Linux系统的兼容性:因为NuttX整体设计、代码组织,编译过程和Linux非常接近,将会极大地降低Android/Linux开发者的迁移成本。
活跃开放的社区:很多厂商(比如小米、Sony,乐鑫、NXP等)和开源爱好者都在积极回馈社区。
APM:裸奔
Pixhawk:Nuttx
MWC/Naze32:裸奔
Openpilot:PIOS
Autoquad:CoOS (an embedded real-time multi-task OS specially for ARM Cortex M series)
Paparazzi:ChibiOS匿名飞控:
RT-Thread(国产飞控+国产RTOS)
Crazyflie:FreeOS
https://www.zhihu.com/question/28981423/answer/51314550
知乎上看到的。
另,遥控器,有哪些开源硬件?指的是pcb及原理图也公开了的。
http://science.china.com.cn/2023-11/24/content_42608233.htm
今天看到这个消息,来转发一下。
hp5301, 8元,300M,没can,16位adc,开发板40元。
看了下sdk,gitee上有,rtos开发。
硬件源文件 imx6ull-v3.zip
感谢,学习。
这个函数的作用是,将表示四则运算的中缀表达式,变成后缀表达式。
void infixToPostfix(char* infix, char* postfix)
{
Stack s;
initStack(&s);
char* p = infix;
char* q = postfix;
while(*p != '\0')
{
...
}
while (!isEmpty(&s))
{
...
}
*(q - 1) = '\0';
}
infix字符串数组,如果给正确的字符串表达式,则程序运行正常。
可有的时候,没有给infix字符串数组赋值,结果全是0x00,结果运行这个函数后,跟紧该函数的其他语句,都没有执行,直接跳出上一层函数了。
想了想,估计问题是出在函数结尾这个*(q-1) = '\0',本来q指向postfix数组的开头,结果,因为给的infix里没有找到字符串或运算符,直接执行这一句了,那么就是将postfi数组的上一个地址里的数据赋值为0x00了。
我好奇的是,为什么造成的结果是跳过接下来的语句,直接返回上一层的函数了呢?
搜了下单片机lua,知乎上有篇文章,其中有个回复说最小也是4k左右。
将lua移植到单片机可行吗? - 知乎
https://www.zhihu.com/question/58988100
问题找到了,在一个函数中,给某个数组赋值时,访问越界,比如int arr[8],结果我给arr[9]赋值了,于是进入hardfault_handler了。
更详细一点就是,本来NUMBER定义的比较小,这次我改大了,没注意到有个数组赋值时用到了这个宏定义。
//#define NUMBER 16
#define NUMBER 32
uint8_t arr[32];
for(u8 i = 0; i < 16+i+NUMBER; i++)
{
arr[i] = 1;
}
而这个函数里,还调用了spi_flash_write(),于是我就以为是spi_flash操作引起了错误。
这能解释-o0会进入hardfault_hander(),但是为什么-o3优化能正常运行?
-o1,o2 led狂闪?
硬件仿真,对比-o1情况下定时器的寄存器情况,前20面正常时和后来狂闪时,发现定时器的重载定时器和控制器寄存器1没有变化。
-o0情况下,程序运行20秒后卡死,发现尽到了HardFault_Handler()。
根据https://blog.csdn.net/electrocrazy/article/details/78173558
定位到是spi_flash_write()函数。
挨个注释main主循环里的函数,发现注释掉保存数据到spiflash这个函数后,程序正常运行。那么,问题应该就是出在spi_ flash_ write这个函数了,但是我看网上大部分教程,原子、野火,大都是这么写的:
void SPI_FLASH_Write ( u8* pBuffer, u32 WriteAddr, u16 NumByteToWrite )
{
u32 secpos;
u16 secoff;
u16 secremain;
u16 i;
secpos = WriteAddr / 4096;
secoff = WriteAddr % 4096;
secremain = 4096 - secoff;
if ( NumByteToWrite <= secremain )
secremain = NumByteToWrite;
while ( 1 )
{
SPI_FLASH_BufferRead ( spiFlashBuff, secpos * 4096, 4096 );
for ( i = 0; i < secremain; i++ )
{
if ( spiFlashBuff[secoff+i] != 0xFF )
break;
}
if ( i < secremain )
{
SPI_FLASH_SectorErase ( secpos * 4096 );
for ( i = 0; i < secremain; i++ )
spiFlashBuff[i+secoff] = pBuffer[i];
SPI_FLASH_BufferWrite ( spiFlashBuff, secpos * 4096, 4096 );
}
else
SPI_FLASH_BufferWrite ( pBuffer, WriteAddr, secremain );
if ( NumByteToWrite == secremain )
break;
else
{
secpos++;
secoff = 0;
pBuffer += secremain;
NumByteToWrite -= secremain;
if ( NumByteToWrite > 4096 )
secremain = 4096;
else
secremain = NumByteToWrite;
}
}
}
而且,为何优化等级不同,结果却不同?
gd32f103,定时器10ms一中断,让一变量自增,其他函数里根据这个变量计数100次后置位1秒标值。main函数主循环里判断该标志位是否置位,是1的话,让led反转,并清该标志位。
mdk工程,之前是-o3优化等级,运行后正常。硬件仿真时,我改成了-o1优化,发现运行大概20秒后,led就不正常反转了。
-o3优化:led每秒反转,正常;
-o2优化,前20秒led能每秒反转,然后就变成很快的频率闪烁了;
-o1优化,前20秒led能每秒反转,然后就变成很快的频率闪烁了;
-o0优化,前20秒led能每秒反转,然后就变成很快常亮了;
程序比较大,有modbus数据区,占几k字节。编译后也比较占资源。
-o3:
Program Size: Code=31348 RO-data=1104 RW-data=504 ZI-data=24368
-o2:
Program Size: Code=31408 RO-data=1104 RW-data=504 ZI-data=24368
-o1:
Program Size: Code=33712 RO-data=1204 RW-data=504 ZI-data=24368
-o0:
Program Size: Code=41236 RO-data=1204 RW-data=536 ZI-data=28656
看了下-o3和-o2,应该是rom只差1k左右。
芯片是gd32f105vc,我查gd32f103vc是48k ram, 256k rom.
10ms定时器中断里自增的变量是volatile类型的,该变量整除100时置位的bool类型变量,也是声明成volatile类型的。
@kin
这是专门为了我的需求写了个程序?太感谢了。
-----------------------------------
因为没有注释,有不少地方没看明白,比如各函数的用途,rpnbuf[ ]数组的用途。
reverse_polish_nnotatio_append_char()这个函数,
如果给的是'(',则压入stk里;
如果是')',则从stk里取出数据放到rpnbuf里;
如果是'&'或者'|',如果栈里没数据,则入栈,如果有数据,取栈顶数据,如果是'(',则将符号入栈,否则,将栈顶字符串出栈,存到rpnbuf数组里,不知道这里为什么要存到rpnbuf里。
如果是字符1-8,则直接存到rpnbuf里。
感觉rpnbuf像是完成后缀表达式的存放位置,但不确定。
run_exp( )函数里也有不明白的地方:
while((chr = exp[0])){...}这里只是判断下表达式的第一个字符吗?(这个明白了,while循环里有exp+=2,这样就会遍历整个输入字符串了)
那么这个while循环里,就会把输入表达式里的‘0-9, & , | ( )'分别代入到reverse_polish_notatio_append_chr( )函数里去处理
根据我在上一段落分析,‘0-9’是存到rpnbuf数组里的,‘(xxxx)'括号里的内容,也会存到rpnbuf里。
我的理解是,rpnbuf数组存放的是后缀表达式,但没看明白什么时候把逻辑符号放进去的。而stk是中缀转后缀时存放临时数据的,比如有括号情况下,将左括号及数据先放到stk里,如果再遇到右括号,则将数据从stk里取出来放到rpnbuf数组里。
https://blog.csdn.net/crr411422/article/details/130306750
按这个文章里的代码抄了一遍,没用malloc申请栈空间,而是用了固定数组,把浮点数变量改成了uint8类型,在pc上gcc编译后,可以运行进行整数四则运算。
又将里边的“+-*/”改成了“&|”,可以进行逻辑运算。
$ ./test5
Enter an infix expression: 1&1
infix notation: 1&1
Postfix notation: 1 1 &
Result: 1
$ ./test5
Enter an infix expression: 1&(0|1)
infix notation: 1&(0|1)
Postfix notation: 1 0 1 | &
Result: 1
$ ./test5
Enter an infix expression: (1|1)&(0|1)
infix notation: (1|1)&(0|1)
Postfix notation: 1 1 | 0 1 | &
Result: 1
$ ./test5
Enter an infix expression: (0|1)&(1&0)
infix notation: (0|1)&(1&0)
Postfix notation: 0 1 | 1 0 & &
Result: 0
$ ./test5
Enter an infix expression: (0|1)&(1|0)
infix notation: (0|1)&(1|0)
Postfix notation: 0 1 | 1 0 | &
Result: 1
对于方法3,别墅业主群里很多群友推荐了。其中有朋友推荐了c4.c,我看到简介里写的c in four function。我以为是四则运算呢?结果晚上刷知乎搜c4.c才知道是实现了编译器...虽然里边也有四则运算符,也有与或逻辑运算符,但是我觉得对于我来说内容有深度了...
搜 使用栈完成算术表达式 搜到这么一篇文章,觉得不多:
https://www.cnblogs.com/inghzhang/p/3901334.html
还没仔细看。
感谢各位。
关于1里的真值表,我是没搞明白的,分别用1和0表示输入信号的有无,8个输入信号的话,组合就是2^8=256种。那么需要上位机算出这种比如(x1||x2)&&(x3||x4)这种情况下,对应的8个输入有那几种组合,如何输入满足的话,就控制输出。
问了gpt,列出来上式的真值表:
x1 | x2 | x3 | x4 | Output
---------------------------
0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 1 | 1
0 | 0 | 1 | 0 | 1
0 | 0 | 1 | 1 | 1
0 | 1 | 0 | 0 | 0
0 | 1 | 0 | 1 | 1
0 | 1 | 1 | 0 | 1
0 | 1 | 1 | 1 | 1
1 | 0 | 0 | 0 | 0
1 | 0 | 0 | 1 | 1
1 | 0 | 1 | 0 | 1
1 | 0 | 1 | 1 | 1
1 | 1 | 0 | 0 | 1
1 | 1 | 0 | 1 | 1
1 | 1 | 1 | 0 | 1
1 | 1 | 1 | 1 | 1
可以看到output是1的就有13项,那么我需要判断输入信号是否是这13项里的其中一个,是的话,就满足。
这种方法的话,需要上位机计算出真值表里output为1的项目,把对应的输入状态,发给单片机吧?比如上式,就需要将
x1 | x2 | x3 | x4 | Output
---------------------------
0 | 0 | 0 | 1 | 1
0 | 0 | 1 | 0 | 1
0 | 0 | 1 | 1 | 1
0 | 1 | 0 | 1 | 1
0 | 1 | 1 | 0 | 1
0 | 1 | 1 | 1 | 1
1 | 0 | 0 | 1 | 1
1 | 0 | 1 | 0 | 1
1 | 0 | 1 | 1 | 1
1 | 1 | 0 | 0 | 1
1 | 1 | 0 | 1 | 1
1 | 1 | 1 | 0 | 1
1 | 1 | 1 | 1 | 1
这些发给单片机去进行判断吧?
这样倒是简单些,但是实际应该把8个输入都考虑进去,这样最后就是就是一种输出结果可能对应着非常多的输入情况,比如几十个。
又想了想,应该真值表里的256项都写入单片机。单片机里利用switch()判断输入是否在真值表里对应的output是否为1,为1的话,说明输入满足逻辑关系。
单片机板有8个输入信号以及若干个输出信号。客户提出要求,希望能通过上位机来配置这8个信号的逻辑关系实现与或操作。头大,不知道该怎么实现。想过如下办法:
1,上位机传递输入信号的序号,然后将所有逻辑关系按序号排出来,将逻辑关系序号也发给单片机,单片机按需要去反推逻辑关系。但是可能的逻辑关系也太多了...
因为只有与和或两种逻辑关系,有群友指出有2^8种排列。
2,上位机发送输入信号的序号,然后再发送几组数据,每组数据包含两个参与操作的信号打序号,再包含一个逻辑关系。这样的话,需要上位机先推算出运算打先后顺序。上位机这里有点麻烦。
3,上位机直接将逻辑运算发送给单片机,包括括号以及运算符,这样上位机就简单了,但是单片机这里就很难了。
如果单片机收到的是类似“x1 && (x2 || x3)"这样的字符串,能否直接转化为可执行语句来执行?
请大家给个思路。
目前的程序是这样的:
void ModbusProc::modbusPoll()
{
while (true)
{
foreach (int index, readList)
{
uint8_t funcR = dataPoint[index].funcR;
uint16_t addr = dataPoint[index].addr;
uint8_t dataLen = dataPoint[index].dataLen;
uint8_t slave = dataPoint[index].slave;
if (dataLen == 0)
dataLen = 1;
if (slave == 0)
slave = 1;
if (funcR == 1 || funcR == 2 || funcR == 3 || funcR == 4)
{
uint8_t readType;
if (funcR == 1)
readType = QModbusDataUnit::Coils;
else if (funcR == 2)
readType = QModbusDataUnit::DiscreteInputs;
else if (funcR == 3)
readType = QModbusDataUnit::HoldingRegisters;
else if (funcR == 4)
readType = QModbusDataUnit::InputRegisters;
else
{
continue;
}
QModbusDataUnit readData((QModbusDataUnit::RegisterType)readType, addr, dataLen);
QModbusReply *reply = modbusDevice->sendReadRequest(readData, slave);
if (reply)
{
if (!reply->isFinished())
{
qDebug() << "modbus reply is not finished." << endl;
QEventLoop loop;
QObject::connect(reply, &QModbusReply::finished, &loop, &QEventLoop::quit);
loop.exec();
}
if (reply->error() == QModbusDevice::NoError)
{
qDebug() << "modbus reply is finished." << endl;
currentIndex = index;
delete reply;
}
}
else
{
qDebug() << "Read request failed";
delete reply;
}
}
QCoreApplication::processEvents();
QThread::msleep(10);
}
QCoreApplication::processEvents();
QThread::msleep(10);
}
}
现在设置的modbus的超时时间是50ms,每发送一次后有个线程的延时10ms,算下来应该是60ms一帧数据。实际pc端收到的数据,大概是110ms左右。
一帧8个字节。
设置超时时间为100ms,结果pc端收到数据的间隔,大概是160ms左右。
用的qt的Modbus库,想在子线程里不停地进行modbus读操作,写了这么个函数。
如果只执行一次的话,串口能输出正确的数据,或者用定时器定时调用这个函数,串口也能不停地输出数据。
但是如果在while循环里不停的调用这个函数的话,则串口只会输出第一个字节。
void ModbusProc::modbusPoll()
{
while (true)
{
readDataPoint();
QCoreApplication::processEvents();
QThread::msleep(1000);
}
}
void ModbusProc::readDataPoint()
{
if (!modbusDevice)
return;
QModbusDataUnit readData(QModbusDataUnit::InputRegisters, 10, 2);
QModbusReply *reply = modbusDevice->sendReadRequest(readData, 01);
if (reply){
if (!reply->isFinished())
{
qDebug() << "modbus reply is finished." << endl;
// delete reply;
}
else
{
qDebug() << "modbus reply is not finished." << endl;
delete reply;
}
}
else
{
qDebug() << "read request failed" << endl;
}
QThread::msleep(100);
}
按gpt的回答,加了QEventLoop事件循环,算是死等发送完成,可以正常工作了。
void ModbusProc::readDataPoint()
{
if (!modbusDevice)
return;
QModbusDataUnit readData(QModbusDataUnit::InputRegisters, 10, 2);
QModbusReply *reply = modbusDevice->sendReadRequest(readData, 01);
if (reply){
if (!reply->isFinished())
{
qDebug() << "modbus reply is finished." << endl;
// delete reply;
QEventLoop loop;
QObject::connect(reply, &QModbusReply::finished, &loop, &QEventLoop::quit);
loop.exec();
}
else
{
qDebug() << "modbus reply is not finished." << endl;
delete reply;
}
}
else
{
qDebug() << "read request failed" << endl;
}
QThread::msleep(100);
}
请教,单次执行时不需要死等,为什么连续循环就需要死等?除此之外还有其他办法吗?
看到了friendly,就去友善搜了下,貌似是H5。
http://friendlyelec.com.cn/nanopi-neo-plus2.asp
-----------------------------------------------------------------------------
看错了,多了网口,usb也变成2个了。
汇报下今天的进展。
感谢坑网群里的吴师、周师两位群友,给了我很多指导。
在次把吴师在群里的部分回复汇总下。
1. 可以看到灯亮! tx, rx , 25M 不用看;
2. 可以抓到芯片 mdc, mdio 不用看;
3. 所以只要看 rmii 的 txd, rxd, txen , rxdv , clk;
工作正常! mdc, mdio 可以读寄存器, rst 不用看;
1. pc 和 版子 都设置固定 ip;
2. 使用 版子来 ping pc 的 ip , 此时在 pc 端,打 arp;
3. 再反向,pc 去 ping 版子,板子打 arp ,看看有没有 pc 的 mac 地址
若是有一边有! 一边没有,那就只要解决 tx 或 rx 即可;
例如! pc 看不到版子的 mac , 但是板子可以看到 pc 的!
这样就是 rx 是正常的! 只要解决 tx 的就行!
经测试,pc ping arm板,arm板可看到pc地址,反之不行。结论,arm板rmii发送有问题,集中在了txd0、txd1、txen三条线上。
用示波器测量,发现txd0、txd1上有波形,txen一直低电平。所以是txen有问题,可能和想临的焊盘短路了。暂时还未确定是哪个位置。
t113-s3 + sr8201,网口部分抄的jlc上开源的的板子。总共做了5块,4块网络正常,就1块网络总是连不同。
一开始是网口灯都不亮,后来发现25M晶振有个管脚和外壳GND连了。重新焊接晶振后,有25M晶振波形了,网口link灯能闪烁。
但是如果执行udhcpc,则报错:
sunxi-gmac 4500000.eth eth0: Initialize hardware error
然后linkled灯就停止闪烁了。
以为是sr8201坏了,然后手头也没多余的8201了,就和另一块位网络正常的板子,对掉了sr8201。
结果对掉后,原来网络正常的板子,网络还是正常。
而这块有问题的板子,执行udhcpc后,不再报哪个错误了,linkled灯也始终保持闪烁。但是就是获取不了ip。
root@TinaLinux:/# udhcpc
udhcpc: started, v1.27.2
[ 502.500278] libphy: 4500000.eth: probed
[ 502.504630] sunxi-gmac 4500000.eth eth0: eth0: Type(7) PHY ID 001cc816 at 0 IRQ poll (4500000.eth-0:00)
udhcpc: sending discover
udhcpc: sending discover
[ 506.766651] sunxi-gmac 4500000.eth eth0: Link is Up - 100Mbps/Full - flow control off
[ 506.775419] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
udhcpc: sending discover
依照群友的建议,用ifconfig直接设置ip,然后和pc互ping,pc找不到arm板,arm板也ping连接不上。
8201的1脚RSET管脚应该接2.49K电阻,手头没有,之前是并联了4.7K和5.1K,算了下大约2.45K。怀疑是这个电阻阻值的问题,直接并联了4个10K电阻,应该是2.5K左右了。但问题依旧。
测量了1.0V输出,有1.1V左右电压。也是正常的。
可能的原因:
1, sr8201焊接问题,但是吹下来过三次了... 不过还是这个问题最大,因为对掉过一次8201后,不再出现“Initialize hardware error”这个错误了。
2, sr8201坏了?对掉过一次8201,以为有问题的8201焊接换到其他板子上能正常工作联网。
3, t113-s3 坏了?
4, 晶振坏了?目前测试有25M波形。
5, 网络端口坏了?用的是HR913129AE,看到的例子是911105A,不过库房里有这个就用了,其他还有两块也是用的这个型号,网络正常。 而且查拔网线有link is down或link is up提示。
6, 周边阻容虚焊?在不通电的情况下测试了周围的电阻组织,主要是4.7K和1.5K,都正常,2.5K也近似。而且,也手动重新焊了一边阻容两端。
想改为rsync方式,结果下载rsync源码下来,configure --host=arm-linux CC=XXX,结果有4个库文件及头文件找不到,ssl,lbmz4等。也不知道该怎么指定,暂时放弃rsync方式。
尝试板子运行gdbserver,pc运行gdb,然后target remote=xxx,可以运行及调试,就是不知道如何设置断点。可以break main,在main函数处设置了断点,但是想在main.cpp其他行设置断点,break main.cpp:43,结果报错,找不到main.cpp。
qtcrator可以通过remote方式连上板子运行程序,就是设置的断点无法停止。
kit构建套件里,设备类型选为 remote linux device的话,如果编译器这里选交叉编译器,则pro文件就不能正常打开,出现qmake_cxx找不到compile_macros定义。
但是,保持设备类型不变,改为pc上用的gcc和gc++,则就能正常打开工程。
于是怀疑是交叉编译器的问题,就又建立个kit,设备类型选为 桌面,仍用交叉编译器,结果pro文件可以正常打开,可以构建生成可执行文件。
------------------------------------------------------------
run选项里有个build device,这里应该选local pc,我之前选的是remote linux devce。改了这里后就没那三个报错了。
我看的是原子的教程,到这里后,该通过ssh和scp命令往板子里拷贝程序,是在qtcreator里的自定义的部署命令里实现的:
ssh -p %{Device:SshPort} %{Device:UserName}@%{Device:H
ostAddress} 'mkdir -p %{CurrentRun:Executable:Path}'
可是qtcreator里没有CurrentRun这个参数,所以又卡到这里了。
------------------------------------------------------------
记录以下qtcreator使用gdb遇到的问题,pc上的gdb和板子上的gdbserver是用同一份原文件编译出来的。结果qtcreator里按f10进入单步调试,提示gdb不支持python脚本。网上搜了说编译时要加--with-python,结果编译时报错,make distclean后,又删了gdb/cache啥的,报错改变了,找不到python,我板子上python默认时python2,改为指向python3后,报错又变了,提示有些python库快要遗弃了,然后又报错找不到python。继续搜,说要安装python-dev。现在用的是python3.10,就安装了python3.10-dev。通过编译了。然后make install。
但是qtcreator里无论用f5还是f10,貌似都不在设置的断点地方停下来...
现在先用的是qt的一个例程,modbus master例程。如果kit套件里,不选择为远程linux设备,而选择本地编译,仍选择交叉编译的gcc,则可以生成可执行文件,拷贝到arm上可以运行。
kit套件里,设置为远程linux设备,则应该是无法正常打开工程,左侧工程列表里只有pro文件,而看不到头文件、源文件等。
-----------------------------------------
arm板子启动sshd时有这个警告:
/sshd start
root@TinaLinux:/etc/init.d# /etc/rc.common: line 128: procd_add_mdns: not found
不过pc上用ssh可以登陆这个板子。
----------------------------------------
qtcreator里设备这里点击测试,有如下:
Sending echo to device...
Device replied to echo with expected contents.
Checking kernel version...
Linux 5.4.61 armv7l
检查指定端口是否可用...
所有指定的端口都可用。
Checking whether "sftp" works...
"sftp" failed with exit code 255:
Connection closed.
Connection closed
Checking whether "rsync" works...
"rsync" failed with exit code 127: ash: rsync: not found
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: remote command not found (code 127) at io.c(231) [Receiver=3.2.7]
Deployment to this device will not work out of the box.
设备测试失败。
虽然有stfp和rsync报错,但是没打算用这两个。
show running process也可以显示板子上运行的进程。
open remote shell也可以打开终端并链接。
-------------------------------------------------------
板子上没装gdb server,pc上也没有交叉编译的gdb。正在装。
-------------------------------------------------------
tina sdk里勾选了gdb和gdb server,编译后也生成了对应的程序。不过不知道怎么用,现在qt creator还是提示原来的错误。
-------------------------------------------------------
其实板子上只用gdb server就行了。我之前以为pc上需要用到交叉编译的gdb,其实是不行的,得用pc版的gdb。我尝试用ubuntu自带的gdb,结果版本太高,链接后,出现了个too long的错误。在pc上重新源码编译gdb,让gdb和gdbserver用的是同一份源码,就没那个问题了。
arm板上:gdbserver :1234 ./test
pc端:arm-linux-gdb ./test 注意这个arm-linux-gdb只是个名字,并不表示这是交叉编译出来的gdb。
然后gdb命令行中,target remote 192.168.1.xxx:1234
开始执行程序后,按c是直接运行程序了。其他还在研究。
而帖子里一开始的报错,和gdb貌似无关。现在还没解决。
板子已经打开sshd服务了,pc上终端可以通过ssh登陆板子了。
qtcreator打开选项-设备,选择remote linux设备,输入ip地址相关,旁边有个按钮,可以打开shell登陆板子。说明这部分没问题。
但是kid设置后,工程里,选择run,结果总是报错。
/xxx/AllWinner/t113s3/qt-everywhere-opensource-src-5.12.9/t113-qt/mkspecs/features/toolchain.prf:76: error: Variable QMAKE_CXX.COMPILER_MACROS is not defined.
:-1: error: Project ERROR: failed to parse default search paths from compiler output
/XXX/Qt5/t113-s3/modbusmaster/master.pro:-1: error: 分析文件/XXX/Qt5/t113-s3/modbusmaster/master.pro时发生错误,放弃中。
硬件源文件 imx6ull-v3.zip
好东西,感谢分享。
请教个问题,交叉编译个源码工程,报错找不到FILE结构体定义。
搜了下,说这个一般是需要#include <stdio.h>
看了下ubuntu系统里的/usr/include/stdio.h,里面是包含了多个bit/目录下的头文件,其中就有types/FILE.h。
我在t113-s3的tina sdk里搜FILE.h,只在两个risv目录下搜到了,但是prebuild/gcc/的arm目录下没有。
tinasdkv21/tina-d1-h$ find . -name FILE.h
./lichee/brandy-2.0/tools/toolchain/riscv64-linux-x86_64-20200528/sysroot/usr/include/bits/types/FILE.h
./prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/sysroot/usr/include/bits/types/FILE.h
搜到的两个,都是在sysroot目录下,但是arm工具链目录下没sysroot目录。
Winston 说:wupaul2001 说:电源问题,换个好点的电源就没事了,我的产品也遇到
ok谢谢!目前也是打算换电源.
最近又遇到了,把设备树usb_otg设为disabled好了
没找到usb_otg这个变量,在内核设备树里关于usb0的是这样的,usb_port_type = 0已经算是device了,但调适口还是有那些信息。
0 &usbc0 { │ sys_config.fex*
1 device_type = "usbc0"; │ sys_partition.fex*
2 usb_port_type = <0x0>; │ uboot-board.dts*
3 usb_detect_type = <0x0>; │~
4 /* usb_detect_mode = <0>; │~
5 usb_id_gpio = <&pio PB 8 GPIO_ACTIVE_HIGH>; │~
6 enable-active-high; │~
7 usb_det_vbus_gpio = <&pio PB 9 GPIO_ACTIVE_HIGH>; */ │~
8 usb_wakeup_suspend = <0>; │~
9 usb_serial_unique = <0>; │~
10 usb_serial_number = "20080411"; │~
11 rndis_wceis = <1>; │~
12 status = "okay"; │~
13 };
linux-5.4/drivers/clk/sunxi-ng/ccu-sun8iw20.c
该文件里, 缺少这几行:
static SUNXI_CCU_GATE(bus_can0_clk, "bus-can0", "apb1", 0x92c, BIT(0), 0);
static SUNXI_CCU_GATE(bus_can1_clk, "bus-can1", "apb1", 0x92c, BIT(1), 0);
&bus_can0_clk.common,
&bus_can1_clk.common,
在mango sdk里,是默认就有这些的。
注意,修改后,再mp,结果还是会报同样的错误,但是在linux目录下make clean后,然后顶层目录下mp就没事了。
按aw-ol的这个帖子修改的。
之前用的mango sdk,也是按这个修改后,can功能可以正常使用。这次用了tina linux 2.1,结果按帖子配置后,配置can波特率失败。
https://bbs.aw-ol.com/topic/1383/t113-s3-can%E6%A8%A1%E5%9D%97%E4%BD%BF%E7%94%A8%E7%9A%84%E5%85%A8%E9%83%A8%E4%BF%A1%E6%81%AF
root@TinaLinux:/# ip link set can0 type can bitrate 100000
[77081.499110] sunxi_can 2504400.can can0: 0-3343301252-0
[77081.504850] sunxi_can 2504400.can can0: bitrate error 100.0% too high
RTNETLINK answers: Domain error
在drive/net/can/dev.c里的
static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, const struct can_bittiming_const *btc)
函数里找到了对应报错信息:
188 if (bitrate_error > CAN_CALC_MAX_ERROR) {
1 netdev_err(dev, "%u-%u-%u\n", bitrate, bt-bitrate, priv->clock.freq); //any
2 netdev_err(dev,
3 "bitrate error %d.%d%% too high\n",
4 bitrate_error / 10, bitrate_error % 10);
5 return -EDOM;
6 }
结果priv->clock.freq是0.
我觉得可能是没打开can时钟,那么,在哪里打开呢?
交叉编译qt源码时,增加了openssl选项,结果报错。
我选的时-openssl-linked,这是静态连接openssl吧?报错找不到libcrypto.so,提示用-rpath或-rpath-link。
我直接用了-R 库路径,竟然通过编译了。于是好奇 -rpath, -rpath-link, -R的作用。
configure -h时发现有-rpath和-R的选项,看描述,两者相似。没找到-rpath-link描述。
而看描述,前两者是用来制定动态链接库的路径的,而我这里是静态连接库,为何也能其作用?
qt warning: libcrypto.so.1.1, not found (try using -rpath or -rpath-link)
-R <string> .......... Add an explicit runtime library path to the Qt
libraries. Supports paths relative to LIBDIR.
-rpath ............... Link Qt libraries and executables using the library
install path as a runtime library path. Similar to
-R LIBDIR. On Apple platforms, disabling this implies
using absolute install names (based in LIBDIR) for
dynamic libraries and frameworks. [auto]
加了个新的硬盘,在新硬盘上重新安装了ubuntu22.04,尝试官方的tina sdk 2.1版本。
从aw-ol上下载了t113的补丁。
https://bbs.aw-ol.com/topic/2027/%E4%B8%80%E4%B8%AA%E8%A1%A5%E4%B8%81-%E8%AE%A9d1-h%E7%9A%84sdk%E6%94%AF%E6%8C%81t113%E8%8A%AF%E7%89%87
https://github.com/YuzukiHD/TinaAddons
这样d1-h的sdk就支持t113-s3了。make时报错,c-stack错误,搜了下,说要升级m4版本,或者打补丁。
https://bbs.aw-ol.com/topic/171/%E6%9E% … 8518359186
遇到个问题,在这里反馈一下。在ubuntu22.04上,m4编译会报一个错:
c-stack.c:55:26: error: missing binary operator before token "("
55 | #elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384
|
这里可以去https://toolchains.bootlin.com/downloads/releases/sources/m4-1.4.18/ 下载0003-c-stack-stop-using-SIGSTKSZ.patch
然后拷贝package/m4目录下重新编译即可。
补丁放到了out/compile/xxx/m4目录下,执行patch -p1 < xxx.patch。则该问题解决。
------------------------------------------------------
再记录一下,qt程序modbus做从机,设置数据点,一种类型只能设置一次,多次设置的话只有最后一次有效。比如定义04功能码读输入寄存器,如果地址不连续,有4300, 5300两个地址,那么不能设置两次,只能设置一次,设初始地址为4300,数量为1000个。
---------------------------------------------------------------------------
上个楼层里说的那个加延时,也是没必要的。尝试把延时去掉了,modbus超时时间设为最小的50ms,重试次数设为0,也就是只发一次,波特率9600的情况下,收发正常。如果超时时间设为100ms, 9600波特率下,大该两次正常通讯后就有一次通讯超时,500ms,大部分情况下出错,应该是发送被分帧了。还没明白其中原因。
---------------------------------------------------------------------------
在reply收到数据后,调用下一次poll前,加的这个延时,尝试减小,由50ms减小到了5ms,只要这个延时存在,超时时间设大也没事,设置成500ms超时,重试2次,仍能正常通讯。但是这个延时时间再小,就又出现通讯错误了。是不是需要等待发送完成,发送目前的8个字节需要一定时间?有这个可能,9600波特率下发送一个字节大该833us,8个字节大该是6.6ms。如果是这样的话,那发送数据较长时,这个延时也该变化,不好整啊。
--------------------------------------------------------------------------
群里一位朋友解释了,modbusrtu通讯本身就需要发送间隔大于3.5个字符间隔。9600波特率下对应差不多4ms。这么说,应该是发送粘包了...