Recorder threshold issue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Recorder threshold issue

ソリューションへジャンプ
499件の閲覧回数
rafal_szczepaniak
Contributor I

Hello,
during using freemaster recorder i noticed a problem. When the observed value is 2 bytes signed int, and it is selected for the recorder trigger with threshold lower than -8192 then it cause the board resets.

After debugging, i suppose, that problem may be on freemaster side. When i look into communication logs, i can see something like on picture below.

 

image-2023-08-18-15-32-36-726.png

I guess, that in red box is size of the number. Looking on source code of the freemaster on microcontroller i think, that it is used for example for selecting comparison function.
In green box is threshold encoded in LEB128.

Going to freemaster code on the microcontroller to initialize recorder we can find the line: 

image-2023-08-18-15-39-07-647.png

As we can see, decoder as size takes number obtained from the from PC tool. constThresholdPtr is pointer to an 8-byte array that can keep decoded threshold. It is placed in freemaster_rec.c file.

Next thing is going to decoder:

image-2023-08-18-15-44-15-517.png

image-2023-08-18-15-45-12-338.png

As you can see we can go into FMSTR_LebDecode. Our arguments for bug example (threshold -8193 ) are: in buffer with bytes [FF BF 7F], result - pointer to array of 8 bytes, size - 2, sleb - true.

I will skip precise description how most of decoding will be take place. In do .. while loop it iterates twice (because two bytes have MSB bit set), always decrementing size.
So when we go to line 569, we have b = 7F, sleb = true, and size =0. 
In 571 we have false but decrement size value, what cause underflow and size turn into (2^32)-1. In that case, while loop (576) start filling memory with 0xff.

Have you encountered this problem?



0 件の賞賛
1 解決策
474件の閲覧回数
MichalH
NXP Apps Support
NXP Apps Support

Dear Rafal,

thanks for your report. We were solving this issue for MCUXpresso SDK 2.10 back in 2021/2022 - It may happen you are using older code. I'm sorry for this. 

Your analysis is correct, though. This is the fix needed in the FMSTR_LebDecode:

MichalH_0-1692800228066.png

Thank you,
Michal

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
467件の閲覧回数
rafal_szczepaniak
Contributor I

This solution helps.
Thank you very much! 

0 件の賞賛
475件の閲覧回数
MichalH
NXP Apps Support
NXP Apps Support

Dear Rafal,

thanks for your report. We were solving this issue for MCUXpresso SDK 2.10 back in 2021/2022 - It may happen you are using older code. I'm sorry for this. 

Your analysis is correct, though. This is the fix needed in the FMSTR_LebDecode:

MichalH_0-1692800228066.png

Thank you,
Michal

0 件の賞賛