Skip to content

[BUG] Stream buffer 's configMESSAGE_BUFFER_LENGTH_TYPE is not portable between little / big endian. #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dry-75 opened this issue Sep 10, 2021 · 2 comments · Fixed by #391
Labels
bug Something isn't working

Comments

@dry-75
Copy link

dry-75 commented Sep 10, 2021

Describe the bug
Stream buffer 's configMESSAGE_BUFFER_LENGTH_TYPE is not portable between little / big endian.

Target

  • Development board: TMS570xxxx
  • Instruction Set Architecture: ARMv7, BE
  • IDE and version: TI ARM CC v20.x.x
  • Toolchain and version: TI ARM CC v20.x.x

Host

  • Host OS: Linux x86_x64
  • Version: Fedora 32

To Reproduce
Configure FreeRTOS.h with #define configMESSAGE_BUFFER_LENGTH_TYPE uint8_t. Send a message with xMessageBufferSend,
to another thread which is waiting for it on xMessageBufferReceive; The receiver will now spin always getting 0 from the receive, as length of message is always 0, yet data is available in buffer..

Expected behavior
It should receive the exact sent message , once.

Additional context

In stream_buffer.c: in the function :
static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer,
const void * pvTxData,
size_t xDataLengthBytes,
size_t xSpace,
size_t xRequiredSpace )

....
( void ) prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH );
...

This is not portable between little vs big endian With configMESSAGE_BUFFER_LENGTH_TYPE uint8_t it will write wrong byte on big endian.

The messaging works if the type fixed to 32bits/4bytes, on this system

@dry-75 dry-75 added the bug Something isn't working label Sep 10, 2021
@dry-75 dry-75 changed the title [BUG] [BUG] Stream buffer 's configMESSAGE_BUFFER_LENGTH_TYPE is not portable between little / big endian. Sep 10, 2021
@dry-75
Copy link
Author

dry-75 commented Sep 10, 2021

Needs something like this to fix:

configMESSAGE_BUFFER_LENGTH_TYPE bufflen= xDataLengthBytes;
xShouldWrite = pdTRUE;
( void ) prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( bufflen ), sbBYTES_TO_STORE_MESSAGE_LENGTH );

@archigup
Copy link
Member

Hi, thanks for the bug report! Looking into it

laroche pushed a commit to laroche/FreeRTOS-Kernel that referenced this issue Apr 18, 2024
…RTOS#389)

* Group mbedtls headers in Visual Studio Project Filters for Shadow

* Add missing source for mbedtls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants