MrzhangF1ghter / mp3player

mp3 player for rt-thread
Apache License 2.0
6 stars 4 forks source link

在全志F1C上执行时出现data abort 或者undefined instruction #3

Closed xfdr0805 closed 1 year ago

xfdr0805 commented 1 year ago

data abort是地址未4字节对齐,但是我对齐后,又出现下边这个异常。调试发现是在mp3dec.c文件里 函数IMDCT和Subband 会出现这个异常,请大佬指点一下是什么原因,查了几天也没找到原因

rt_kprintf("5\n");
        /* alias reduction, inverse MDCT, overlap-add, frequency inversion */
        for (ch = 0; ch < mp3DecInfo->nChans; ch++)
            if (IMDCT(mp3DecInfo, gr, ch) < 0) {
                MP3ClearBadFrame(mp3DecInfo, outbuf);
                return ERR_MP3_INVALID_IMDCT;           
            }

        /* subband transform - if stereo, interleaves pcm LRLRLR */
        if (Subband(mp3DecInfo, outbuf + gr*mp3DecInfo->nGranSamps*mp3DecInfo->nChans) < 0) {
            MP3ClearBadFrame(mp3DecInfo, outbuf);
            return ERR_MP3_INVALID_SUBBAND;         
        }
    }
    return ERR_MP3_NONE;
}
msh />mp3play -s ring.mp3
[D/mp3 player] EVENT:PLAYSTOPPAUSERESUME, STATE:STOPPED -> PLAYING
[D/I2S] channels:2,SUNXI_DA_TXCHMAP:76543210

[I/mp3 player] play start, uri=ring.mp3
[D/mp3 tag] current file pos:0
[D/mp3 tag] ring.mp3:751 KB,0.73 MB
[D/mp3 tag] mp3 data start at :0.000000 KB
[D/mp3 tag] sync word offset at:0
------------MP3 INFO------------
Title:
Artist:
Year:
Comment:
Genre:Blues
Length:00:48
Bitrate:128 kbit/s
Frequency:44100 Hz
--------------------------------
[D/mp3 player] 0x8110e9e0 0x81123490 2048
xx
zzz
aaa
bbb
1
2
3
4
5
Execption:
r00:0x00000000 r01:0x00000000 r02:0x00000000 r03:0x00000000
r04:0x8111a448 r05:0x00000000 r06:0xe92d40f0 r07:0x00000000
r08:0x00000000 r09:0x00000000 r10:0x00000000
fp :0x00000000 ip :0x00000000
sp :0x80000594 lr :0x800026ae pc :0x800026ae
cpsr:0x40000033
undefined instruction
thread - mp3_play stack:
         pri  status      sp     stack size max used left tick  error
-------- ---  ------- ---------- ----------  ------  ---------- ---
charge    15  suspend 0x00000098 0x00000800    07%   0x00000013 OK
thread    16  ready   0x00000080 0x00001000    05%   0x00000014 ETIMOUT
serial    17  suspend 0x00000188 0x00001000    09%   0x00000014 OK
key       15  ready   0x000000a8 0x00000800    08%   0x00000014 ETIMOUT
usbd_rx    4  suspend 0x000000b0 0x00000800    08%   0x0000000a OK
usbd_tx    4  suspend 0x000000b0 0x00000800    08%   0x00000009 OK
tshell    20  ready   0x00000150 0x00001000    19%   0x00000006 OK
wav_p     15  suspend 0x00000110 0x00000800    13%   0x0000000a OK
mp3_play  15  running 0x00000140 0x00002000    09%   0x00000001 OK
mmcsd_de  22  suspend 0x000000b8 0x00000400    68%   0x00000009 OK
alarmsvc  10  suspend 0x00000098 0x00000800    07%   0x00000005 OK
sys work  23  suspend 0x00000070 0x00000800    05%   0x0000000a OK
tidle0    31  ready   0x00000060 0x00000100    46%   0x00000002 OK
timer      4  suspend 0x00000068 0x00000200    20%   0x00000009 OK
main      10  suspend 0x00000090 0x00000800    27%   0x00000004 OK
shutdown...
MrzhangF1ghter commented 1 year ago

我记得是因为helix硬编码了cotex-m的汇编指令,导致其他架构运行会出现undefined instruction异常,解决方法在rt-thread论坛有,你搜一下mp3player相关帖子发自我的 iPhone在 2023年8月27日,11:35,xfdr0805 @.**> 写道: data abort是地址未4字节对齐,但是我对齐后,又出现下边这个异常。调试发现是在mp3dec.c文件里 函数IMDCT和Subband 会出现这个异常,请大佬指点一下是什么原因,查了几天也没找到原因 ` ``C / alias reduction, inverse MDCT, overlap-add, frequency inversion / for (ch = 0; ch < mp3DecInfo->nChans; ch++) if (IMDCT(mp3DecInfo, gr, ch) < 0) { MP3ClearBadFrame(mp3DecInfo, outbuf); return ERR_MP3_INVALID_IMDCT; } / subband transform - if stereo, interleaves pcm LRLRLR / if (Subband(mp3DecInfo, outbuf + grmp3DecInfo->nGranSamps*mp3DecInfo->nChans) < 0) { MP3ClearBadFrame(mp3DecInfo, outbuf); return ERR_MP3_INVALID_SUBBAND;
}


msh />mp3play -s ring.mp3
[D/mp3 player] EVENT:PLAYSTOPPAUSERESUME, STATE:STOPPED -> PLAYING
[D/I2S] channels:2,SUNXI_DA_TXCHMAP:76543210

[I/mp3 player] play start, uri=ring.mp3
[D/mp3 tag] current file pos:0
[D/mp3 tag] ring.mp3:751 KB,0.73 MB
[D/mp3 tag] mp3 data start at :0.000000 KB
[D/mp3 tag] sync word offset at:0
------------MP3 INFO------------
Title:
Artist:
Year:
Comment:
Genre:Blues
Length:00:48
Bitrate:128 kbit/s
Frequency:44100 Hz
--------------------------------
[D/mp3 player] 0x8110e9e0 0x81123490 2048
xx
zzz
aaa
bbb
1
2
3
4
5
Execption:
r00:0x00000000 r01:0x00000000 r02:0x00000000 r03:0x00000000
r04:0x8111a448 r05:0x00000000 r06:0xe92d40f0 r07:0x00000000
r08:0x00000000 r09:0x00000000 r10:0x00000000
fp :0x00000000 ip :0x00000000
sp :0x80000594 lr :0x800026ae pc :0x800026ae
cpsr:0x40000033
undefined instruction
thread - mp3_play stack:
         pri  status      sp     stack size max used left tick  error
-------- ---  ------- ---------- ----------  ------  ---------- ---
charge    15  suspend 0x00000098 0x00000800    07%   0x00000013 OK
thread    16  ready   0x00000080 0x00001000    05%   0x00000014 ETIMOUT
serial    17  suspend 0x00000188 0x00001000    09%   0x00000014 OK
key       15  ready   0x000000a8 0x00000800    08%   0x00000014 ETIMOUT
usbd_rx    4  suspend 0x000000b0 0x00000800    08%   0x0000000a OK
usbd_tx    4  suspend 0x000000b0 0x00000800    08%   0x00000009 OK
tshell    20  ready   0x00000150 0x00001000    19%   0x00000006 OK
wav_p     15  suspend 0x00000110 0x00000800    13%   0x0000000a OK
mp3_play  15  running 0x00000140 0x00002000    09%   0x00000001 OK
mmcsd_de  22  suspend 0x000000b8 0x00000400    68%   0x00000009 OK
alarmsvc  10  suspend 0x00000098 0x00000800    07%   0x00000005 OK
sys work  23  suspend 0x00000070 0x00000800    05%   0x0000000a OK
tidle0    31  ready   0x00000060 0x00000100    46%   0x00000002 OK
timer      4  suspend 0x00000068 0x00000200    20%   0x00000009 OK
main      10  suspend 0x00000090 0x00000800    27%   0x00000004 OK
shutdown...

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
xfdr0805 commented 1 year ago

我记得是因为helix硬编码了cotex-m的汇编指令,导致其他架构运行会出现undefined instruction异常,解决方法在rt-thread论坛有,你搜一下mp3player相关帖子发自我的 iPhone在 2023年8月27日,11:35

感谢指点,确实是这个问题,暂时先这样解决 Helix MP3解码库脱离汇编指令束缚,运行在任何处理器上的解决方案