Skip to content

Build flags for supporting alternate hardware configuration#1

Open
awonak wants to merge 5 commits intomainfrom
multi-board-support
Open

Build flags for supporting alternate hardware configuration#1
awonak wants to merge 5 commits intomainfrom
multi-board-support

Conversation

@awonak
Copy link
Owner

@awonak awonak commented Sep 15, 2022

When DIY EuroPi modules use different GPIO pin configurations, we want to be able to easily support those different configurations without requiring a separate fork. This can be solved using the Go feature build constraints along with separate gpio configuration files with build constraint headers.

For example, we can define two files 1) board.go for the official hardware configuration and 2) board_rmx.go for the smd remix by @luisgongod. The first line of the file will be // go:build europi and // go:build europi_rmx respectively.

With that in place, the EuroPiGo firmware can be build using the command:

tinygo build -tags europi --target pico examples/

or

tinygo build -tags europi_rmx --target pico examples/

In order to use this in VSCode, we will need to make a few adjustments to the VSCode settings.

Add "-tags europi" to tasks.json (or "-tags europi_rmx")

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "tinygo flash",
            "type": "shell",
            "command": "tinygo flash -tags europi --target pico -opt 1 ${workspaceRoot}/examples/clockwerk",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": []
        }
    ]
}

Add the build constraint flag to settings.json (either "europi" or "europi_rmx"):

{
    "go.toolsEnvVars": {
        "GOROOT": "...",
        "GOFLAGS": "-tags=europi,cortexm,baremetal,linux,arm,rp2040,rp,pico,tinygo,math_big_pure_go,gc.conservative,scheduler.tasks,serial.usb"
    }
}

Now you can build and flash the firmware for either hardware configuration!

@awonak awonak changed the title Multi board support Build flags for supporting alternate hardware configuration Sep 16, 2022
@awonak
Copy link
Owner Author

awonak commented Sep 16, 2022

An alternate design consideration, for the default europi configuration, we could instead add a build flag constraint that will only build that file when no other EuroPi board is specified. Say for example we had the other board configurations europi_rmx and europi_xl. We could add the following build constraint to the default europi configuration: //go:build !(europi_rmx || europi_xl). With that added, we can build the firmware without specifying any build tags when building for the default hardware configuration.

Considering that we can easily automate build tasks in VSCode, I don't think this is necessary to do for the purpose of avoiding specifying -tags europi for default hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant