Загрузка данных
Есть проект pjsip, который отлично работал на imxrt1064. есть задача по переносу этого проекта на imxrt1024.
при переносе проекта видно, что всё подвисает при звонке на imxrt1024. Пришлось перенести буфера I2S sai в TCM, и везде проставить одинаковый битрейт аудио(чтобы не было преобразований) - тогда оно как-то заработало, но звук отвратительный по сравнению с imxrt1064. При компиляции проекта:
Memory region Used Size Region Size %age Used
FLASH: 1176844 B 4 MB 28.06%
RAM: 318300 B 32 MB 0.95%
ITCM: 7880 B 32 KB 24.05%
DTCM: 106624 B 160 KB 65.08%
OCRAM: 0 GB 64 KB 0.00%
IDT_LIST: 0 GB 32 KB 0.00%
Есть ещё место немного в ITCM,DTCM,OCRAM. Надо выделить тяжёлые функции и попытаться их перенести в эту память.
Функция преобразования аудио битрейтов:
void audio_convert_rate(int cur_rate, int out_rate, uint8_t *buf,
size_t buf_sz) {
/* XXX 16-bit stereo buffer */
uint32_t *buf32 = (uint32_t *) buf;
int div, i;
if (cur_rate == out_rate) {
return;
}
div = MAX(cur_rate, out_rate) / MIN(cur_rate, out_rate);
if(div <= 0)
return;
if (cur_rate > out_rate) {
for (i = buf_sz - 1; i >= 0; i--) {
buf32[i] = buf32[i / div];
}
} else {
for (i = 0; i < buf_sz; i++) {
buf32[i] = buf32[div * i];
}
}
Загрузка процессов сейчас:
Scheduler: 8 since last call
Threads:
0x80008d60 clock
options: 0x2, priority: 12 timeout: 77
state: sleeping, entry: 0x60015e6d
Total execution cycles: 3698091456 (0 %)
stack size 16384, unused 14976, usage 1408 / 16384 (8 %)
0x80009150 pa_thread_hnd_out
options: 0x0, priority: 11 timeout: 0
state: pending, entry: 0x60015e6d
Total execution cycles: 638072760 (0 %)
stack size 2048, unused 1480, usage 568 / 2048 (27 %)
0x80009000 i2s_thread_out
options: 0x0, priority: 11 timeout: 7003
state: pending, entry: 0x60015e6d
Total execution cycles: 320139080 (0 %)
stack size 1024, unused 680, usage 344 / 1024 (33 %)
0x800092a0 pa_thread_hnd_in
options: 0x0, priority: 11 timeout: 0
state: pending, entry: 0x60015e6d
Total execution cycles: 2739144006 (0 %)
stack size 2048, unused 352, usage 1696 / 2048 (82 %)
0x800093f0 i2s_thread_in
options: 0x0, priority: 11 timeout: 7
state: pending, entry: 0x60015e6d
Total execution cycles: 294815568 (0 %)
stack size 1024, unused 704, usage 320 / 1024 (31 %)
0x80008c10 pjsua_0
options: 0x2, priority: 12 timeout: 113
state: pending, entry: 0x60015e6d
Total execution cycles: 3043984084 (2 %)
stack size 20480, unused 6856, usage 13624 / 20480 (66 %)
0x80008ac0 ev_thread
options: 0x0, priority: 12 timeout: 0
state: pending, entry: 0x60015e6d
Total execution cycles: 69758 (0 %)
stack size 1024, unused 752, usage 272 / 1024 (26 %)
0x80008970 media
options: 0x2, priority: 12 timeout: 103
state: pending, entry: 0x60015e6d
Total execution cycles: 1958906386 (1 %)
stack size 4096, unused 2440, usage 1656 / 4096 (40 %)
0x80008820 main_thread
options: 0x2, priority: 10 timeout: 7606
state: sleeping, entry: 0x60015e6d
Total execution cycles: 2802904936 (0 %)
stack size 30720, unused 14304, usage 16416 / 30720 (53 %)
0x80009658 usbd_msc
options: 0x0, priority: -1 timeout: 0
state: pending, entry: 0x6001a8c9
Total execution cycles: 24095 (0 %)
stack size 1024, unused 736, usage 288 / 1024 (28 %)
0x80007db8 lcd_thread_id
options: 0x0, priority: 13 timeout: 0
state: pending, entry: 0x6000c051
Total execution cycles: 2351705679 (0 %)
stack size 1024, unused 680, usage 344 / 1024 (33 %)
0x80009770 input
options: 0x0, priority: 14 timeout: 0
state: pending, entry: 0x6001b639
Total execution cycles: 961017 (0 %)
stack size 1024, unused 784, usage 240 / 1024 (23 %)
0x80009b90 rx_q[0]
options: 0x0, priority: -1 timeout: 0
state: pending, entry: 0x600c369b
Total execution cycles: 1655772946 (0 %)
stack size 2048, unused 1616, usage 432 / 2048 (21 %)
0x80009a38 net_mgmt
options: 0x0, priority: -1 timeout: 0
state: pending, entry: 0x6003d63d
Total execution cycles: 106132 (0 %)
stack size 896, unused 456, usage 440 / 896 (49 %)
0x80009d40 tcp_work
options: 0x0, priority: -14 timeout: 0
state: pending, entry: 0x6003d63d
Total execution cycles: 27184 (0 %)
stack size 1024, unused 784, usage 240 / 1024 (23 %)
0x80009540 usbd
options: 0x0, priority: -8 timeout: 0
state: pending, entry: 0x60019305
Total execution cycles: 22468 (0 %)
stack size 1024, unused 768, usage 256 / 1024 (25 %)
*0x80008448 shell_uart
options: 0x0, priority: 14 timeout: 0
state: queued, entry: 0x60012191
Total execution cycles: 311388287 (0 %)
stack size 2048, unused 924, usage 1124 / 2048 (54 %)
0x8000a418 sysworkq
options: 0x1, priority: -1 timeout: -9223372036854775808
state: pending, entry: 0x6003d63d
Total execution cycles: 2419195736 (0 %)
stack size 1664, unused 976, usage 688 / 1664 (41 %)
0x80009e88 udc_work_q
options: 0x0, priority: -1 timeout: 0
state: pending, entry: 0x6003d63d
Total execution cycles: 17358 (0 %)
stack size 512, unused 272, usage 240 / 512 (46 %)
0x80009fc0 ENET_RX
options: 0x2, priority: -14 timeout: 0
state: pending, entry: 0x6003d63d
Total execution cycles: 2287297281 (0 %)
stack size 2048, unused 1544, usage 504 / 2048 (24 %)
0x80007ef0 logging
options: 0x0, priority: 14 timeout: -9223372036854775808
state: pending, entry: 0x6000f93d
Total execution cycles: 1287875 (0 %)
stack size 2048, unused 1688, usage 360 / 2048 (17 %)
0x8000a1a8 idle
options: 0x1, priority: 15 timeout: 0
state: , entry: 0x6003c79d
Total execution cycles: 351501624 (96 %)
stack size 384, unused 312, usage 72 / 384 (18 %)
Если добавить преобразование аудио битрейтов - то процесс clock загружает систему на 40% и у меня уже недоступна консоль(процесс shell_uart)