Skip to content

arduino-cli compile does not respect sketch.json #1691

Closed
@nalzok

Description

@nalzok

Here is a reproducible example

$ arduino-cli sketch new test
Sketch created in: /tmp/test

$ cd test/

$ arduino-cli board attach -p /dev/cu.usbmodem14101
Board found: Adafruit Feather ESP32-S2 TFT...
Selected fqbn: esp32:esp32:adafruit_feather_esp32s2_tft

$ cat sketch.json
{
  "cpu": {
    "fqbn": "esp32:esp32:adafruit_feather_esp32s2_tft",
    "name": "Adafruit Feather ESP32-S2 TFT",
    "port": "serial:///dev/cu.usbmodem14101"
  }
}

$ arduino-cli compile --build-path build -v test.ino
Using board 'adafruit_feather_esp32s2_tft' from platform in folder: /Users/qys/Library/Arduino15/packages/esp32/hardware/esp32/2.0.2
Using core 'esp32' from platform in folder: /Users/qys/Library/Arduino15/packages/esp32/hardware/esp32/2.0.2
... ...
Sketch uses 217374 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 17748 bytes (5%) of dynamic memory, leaving 309932 bytes for local variables. Maximum is 327680 bytes.

$ arduino-cli compile --build-path build -u -v test.ino
Error during FQBN detection: Missing FQBN (Fully Qualified Board Name)

In the last line, I deliberately wrote arduino-cli compile --build-path build -u -v test.ino without -b esp32:esp32:adafruit_feather_esp32s2_tft -p /dev/tty.usbmodem14101 to test if arduino-cli compile can find the missing information in the sketch.json file. As you can see, it throws an error.

// If the user didn't provide an FQBN it might either mean
// that she forgot or that is trying to compile and upload
// using board autodetection.
if detectedFqbn == "" && uploadAfterCompile {
sk = arguments.NewSketch(sketchPath)
discoveryPort = port.GetDiscoveryPort(inst, sk)
rpcPort := discoveryPort.ToRPC()
var err error
pm := commands.GetPackageManager(inst.Id)
detectedFqbn, err = upload.DetectConnectedBoard(pm, rpcPort.Address, rpcPort.Protocol)
if err != nil {
feedback.Errorf(tr("Error during FQBN detection: %v", err))
os.Exit(errorcodes.ErrGeneric)
}
}

Perhaps "board autodetection" should check for sketch.json first?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions