cyhal_spi bug for SPI bit width > 8

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Boris
Employee
Employee
5 sign-ins First solution authored First reply posted

Hello,

I discovered a nasty bug in the cyhal_spi.c implementation.

In some places, it is not taken into account, that the element size of the buffer is 2, in case the bit width is > 8.

The data corruption would have been immediately apparent if anyone ever tried to use this, which weirdly doesn't seem the case...

Anyways, please see attached the fixed cyhal_spi.c for mtb-hal-cat1 release 1.5.0  (btw, I have to stay at this version, because for the used TARGET_CYSBSYSKIT-DEV-01, the SPI clock selection does not work properly in version 1.6.0... It selects the 16.5 bit divider and then returns an error because of that...)
Also I checked that the bug is still present in version 2.0.

 

Best regards

Boris

0 Likes
3 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi @Boris 

 

I tried this at my end and was able to reproduce the error. I have notified the internal team regarding this and will get back with the solution at the earliest. 

 

Thanks, 
Hari

0 Likes
Boris
Employee
Employee
5 sign-ins First solution authored First reply posted

Hi @Hari ,

meanwhile I have tried the version 2.1.0, and while some parts of the problem around cyhal_spi data width have been changed, the bug is still present... It seems only parts of the fix have been applied...

0 Likes
lock attach
Attachments are accessible only for community members.
Boris
Employee
Employee
5 sign-ins First solution authored First reply posted

Find attached a patch for the current version 2.1.0. (maybe consider if you want to include arr_size_modifier in "obj")

Please include in the next release, or in a minor bugfix release...

0 Likes