Colourized Error Messages

One of the really fantastic things about Mecrisp-Stellaris is that one can easily hack it to suit ones requirements because the source code is GPL’d and Open, and the Author Matthias Koch is friendly and helpful.

Mecrisp-Stellaris has a on-chip compiler, which also emits ERROR MESSAGES as it finds them in Source Code that is being uploaded.

The errors are displayed in the Terminal screen as they occur, mixed in with the source code, and all displayed in the same default Terminal text colour.

_images/mecrisp-stellaris-default-error-reporting.jpg

Some clever Serial Terminals such as E4THCOM parse for the known error messages recolouring them and stopping the upload. E4thcom is distributed as a binary and only runs on Linux.

In other ARTICLES I describe the error response system I deploy, namely :

  1. Lighting a bright BLUE led on the Target when a ERROR is detected

  2. Stop the upload at the actual error via Hardware Handshaking

Note

Both these methods tap into the On Chip Compiler Error Message system. It knows all about errors, why not use it ?

Benefit to New Forth Users

When I started learning Forth, I’d often miss a small error message as the upload streamed by in the Terminal. The small error would often lead to subsquent errors that I’d chase not knowing the true cause. It’s my hope that new Forthers may also find this method a time saver once implemented.

YouTube Video

https://youtu.be/vAGTKLZq0PM

Adding Colourized Error Messages to Mecrisp=Stellaris

In this article I describe a somewhat easier to deploy method of error message colouring which should work across the entire Mecrisp-Stellaris MCU range with only a couple of Kernel Source code mods, and a Kernel REBUILD.

Colorized Error Reporting

This errors in this picture were contrived by compiling the source to Flash repeatedly until the Flash was full.

_images/mecrisp-stellaris-coloured-errors.jpg

CRITICAL: RED Colouring

Sourcefile: mecrisp-stellaris-X.X.X/mecrisp-stellaris-source/common/datastackandmacros.s

Note

This adds the ANSI escape sequence for the color RED indicating CRITICAL errors. Lines which start with “-” need to be replaced with lines starting with “+”

.macro Fehler_Quit_n Meldung
bl dotgaensefuesschen
.byte 8f - 7f         @ Compute length of name field.


-  7:      .ascii "\Meldung\r\n"
+  7:      .ascii "\x1B[31;1m\Meldung\x1B[31;0m\r\n"

8:      .p2align 1
.endm

WARNING: BLUE Colouring

Sourcefile: mecrisp-stellaris-X.X.X/mecrisp-stellaris-source/common/compiler-flash.s

Note

This adds the ANSI escape sequence for the color BLUE indicating a WARNING

-    write "Redefine "
+    write "\x1B[34;1m Redefine\x1B[34;0m "

Now Rebuild the Kernel

REBUILD The Kernel