Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e9170e4
feat: add -file-format flag for flexible output formats
cpunion Sep 5, 2025
df8f67d
remove debug log
cpunion Sep 5, 2025
5e5d5c2
Build and run for embeded
cpunion Sep 5, 2025
1033452
extract run from linkMainPkg, add flash scaffold
cpunion Sep 5, 2025
da98651
export flash, openocd, msd
cpunion Sep 6, 2025
7cad146
refactor build/install/run pipeline
cpunion Sep 6, 2025
549beeb
test output format for all target/emuator/flash-method
cpunion Sep 6, 2025
1a3bca4
feat: implement flash functionality
cpunion Sep 6, 2025
519faab
feat: ignore firmware files
cpunion Sep 6, 2025
9a5b231
feat: llgo monitor -target target -port port
cpunion Sep 6, 2025
a2c9c7f
feat: llgo run -target target -port port auto start monitor
cpunion Sep 6, 2025
88e0844
ignore codecov from internal/{monitor,flash}
cpunion Sep 6, 2025
c667691
refine: check msd paths
cpunion Sep 6, 2025
228d7ce
feat: make -port optional
cpunion Sep 6, 2025
4e590d4
feat: auto guess port for monitoring
cpunion Sep 6, 2025
1c2aea1
feat: add Arduino 1200bps reset support before flashing
cpunion Sep 6, 2025
c0afe19
refactor: move device types definition into flash
cpunion Sep 7, 2025
16c8402
refactor: multi format generation and llgo build flags
cpunion Sep 7, 2025
df07513
refine: reduce unnecessary format conversion
cpunion Sep 7, 2025
9eeb14a
feat: support generic bin and intel hex firmware
cpunion Sep 7, 2025
806b16c
refine: reduce duplicated env expand funcs
cpunion Sep 7, 2025
dba719a
doc: update embeded doc of llgo cmds
cpunion Sep 7, 2025
3ecf9b3
refine: safe shell cmd line parse
cpunion Sep 7, 2025
20ce823
fix: targets tests
cpunion Sep 7, 2025
d46a3f2
Merge commit '7de4137d4678a3bcbd735f887028489f97f1e479' into embed-cmds
cpunion Sep 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ coverage:
- "internal/typepatch"
- "internal/github"
- "internal/firmware"
- "internal/flash"
- "internal/monitor"
- "xtool"
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ go.work*
# GoReleaser
.dist/
.sysroot/

