flipperdevices / flipperzero-toolchain

Flipper Zero Embedded Toolchain
GNU General Public License v3.0
103 stars 11 forks source link

[Question] Linker build error on macOS arm64 #8

Closed paulober closed 6 months ago

paulober commented 8 months ago

I tried to build a small fap in the dev branch of the firmware but it failed with following linker error:

...arm-none-eabi/bin/ld: --gc-sections requires a defined symbol root specified by -e or -u
...

my main file (tsw_ctrl.c):

#include <stdio.h>
#include <furi.h>
#include <gui/gui.h>
#include <input/input.h>

static void app_draw_callback(Canvas* canvas, void* ctx) {
    UNUSED(ctx);

    canvas_clear(canvas);
    canvas_set_font(canvas, FontPrimary);
    canvas_draw_str(canvas, 0, 10, "Hello, World!");
}

static void app_input_callback(InputEvent* event, void* ctx) {
    furi_assert(ctx);
    FuriMessageQueue* event_queue = (FuriMessageQueue*)ctx;

    furi_message_queue_put(event_queue, event, FuriWaitForever);
}

int32_t tsw_ctrl_main(void* p) {
    UNUSED(p);

    InputEvent event;
    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));

    ViewPort* view_port = view_port_alloc();
    view_port_draw_callback_set(view_port, app_draw_callback, view_port);
    view_port_input_callback_set(view_port, app_input_callback, event_queue);

    Gui* gui = furi_record_open(RECORD_GUI);
    gui_add_view_port(gui, view_port, GuiLayerFullscreen);

    for(bool processing = true; processing;) {
        FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);

        if(event_status != FuriStatusOk) {
            goto update_ui_invoke;
        }

        switch(event.key) {
        case InputKeyBack:
            processing = false;
            break;
        default:
            break;
        }

    update_ui_invoke:
        view_port_update(view_port);
    }

    furi_message_queue_free(event_queue);

    gui_remove_view_port(gui, view_port);
    furi_record_close(RECORD_GUI);
    view_port_free(view_port);

    return 0;
}

my application.fam:

App(
    appid="tsw_ctrl",
    name="TSW Ctrl",
    apptype=FlipperAppType.EXTERNAL,
    entry_point="tsw_ctrl",
    stack_size=1 * 1024,
    requires=[
        "bt",
        "gui"
    ],
    fap_category="GPIO",
    fap_icon="icon.png"
)
drunkbatya commented 6 months ago

Hey!

Seems you r set a wrong entrypoint, use your main function name entry_point="tsw_ctrl_main" instead of entry_point="tsw_ctrl". But you r discovered a bug - message needs to be more verbose, thanks!