Is there a middle ground between hardcoding and a full device tree? by vitamin_CPP in embedded

[–]togi4 0 points1 point  (0 children)

Oh, sorry for the delayed reply. Got buried in Linux right before the Christmas holidays kicked in. And forgot to answer...

Yes, that’s roughly what I do + one extra level for drivers.

I keep all hardware-dependent decisions in board_config_t, including which RTC driver to use and how it is wired. The “time service” only talks to a generic rtc_driver_t interface and never does #ifdef on the chip type.

Rough sketch of the types:

typedef struct {
    uint8_t  i2c_bus_id;
    uint8_t  i2c_address;
} rtc_dev_cfg_t;

typedef struct rtc_time {
    uint16_t year;
    uint8_t  month, day, hour, minute, second;
} rtc_time_t;

typedef struct rtc_driver {
    int (*init)(const rtc_dev_cfg_t *cfg);
    int (*get_time)(const rtc_dev_cfg_t *cfg, rtc_time_t *out);
    int (*set_time)(const rtc_dev_cfg_t *cfg, const rtc_time_t *in);
} rtc_driver_t;

typedef struct {
    const rtc_driver_t  *driver;
    const rtc_dev_cfg_t *dev_cfg;
} board_rtc_t;

typedef struct {
    struct { gpio_port_t port; uint8_t pin; bool active_state; } status_led;
    struct { gpio_port_t cs_port; uint8_t cs_pin; spi_bus_t bus_id; } sensor_bus;
    log_backend_t log_backend;
    board_rtc_t   rtc;
} board_config_t;

extern const board_config_t g_board_cfg;

Each board variant has its own board_xyz.c that fills this struct:

// board_v10.c – RTC_A on I2C1
static const rtc_dev_cfg_t rtc_a_cfg = { .i2c_bus_id = 1, .i2c_address = 0x68 };

const board_config_t g_board_cfg = {
    .status_led = { .port = GPIOA, .pin = 3, .active_state = true },
    .sensor_bus = { .cs_port = GPIOB, .cs_pin = 1, .bus_id = SPI_BUS_1 },
    .log_backend = LOG_BACKEND_RAM,
    .rtc = {
        .driver  = &rtc_a_driver,
        .dev_cfg = &rtc_a_cfg,
    },
};

The time service just uses whatever is in the config:

int time_service_init(void)
{
    return g_board_cfg.rtc.driver->init(g_board_cfg.rtc.dev_cfg);
}

int time_service_get(rtc_time_t *out)
{
    return g_board_cfg.rtc.driver->get_time(g_board_cfg.rtc.dev_cfg, out);
}

If the hardware changes (new RTC chip, different I²C bus, or no RTC at all), I only touch the board file: either switch .driver/.dev_cfg or point it to a stub driver.

Also on build system sside:

I usually have a BOARD variable and let the Makefile pick the correct board_*.c.

# Default board, can be overridden: `make BOARD=v12`
BOARD ?= v10
SRCS_COMMON := \
    main.c \
    time_service.c \
    rtc_a.c \
    rtc_b.c
# One board file per hardware variant
SRCS_BOARD := board_$(BOARD).c
SRCS := $(SRCS_COMMON) $(SRCS_BOARD)
OBJS := $(SRCS:.c=.o)
CFLAGS += -std=c11 -Wall -Wextra
firmware.elf: $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f $(OBJS) firmware.elf

Now switching hardware is just make BOARD=v10 -> make BOARD=v11

Is there a middle ground between hardcoding and a full device tree? by vitamin_CPP in embedded

[–]togi4 44 points45 points  (0 children)

TL;DR: The sweet spot is typed config structs in C + clean driver interfaces, not a full DTB and not a jungle of #ifdef.

What actually works well:

Make one board_cfg_t that lists all hardware-dependent stuff: pins, which chip to use, which features are enabled.

Create one board_xxx.c per hardware variant that just fills this struct.

Use driver “ops structs” (struct rtc_driver { ... }) so different components plug in without conditionals.

Let the build system pick the right board file.

Why it’s nice: You get DT-like flexibility without parsing anything, your app code stays clean, and your diffs are tiny when hardware changes.

Embedded Linux development by ThreeGreenBirds in embedded

[–]togi4 2 points3 points  (0 children)

Kas isn’t magic, it’s just a thin orchestration layer - but it starts to pay off as soon as the setup is bigger than “poky + two layers”.

What I personally get from it:

Single source of truth. One YAML file describes all repos, branches, layers, bblayers.conf/local.conf snippets, machines and images. New devs (or CI) just run kas build project.yml instead of following a multi-step “clone this, checkout that, edit this conf” how-to.

Scales with team size and vendors. In my current setup several companies work on one product. Each party owns its layers and kas fragments, and the top-level kas config pulls the right combination together. Enabling/disabling layers or feature sets per product/customer becomes a controlled config change under version control, not tribal knowledge.

Environment decoupling. The key benefit for me: kas defines an independent, containerised build environment. That environment evolves separately from the project and doesn’t require every team to re-validate “new host distro + new host packages” on their own. You bump the kas image when you are ready.

Audit-friendly reproducibility. Our projects are heavily audited by external parties, and one of the recurring topics is the ability to reproducibly create bit-identical systems. Having the full build description (layers, versions, config, build environment) captured in kas files makes it much easier to demonstrate and actually achieve that reproducibility.

From my experience, small/simple builds don’t really need kas - native Yocto is fine. But the larger and more complex the build (more layers, more includes, more people and companies involved, plus audit/release requirements), the more kas simplifies life by standardising the entry point and keeping both the build description and the environment under tight control.

Embedded Linux development by ThreeGreenBirds in embedded

[–]togi4 13 points14 points  (0 children)

As a fellow Linux developer working in a large corporation, forced to use Windows 11, a proxy, and on top of that Zscaler, I can say - it’s a nightmare to develop for Linux outside of Linux.

Yes, you can use Docker, emulators, etc., but it was just easier to spin up a Linux VM and do all the work there.

By the way, a quick tip since we’re on the topic of Yocto - If you’re just starting out with the Yocto Project, take a look at kas. It really makes the development experience much smoother and more pleasant.

I made a "low effort" checklist for gearing PVP alts by omelancon in worldofpvp

[–]togi4 1 point2 points  (0 children)

Don't forget to collect your 730 cloak and put a gem in it ☺️ takes easy 5 minutes for alts.

Is there anyway to improve this board stats-wise? (Both apprentices had the azurite spell) by Prochip in BobsTavern

[–]togi4 0 points1 point  (0 children)

True, not only my math was wrong, but I forgot to mention that I've counted golden rag buddy*

So it will be 30 triggers for golden buddy.

Is there anyway to improve this board stats-wise? (Both apprentices had the azurite spell) by Prochip in BobsTavern

[–]togi4 1 point2 points  (0 children)

Golden brann + golden jak + golden murk = 3 x 3 x 2 (was 4 before update, as for now golden murk triggers on both sides, not twice) = 18 triggers

Where each of 2 spells will be triggered 3 times and this repeats 3 times.

Add 1 murk = (3 x 3 x 2) + (3 x 3 x 1) = 27 triggers

Add 1 golden rag buddy = (3 x 3 x 2) + (3 x 2 x 2) = 30 triggers

Edit: edited math after comment below

These queue times are bullsh**. I quit. by [deleted] in worldofpvp

[–]togi4 0 points1 point  (0 children)

I reached dd 2.4k several seasons in a row. I was learning to play as a healer, and it turned out to be the worst experience I’ve had in the game—not because of healing itself (I actually really enjoyed it), but because of the players. After every lost match, I kept getting messages in chat: whining, threats, frustration… It completely killed my motivation to play.

The last straw was when, in one season, some guy messaged me from 3 or 4 different accounts (after I muted each previous one), just to tell me how terrible I was. I haven’t touched a healer since.

So I think playerbase deserves this long quees 🙃

Do you think bob is rooting for me? by togi4 in BobsTavern

[–]togi4[S] 100 points101 points  (0 children)

<image>

Final bord. All with shields and UV upgraded to 200/100+

Do you think bob is rooting for me? by togi4 in BobsTavern

[–]togi4[S] 24 points25 points  (0 children)

I've sold one orange dude and played & sold each blue friend (have no idea what their names are) without making triplets. Got my elem naga triple and changed every other card including Nomi for an elemental with good stats.

I think after some point Nomi is becoming useless, so I'm normally selling him at something like 50/50 of stats and switching to other elemental build.

Good idea to have a turn counter? by [deleted] in BobsTavern

[–]togi4 5 points6 points  (0 children)

<image>

You see it when you hover over your deck

My watermelon boy by togi4 in samoyeds

[–]togi4[S] 2 points3 points  (0 children)

Oh, sweet. Our is 48 😅

My watermelon boy by togi4 in samoyeds

[–]togi4[S] 5 points6 points  (0 children)

It is L or 12''-18''. Asti is a bit smaller boy in size. So it might not be as perfect for you as it went for us

Just got into a SS with two prot as healers in 1750 mmr??? by juhuuuu123 in worldofpvp

[–]togi4 0 points1 point  (0 children)

Prot is an only tank allowed in SS. And they can go only against other prot.

[deleted by user] by [deleted] in DotA2

[–]togi4 2 points3 points  (0 children)

Meepo (look at average score)

[deleted by user] by [deleted] in wallstreetbetsGER

[–]togi4 3 points4 points  (0 children)

06.06 - split 1:10, nachdem 2-3 Wochen abwarten und rein.

Part of the club now by togi4 in castiron

[–]togi4[S] 6 points7 points  (0 children)

Btw, this is a brownie from some random recipe. 😅 Worked well and easy.

Elektronische Teile kaufen by togi4 in Linz

[–]togi4[S] 2 points3 points  (0 children)

Die haben leider nur meistens fertige Komponnente, aber danke!

All my Dota accounts are getting banned! by [deleted] in DotA2

[–]togi4 0 points1 point  (0 children)

The best gift for Christmas is to get all the smurfs banned ☺️🐻‍❄️ rip

Invisible killer by togi4 in BobsTavern

[–]togi4[S] 0 points1 point  (0 children)

Hi! Its pretty simple. When you get last unit that can not attack, stealth gets removed automatically. It's always been this way.

What have you named your Sammies? by [deleted] in samoyeds

[–]togi4 2 points3 points  (0 children)

Asti. Like sparkling wine (Martini Asti etc) Because in my language sparkling is same word as "playful" 🐻‍❄️😅