tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

Don't depend board definition

Open cpunion opened this issue 3 years ago • 1 comments

I'm deploping a program on stm32f429, I don't want use any predefined board, because it's a custom board, and I want define it in my project. So I create a project with structure likes below:

PROJ/
  main.go
  go.mod
  stm32f429.json
  ...

Content of stm32f429.json:

{
  "inherits": ["cortex-m4"],
  "build-tags": ["stm32f429", "stm32f4", "stm32"],
  "serial": "none",
  "linkerscript": "targets/stm32f429.ld",
  "extra-files": [
    "src/device/stm32/stm32f429.s"
  ],
  "flash-method": "openocd",
  "openocd-interface": "stm32f429-myboard",
  "openocd-target": "stm32f4x"
}

And then I run with command:

tinygo flash -target=./stm32f429.json main.go

It outputs:

# machine
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_i2c_reva.go:132:16: undeclared name: I2C0_SCL_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_i2c_reva.go:133:16: undeclared name: I2C0_SDA_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_spi.go:55:16: undeclared name: SPI0_SCK_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_spi.go:56:16: undeclared name: SPI0_SDO_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_spi.go:57:16: undeclared name: SPI0_SDI_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_uart.go:38:15: undeclared name: UART_TX_PIN
/opt/homebrew/Cellar/tinygo/0.22.0/src/machine/machine_stm32_uart.go:39:15: undeclared name: UART_RX_PIN

I think we can remove those lines.

cpunion avatar Feb 03 '22 08:02 cpunion

Yes, I would be in favor of removing those lines. However, doing that would be a breaking change. It is something I've wanted to do for a long time though.

aykevl avatar Feb 03 '22 18:02 aykevl