diff --git a/boardgen/boardgen.go b/boardgen/boardgen.go new file mode 100644 index 0000000000..3187873a6b --- /dev/null +++ b/boardgen/boardgen.go @@ -0,0 +1,304 @@ +package boardgen + +import ( + "fmt" + "os" + "path/filepath" + "slices" + "strings" + "text/template" + + "github.com/tinygo-org/tinygo/goenv" +) + +type Board struct { + Name string `json:"name,omitempty"` + BoardFiles map[string]string `json:"files,omitempty"` + Imports []string `json:"imports,omitempty"` + InitFuncs []string `json:"init-funcs,omitempty"` + PinAliases []PinAlias `json:"pin-aliases,omitempty"` + Constants []Variable `json:"constants,omitempty"` + Variables []Variable `json:"variables,omitempty"` + fileDirs []string `json:"-"` + tempDirs []string `json:"-"` +} + +func (board *Board) Files() map[string]string { + if board == nil || board.BoardFiles == nil { + return nil + } + return board.BoardFiles +} + +func (board *Board) DirsFromFiles() []string { + if board == nil || board.BoardFiles == nil { + return []string{} + } + + for dst, src := range board.BoardFiles { + dir := filepath.Clean(dst) + if !isDir(src) { + dir = filepath.Dir(dir) + } + if !slices.Contains(board.fileDirs, dir) { + board.fileDirs = append(board.fileDirs, dir+"/") + } + } + return board.fileDirs +} + +func (board *Board) TempDirs() []string { + if board == nil || board.tempDirs == nil { + return []string{} + } + return board.tempDirs +} + +type PinAlias struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` + Pin string `json:"pin,omitempty"` +} + +func (pa PinAlias) NameLen() int { + return len(pa.Name) +} + +func (pa PinAlias) TypeLen() int { + return len(pa.Type) +} + +func (pa PinAlias) Print(nameLen int, typeLen int) string { + if typeLen != 0 { + // Add an extra space between the name and type + nameLen++ + } + pattern := "\t%-*s%-*s = %s" + return fmt.Sprintf(pattern, nameLen, pa.Name, typeLen, pa.Type, pa.Pin) +} + +type Variable struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` + Quote bool `json:"quote,omitempty"` + Value string `json:"value,omitempty"` +} + +func (v Variable) NameLen() int { + return len(v.Name) +} + +func (v Variable) TypeLen() int { + return len(v.Type) +} + +func (v Variable) Print(nameLen int, typeLen int) string { + if typeLen != 0 { + // Add an extra space between the name and type + nameLen++ + } + pattern := "\t%-*s%-*s = %s" + if v.Quote { + pattern = "\t%-*s%-*s = %q" + } + return fmt.Sprintf(pattern, nameLen, v.Name, typeLen, v.Type, v.Value) +} + +type boardData struct { + BuildTags []string `json:"build-tags,omitempty"` + Board *Board `json:"board,omitempty"` +} + +const boardTemplate = `// Code generated by board-generator. DO NOT EDIT. +{{ buildtags .BuildTags -}} + +package machine + +{{ imports .Board.Imports -}} + +// Pin aliases for the {{.Board.Name}}. +{{ pinAliases .Board.PinAliases -}} + +{{ constants .Board.Constants -}} + +{{ variables .Board.Variables -}} + +{{ initFuncs .Board.InitFuncs -}} +` + +var funcMap = template.FuncMap{ + "buildtags": func(tags []string) string { + if len(tags) == 0 { + return "\n" + } + return "//go:build " + strings.Join(tags, " && ") + "\n\n" + }, + "constants": func(constants []Variable) string { + if len(constants) == 0 { + return "" + } + + longName, longType := longestVar[Variable](constants) + var builder strings.Builder + + builder.WriteString("\nconst (\n") + for _, v := range constants { + if v.Name == "" || v.Value == "" { + // Can't declare a constant with no value + builder.WriteString(fmt.Sprintf("// Invalid constant: %+v\n", v)) + continue + } + builder.WriteString(v.Print(longName, longType)) + builder.WriteString("\n") + } + builder.WriteString(")\n") + return builder.String() + }, + "imports": func(imports []string) string { + if len(imports) == 0 { + return "" + } + var builder strings.Builder + builder.WriteString("\nimport (\n") + for _, imp := range imports { + builder.WriteString(fmt.Sprintf("\t\"%s\"\n", imp)) + } + builder.WriteString(")\n") + return builder.String() + }, + "initFuncs": func(funcs []string) string { + if len(funcs) == 0 { + return "" + } + var builder strings.Builder + builder.WriteString("\nfunc init() {\n") + for _, fn := range funcs { + builder.WriteString(fmt.Sprintf("\t%s\n", fn)) + } + builder.WriteString("}\n") + return builder.String() + }, + "pinAliases": func(pinAliases []PinAlias) string { + if len(pinAliases) == 0 { + return "" + } + + longName, longType := longestVar[PinAlias](pinAliases) + var builder strings.Builder + + builder.WriteString("\nconst (\n") + for _, pa := range pinAliases { + if pa.Name == "" || pa.Pin == "" { + // Can't declare a pin alias with no pin or name + builder.WriteString(fmt.Sprintf("// Invalid pin alias: %+v\n", pa)) + continue + } + builder.WriteString(pa.Print(longName, longType)) + builder.WriteString("\n") + } + builder.WriteString(")\n") + return builder.String() + }, + "variables": func(variables []Variable) string { + if len(variables) == 0 { + return "" + } + + longName, longType := longestVar[Variable](variables) + var builder strings.Builder + + builder.WriteString("\nvar (\n") + + for _, v := range variables { + if v.Name == "" || v.Type == "" && v.Value == "" { + // Can't declare a variable with no name or no type/value + builder.WriteString(fmt.Sprintf("// Invalid variable: %+v\n", v)) + continue + } + builder.WriteString(v.Print(longName, longType)) + builder.WriteString("\n") + } + builder.WriteString(")\n") + return builder.String() + }, +} + +type varStruct interface { + NameLen() int + TypeLen() int +} + +func longestVar[T varStruct](v []T) (int, int) { + longName := 0 + longType := 0 + for _, variable := range v { + if variable.NameLen() > longName { + longName = variable.NameLen() + } + if variable.TypeLen() > longType { + longType = variable.TypeLen() + } + } + return longName, longType +} + +func (board *Board) Generate(target string, buildTags []string) error { + if board == nil { + return fmt.Errorf("board is nil") + } + + board.BoardFiles = make(map[string]string) + + // Make a temp directory to import the target's generated files for later import + err := os.MkdirAll(goenv.Get("GOCACHE"), 0777) + if err != nil { + return err + } + tmpDir, err := os.MkdirTemp(goenv.Get("GOCACHE"), target+".tmp") + if err != nil { + return err + } + board.tempDirs = append(board.tempDirs, tmpDir) + + fileName := "boardgen_" + target + ".go" + destPath := filepath.Join("machine", fileName) + sourcePath := filepath.Join(tmpDir, fileName) + + // Generate a go file for the board + boardData := boardData{ + BuildTags: buildTags, + Board: board, + } + tmpl, err := template.New("board").Funcs(funcMap).Parse(boardTemplate) + if err != nil { + return err + } + + fp, err := os.Create(sourcePath) + if err != nil { + return err + } + defer fp.Close() + + err = tmpl.Execute(fp, boardData) + if err != nil { + return err + } + // Write the file to disk ASAP + err = fp.Sync() + if err != nil { + return err + } + + board.BoardFiles[destPath] = sourcePath + + return nil +} + +func isDir(path string) bool { + f, err := os.Stat(path) + if err != nil { + return false + } + return f.IsDir() +} diff --git a/compileopts/target.go b/compileopts/target.go index 16d21f46c5..48e9c96e82 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -14,6 +14,7 @@ import ( "runtime" "strings" + "github.com/tinygo-org/tinygo/boardgen" "github.com/tinygo-org/tinygo/goenv" ) @@ -23,50 +24,51 @@ import ( // https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html // https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json type TargetSpec struct { - Inherits []string `json:"inherits,omitempty"` - Triple string `json:"llvm-target,omitempty"` - CPU string `json:"cpu,omitempty"` - ABI string `json:"target-abi,omitempty"` // roughly equivalent to -mabi= flag - Features string `json:"features,omitempty"` - GOOS string `json:"goos,omitempty"` - GOARCH string `json:"goarch,omitempty"` - SoftFloat bool // used for non-baremetal systems (GOMIPS=softfloat etc) - BuildTags []string `json:"build-tags,omitempty"` - BuildMode string `json:"buildmode,omitempty"` // default build mode (if nothing specified) - GC string `json:"gc,omitempty"` - Scheduler string `json:"scheduler,omitempty"` - Serial string `json:"serial,omitempty"` // which serial output to use (uart, usb, none) - Linker string `json:"linker,omitempty"` - RTLib string `json:"rtlib,omitempty"` // compiler runtime library (libgcc, compiler-rt) - Libc string `json:"libc,omitempty"` - AutoStackSize *bool `json:"automatic-stack-size,omitempty"` // Determine stack size automatically at compile time. - DefaultStackSize uint64 `json:"default-stack-size,omitempty"` // Default stack size if the size couldn't be determined at compile time. - CFlags []string `json:"cflags,omitempty"` - LDFlags []string `json:"ldflags,omitempty"` - LinkerScript string `json:"linkerscript,omitempty"` - ExtraFiles []string `json:"extra-files,omitempty"` - RP2040BootPatch *bool `json:"rp2040-boot-patch,omitempty"` // Patch RP2040 2nd stage bootloader checksum - BootPatches []string `json:"boot-patches,omitempty"` // Bootloader patches to be applied in the order they appear. - Emulator string `json:"emulator,omitempty"` - FlashCommand string `json:"flash-command,omitempty"` - GDB []string `json:"gdb,omitempty"` - PortReset string `json:"flash-1200-bps-reset,omitempty"` - SerialPort []string `json:"serial-port,omitempty"` // serial port IDs in the form "vid:pid" - FlashMethod string `json:"flash-method,omitempty"` - FlashVolume []string `json:"msd-volume-name,omitempty"` - FlashFilename string `json:"msd-firmware-name,omitempty"` - UF2FamilyID string `json:"uf2-family-id,omitempty"` - BinaryFormat string `json:"binary-format,omitempty"` - OpenOCDInterface string `json:"openocd-interface,omitempty"` - OpenOCDTarget string `json:"openocd-target,omitempty"` - OpenOCDTransport string `json:"openocd-transport,omitempty"` - OpenOCDCommands []string `json:"openocd-commands,omitempty"` - OpenOCDVerify *bool `json:"openocd-verify,omitempty"` // enable verify when flashing with openocd - JLinkDevice string `json:"jlink-device,omitempty"` - CodeModel string `json:"code-model,omitempty"` - RelocationModel string `json:"relocation-model,omitempty"` - WITPackage string `json:"wit-package,omitempty"` - WITWorld string `json:"wit-world,omitempty"` + Inherits []string `json:"inherits,omitempty"` + Triple string `json:"llvm-target,omitempty"` + CPU string `json:"cpu,omitempty"` + ABI string `json:"target-abi,omitempty"` // roughly equivalent to -mabi= flag + Features string `json:"features,omitempty"` + GOOS string `json:"goos,omitempty"` + GOARCH string `json:"goarch,omitempty"` + SoftFloat bool // used for non-baremetal systems (GOMIPS=softfloat etc) + BuildTags []string `json:"build-tags,omitempty"` + BuildMode string `json:"buildmode,omitempty"` // default build mode (if nothing specified) + GC string `json:"gc,omitempty"` + Scheduler string `json:"scheduler,omitempty"` + Serial string `json:"serial,omitempty"` // which serial output to use (uart, usb, none) + Linker string `json:"linker,omitempty"` + RTLib string `json:"rtlib,omitempty"` // compiler runtime library (libgcc, compiler-rt) + Libc string `json:"libc,omitempty"` + AutoStackSize *bool `json:"automatic-stack-size,omitempty"` // Determine stack size automatically at compile time. + DefaultStackSize uint64 `json:"default-stack-size,omitempty"` // Default stack size if the size couldn't be determined at compile time. + CFlags []string `json:"cflags,omitempty"` + LDFlags []string `json:"ldflags,omitempty"` + LinkerScript string `json:"linkerscript,omitempty"` + ExtraFiles []string `json:"extra-files,omitempty"` + RP2040BootPatch *bool `json:"rp2040-boot-patch,omitempty"` // Patch RP2040 2nd stage bootloader checksum + BootPatches []string `json:"boot-patches,omitempty"` // Bootloader patches to be applied in the order they appear. + Emulator string `json:"emulator,omitempty"` + FlashCommand string `json:"flash-command,omitempty"` + GDB []string `json:"gdb,omitempty"` + PortReset string `json:"flash-1200-bps-reset,omitempty"` + SerialPort []string `json:"serial-port,omitempty"` // serial port IDs in the form "vid:pid" + FlashMethod string `json:"flash-method,omitempty"` + FlashVolume []string `json:"msd-volume-name,omitempty"` + FlashFilename string `json:"msd-firmware-name,omitempty"` + UF2FamilyID string `json:"uf2-family-id,omitempty"` + BinaryFormat string `json:"binary-format,omitempty"` + OpenOCDInterface string `json:"openocd-interface,omitempty"` + OpenOCDTarget string `json:"openocd-target,omitempty"` + OpenOCDTransport string `json:"openocd-transport,omitempty"` + OpenOCDCommands []string `json:"openocd-commands,omitempty"` + OpenOCDVerify *bool `json:"openocd-verify,omitempty"` // enable verify when flashing with openocd + JLinkDevice string `json:"jlink-device,omitempty"` + CodeModel string `json:"code-model,omitempty"` + RelocationModel string `json:"relocation-model,omitempty"` + WITPackage string `json:"wit-package,omitempty"` + WITWorld string `json:"wit-world,omitempty"` + Board *boardgen.Board `json:"board,omitempty"` } // overrideProperties overrides all properties that are set in child into itself using reflection. @@ -215,6 +217,9 @@ func LoadTarget(options *Options) (*TargetSpec, error) { spec.ExtraFiles = append(spec.ExtraFiles, "src/internal/task/task_asyncify_wasm.S") } + // Template out board-specific files + spec.Board.Generate(options.Target, spec.BuildTags) + return spec, nil } diff --git a/loader/goroot.go b/loader/goroot.go index 00a7124d80..6867034de5 100644 --- a/loader/goroot.go +++ b/loader/goroot.go @@ -23,9 +23,11 @@ import ( "path" "path/filepath" "runtime" + "slices" "sort" "sync" + "github.com/tinygo-org/tinygo/boardgen" "github.com/tinygo-org/tinygo/compileopts" "github.com/tinygo-org/tinygo/goenv" ) @@ -43,12 +45,13 @@ func GetCachedGoroot(config *compileopts.Config) (string, error) { if tinygoroot == "" { return "", errors.New("could not determine TINYGOROOT") } + board := config.Target.Board // Find the overrides needed for the goroot. - overrides := pathsToOverride(config.GoMinorVersion, needsSyscallPackage(config.BuildTags())) + overrides := pathsToOverride(config.GoMinorVersion, needsSyscallPackage(config.BuildTags()), board) // Resolve the merge links within the goroot. - merge, err := listGorootMergeLinks(goroot, tinygoroot, overrides) + merge, err := listGorootMergeLinks(goroot, tinygoroot, overrides, board) if err != nil { return "", err } @@ -113,12 +116,28 @@ func GetCachedGoroot(config *compileopts.Config) (string, error) { // Create all symlinks. for dst, src := range merge { + if src == "." { + // Merges with a src of "." will be copied instead of linked. + continue + } err := symlink(src, filepath.Join(tmpgoroot, dst)) if err != nil { return "", err } } + // Inject board-specific files into the cache. + for dst, src := range board.Files() { + err := fileCopy(src, filepath.Join(tmpgoroot, "src", dst)) + if err != nil { + return "", err + } + } + // Try not too hard to clean up temp dirs used to generate board files. + for _, dir := range board.TempDirs() { + os.RemoveAll(dir) + } + // Rename the new merged gorooot into place. err = os.Rename(tmpgoroot, cachedgoroot) if err != nil { @@ -143,10 +162,11 @@ func GetCachedGoroot(config *compileopts.Config) (string, error) { } // listGorootMergeLinks searches goroot and tinygoroot for all symlinks that must be created within the merged goroot. -func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool) (map[string]string, error) { +func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool, board *boardgen.Board) (map[string]string, error) { goSrc := filepath.Join(goroot, "src") tinygoSrc := filepath.Join(tinygoroot, "src") merges := make(map[string]string) + boardDirs := board.DirsFromFiles() for dir, merge := range overrides { if !merge { // Use the TinyGo version. @@ -154,6 +174,20 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool) continue } + // Use the override to individually symlink files in a directory with + // board-specific files rather than the directory itself, so generated + // files can be injected into the cache. + // e.g. src/machine -> tinygo/src/machine becomes: + // src/machine/machine.go -> tinygo/src/machine/machine.go + // Otherwise, adding a generated file to src/machine/ just adds it to + // tinygo/src/machine/ and the intent is to avoid requiring write + // access to TINYGOROOT. + var tinyGoMerge bool + if slices.Contains(boardDirs, dir) { + // Don't try to insert non-existent BigGo files. + tinyGoMerge = true + } + // Add files from TinyGo. tinygoDir := filepath.Join(tinygoSrc, dir) tinygoEntries, err := os.ReadDir(tinygoDir) @@ -162,7 +196,7 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool) } var hasTinyGoFiles bool for _, e := range tinygoEntries { - if e.IsDir() { + if e.IsDir() && !tinyGoMerge { continue } @@ -173,6 +207,10 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool) hasTinyGoFiles = true } + if tinyGoMerge { + continue + } + // Add all directories from $GOROOT that are not part of the TinyGo // overrides. goDir := filepath.Join(goSrc, dir) @@ -201,6 +239,11 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool) } } + // Insert board-specific file merge placeholders + for dst := range board.Files() { + merges[filepath.Join("src", dst)] = "." + } + // Merge the special directories from goroot. for _, dir := range []string{"bin", "lib", "pkg"} { merges[dir] = filepath.Join(goroot, dir) @@ -227,7 +270,7 @@ func needsSyscallPackage(buildTags []string) bool { // The boolean indicates whether to merge the subdirs. True means merge, false // means use the TinyGo version. -func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool { +func pathsToOverride(goMinor int, needsSyscallPackage bool, board *boardgen.Board) map[string]bool { paths := map[string]bool{ "": true, "crypto/": true, @@ -272,6 +315,13 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool { paths["internal/syscall/"] = true paths["internal/syscall/unix/"] = false } + + // Add board-specific directories to the override merges. + for _, dir := range board.DirsFromFiles() { + if _, ok := paths[dir]; ok { + paths[dir] = true + } + } return paths } @@ -334,3 +384,29 @@ func symlink(oldname, newname string) error { } return symlinkErr } + +func fileCopy(src, dst string) error { + // Make sure we're not overwriting an existing file. + if _, err := os.Lstat(dst); err == nil { + return errors.New("destination file already exists: " + dst) + } + + srcFile, err := os.Open(src) + if err != nil { + return err + } + defer srcFile.Close() + + dstFile, err := os.Create(dst) + if err != nil { + return err + } + defer dstFile.Close() + + _, err = io.Copy(dstFile, srcFile) + if err != nil { + return err + } + + return nil +} diff --git a/loader/loader.go b/loader/loader.go index e935a9de3a..705bfeaea2 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -279,7 +279,7 @@ func (p *Program) getOriginalPath(path string) string { originalPath = realgorootPath } maybeInTinyGoRoot := false - for prefix := range pathsToOverride(p.config.GoMinorVersion, needsSyscallPackage(p.config.BuildTags())) { + for prefix := range pathsToOverride(p.config.GoMinorVersion, needsSyscallPackage(p.config.BuildTags()), p.config.Target.Board) { if runtime.GOOS == "windows" { prefix = strings.ReplaceAll(prefix, "/", "\\") } diff --git a/src/machine/board_elecrow-rp2350-w5.go b/src/machine/board_elecrow-rp2350-w5.go deleted file mode 100644 index 80a8436444..0000000000 --- a/src/machine/board_elecrow-rp2350-w5.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build elecrow_rp2350 - -// This file contains the pin mappings for the Elecrow Pico rp2350 W5 boards. -// -// Elecrow Pico rp2350 W5 is a microcontroller using the Raspberry Pi RP2350 -// chip and rtl8720d Wifi chip. -// -// - https://www.elecrow.com/pico-w5-microcontroller-development-boards-rp2350-microcontroller-board.html -package machine - -// GPIO pins -const ( - GP0 Pin = GPIO0 - GP1 Pin = GPIO1 - GP2 Pin = GPIO2 - GP3 Pin = GPIO3 - GP4 Pin = GPIO4 - GP5 Pin = GPIO5 - GP6 Pin = GPIO6 - GP7 Pin = GPIO7 - GP8 Pin = GPIO8 - GP9 Pin = GPIO9 - GP10 Pin = GPIO10 - GP11 Pin = GPIO11 - GP12 Pin = GPIO12 - GP13 Pin = GPIO13 - GP14 Pin = GPIO14 - GP15 Pin = GPIO15 - GP16 Pin = GPIO16 - GP17 Pin = GPIO17 - GP18 Pin = GPIO18 - GP19 Pin = GPIO19 - GP20 Pin = GPIO20 - GP21 Pin = GPIO21 - GP22 Pin = GPIO22 - GP26 Pin = GPIO26 - GP27 Pin = GPIO27 - GP28 Pin = GPIO28 - - // Onboard LED - LED Pin = GPIO25 - - // Onboard crystal oscillator frequency, in MHz. - xoscFreq = 12 // MHz -) - -// I2C Default pins on Raspberry Pico. -const ( - I2C0_SDA_PIN = GP4 - I2C0_SCL_PIN = GP5 - - I2C1_SDA_PIN = GP2 - I2C1_SCL_PIN = GP3 -) - -// SPI default pins -const ( - // Default Serial Clock Bus 0 for SPI communications - SPI0_SCK_PIN = GPIO18 - // Default Serial Out Bus 0 for SPI communications - SPI0_SDO_PIN = GPIO19 // Tx - // Default Serial In Bus 0 for SPI communications - SPI0_SDI_PIN = GPIO16 // Rx - - // Default Serial Clock Bus 1 for SPI communications - SPI1_SCK_PIN = GPIO10 - // Default Serial Out Bus 1 for SPI communications - SPI1_SDO_PIN = GPIO11 // Tx - // Default Serial In Bus 1 for SPI communications - SPI1_SDI_PIN = GPIO12 // Rx -) - -// UART pins -const ( - UART0_TX_PIN = GPIO0 - UART0_RX_PIN = GPIO1 - UART1_TX_PIN = GPIO4 // Wired to rtl8720d UART1_Tx - UART1_RX_PIN = GPIO5 // Wired to rtl8720n UART1_Rx - UART_TX_PIN = UART0_TX_PIN - UART_RX_PIN = UART0_RX_PIN -) - -var DefaultUART = UART0 - -// USB identifiers -const ( - usb_STRING_PRODUCT = "Pico2" - usb_STRING_MANUFACTURER = "Raspberry Pi" -) - -var ( - usb_VID uint16 = 0x2E8A - usb_PID uint16 = 0x000F -) diff --git a/src/machine/board_metro_rp2350.go b/src/machine/board_metro_rp2350.go deleted file mode 100644 index 3bffe30d60..0000000000 --- a/src/machine/board_metro_rp2350.go +++ /dev/null @@ -1,183 +0,0 @@ -//go:build metro_rp2350 - -package machine - -// GPIO pins -const ( - GP0 Pin = GPIO0 - GP1 Pin = GPIO1 - GP2 Pin = GPIO2 - GP3 Pin = GPIO3 - GP4 Pin = GPIO4 - GP5 Pin = GPIO5 - GP6 Pin = GPIO6 - GP7 Pin = GPIO7 - GP8 Pin = GPIO8 - GP9 Pin = GPIO9 - GP10 Pin = GPIO10 - GP11 Pin = GPIO11 - GP12 Pin = GPIO12 - GP13 Pin = GPIO13 - GP14 Pin = GPIO14 - GP15 Pin = GPIO15 - GP16 Pin = GPIO16 - GP17 Pin = GPIO17 - GP18 Pin = GPIO18 - GP19 Pin = GPIO19 - GP20 Pin = GPIO20 - GP21 Pin = GPIO21 - GP22 Pin = GPIO22 - GP23 Pin = GPIO23 - GP24 Pin = GPIO24 - GP25 Pin = GPIO25 - GP26 Pin = GPIO26 - GP27 Pin = GPIO27 - GP28 Pin = GPIO28 - GP29 Pin = GPIO29 - GP30 Pin = GPIO30 - GP31 Pin = GPIO31 - GP32 Pin = GPIO32 - GP33 Pin = GPIO33 - GP34 Pin = GPIO34 - GP35 Pin = GPIO35 - GP36 Pin = GPIO36 - GP37 Pin = GPIO37 - GP38 Pin = GPIO38 - GP39 Pin = GPIO39 - GP40 Pin = GPIO40 - GP41 Pin = GPIO41 - GP42 Pin = GPIO42 - GP43 Pin = GPIO43 - GP44 Pin = GPIO44 - GP45 Pin = GPIO45 - GP46 Pin = GPIO46 - - // Boot button - BUTTON Pin = GPIO24 - - // Onboard LED - LED Pin = GPIO23 - - // Onboard NeoPixel - NEOPIXEL Pin = GPIO25 - WS2812 Pin = GPIO25 - - // Onboard crystal oscillator frequency, in MHz. - xoscFreq = 12 // MHz -) - -// Arduino-header digital pins -const ( - RX Pin = GPIO1 - TX Pin = GPIO0 - D2 Pin = GPIO2 - D3 Pin = GPIO3 - D4 Pin = GPIO4 - D5 Pin = GPIO5 - D6 Pin = GPIO6 - D7 Pin = GPIO7 - D8 Pin = GPIO8 - D9 Pin = GPIO9 - D10 Pin = GPIO10 - D11 Pin = GPIO11 - D22 Pin = GPIO22 - D23 Pin = GPIO23 -) - -// Arduino-header analog pins -const ( - A0 Pin = GPIO41 - A1 Pin = GPIO42 - A2 Pin = GPIO43 - A3 Pin = GPIO44 - A4 Pin = GPIO45 - A5 Pin = GPIO46 -) - -// I2C Default pins on Raspberry Pico. -const ( - I2C0_SDA_PIN = GP20 - I2C0_SCL_PIN = GP21 - - I2C1_SDA_PIN = GP2 - I2C1_SCL_PIN = GP3 -) - -// SPI default pins -const ( - // Default Serial Clock Bus 0 for SPI communications - SPI0_SCK_PIN = GPIO18 - // Default Serial Out Bus 0 for SPI communications - SPI0_SDO_PIN = GPIO19 // Tx - // Default Serial In Bus 0 for SPI communications - SPI0_SDI_PIN = GPIO16 // Rx - - // Default Serial Clock Bus 1 for SPI communications - SPI1_SCK_PIN = GPIO30 - // Default Serial Out Bus 1 for SPI communications - SPI1_SDO_PIN = GPIO31 // Tx - // Default Serial In Bus 1 for SPI communications - SPI1_SDI_PIN = GPIO28 // Rx - - // SPI header pins - MOSI Pin = SPI1_SDO_PIN - MISO Pin = SPI1_SDI_PIN - SCK Pin = SPI1_SCK_PIN -) - -// SD card reader pins -const ( - SD_SCK = GPIO34 - SD_MOSI = GPIO35 - SD_MISO = GPIO36 - SDIO_DATA1 = GPIO37 - SDIO_DATA2 = GPIO38 - SD_CS = GPIO39 - SD_CARD_DETECT = GPIO40 -) - -// HSTX pins -const ( - CKN Pin = GPIO15 - CKP Pin = GPIO14 - D0N Pin = GPIO19 - D0P Pin = GPIO18 - D1N Pin = GPIO17 - D1P Pin = GPIO16 - D2N Pin = GPIO13 - D2P Pin = GPIO12 - D26 Pin = GPIO26 - D27 Pin = GPIO27 - SCL Pin = GPIO21 - SDA Pin = GPIO20 -) - -// USB host header pins -const ( - USB_HOST_DATA_PLUS Pin = GPIO32 - USB_HOST_DATA_MINUS Pin = GPIO33 - USB_HOST_5V_POWER Pin = GPIO29 -) - -// UART pins -const ( - UART0_TX_PIN = GPIO0 - UART0_RX_PIN = GPIO1 - UART1_TX_PIN = GPIO8 - UART1_RX_PIN = GPIO9 - UART_TX_PIN = UART0_TX_PIN - UART_RX_PIN = UART0_RX_PIN -) - -var DefaultUART = UART0 - -// USB identifiers -const ( - usb_STRING_PRODUCT = "Metro RP2350" - usb_STRING_MANUFACTURER = "Adafruit" -) - -var ( - usb_VID uint16 = 0x239A - usb_PID uint16 = 0x814E -) diff --git a/src/machine/board_pga2350.go b/src/machine/board_pga2350.go deleted file mode 100644 index 9bfb9653b3..0000000000 --- a/src/machine/board_pga2350.go +++ /dev/null @@ -1,97 +0,0 @@ -//go:build pga2350 - -package machine - -// PGA2350 pin definitions. -const ( - GP0 = GPIO0 - GP1 = GPIO1 - GP2 = GPIO2 - GP3 = GPIO3 - GP4 = GPIO4 - GP5 = GPIO5 - GP6 = GPIO6 - GP7 = GPIO7 - GP8 = GPIO8 - GP9 = GPIO9 - GP10 = GPIO10 - GP11 = GPIO11 - GP12 = GPIO12 - GP13 = GPIO13 - GP14 = GPIO14 - GP15 = GPIO15 - GP16 = GPIO16 - GP17 = GPIO17 - GP18 = GPIO18 - GP19 = GPIO19 - GP20 = GPIO20 - GP21 = GPIO21 - GP22 = GPIO22 - GP26 = GPIO26 - GP27 = GPIO27 - GP28 = GPIO28 - GP29 = GPIO29 - GP30 = GPIO30 - GP31 = GPIO31 - GP32 = GPIO32 - GP33 = GPIO33 - GP34 = GPIO34 - GP35 = GPIO35 - GP36 = GPIO36 - GP37 = GPIO37 - GP38 = GPIO38 - GP39 = GPIO39 - GP40 = GPIO40 - GP41 = GPIO41 - GP42 = GPIO42 - GP43 = GPIO43 - GP44 = GPIO44 - GP45 = GPIO45 - GP46 = GPIO46 - GP47 = GPIO47 -) - -var DefaultUART = UART0 - -// Peripheral defaults. -const ( - xoscFreq = 12 // MHz - - I2C0_SDA_PIN = GP4 - I2C0_SCL_PIN = GP5 - - I2C1_SDA_PIN = GP2 - I2C1_SCL_PIN = GP3 - - // Default Serial Clock Bus 0 for SPI communications - SPI0_SCK_PIN = GPIO18 - // Default Serial Out Bus 0 for SPI communications - SPI0_SDO_PIN = GPIO19 // Tx - // Default Serial In Bus 0 for SPI communications - SPI0_SDI_PIN = GPIO16 // Rx - - // Default Serial Clock Bus 1 for SPI communications - SPI1_SCK_PIN = GPIO10 - // Default Serial Out Bus 1 for SPI communications - SPI1_SDO_PIN = GPIO11 // Tx - // Default Serial In Bus 1 for SPI communications - SPI1_SDI_PIN = GPIO12 // Rx - - UART0_TX_PIN = GPIO0 - UART0_RX_PIN = GPIO1 - UART1_TX_PIN = GPIO8 - UART1_RX_PIN = GPIO9 - UART_TX_PIN = UART0_TX_PIN - UART_RX_PIN = UART0_RX_PIN -) - -// USB identifiers -const ( - usb_STRING_PRODUCT = "PGA2350" - usb_STRING_MANUFACTURER = "Pimoroni" -) - -var ( - usb_VID uint16 = 0x2E8A - usb_PID uint16 = 0x000A -) diff --git a/src/machine/board_pico2.go b/src/machine/board_pico2.go deleted file mode 100644 index 327c542fbc..0000000000 --- a/src/machine/board_pico2.go +++ /dev/null @@ -1,88 +0,0 @@ -//go:build pico2 - -package machine - -// GPIO pins -const ( - GP0 Pin = GPIO0 - GP1 Pin = GPIO1 - GP2 Pin = GPIO2 - GP3 Pin = GPIO3 - GP4 Pin = GPIO4 - GP5 Pin = GPIO5 - GP6 Pin = GPIO6 - GP7 Pin = GPIO7 - GP8 Pin = GPIO8 - GP9 Pin = GPIO9 - GP10 Pin = GPIO10 - GP11 Pin = GPIO11 - GP12 Pin = GPIO12 - GP13 Pin = GPIO13 - GP14 Pin = GPIO14 - GP15 Pin = GPIO15 - GP16 Pin = GPIO16 - GP17 Pin = GPIO17 - GP18 Pin = GPIO18 - GP19 Pin = GPIO19 - GP20 Pin = GPIO20 - GP21 Pin = GPIO21 - GP22 Pin = GPIO22 - GP26 Pin = GPIO26 - GP27 Pin = GPIO27 - GP28 Pin = GPIO28 - - // Onboard LED - LED Pin = GPIO25 - - // Onboard crystal oscillator frequency, in MHz. - xoscFreq = 12 // MHz -) - -// I2C Default pins on Raspberry Pico. -const ( - I2C0_SDA_PIN = GP4 - I2C0_SCL_PIN = GP5 - - I2C1_SDA_PIN = GP2 - I2C1_SCL_PIN = GP3 -) - -// SPI default pins -const ( - // Default Serial Clock Bus 0 for SPI communications - SPI0_SCK_PIN = GPIO18 - // Default Serial Out Bus 0 for SPI communications - SPI0_SDO_PIN = GPIO19 // Tx - // Default Serial In Bus 0 for SPI communications - SPI0_SDI_PIN = GPIO16 // Rx - - // Default Serial Clock Bus 1 for SPI communications - SPI1_SCK_PIN = GPIO10 - // Default Serial Out Bus 1 for SPI communications - SPI1_SDO_PIN = GPIO11 // Tx - // Default Serial In Bus 1 for SPI communications - SPI1_SDI_PIN = GPIO12 // Rx -) - -// UART pins -const ( - UART0_TX_PIN = GPIO0 - UART0_RX_PIN = GPIO1 - UART1_TX_PIN = GPIO8 - UART1_RX_PIN = GPIO9 - UART_TX_PIN = UART0_TX_PIN - UART_RX_PIN = UART0_RX_PIN -) - -var DefaultUART = UART0 - -// USB identifiers -const ( - usb_STRING_PRODUCT = "Pico2" - usb_STRING_MANUFACTURER = "Raspberry Pi" -) - -var ( - usb_VID uint16 = 0x2E8A - usb_PID uint16 = 0x000A -) diff --git a/src/machine/board_tiny2350.go b/src/machine/board_tiny2350.go deleted file mode 100644 index f04fa061b6..0000000000 --- a/src/machine/board_tiny2350.go +++ /dev/null @@ -1,82 +0,0 @@ -//go:build tiny2350 - -package machine - -// GPIO pins -const ( - GP0 Pin = GPIO0 - GP1 Pin = GPIO1 - GP2 Pin = GPIO2 - GP3 Pin = GPIO3 - GP4 Pin = GPIO4 - GP5 Pin = GPIO5 - GP6 Pin = GPIO6 - GP7 Pin = GPIO7 - GP12 Pin = GPIO12 - GP13 Pin = GPIO13 - GP18 Pin = GPIO18 - GP19 Pin = GPIO19 - GP20 Pin = GPIO20 - GP26 Pin = GPIO26 - GP27 Pin = GPIO27 - GP28 Pin = GPIO28 - GP29 Pin = GPIO29 - - // Onboard LED - LED_RED Pin = GPIO18 - LED_GREEN Pin = GPIO19 - LED_BLUE Pin = GPIO20 - LED = LED_RED - - // Onboard crystal oscillator frequency, in MHz. - xoscFreq = 12 // MHz -) - -// I2C Default pins on Tiny2350. -const ( - I2C0_SDA_PIN = GP12 - I2C0_SCL_PIN = GP13 - - I2C1_SDA_PIN = GP2 - I2C1_SCL_PIN = GP3 -) - -// SPI default pins -const ( - // Default Serial Clock Bus 0 for SPI communications - SPI0_SCK_PIN = GPIO6 - // Default Serial Out Bus 0 for SPI communications - SPI0_SDO_PIN = GPIO7 // Tx - // Default Serial In Bus 0 for SPI communications - SPI0_SDI_PIN = GPIO4 // Rx - - // Default Serial Clock Bus 1 for SPI communications - SPI1_SCK_PIN = GPIO26 - // Default Serial Out Bus 1 for SPI communications - SPI1_SDO_PIN = GPIO27 // Tx - // Default Serial In Bus 1 for SPI communications - SPI1_SDI_PIN = GPIO28 // Rx -) - -// UART pins -const ( - UART0_TX_PIN = GPIO0 - UART0_RX_PIN = GPIO1 - UART1_TX_PIN = GPIO4 - UART1_RX_PIN = GPIO5 - UART_TX_PIN = UART0_TX_PIN - UART_RX_PIN = UART0_RX_PIN -) - -var DefaultUART = UART0 - -// USB identifiers -const ( - usb_STRING_PRODUCT = "Tiny2350" - usb_STRING_MANUFACTURER = "Pimoroni" -) - -var ( - usb_VID uint16 = 0x2E8A - usb_PID uint16 = 0x000F -) diff --git a/targets/elecrow-rp2350.json b/targets/elecrow-rp2350.json index 75876ed5ff..60e1acb1c8 100644 --- a/targets/elecrow-rp2350.json +++ b/targets/elecrow-rp2350.json @@ -8,5 +8,63 @@ ], "extra-files": [ "targets/pico-boot-stage2.S" - ] + ], + "board": { + "name": "Elecrow Pico rp2350 W5", + "constants": [ + { "name": "xoscFreq", "value": "12" }, + { "name": "usb_STRING_MANUFACTURER", "value": "Raspberry Pi", "quote": true }, + { "name": "usb_STRING_PRODUCT", "value": "Pico2", "quote": true } + ], + "variables": [ + { "name": "DefaultUART", "value": "UART0" }, + { "name": "usb_VID", "type": "uint16", "value": "0x2E8A" }, + { "name": "usb_PID", "type": "uint16", "value": "0x000F" } + ], + "pin-aliases": [ + { "name": "GP0", "pin": "GPIO0" }, + { "name": "GP1", "pin": "GPIO1" }, + { "name": "GP2", "pin": "GPIO2" }, + { "name": "GP3", "pin": "GPIO3" }, + { "name": "GP4", "pin": "GPIO4" }, + { "name": "GP5", "pin": "GPIO5" }, + { "name": "GP6", "pin": "GPIO6" }, + { "name": "GP7", "pin": "GPIO7" }, + { "name": "GP8", "pin": "GPIO8" }, + { "name": "GP9", "pin": "GPIO9" }, + { "name": "GP10", "pin": "GPIO10" }, + { "name": "GP11", "pin": "GPIO11" }, + { "name": "GP12", "pin": "GPIO12" }, + { "name": "GP13", "pin": "GPIO13" }, + { "name": "GP14", "pin": "GPIO14" }, + { "name": "GP15", "pin": "GPIO15" }, + { "name": "GP16", "pin": "GPIO16" }, + { "name": "GP17", "pin": "GPIO17" }, + { "name": "GP18", "pin": "GPIO18" }, + { "name": "GP19", "pin": "GPIO19" }, + { "name": "GP20", "pin": "GPIO20" }, + { "name": "GP21", "pin": "GPIO21" }, + { "name": "GP22", "pin": "GPIO22" }, + { "name": "GP26", "pin": "GPIO26" }, + { "name": "GP27", "pin": "GPIO27" }, + { "name": "GP28", "pin": "GPIO28" }, + { "name": "LED", "pin": "GPIO25" }, + { "name": "I2C0_SDA_PIN", "pin": "GP4" }, + { "name": "I2C0_SCL_PIN", "pin": "GP5" }, + { "name": "I2C1_SDA_PIN", "pin": "GP2" }, + { "name": "I2C1_SCL_PIN", "pin": "GP3" }, + { "name": "SPI0_SCK_PIN", "pin": "GPIO18" }, + { "name": "SPI0_SDO_PIN", "pin": "GPIO19" }, + { "name": "SPI0_SDI_PIN", "pin": "GPIO16" }, + { "name": "SPI1_SCK_PIN", "pin": "GPIO10" }, + { "name": "SPI1_SDO_PIN", "pin": "GPIO11" }, + { "name": "SPI1_SDI_PIN", "pin": "GPIO12" }, + { "name": "UART0_TX_PIN", "pin": "GPIO0" }, + { "name": "UART0_RX_PIN", "pin": "GPIO1" }, + { "name": "UART1_TX_PIN", "pin": "GPIO4" }, + { "name": "UART1_RX_PIN", "pin": "GPIO5" }, + { "name": "UART_TX_PIN", "pin": "UART0_TX_PIN" }, + { "name": "UART_RX_PIN", "pin": "UART0_RX_PIN" } + ] + } } diff --git a/targets/metro-rp2350.json b/targets/metro-rp2350.json index 8a13ab2454..ed8210b2d2 100644 --- a/targets/metro-rp2350.json +++ b/targets/metro-rp2350.json @@ -7,5 +7,132 @@ "default-stack-size": 8192, "ldflags": [ "--defsym=__flash_size=16M" - ] + ], + "board": { + "name": "Adafruit Metro RP2350", + "constants": [ + { "name": "xoscFreq", "value": "12" }, + { "name": "usb_STRING_MANUFACTURER", "value": "Adafruit", "quote": true }, + { "name": "usb_STRING_PRODUCT", "value": "Metro RP2350", "quote": true } + ], + "variables": [ + { "name": "DefaultUART", "value": "UART0" }, + { "name": "usb_VID", "type": "uint16", "value": "0x239A" }, + { "name": "usb_PID", "type": "uint16", "value": "0x814E" } + ], + "pin-aliases": [ + { "name": "GP0", "pin": "GPIO0" }, + { "name": "GP1", "pin": "GPIO1" }, + { "name": "GP2", "pin": "GPIO2" }, + { "name": "GP3", "pin": "GPIO3" }, + { "name": "GP4", "pin": "GPIO4" }, + { "name": "GP5", "pin": "GPIO5" }, + { "name": "GP6", "pin": "GPIO6" }, + { "name": "GP7", "pin": "GPIO7" }, + { "name": "GP8", "pin": "GPIO8" }, + { "name": "GP9", "pin": "GPIO9" }, + { "name": "GP10", "pin": "GPIO10" }, + { "name": "GP11", "pin": "GPIO11" }, + { "name": "GP12", "pin": "GPIO12" }, + { "name": "GP13", "pin": "GPIO13" }, + { "name": "GP14", "pin": "GPIO14" }, + { "name": "GP15", "pin": "GPIO15" }, + { "name": "GP16", "pin": "GPIO16" }, + { "name": "GP17", "pin": "GPIO17" }, + { "name": "GP18", "pin": "GPIO18" }, + { "name": "GP19", "pin": "GPIO19" }, + { "name": "GP20", "pin": "GPIO20" }, + { "name": "GP21", "pin": "GPIO21" }, + { "name": "GP22", "pin": "GPIO22" }, + { "name": "GP23", "pin": "GPIO23" }, + { "name": "GP24", "pin": "GPIO24" }, + { "name": "GP25", "pin": "GPIO25" }, + { "name": "GP26", "pin": "GPIO26" }, + { "name": "GP27", "pin": "GPIO27" }, + { "name": "GP28", "pin": "GPIO28" }, + { "name": "GP29", "pin": "GPIO29" }, + { "name": "GP30", "pin": "GPIO30" }, + { "name": "GP31", "pin": "GPIO31" }, + { "name": "GP32", "pin": "GPIO32" }, + { "name": "GP33", "pin": "GPIO33" }, + { "name": "GP34", "pin": "GPIO34" }, + { "name": "GP35", "pin": "GPIO35" }, + { "name": "GP36", "pin": "GPIO36" }, + { "name": "GP37", "pin": "GPIO37" }, + { "name": "GP38", "pin": "GPIO38" }, + { "name": "GP39", "pin": "GPIO39" }, + { "name": "GP40", "pin": "GPIO40" }, + { "name": "GP41", "pin": "GPIO41" }, + { "name": "GP42", "pin": "GPIO42" }, + { "name": "GP43", "pin": "GPIO43" }, + { "name": "GP44", "pin": "GPIO44" }, + { "name": "GP45", "pin": "GPIO45" }, + { "name": "GP46", "pin": "GPIO46" }, + { "name": "BUTTON", "pin": "GPIO24" }, + { "name": "LED", "pin": "GPIO23" }, + { "name": "NEOPIXEL", "pin": "GPIO25" }, + { "name": "WS2812", "pin": "GPIO25" }, + { "name": "RX", "pin": "GPIO1" }, + { "name": "TX", "pin": "GPIO0" }, + { "name": "D2", "pin": "GPIO2" }, + { "name": "D3", "pin": "GPIO3" }, + { "name": "D4", "pin": "GPIO4" }, + { "name": "D5", "pin": "GPIO5" }, + { "name": "D6", "pin": "GPIO6" }, + { "name": "D7", "pin": "GPIO7" }, + { "name": "D8", "pin": "GPIO8" }, + { "name": "D9", "pin": "GPIO9" }, + { "name": "D10", "pin": "GPIO10" }, + { "name": "D11", "pin": "GPIO11" }, + { "name": "D22", "pin": "GPIO22" }, + { "name": "D23", "pin": "GPIO23" }, + { "name": "A0", "pin": "GPIO41" }, + { "name": "A1", "pin": "GPIO42" }, + { "name": "A2", "pin": "GPIO43" }, + { "name": "A3", "pin": "GPIO44" }, + { "name": "A4", "pin": "GPIO45" }, + { "name": "A5", "pin": "GPIO46" }, + { "name": "I2C0_SDA_PIN", "pin": "GP20" }, + { "name": "I2C0_SCL_PIN", "pin": "GP21" }, + { "name": "I2C1_SDA_PIN", "pin": "GP2" }, + { "name": "I2C1_SCL_PIN", "pin": "GP3" }, + { "name": "SPI0_SCK_PIN", "pin": "GPIO18" }, + { "name": "SPI0_SDO_PIN", "pin": "GPIO19" }, + { "name": "SPI0_SDI_PIN", "pin": "GPIO16" }, + { "name": "SPI1_SCK_PIN", "pin": "GPIO30" }, + { "name": "SPI1_SDO_PIN", "pin": "GPIO31" }, + { "name": "SPI1_SDI_PIN", "pin": "GPIO28" }, + { "name": "MOSI", "pin": "SPI1_SDO_PIN" }, + { "name": "MISO", "pin": "SPI1_SDI_PIN" }, + { "name": "SCK", "pin": "SPI1_SCK_PIN" }, + { "name": "SD_SCK", "pin": "GPIO34" }, + { "name": "SD_MOSI", "pin": "GPIO35" }, + { "name": "SD_MISO", "pin": "GPIO36" }, + { "name": "SDIO_DATA1", "pin": "GPIO37" }, + { "name": "SDIO_DATA2", "pin": "GPIO38" }, + { "name": "SD_CS", "pin": "GPIO39" }, + { "name": "SD_CARD_DETECT", "pin": "GPIO40" }, + { "name": "CKN", "pin": "GPIO15" }, + { "name": "CKP", "pin": "GPIO14" }, + { "name": "D0N", "pin": "GPIO19" }, + { "name": "D0P", "pin": "GPIO18" }, + { "name": "D1N", "pin": "GPIO17" }, + { "name": "D1P", "pin": "GPIO16" }, + { "name": "D2N", "pin": "GPIO13" }, + { "name": "D2P", "pin": "GPIO12" }, + { "name": "D26", "pin": "GPIO26" }, + { "name": "D27", "pin": "GPIO27" }, + { "name": "SCL", "pin": "GPIO21" }, + { "name": "SDA", "pin": "GPIO20" }, + { "name": "USB_HOST_DATA_PLUS", "pin": "GPIO32" }, + { "name": "USB_HOST_DATA_MINUS", "pin": "GPIO33" }, + { "name": "USB_HOST_5V_POWER", "pin": "GPIO29" }, + { "name": "UART0_TX_PIN", "pin": "GPIO0" }, + { "name": "UART0_RX_PIN", "pin": "GPIO1" }, + { "name": "UART1_TX_PIN", "pin": "GPIO8" }, + { "name": "UART1_RX_PIN", "pin": "GPIO9" }, + { "name": "UART_TX_PIN", "pin": "UART0_TX_PIN" }, + { "name": "UART_RX_PIN", "pin": "UART0_RX_PIN" } + ] + } } diff --git a/targets/pga2350.json b/targets/pga2350.json index 5afe89ec07..73c94ce23d 100644 --- a/targets/pga2350.json +++ b/targets/pga2350.json @@ -3,5 +3,82 @@ "build-tags": ["pga2350"], "ldflags": [ "--defsym=__flash_size=16M" - ] + ], + "board": { + "name": "Pimoroni PGA2350", + "constants": [ + { "name": "xoscFreq", "value": "12" }, + { "name": "usb_STRING_MANUFACTURER", "value": "Pimoroni", "quote": true }, + { "name": "usb_STRING_PRODUCT", "value": "PGA2350", "quote": true } + ], + "variables": [ + { "name": "DefaultUART", "value": "UART0" }, + { "name": "usb_VID", "type": "uint16", "value": "0x2E8A" }, + { "name": "usb_PID", "type": "uint16", "value": "0x000A" } + ], + "pin-aliases": [ + { "name": "GP0", "pin": "GPIO0" }, + { "name": "GP1", "pin": "GPIO1" }, + { "name": "GP2", "pin": "GPIO2" }, + { "name": "GP3", "pin": "GPIO3" }, + { "name": "GP4", "pin": "GPIO4" }, + { "name": "GP5", "pin": "GPIO5" }, + { "name": "GP6", "pin": "GPIO6" }, + { "name": "GP7", "pin": "GPIO7" }, + { "name": "GP8", "pin": "GPIO8" }, + { "name": "GP9", "pin": "GPIO9" }, + { "name": "GP10", "pin": "GPIO10" }, + { "name": "GP11", "pin": "GPIO11" }, + { "name": "GP12", "pin": "GPIO12" }, + { "name": "GP13", "pin": "GPIO13" }, + { "name": "GP14", "pin": "GPIO14" }, + { "name": "GP15", "pin": "GPIO15" }, + { "name": "GP16", "pin": "GPIO16" }, + { "name": "GP17", "pin": "GPIO17" }, + { "name": "GP18", "pin": "GPIO18" }, + { "name": "GP19", "pin": "GPIO19" }, + { "name": "GP20", "pin": "GPIO20" }, + { "name": "GP21", "pin": "GPIO21" }, + { "name": "GP22", "pin": "GPIO22" }, + { "name": "GP26", "pin": "GPIO26" }, + { "name": "GP27", "pin": "GPIO27" }, + { "name": "GP28", "pin": "GPIO28" }, + { "name": "GP29", "pin": "GPIO29" }, + { "name": "GP30", "pin": "GPIO30" }, + { "name": "GP31", "pin": "GPIO31" }, + { "name": "GP32", "pin": "GPIO32" }, + { "name": "GP33", "pin": "GPIO33" }, + { "name": "GP34", "pin": "GPIO34" }, + { "name": "GP35", "pin": "GPIO35" }, + { "name": "GP36", "pin": "GPIO36" }, + { "name": "GP37", "pin": "GPIO37" }, + { "name": "GP38", "pin": "GPIO38" }, + { "name": "GP39", "pin": "GPIO39" }, + { "name": "GP40", "pin": "GPIO40" }, + { "name": "GP41", "pin": "GPIO41" }, + { "name": "GP42", "pin": "GPIO42" }, + { "name": "GP43", "pin": "GPIO43" }, + { "name": "GP44", "pin": "GPIO44" }, + { "name": "GP45", "pin": "GPIO45" }, + { "name": "GP46", "pin": "GPIO46" }, + { "name": "GP47", "pin": "GPIO47" }, + { "name": "LED", "pin": "GPIO25" }, + { "name": "I2C0_SDA_PIN", "pin": "GP4" }, + { "name": "I2C0_SCL_PIN", "pin": "GP5" }, + { "name": "I2C1_SDA_PIN", "pin": "GP2" }, + { "name": "I2C1_SCL_PIN", "pin": "GP3" }, + { "name": "SPI0_SCK_PIN", "pin": "GPIO18" }, + { "name": "SPI0_SDO_PIN", "pin": "GPIO19" }, + { "name": "SPI0_SDI_PIN", "pin": "GPIO16" }, + { "name": "SPI1_SCK_PIN", "pin": "GPIO10" }, + { "name": "SPI1_SDO_PIN", "pin": "GPIO11" }, + { "name": "SPI1_SDI_PIN", "pin": "GPIO12" }, + { "name": "UART0_TX_PIN", "pin": "GPIO0" }, + { "name": "UART0_RX_PIN", "pin": "GPIO1" }, + { "name": "UART1_TX_PIN", "pin": "GPIO8" }, + { "name": "UART1_RX_PIN", "pin": "GPIO9" }, + { "name": "UART_TX_PIN", "pin": "UART0_TX_PIN" }, + { "name": "UART_RX_PIN", "pin": "UART0_RX_PIN" } + ] + } } \ No newline at end of file diff --git a/targets/pico2.json b/targets/pico2.json index af156d54d8..fb4c341980 100644 --- a/targets/pico2.json +++ b/targets/pico2.json @@ -7,5 +7,63 @@ "default-stack-size": 8192, "ldflags": [ "--defsym=__flash_size=4M" - ] + ], + "board": { + "name": "Raspberry Pi Pico 2", + "constants": [ + { "name": "xoscFreq", "value": "12" }, + { "name": "usb_STRING_MANUFACTURER", "value": "Raspberry Pi", "quote": true }, + { "name": "usb_STRING_PRODUCT", "value": "Pico2", "quote": true } + ], + "variables": [ + { "name": "DefaultUART", "value": "UART0" }, + { "name": "usb_VID", "type": "uint16", "value": "0x2E8A" }, + { "name": "usb_PID", "type": "uint16", "value": "0x000A" } + ], + "pin-aliases": [ + { "name": "GP0", "pin": "GPIO0" }, + { "name": "GP1", "pin": "GPIO1" }, + { "name": "GP2", "pin": "GPIO2" }, + { "name": "GP3", "pin": "GPIO3" }, + { "name": "GP4", "pin": "GPIO4" }, + { "name": "GP5", "pin": "GPIO5" }, + { "name": "GP6", "pin": "GPIO6" }, + { "name": "GP7", "pin": "GPIO7" }, + { "name": "GP8", "pin": "GPIO8" }, + { "name": "GP9", "pin": "GPIO9" }, + { "name": "GP10", "pin": "GPIO10" }, + { "name": "GP11", "pin": "GPIO11" }, + { "name": "GP12", "pin": "GPIO12" }, + { "name": "GP13", "pin": "GPIO13" }, + { "name": "GP14", "pin": "GPIO14" }, + { "name": "GP15", "pin": "GPIO15" }, + { "name": "GP16", "pin": "GPIO16" }, + { "name": "GP17", "pin": "GPIO17" }, + { "name": "GP18", "pin": "GPIO18" }, + { "name": "GP19", "pin": "GPIO19" }, + { "name": "GP20", "pin": "GPIO20" }, + { "name": "GP21", "pin": "GPIO21" }, + { "name": "GP22", "pin": "GPIO22" }, + { "name": "GP26", "pin": "GPIO26" }, + { "name": "GP27", "pin": "GPIO27" }, + { "name": "GP28", "pin": "GPIO28" }, + { "name": "LED", "pin": "GPIO25" }, + { "name": "I2C0_SDA_PIN", "pin": "GP4" }, + { "name": "I2C0_SCL_PIN", "pin": "GP5" }, + { "name": "I2C1_SDA_PIN", "pin": "GP2" }, + { "name": "I2C1_SCL_PIN", "pin": "GP3" }, + { "name": "SPI0_SCK_PIN", "pin": "GPIO18" }, + { "name": "SPI0_SDO_PIN", "pin": "GPIO19" }, + { "name": "SPI0_SDI_PIN", "pin": "GPIO16" }, + { "name": "SPI1_SCK_PIN", "pin": "GPIO10" }, + { "name": "SPI1_SDO_PIN", "pin": "GPIO11" }, + { "name": "SPI1_SDI_PIN", "pin": "GPIO12" }, + { "name": "UART0_TX_PIN", "pin": "GPIO0" }, + { "name": "UART0_RX_PIN", "pin": "GPIO1" }, + { "name": "UART1_TX_PIN", "pin": "GPIO8" }, + { "name": "UART1_RX_PIN", "pin": "GPIO9" }, + { "name": "UART_TX_PIN", "pin": "UART0_TX_PIN" }, + { "name": "UART_RX_PIN", "pin": "UART0_RX_PIN" } + ] + } } diff --git a/targets/tiny2350.json b/targets/tiny2350.json index 660e096468..c210047a9b 100644 --- a/targets/tiny2350.json +++ b/targets/tiny2350.json @@ -6,5 +6,57 @@ "ldflags": [ "--defsym=__flash_size=4M" ], - "serial-port": ["2e8a:000f"] + "serial-port": ["2e8a:000f"], + "board": { + "name": "Pimoroni Tiny 2350", + "constants": [ + { "name": "xoscFreq", "value": "12" }, + { "name": "usb_STRING_MANUFACTURER", "value": "Pimoroni", "quote": true }, + { "name": "usb_STRING_PRODUCT", "value": "Tiny2350", "quote": true } + ], + "variables": [ + { "name": "DefaultUART", "value": "UART0" }, + { "name": "usb_VID", "type": "uint16", "value": "0x2E8A" }, + { "name": "usb_PID", "type": "uint16", "value": "0x000F" } + ], + "pin-aliases": [ + { "name": "GP0", "pin": "GPIO0" }, + { "name": "GP1", "pin": "GPIO1" }, + { "name": "GP2", "pin": "GPIO2" }, + { "name": "GP3", "pin": "GPIO3" }, + { "name": "GP4", "pin": "GPIO4" }, + { "name": "GP5", "pin": "GPIO5" }, + { "name": "GP6", "pin": "GPIO6" }, + { "name": "GP7", "pin": "GPIO7" }, + { "name": "GP12", "pin": "GPIO12" }, + { "name": "GP13", "pin": "GPIO13" }, + { "name": "GP18", "pin": "GPIO18" }, + { "name": "GP19", "pin": "GPIO19" }, + { "name": "GP20", "pin": "GPIO20" }, + { "name": "GP26", "pin": "GPIO26" }, + { "name": "GP27", "pin": "GPIO27" }, + { "name": "GP28", "pin": "GPIO28" }, + { "name": "GP29", "pin": "GPIO29" }, + { "name": "LED", "pin": "LED_RED" }, + { "name": "LED_RED", "pin": "GPIO18" }, + { "name": "LED_GREEN", "pin": "GPIO19" }, + { "name": "LED_BLUE", "pin": "GPIO20" }, + { "name": "I2C0_SDA_PIN", "pin": "GP12" }, + { "name": "I2C0_SCL_PIN", "pin": "GP13" }, + { "name": "I2C1_SDA_PIN", "pin": "GP2" }, + { "name": "I2C1_SCL_PIN", "pin": "GP3" }, + { "name": "SPI0_SCK_PIN", "pin": "GPIO6" }, + { "name": "SPI0_SDO_PIN", "pin": "GPIO7" }, + { "name": "SPI0_SDI_PIN", "pin": "GPIO4" }, + { "name": "SPI1_SCK_PIN", "pin": "GPIO26" }, + { "name": "SPI1_SDO_PIN", "pin": "GPIO27" }, + { "name": "SPI1_SDI_PIN", "pin": "GPIO28" }, + { "name": "UART0_TX_PIN", "pin": "GPIO0" }, + { "name": "UART0_RX_PIN", "pin": "GPIO1" }, + { "name": "UART1_TX_PIN", "pin": "GPIO4" }, + { "name": "UART1_RX_PIN", "pin": "GPIO5" }, + { "name": "UART_TX_PIN", "pin": "UART0_TX_PIN" }, + { "name": "UART_RX_PIN", "pin": "UART0_RX_PIN" } + ] + } }