This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MCU-PLUS-SDK-AM243X: How does one define their own putchar_ with sysconfig?

Part Number: MCU-PLUS-SDK-AM243X
Other Parts Discussed in Thread: SYSCONFIG

I need to define my own putchar_ instead of what sysconfig is generating. The sdk *PutChar functions damage the data being sent through them and I need to replace it with my own. 

However when I disabled the Uart/CCS/SharedMem logging, it's still generating an empty function, blocking it being redefined elsewhere. 

What's the official intent here? Can we get a way to either disable it being generated? Or perhaps be allowed to provide a function to be called inside it?

In the meantime I'm hacking sysconfig as follows:

<snip> debug_log.c.xdt

% if(instance.enableCssLog || instance.enableMemLog || instance.enableSharedMemLog || instance.enableUartLog) {
/* ----------- DebugP ----------- */
void putchar_(char character)

</snip>
  • Hi Traveler,

    First of all, none of the DebugP_memLogWriterPutChar, DebugP_shmLogWriterPutChar nor the DebugP_uartLogWriterPutChar damage the data it transfers, because they were called using passing value only.

    Secondly, the reason we have to have putchar_() defined is that it is used by _out_char which in turn used by vprintf_ and printf_ which have been used in many places.

    If you still think it is necessary to create your own version of putchar_, the workaround you used in debug_log.c.xdt should be OK.

    Best regards,

    Ming

  • By 'damage' I mean is that they all insert extra characters and remove other characters, altering the information I am logging. 

    The SDK intent is clear. The user should define the putchar_ symbol to direct output from printf, etc, to where it needs to go.

    Sysconfig is helpful, up to a point, setting up putchar for the UART, CCS, or shared memory transfer.

    The problem is that there are so many other ways the user might want to do this. I want a putchar that does not change the characters I am sending (as the DebugP functions currently do). Later I am going to want putchar to send out the USB device since the UART will be removed in later versions of my project.

    I'd rather not maintain my own fork of the SDK (and it's sysconfig meta files). 

    Can we either get a way to disable putchar_ being generated by sysconfig or perhaps be allowed to provide a function to be called inside it?

  • Hi Traveler,

    I do not think there is a n easy way to remove the putchar_ from the syscfg generated files without affect the MCU+ SDK.

    There is one thing you can try to overwrite the putchar_ defined in the syscfg generated file: You can try to define your own putchar_ in your application program. I think the linker will pick up the one you defined instead of the one defined in the syscfg generated file.

    Best regards,

    Ming

  • There are easy ways to allow the SDK users to use their own putchar_ if they have a situation not anticipated by the SDK authors. Below is an example that keeps the SDK functional under all situations and is what I'm currently using.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    source/kernel/.meta/dpl/debug_log.c.xdt | 3 +++
    source/kernel/.meta/dpl/debug_log.syscfg.js | 6 ++++++
    2 files changed, 9 insertions(+)
    diff --git a/source/kernel/.meta/dpl/debug_log.c.xdt b/source/kernel/.meta/dpl/debug_log.c.xdt
    index 0224bee..c0139f7 100644
    --- a/source/kernel/.meta/dpl/debug_log.c.xdt
    +++ b/source/kernel/.meta/dpl/debug_log.c.xdt
    @@ -11,6 +11,9 @@
    /* ----------- DebugP ----------- */
    void putchar_(char character)
    {
    +% if(instance.putchar_UserCallback) {
    + `instance.putchar_UserCallback.toString(16)`(character);
    +% }
    % if(instance.enableCssLog) {
    /* Output to CCS console */
    putchar(character);
    diff --git a/source/kernel/.meta/dpl/debug_log.syscfg.js b/source/kernel/.meta/dpl/debug_log.syscfg.js
    index 3aa7d5e..87e2baa 100644
    --- a/source/kernel/.meta/dpl/debug_log.syscfg.js
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I tried using my own putchar_ in my application before the original post. The linker complained about redefined symbols. If you have a technique for this, I would be interested to learn it.

  • Hi Traveler,

    If you put the __attribute__((weak))  in front of the void_putchar_(char character) in the  ti_dpl,config.c, then the user defined putchar_() in application code will take over without error. Unfortunately, you still need to change the debug_log.c.xdt.p unless the MCU+ SDK is revised.

    Best regards,

    Ming