For the i.MX RT105x processor I downloaded the SDKs both in version 2.4.2 and 2.5.0.
In the driver sources (the fsl_* files) the assert() function is used in many points of the code.
I would like to use my own version of the assert() and not the one provided by the standard c library (either newlib nano, or redlib).
What is the correct way to do this?
I don't know if we should edit the fsl_* files. However, I have seen that the file fsl_common.h includes the standard header assert.h.
How "bad practice" is to edit this file to replace the inclusion of assert.h with my own file where I then redefine the assert function in the most convenient way?
Hi Massimiliano Cialdi
As you mentioned, it is not the optimal practice to replace the assert.h from a common file, but if you consider necessary to use your own driver, then yes, you can use this.
It's also a bad practice to use the assert provided by the libc used (*if* it is used one).
For example newlib provided assert calls printf(), that in turns calls malloc that it is a big problem. In the specific case we do not have heap for the malloc provided by newlib-nano (we use the allocator 4 provided by FreeRTOS). The malloc is very slow and indeterministic about the timing, and also is not thread safe and we should allocate a _reent structure of about 2KB for each task, because it is too much memory consuming. It's also very slow.
In general, I don't think it's a good practice that the HAL driver library (the fsl_*.[ch] files) relies on the library API (see the include list at the top of the fsl_common.h file).