Soon enough I have learned about the whole nightmare with passing float/double parameters to functions and alignment, I have resolved it by
Code: Select all
case 'f':
{
// http://wiki.debian.org/ArmEabiPort#Structpackingandalignment
// Stack alignment
//
// The ARM EABI requires 8-byte stack alignment at public function entry points,
// compared to the previous 4-byte alignment.
char *cptr = (char *) varg ; //lint !e740 !e826 convert to double pointer
// just a bit of hell related to parameters alignment
uint caddr = (uint) cptr ;
if ((caddr & 0x7) != 0) {
cptr += 4 ;
}
I was happy while I was only working with all this in the main thread. As soon as I have started printing doubles from user threads, same issues with weird output came back, and the alignment trick does not work any more. I have even tried pragma to align the stack array but this made zero difference
Code: Select all
#pragma pack(16)
static WORKING_AREA(consoleThread, 512);
#pragma pack()
Is there maybe a know way to avoid all this pain with floats and doubles and functions invocations?,,,
I am using stm32f4 and Chibi 2.4.2