目前测试,证实确实是tina linux的问题导致的,更换镜像重新烧录后,执行wait线程挂起,cpu消耗为0,测试正常,目前已经修改了SDK重新编译系统(PS:来路不明的野SDK最好不要用,否则掉到坑里很难爬出来)
root@TinaLinux:~# ./xhl &
root@TinaLinux:~# top
Mem: 18828K used, 93844K free, 0K shrd, 1248K buff, 2716K cached
CPU: 0% usr 4% sys 0% nic 95% idle 0% io 0% irq 0% sirq
Load average: 0.00 0.00 0.00 1/55 225
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
223 150 root S 1880 2% 0% ./xhl
143 1 root S 1312 1% 0% /bin/adbd -D
1 0 root S 1056 1% 0% /sbin/init
150 1 root S 1056 1% 0% -/bin/sh
225 150 root R 1056 1% 0% top
141 1 root S 696 1% 0% /sbin/swupdate-progress -w
55 2 root SW 0 0% 0% [spi0]
10 2 root IW 0 0% 0% [rcu_preempt]
21 2 root IW 0 0% 0% [kworker/1:1-ubi]
53 2 root IW 0 0% 0% [kworker/u4:1-ev]
7 2 root IW 0 0% 0% [kworker/u4:0-ev]
5 2 root IW 0 0% 0% [kworker/0:0-mm_]
15 2 root SW 0 0% 0% [ksoftirqd/1]
73 2 root IW 0 0% 0% [kworker/1:2-ubi]
20 2 root IW 0 0% 0% [kworker/0:1-ubi]
9 2 root SW 0 0% 0% [ksoftirqd/0]
103 2 root SW 0 0% 0% [ubifs_bgt0_7]
16 2 root IW 0 0% 0% [kworker/1:0-mm_]
19 2 root SW 0 0% 0% [rcu_tasks_kthre]
^C 17 2 root IW< 0 0% 0% [kworker/1:0H-kb]
root@TinaLinux:~# ./cpu_usage 223
Analyzing CPU usage for program: xhl (PID: 223)
TID Thread_Name CPU_Usage(%)
223 xhl 0.00%
224 xhl 0.00%
root@TinaLinux:~# Task is ready, proceeding...
感觉应该是编译器问题或者是我的linux线程调度问题,目前采用了一种十分呆瓜的方案,使用while循环,然后再循环中使用sleep来释放cpu,目前能够有效的降低线程中的cpu占用。但是问题依旧存在。
root@TinaLinux:~# ./cpu_usage 312
Analyzing CPU usage for program: main (PID: 312)
TID Thread_Name CPU_Usage(%)
312 main 0.00%
313 scan_key 0.00%
314 mount_check 0.00%
315 read_rs485 7.50%
316 din_interrupt 0.00%
317 addr_led_blink 0.00%
318 addr_led_blink 0.00%
319 mixing 0.00%
325 send_codec 30.00%
326 send_spdif 35.50%
root@TinaLinux:~# kill -9 312
root@TinaLinux:~# Killed
TXplayer has stopped. Restarting in 5 seconds...
TXplayer lost executable permission. Adding executable permission again...
Thread Name: main, TID: 332
[ 1542.112483] sw_uart_check_baudset()903 - uart1, baud 500000 beyond rance
Thread Name: mount_check, TID: 334
Thread Name: scan_key, TID: 333
Thread Name: mixing, TID: 339
Thread Name: addr_led_blink, TID: 337
Thread Name: read_rs485, TID: 335
Thread Name: din_interrupt, TID: 336
Thread Name: addr_led_blink, TID: 338
[ 1542.149690] [SNDCODEC][sunxi_card_hw_params][620]:stream_flag: 0
[ 1542.374365] sunxi-spdif 2036000.spdif: active: 1
Thread Name: send_codec, TID: 345
Thread Name: send_spdif, TID: 346
root@TinaLinux:~# ./cpu_usage 332
Analyzing CPU usage for program: main (PID: 332)
TID Thread_Name CPU_Usage(%)
332 main 0.00%
333 scan_key 0.00%
334 mount_check 0.00%
335 read_rs485 7.50%
336 din_interrupt 0.00%
337 addr_led_blink 0.00%
338 addr_led_blink 0.00%
339 mixing 0.00%
345 send_codec 0.00%
346 send_spdif 1.00%
同样得代码再服务器上跑没啥问题,两个线程得占用都是0,奇奇怪怪得。
t113@t113-docker-1:~/t113/cpu_usage/build$ ./waitT &
[2] 9925
t113@t113-docker-1:~/t113/cpu_usage/build$ ./cpu_usage 9925
Analyzing CPU usage for program: waitT (PID: 9925)
TID Thread_Name CPU_Usage(%)
9925 waitT 0.00%
9926 waitT 0.00%
t113@t113-docker-1:~/t113/cpu_usage/build$ Task is ready, proceeding...
基于全志T113-s3硬件平台,使用condition_variable 条件变量时候调用wait阻塞等待变量释放,但是再等待通知期间,cpu并不会释放,而是一直保持占用状态。难以理解。
以下是测试代码:
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
std::mutex mtx;
std::condition_variable cond_not_empty_;
bool ready = false;
void wait_for_task() {
std::unique_lock<std::mutex> lock(mtx);
// 等待直到 ready 为 true
cond_not_empty_.wait(lock, []{ return ready; });
std::cout << "Task is ready, proceeding...\n";
}
void signal_task() {
std::lock_guard<std::mutex> lock(mtx);
ready = true;
// 唤醒等待的线程
cond_not_empty_.notify_one();
}
int main() {
std::thread worker(wait_for_task);
// 模拟其他工作
std::this_thread::sleep_for(std::chrono::seconds(20));
signal_task(); // 通知任务已准备好
worker.join();
return 0;
}
以下是执行完代码处理后得结果,主线程休眠装台0占用,worker线程占用cpu再25%:
乐鑫官方的esp32-p4开发板原理图,各位大佬可以参考一下
esp32-p4-function-ev-board-schematics.pdf
完结撒花,调试到最后还是驱动问题,完成了 f1c200s tina 3.5 kernel 3.10硬件平台的xr829驱动调试,完成了wifi版本移植,踩坑了驱动移植、驱动加载不成功、扫描不到wifi、ping时间超时等一堆问题,终于爬坑成功,感谢各位大佬的支持。
root@TinaLinux:/# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 90:85:DC:C6:92:77
inet addr:192.168.31.5 Bcast:192.168.31.255 Mask:255.255.255.0
inet6 addr: fe80::9285:dcff:fec6:9277/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5912 errors:0 dropped:28 overruns:0 frame:0
TX packets:238 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:992559 (969.2 KiB) TX bytes:27956 (27.3 KiB)
root@TinaLinux:/# ping www.baidu.com
PING www.baidu.com (36.155.132.3): 56 data bytes
64 bytes from 36.155.132.3: seq=0 ttl=53 time=15.144 ms
64 bytes from 36.155.132.3: seq=1 ttl=53 time=17.370 ms
64 bytes from 36.155.132.3: seq=2 ttl=53 time=12.862 ms
64 bytes from 36.155.132.3: seq=3 ttl=53 time=21.165 ms
64 bytes from 36.155.132.3: seq=4 ttl=53 time=23.217 ms
64 bytes from 36.155.132.3: seq=5 ttl=53 time=86.893 ms
^C
--- www.baidu.com ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss
round-trip min/avg/max = 12.862/29.441/86.893 ms
大佬们,请教一下,f1c200s tina 3.5.1 linux-3.10 硬件平台,移植了xr829驱动,目前网课是可以使用了,但是大概率扫描不到wifi,该往哪方面偏差问题啊。
下面是扫描wifi路由的结果,大概率情况下设备是一个wifi都扫描不到的,只能偶尔扫描到几个wifi。
偶尔赛秒到的几个wifi,看样子不像是硬件设计问题:
root@TinaLinux:/# wifi_scan_results_test ?[J
*********************************
***Start scan!***
*********************************
bssid / frequency / signal level / flags / ssid
60:fa:9d:0b:83:70 2437 -55 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] ChinaNet-wQLp
02:68:eb:53:82:76 2437 -62 [WPA2-PSK-CCMP][WPS][ESS][P2P] DIRECT-76-HP M429fdw LJ
ac:74:09:91:b6:66 2437 -85 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS] 14-603
ac:74:09:91:b6:64 2437 -86 [ESS]
******************************
Wifi get_scan_results: Success!
******************************
大概率是扫描不到wifi:
root@TinaLinux:/# wifi_scan_results_test ?[J
*********************************
***Start scan!***
*********************************
bssid / frequency / signal level / flags / ssid
******************************
Wifi get_scan_results: Success!
目前好像调试成功了,能够扫描到wifi网络了,但是硬件设计的天线好像有点问题,扫描到的wifi比较少
root@TinaLinux:/etc/init.d# wifi_scan_results_test ?[J
*********************************
***Start scan!***
*********************************
bssid / frequency / signal level / flags / ssid
60:fa:9d:0b:83:70 2437 -63 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] ChinaNet-wQLp
80:b5:75:16:07:e8 2437 -79 [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS] ChinaNet-YejT
******************************
Wifi get_scan_results: Success!
******************************
https://pan.baidu.com/s/1zm8A8aczylv5yje-9JCLtw 提取码:wj0v
之前买的开发板
正在找这款芯片的sdk,非常感谢大佬的分享
目前insmod xr829可以正常加载了,再系统中也能正常的看到网卡设备了,但是wifi还是不能正常使用,也不知道问题出在哪里了,有大佬知道的么
下面是加载驱动打样的信息
[ 114.160762] ======== XRADIO WIFI OPEN ========
[ 114.175860] [XRADIO_ERR] <try_create_hwinfo_buffer : 1513>read hwinfo file:/tmp/hwinfo.bin failed!
[ 114.186041] [XRADIO] Driver Label:XR_V02.16.77_HT40_01.31 Jun 30 2024 09:33:05
[ 114.197532] [XRADIO] Allocated hw_priv @ c1b90fa0
[ 114.206299] sunxi-wlan wlan: bus_index: 0
[ 114.320923] [XRADIO] Detect SDIO card 0
[ 114.336079] sunxi-mmc sdc0: sdc set ios: clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[ 114.365446] sunxi-mmc sdc0: sdc set ios: clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[ 114.394618] sunxi-mmc sdc0: sdc set ios: clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[ 114.408681] sunxi-mmc sdc0: sdc set ios: clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[ 114.422091] sunxi-mmc sdc0: sdc set ios: clk 400000Hz bm PP pm ON vdd 16 width 1 timing LEGACY(SDR12) dt B
[ 114.443349] sunxi-mmc sdc0: sdc set ios: clk 400000Hz bm PP pm ON vdd 16 width 1 timing SD-HS(SDR25) dt B
[ 114.454933] sunxi-mmc sdc0: sdc set ios: clk 50000000Hz bm PP pm ON vdd 16 width 1 timing SD-HS(SDR25) dt B
[ 114.466830] sunxi-mmc sdc0: sdc set ios: clk 50000000Hz bm PP pm ON vdd 16 width 4 timing SD-HS(SDR25) dt B
[ 114.479751] mmc0: new high speed SDIO card at address 0001
[ 114.495005] [SBUS] XRadio Device:sdio clk=50000000
[ 114.525035] [XRADIO] XRADIO_HW_REV 1.0 detected.
[ 114.624683] [XRADIO] xradio_update_dpllctrl: DPLL_CTRL Sync=0x01400000.
[ 114.739374] [XRADIO] Bootloader complete
[ 114.861895] [XRADIO] Firmware completed.
[ 114.877836] [WSM] Firmware Label:XR_C09.08.52.64_DBG_02.85 2GHZ HT40 Apr 9 2019 11:15:08
[ 114.888069] [XRADIO] Firmware Startup Done.
[ 114.894755] [XRADIO_WRN] enable Multi-Rx!
[ 114.901150] cfg80211: Updating information on frequency 2412 MHz with regulatory rule:
[ 114.910123] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 114.918481] cfg80211: Updating information on frequency 2417 MHz with regulatory rule:
[ 114.927300] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 114.935641] cfg80211: Updating information on frequency 2422 MHz with regulatory rule:
[ 114.944452] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 114.952750] cfg80211: Updating information on frequency 2427 MHz with regulatory rule:
[ 114.961566] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 114.969890] cfg80211: Updating information on frequency 2432 MHz with regulatory rule:
[ 114.978705] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 114.987029] cfg80211: Updating information on frequency 2437 MHz with regulatory rule:
[ 114.995840] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.004177] cfg80211: Updating information on frequency 2442 MHz with regulatory rule:
[ 115.012957] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.021297] cfg80211: Updating information on frequency 2447 MHz with regulatory rule:
[ 115.030121] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.038452] cfg80211: Updating information on frequency 2452 MHz with regulatory rule:
[ 115.047259] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.055592] cfg80211: Updating information on frequency 2457 MHz with regulatory rule:
[ 115.064399] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.072694] cfg80211: Updating information on frequency 2462 MHz with regulatory rule:
[ 115.081508] cfg80211: 2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.089831] cfg80211: Updating information on frequency 2467 MHz with regulatory rule:
[ 115.098638] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.106967] cfg80211: Updating information on frequency 2472 MHz with regulatory rule:
[ 115.115774] cfg80211: 2457000 KHz - 2482000 KHz @ 40000 KHz), (600 mBi, 2000 mBm)
[ 115.124096] cfg80211: Updating information on frequency 2484 MHz with regulatory rule:
[ 115.132884] cfg80211: 2474000 KHz - 2494000 KHz @ 20000 KHz), (600 mBi, 2000 mBm)
[ 115.159424] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
分享一个esp32 p4的初版数据手册
ESP32-P4_datasheet.pdf
合宙air780e提供的音频压缩算法库只有amr-nb算法,只支持8k 采样率的音频,已经满足不了现在的语言识别等系统中对录音采样率的要求了,于是移植了一个amr-wb音频压缩算法,支持16k采样率。移植的是定点计算版本,减少对对算力的消耗,不过从最终的测试结果来看amr-wb算法,消耗的内存空间比较小,对算力的要求比较高,实际使用只能用最低一档的码率输出。放在其他算力高一点的平台可能效果更好。以下是对应的编码库和调用demo。