# Embedded firmware files
*.bin
*.hex
*.elf
*.uf2
*.img
*.zip
4 changes: 4 additions & 0 deletions cmd/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ var Cmd = &base.Command{
func init() {
Cmd.Run = runCmd
base.PassBuildFlags(Cmd)

flags.AddCommonFlags(&Cmd.Flag)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddEmulatorFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag)
flags.AddOutputFlags(&Cmd.Flag)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/internal/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var Cmd = &base.Command{

func init() {
Cmd.Run = runCmd
flags.AddCommonFlags(&Cmd.Flag)
flags.AddBuildFlags(&Cmd.Flag)
}

Expand Down
43 changes: 41 additions & 2 deletions cmd/internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,41 @@ import (
)

var OutputFile string
var OutBin bool
var OutHex bool
var OutImg bool
var OutUf2 bool
var OutZip bool

func AddOutputFlags(fs *flag.FlagSet) {
fs.StringVar(&OutputFile, "o", "", "Output file")
fs.BoolVar(&OutBin, "obin", false, "Generate binary output (.bin)")
fs.BoolVar(&OutHex, "ohex", false, "Generate Intel hex output (.hex)")
fs.BoolVar(&OutImg, "oimg", false, "Generate image output (.img)")
fs.BoolVar(&OutUf2, "ouf2", false, "Generate UF2 output (.uf2)")
fs.BoolVar(&OutZip, "ozip", false, "Generate ZIP/DFU output (.zip)")
}

var Verbose bool
var BuildEnv string
var Tags string
var Target string
var Emulator bool
var Port string
var BaudRate int
var AbiMode int
var CheckLinkArgs bool
var CheckLLFiles bool
var GenLLFiles bool
var ForceEspClang bool

func AddCommonFlags(fs *flag.FlagSet) {
fs.BoolVar(&Verbose, "v", false, "Verbose output")
}

func AddBuildFlags(fs *flag.FlagSet) {
fs.BoolVar(&Verbose, "v", false, "Verbose mode")
fs.StringVar(&Tags, "tags", "", "Build tags")
fs.StringVar(&BuildEnv, "buildenv", "", "Build environment")
fs.StringVar(&Target, "target", "", "Target platform (e.g., rp2040, wasi)")
if buildenv.Dev {
fs.IntVar(&AbiMode, "abi", 2, "ABI mode (default 2). 0 = none, 1 = cfunc, 2 = allfunc.")
fs.BoolVar(&CheckLinkArgs, "check-linkargs", false, "check link args valid")
Expand All @@ -39,6 +54,16 @@ func AddBuildFlags(fs *flag.FlagSet) {

var Gen bool

func AddEmulatorFlags(fs *flag.FlagSet) {
fs.BoolVar(&Emulator, "emulator", false, "Run in emulator mode")
}

func AddEmbeddedFlags(fs *flag.FlagSet) {
fs.StringVar(&Target, "target", "", "Target platform (e.g., rp2040, wasi)")
fs.StringVar(&Port, "port", "", "Target port for flashing")
fs.IntVar(&BaudRate, "baudrate", 115200, "Baudrate for serial communication")
}

func AddCmpTestFlags(fs *flag.FlagSet) {
fs.BoolVar(&Gen, "gen", false, "Generate llgo.expect file")
}
Expand All @@ -47,10 +72,24 @@ func UpdateConfig(conf *build.Config) {
conf.Tags = Tags
conf.Verbose = Verbose
conf.Target = Target
conf.Port = Port
conf.BaudRate = BaudRate
switch conf.Mode {
case build.ModeBuild:
conf.OutFile = OutputFile
conf.OutFmts = build.OutFmts{
Bin: OutBin,
Hex: OutHex,
Img: OutImg,
Uf2: OutUf2,
Zip: OutZip,
}
case build.ModeRun, build.ModeTest:
conf.Emulator = Emulator
case build.ModeInstall:

case build.ModeCmpTest:
conf.Emulator = Emulator
conf.GenExpect = Gen
}
if buildenv.Dev {
Expand Down
2 changes: 2 additions & 0 deletions cmd/internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ var Cmd = &base.Command{

func init() {
Cmd.Run = runCmd
flags.AddCommonFlags(&Cmd.Flag)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag)
}

func runCmd(cmd *base.Command, args []string) {
Expand Down
77 changes: 77 additions & 0 deletions cmd/internal/monitor/monitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package monitor

import (
"fmt"
"os"

"github.com/goplus/llgo/cmd/internal/base"
"github.com/goplus/llgo/cmd/internal/flags"
"github.com/goplus/llgo/internal/crosscompile"
"github.com/goplus/llgo/internal/monitor"
)

// Cmd represents the monitor command.
var Cmd = &base.Command{
UsageLine: "llgo monitor [flags] [executable]",
Short: "Monitor serial output from device",
}

func init() {
flags.AddCommonFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag)
Cmd.Run = runMonitor
}

func runMonitor(cmd *base.Command, args []string) {
cmd.Flag.Parse(args)
args = cmd.Flag.Args()

if len(args) > 1 {
fmt.Fprintf(os.Stderr, "llgo monitor: too many arguments\n")
os.Exit(1)
}

var executable string
if len(args) == 1 {
executable = args[0]
}

var serialPort []string
if flags.Target != "" {
conf, err := crosscompile.UseTarget(flags.Target)
if err != nil {
fmt.Fprintf(os.Stderr, "llgo monitor: %v\n", err)
os.Exit(1)
}
serialPort = conf.Device.SerialPort
}

config := monitor.MonitorConfig{
Port: flags.Port,
Target: flags.Target,
BaudRate: flags.BaudRate,
Executable: executable,
SerialPort: serialPort,
}

if err := monitor.Monitor(config, flags.Verbose); err != nil {
fmt.Fprintf(os.Stderr, "llgo monitor: %v\n", err)
os.Exit(1)
}
}
8 changes: 8 additions & 0 deletions cmd/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@ func init() {
Cmd.Run = runCmd
CmpTestCmd.Run = runCmpTest
base.PassBuildFlags(Cmd)
flags.AddCommonFlags(&Cmd.Flag)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddEmulatorFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag) // for -target support

base.PassBuildFlags(CmpTestCmd)
flags.AddCommonFlags(&CmpTestCmd.Flag)
flags.AddBuildFlags(&CmpTestCmd.Flag)
flags.AddEmulatorFlags(&CmpTestCmd.Flag)
flags.AddEmbeddedFlags(&CmpTestCmd.Flag) // for -target support
flags.AddCmpTestFlags(&CmpTestCmd.Flag)
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ var Cmd = &base.Command{

func init() {
Cmd.Run = runCmd
flags.AddCommonFlags(&Cmd.Flag)
flags.AddBuildFlags(&Cmd.Flag)
flags.AddEmulatorFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag)
}

func runCmd(cmd *base.Command, args []string) {
Expand Down
29 changes: 29 additions & 0 deletions cmd/llgo/monitor_cmd.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import (
self "github.com/goplus/llgo/cmd/internal/monitor"
)

use "monitor [flags] [executable]"

short "Monitor serial output from device"

flagOff

run args => {
self.Cmd.Run self.Cmd, args
}
42 changes: 38 additions & 4 deletions cmd/llgo/xgo_autogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading