machine: add generic board support on non-baremetal hardware - #426
Conversation
Instead of trying to modify periperhals directly, external functions are called. For example, __tinygo_gpio_set sets a GPIO pin to a specified value (high or low). It is expected that binaries made this way will be linked with some extra libraries that implement support for these functions. One particularly interesting case is this experimental board simulator: https://github.com/aykevl/tinygo-play Compiling code to WebAssembly with the correct build tag for a board will enable this board to be simulated in the browser. Atmel/Microchip based SAMD boards are not currently supported, because their I2C/SPI support is somewhat uncommon and harder to support in the machine API. They may require a modification to the machine API for proper support.
|
Extremely exciting progress. Merging... |
| tinygo build -size short -o test.elf -target=pca10040 examples/test | ||
| # test all targets/boards | ||
| tinygo build -o test.elf examples/blinky2 # TODO: re-enable -size flag with MachO support | ||
| tinygo build -o test.wasm -tags=pca10040 examples/blinky2 |
There was a problem hiding this comment.
Is this supposed to be -tags instead of -target? It's the odd-one out now.
Also, there's no longer a smoketest of no-target no-tags build (which I guess is native?)
There was a problem hiding this comment.
PS, I ask because the old smoketest used to fail on other arches, but if there's no expectation of compiling natively, then I won't continue investigating the missing support, as it won't be needed by the next release.
There was a problem hiding this comment.
Well, 0.7.0 is out now and this smoketest is still gone, but regular go test still fails on other arches, so I guess I still need to investigate them.
There was a problem hiding this comment.
Sorry, I think I missed this comment. I'm pretty sure I added this test with -tags to test for board simulation, see https://play.tinygo.org/. The regular -target=pca10040 is already tested above.
Instead of trying to modify periperhals directly, external functions are
called. For example, __tinygo_gpio_set sets a GPIO pin to a specified
value (high or low). It is expected that binaries made this way will be
linked with some extra libraries that implement support for these
functions.
One particularly interesting case is this experimental board simulator:
https://github.com/aykevl/tinygo-play
Compiling code to WebAssembly with the correct build tag for a board
will enable this board to be simulated in the browser.
Atmel/Microchip based SAMD boards are not currently supported, because
their I2C/SPI support is somewhat uncommon and harder to support in the
machine API. They may require a modification to the machine API for
proper support.