export flash, openocd, msd
This commit is contained in:
@@ -42,11 +42,11 @@ llgo run hello.go # run locally
|
||||
llgo install hello.go # install to bin
|
||||
|
||||
# Cross-compilation
|
||||
llgo build -target esp32 hello.go # -> hello (ELF)
|
||||
llgo build -target esp32 -file-format bin hello.go # -> hello.bin
|
||||
llgo run -target esp32 hello.go # run on ESP32
|
||||
llgo run -target esp32 -emulator hello.go # run in emulator
|
||||
llgo test -target esp32 -port /dev/ttyUSB0 . # run tests on device
|
||||
llgo build -target esp32 . # -> hello (ELF)
|
||||
llgo build -target esp32 -file-format bin , # -> hello.bin
|
||||
llgo run -target esp32 . # run on ESP32 (guess a port)
|
||||
llgo run -target esp32 -emulator . # run in emulator
|
||||
llgo test -target esp32 -port /dev/ttyUSB0 . # run tests on device
|
||||
llgo test -target esp32 -emulator . # run tests in emulator
|
||||
llgo install -target esp32 -port /dev/ttyUSB0 hello.go # flash to specific port
|
||||
llgo install -target esp32 -port /dev/ttyUSB0 . # flash to specific port
|
||||
```
|
||||
|
||||
@@ -16,6 +16,27 @@ import (
|
||||
"github.com/goplus/llgo/internal/xtool/llvm"
|
||||
)
|
||||
|
||||
// Flash contains configuration for device flashing
|
||||
type Flash struct {
|
||||
Command string // Flash command template
|
||||
Serial string // Serial communication settings
|
||||
SerialPort []string // Available serial ports
|
||||
Flash1200BpsReset bool // Whether to use 1200bps reset
|
||||
}
|
||||
|
||||
// MSD contains configuration for Mass Storage Device flashing
|
||||
type MSD struct {
|
||||
VolumeName []string // Names of the volumes
|
||||
FirmwareName string // Firmware file name pattern
|
||||
}
|
||||
|
||||
// OpenOCD contains configuration for OpenOCD debugging/flashing
|
||||
type OpenOCD struct {
|
||||
Interface string // Interface configuration (e.g., "stlink")
|
||||
Transport string // Transport protocol (e.g., "swd", "jtag")
|
||||
Target string // Target configuration (e.g., "stm32f4x")
|
||||
}
|
||||
|
||||
type Export struct {
|
||||
CC string // Compiler to use
|
||||
CCFLAGS []string
|
||||
@@ -35,6 +56,11 @@ type Export struct {
|
||||
BinaryFormat string // Binary format (e.g., "elf", "esp", "uf2")
|
||||
FormatDetail string // For uf2, it's uf2FamilyID
|
||||
Emulator string // Emulator command template (e.g., "qemu-system-arm -M {} -kernel {}")
|
||||
|
||||
// Flashing/Debugging configuration
|
||||
Flash Flash // Flash configuration for device programming
|
||||
MSD MSD // Mass Storage Device configuration
|
||||
OpenOCD OpenOCD // OpenOCD configuration for debugging/flashing
|
||||
}
|
||||
|
||||
// URLs and configuration that can be overridden for testing
|
||||
@@ -502,6 +528,23 @@ func useTarget(targetName string) (export Export, err error) {
|
||||
export.FormatDetail = config.FormatDetail()
|
||||
export.Emulator = config.Emulator
|
||||
|
||||
// Set flashing/debugging configuration
|
||||
export.Flash = Flash{
|
||||
Command: config.FlashCommand,
|
||||
Serial: config.Serial,
|
||||
SerialPort: config.SerialPort,
|
||||
Flash1200BpsReset: config.Flash1200BpsReset == "true",
|
||||
}
|
||||
export.MSD = MSD{
|
||||
VolumeName: config.MSDVolumeName,
|
||||
FirmwareName: config.MSDFirmwareName,
|
||||
}
|
||||
export.OpenOCD = OpenOCD{
|
||||
Interface: config.OpenOCDInterface,
|
||||
Transport: config.OpenOCDTransport,
|
||||
Target: config.OpenOCDTarget,
|
||||
}
|
||||
|
||||
// Build environment map for template variable expansion
|
||||
envs := buildEnvMap(env.LLGoROOT())
|
||||
|
||||
|
||||
@@ -35,10 +35,14 @@ type Config struct {
|
||||
UF2FamilyID string `json:"uf2-family-id"`
|
||||
|
||||
// Flash and deployment configuration
|
||||
FlashCommand string `json:"flash-command"`
|
||||
FlashMethod string `json:"flash-method"`
|
||||
FlashMethod string `json:"flash-method"` // values: command, openocd, msd
|
||||
FlashCommand string `json:"flash-command"` // used when FlashMethod == "command"
|
||||
Flash1200BpsReset string `json:"flash-1200-bps-reset"`
|
||||
|
||||
// Serial configuration
|
||||
Serial string `json:"serial"` // Serial communication type (e.g., "usb")
|
||||
SerialPort []string `json:"serial-port"` // Serial port identifiers (e.g., vendor:product IDs)
|
||||
|
||||
// Mass storage device configuration
|
||||
MSDVolumeName []string `json:"msd-volume-name"`
|
||||
MSDFirmwareName string `json:"msd-firmware-name"`
|
||||
|
||||
@@ -167,6 +167,9 @@ func (l *Loader) mergeConfig(dst, src *Config) {
|
||||
if src.Flash1200BpsReset != "" {
|
||||
dst.Flash1200BpsReset = src.Flash1200BpsReset
|
||||
}
|
||||
if src.Serial != "" {
|
||||
dst.Serial = src.Serial
|
||||
}
|
||||
if src.MSDFirmwareName != "" {
|
||||
dst.MSDFirmwareName = src.MSDFirmwareName
|
||||
}
|
||||
@@ -202,6 +205,9 @@ func (l *Loader) mergeConfig(dst, src *Config) {
|
||||
if len(src.ExtraFiles) > 0 {
|
||||
dst.ExtraFiles = append(dst.ExtraFiles, src.ExtraFiles...)
|
||||
}
|
||||
if len(src.SerialPort) > 0 {
|
||||
dst.SerialPort = append(dst.SerialPort, src.SerialPort...)
|
||||
}
|
||||
if len(src.MSDVolumeName) > 0 {
|
||||
dst.MSDVolumeName = append(dst.MSDVolumeName, src.MSDVolumeName...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user