How to make vbl_printf_stdout() work?

Hi everyone,

how to make vbl_printf_stdout() do what it is supposed to do? At the moment, it just crashes my board. print() in Python code works as expected.

I’m trying to upgrade u-blox G350 module by adding support to SMS first (my branch on GitHub) and then moving to Zerynth socket. I’m following the line of current Quectel BG96 module which seems more actively maintained.

Thanks in advance.

Hello @lorcap,

the vbl_printf_stdout() is an internal API that should not be used. However, the crash is weird…are you using it with a non-opened serial port?

With r2.6.0 we released a set of debug macros (not yet official, so not publicly documented) that can make debugging C code easier.

Here are the steps to enable it:

  • create a your_library_debug.h
  • enable debugging in project.yml by adding ZERYNTH_DEBUG and ZERYNTH_YOUR_LIBRARY_DEBUG in the config section.
  • include zerynth.h and your_library_debug.h in the C file you need to debug
  • use macros DEBUG0, DEBUG1, ... to print out on the default serial port

you can find a working example here and the related macros here.

Basically, ZERYNTH_DEBUG activates debug globally, while ZERYNTH_YOUR_LIBRARY_DEBUG activates debug for the specific library. It takes values from 0 to 4 corresponding to the desired debug level.

Here is an example of project.yml:

    # Debug enabled
    # Debug level 0

Let us know if this is helpful.

@Giacomo, thanks for your reply.

When using DEBUG0("foo") in the library, I got the following compilation error:

[error] /home/lorcap/.zerynth2/dist/r2.6.0/stdlib/__cdefs/zerynth_debug.h => line 7 : expected expression before ')' token

which I fixed by adding __VA_OPT__(,) function macro as explained GNU GCC’s chapter Variadic Macros (see PR #7).

No, the Python code initializes the output port as per documentation:

import streams

print("It works!")

On the other hand, a “printf” from a .c file doesn’t work:

#include "zerynth.h"
#include "g350_debug.h"
#include "g350.h"

//DEBUG0("This doesn't work.");
vbl_printf_stdout("This doesn't neither");

Commenting out vbl_printf_stdout()

If a guard the C routine with a couple of print("before") and print("after"), after is printed if and only if I comment out the vbl_printf_stdout() line. It means to me the routine is fine and vbl_printf_stdout() crashes the program.

vbl_printf_stdout is found

If I comment out the line NATIVE_UNWARN(), I get the following compilation warning:

pointer targets in passing argument 1 of 'vbl_printf_stdout' differ in signedness [-Wpointer-sign]

which means the declaration of vbl_printf_stdout is found by the compiler.

Compiler version

I discovered that Zerynth compiles with the GCC version I installed in my system under /usr/bin/. Even if I change my $PATH and compile via ztc compile, I get the same result: vbl_printf_stdout() crashes.

Testing environemnt

I’m working with a Mikroe Quail board.

Any help is appreciated because I’m stuck at this point.

Hi @lorcap
sorry for the late reply.
The behavior and errors you are mentioned requires a detailed look from us.
Let us look into this and we will keep you updated.

Hi there, any news on this topic? Thanks.

Hi there,

I just created the new minimalistic repository vbl_printf_stdout on GitHub which demonstrate that C function vbl_printf_stdout() is bugged and crashes on Mikroe Quail board. On the other hand, print() and vhalSerialWrite() work just fine.

When uploaded on my Quail board, the result is:


whereas the expected result would be:


Please, advice on how to fix it so that I can finish up the upgrade to my u-blox G350 module and give it back to the community.