Have you tried removing some bits of unrelated code, and seeing if things start working again?

I solved the problem by creating diffs, rebasing backwards, and applying the diffs. There might have been something wrong in the files that were checked out. I was having issues with op_enum.h. I always make clean and run the enum py script.

Figure that it was something wrong with my git cache.

Alright, I’ve hit the same snag again. The codebase that I once built and released as Alpha 3 now does not operate on the module when I rebuild it.

Steps to reproduce:

Behaviour:

  • Firmware uploads, but teletype never starts

Notes:

  • I’ve tried this with 2 different toolchains, same result
  • I once built this firmware, as evidenced by the release of Alpha 3

Do you have the FTDI serial up and running? If so do you get any output at boot?

Naked, I get the boot message “// teletype” and the “clearing flash” message.

So I started adding debug statements to see what’s happening. I eventually track it down to handler_ScreenRefresh()

Here’s where I get stuck. The bottom of screen_refresh_live():

char s[8];
itoa(screen_dirty, s, 10);
print_dbg("\r\nlive mode dirty: ");
print_dbg(s);
return screen_dirty;

The serial console displays that dirty is 255. Back in handler_ScreenRefresh():

    switch (mode) {
        case M_PATTERN: screen_dirty = screen_refresh_pattern(); break;
        case M_PRESET_W: screen_dirty = screen_refresh_preset_w(); break;
        case M_PRESET_R: screen_dirty = screen_refresh_preset_r(); break;
        case M_HELP: screen_dirty = screen_refresh_help(); break;
        case M_LIVE: screen_dirty = screen_refresh_live(); break;
        case M_EDIT: screen_dirty = screen_refresh_edit(); break;
        case M_SCREENSAVER: screen_dirty = screen_refresh_screensaver(); break;
    }

    print_dbg("\r\nscreen_dirty: ");
    itoa(screen_dirty, s, 10);
    print_dbg(s);

I never see this debug line appear. Additionally, no further events are called.

you can use print_dbg_ulong to avoid having to use itoa.
what happens if you comment out screen_refresh_live?

If I comment out screen_refresh_live, everything works in that I can change to other modes and teletype operates correctly. Obviously live mode is never displayed.

No change in behaviour on the ulong change.

So… compiler bug? Linker bug? Stack overflow?

The variable display is the newest bit of the live screen refresh, try commenting that out?

If that does fix the issue, I’d suggest going through the pointer arithmetic in that bit of code line by line.

1 Like

Looking at the code, is vars_prev uninitialised? (edit: doesn’t matter)

yeah, didn’t mean to suggest changing to print_dbg_ulong would fix the issue, just that it’s easier to use.

really weird, i’m doing much heavier updates in screen_refresh_live for the grid visualizer and haven’t seen any issues.

vars_prev is lazily initialized (D_LIST will be true when the variable display is enabled for the first time).

show_vars will be false on first run, so none of that code is relevant.

Commenting it out doesn’t work.

This bit has changed recently too:

        else if (show_welcome_message) {
            strcpy(s, TELETYPE_VERSION ": ");
            strcat(s, git_version);
            show_welcome_message = false;
        }

Try changing it to:

        else if (show_welcome_message) {
            strcpy(s, TELETYPE_VERSION ": ");
            // strcat(s, git_version);
            show_welcome_message = false;
        }

edit: I reckon it is this, it’s trying to include your tag in the version string, and it’s ending up too long.

1 Like

No luck, same behaviour.

I’m trying to look through the disassembly but it seems that the source lines indicated in between the assembly code don’t correlate. Is that normal?

I found it.

Defined int i in one place and size_t i in the same function.

Would have thought that this would not have been a problem given my understanding of variable scope, but I guess I’ve run into this before.

1 Like

I guess that wasn’t it. After checking out master and applying that change, I get the same behaviour again.

I’ll start commenting again and see what I find.

Yup, it was this, after all. Don’t know why the build didn’t work the first time I commented it out.

The git version now includes the tag, I see. I’ll fix up this bug (bigger buffer, strncat), but we should prevent the gitversion from including the tag or else we won’t be able to see the build number.

It includes the tag so that it picks up the version automatically too. Most tags are quite short, e.g. v2.1.1.

Just changing to strncat should be enough.

But then there will be duplicate information in tagged builds, e.g.:

TELETYPE 2.2.0: v2.2.0-DEADBEE

If we’re including TELETYPE_VERSION, why would we need tags?

Ah sorry. I’m getting confused, I thought we’d already merged this PR:

But we haven’t yet. I might get round to it next week…

What’s really funny is that I suspected those lines because I thought that they had changed recently, but they haven’t for 7 months!

1 Like

Changed my code to reflect that change. Thanks for finding this bug for me! Working with a lot of code at once makes my eyes glaze over sometimes.