Hi Myke,
I tried the assert() with CW7.2.1, FSLMQX3.6, and M52259EVB, and it too did not work. I dug into source and have a workaround and will also mention this to our FSLMQX development team.
The assert() is part of the EWL library in the CodeWarrior path. At some point it calls a printf() but instead of calling the FSLMQX printf() it calls the EWL printf(). I had to modify a couple EWL "C" source files and re-compile the library.
Here are the modifications and steps I made:
- open CodeWarrior for ColdFire V7.2\ColdFire_Support\ewl\EWL_C\EWL_C.CF.mcp
- open ansi_prefix.CF.h (NOTE: not certain this change needed) and change as follows:
#ifndef _EWL_ASSERT_DISPLAYS_FUNC
//DES #define _EWL_ASSERT_DISPLAYS_FUNC 0 // Assert will not display function name, non-c99 behavior (7.2.1.1)
#define _EWL_ASSERT_DISPLAYS_FUNC 1 //DES was 0 // Assert will not display function name, non-c99 behavior (7.2.1.1)
#endif
- open assert.c and change as follows:
extern int _io_printf(const char * , ... ); //DES
MISRA_QUIET(715, "ununsed arg")
void __ewl_assertion_failed(char_t const *condition, char_t const *filename, char_t const *funcname, int_t lineno)
{
#if !_EWL_ASSERT_DISPLAYS_FUNC
#pragma unused(funcname)
#endif
#if _EWL_OS_DISK_FILE_SUPPORT
#if _EWL_ASSERT_DISPLAYS_FUNC
(void)fprintf(stderr, "Assertion (%s) failed in \"%s\", function \"%s\", line %d\n", condition, filename, funcname, lineno);
#else
(void)fprintf(stderr, "Assertion (%s) failed in \"%s\", line %d\n", condition, filename, lineno);
#endif
#elif (_EWL_CONSOLE_SUPPORT)
#if _EWL_ASSERT_DISPLAYS_FUNC
(void)_io_printf("Assertion (%s) failed in \"%s\", function \"%s\", line %d\n", condition, filename, funcname, lineno);
//DES (void)printf("Assertion (%s) failed in \"%s\", function \"%s\", line %d\n", condition, filename, funcname, lineno);
#else
(void)printf("Assertion (%s) failed in \"%s\", line %d\n", condition, filename, lineno);
#endif
#else
#pragma unused(condition, filename, funcname, lineno)
/* Use some other form of assertion since there is no disk or console I/O */
#endif
- Now build/make the Build All target to update the EWL library
- I used the ~mqx/examples/hello project as a file to add your code. I got an error during build and had to change the target configuration dialog box Linker->Librarian fields as follows:
Print and Scan formatter from "in_FP" to "int" and Console IO from "buffer" to"raw".
- Now re-build your project and run .
Regards,
David
PS
I've added the source files in a ZIP if you don't want to cut&paste.
PSS
Please note that these mods to make assert() work with FSLMQX make it not work for non-FSLMQX (raw) applications. So what I've done is a workaround for FSLMQX only and I'm sure our FSLMQX and CodeWarrior developers will have proper long-term solution.