refactor: move device types definition into flash
This commit is contained in:
@@ -12,32 +12,11 @@ import (
|
||||
|
||||
"github.com/goplus/llgo/internal/crosscompile/compile"
|
||||
"github.com/goplus/llgo/internal/env"
|
||||
"github.com/goplus/llgo/internal/flash"
|
||||
"github.com/goplus/llgo/internal/targets"
|
||||
"github.com/goplus/llgo/internal/xtool/llvm"
|
||||
)
|
||||
|
||||
// Flash contains configuration for device flashing
|
||||
type Flash struct {
|
||||
Method string // Flash method: "command", "openocd", "msd", "bmp"
|
||||
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
|
||||
@@ -59,9 +38,7 @@ type Export struct {
|
||||
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
|
||||
Device flash.Device // Device configuration for flashing/debugging
|
||||
}
|
||||
|
||||
// URLs and configuration that can be overridden for testing
|
||||
@@ -530,21 +507,23 @@ func UseTarget(targetName string) (export Export, err error) {
|
||||
export.Emulator = config.Emulator
|
||||
|
||||
// Set flashing/debugging configuration
|
||||
export.Flash = Flash{
|
||||
Method: config.FlashMethod,
|
||||
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,
|
||||
export.Device = flash.Device{
|
||||
Serial: config.Serial,
|
||||
SerialPort: config.SerialPort,
|
||||
Flash: flash.Flash{
|
||||
Method: config.FlashMethod,
|
||||
Command: config.FlashCommand,
|
||||
Flash1200BpsReset: config.Flash1200BpsReset == "true",
|
||||
},
|
||||
MSD: flash.MSD{
|
||||
VolumeName: config.MSDVolumeName,
|
||||
FirmwareName: config.MSDFirmwareName,
|
||||
},
|
||||
OpenOCD: flash.OpenOCD{
|
||||
Interface: config.OpenOCDInterface,
|
||||
Transport: config.OpenOCDTransport,
|
||||
Target: config.OpenOCDTarget,
|
||||
},
|
||||
}
|
||||
|
||||
// Build environment map for template variable expansion
|
||||
|
||||
Reference in New Issue
Block a user