Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload command requires a .bin file despite a .hex file was provided! #2779

Open
3 tasks done
arduino12 opened this issue Dec 7, 2024 · 1 comment
Open
3 tasks done
Labels
type: imperfection Perceived defect in any part of project

Comments

@arduino12
Copy link

Describe the problem

The upload commands supports a binary file upload with a -i, --input-file string argument.

Currently, when called with a .hex file, it fails because a missing .bin file on the same folder:

PS C:\> arduino-cli upload -b STMicroelectronics:stm32:GenL0 -i test.hex
Selected interface: swd
Error test.bin does not exist!
Usage: stm32CubeProg.sh [OPTIONS]...

  Mandatory options:
    -i, --interface <'swd'/'dfu'/'serial'/'jlink'>   interface identifier: 'swd', 'dfu', 'serial' or 'jlink'
    -f, --file <path>                        file path to be downloaded: bin or hex
  Optional options:
    -e, --erase                              erase all sectors before flashing
    -o, --offset <hex value>                 offset from flash base (0x8000000) where flashing should start

  Specific options for Serial protocol:
    Mandatory:
    -c, --com <name>                         serial identifier, ex: COM1 or /dev/ttyS0,...
    Optional:
      -r, --rts <low/high>                   polarity of RTS signal ('low' by default)
      -d, --dtr <low/high>                   polarity of DTR signal

  Specific options for DFU protocol:
    Mandatory:
      -v, --vid <hex value>                  vendor id, ex: 0x0483
      -p, --pid <hex value>                  product id, ex: 0xdf11


Failed uploading: uploading error: exit status 1

Please fix it so the .bin file is not required (the .hex file contains all the binary data + the addresses to program it onto..).
Also the stm32CubeProg.sh error message seems to support the .hex file- -f, --file <path> file path to be downloaded: bin or hex.

To reproduce

See example above.

Expected behavior

Successfully upload a .hex file without a .bin file by its side..

Arduino CLI version

arduino-cli Version: 1.1.1 Commit: fa6eafc Date: 2024-11-22T09:31:38Z

Operating system

Windows

Operating system version

Windows 11

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@arduino12 arduino12 added the type: imperfection Perceived defect in any part of project label Dec 7, 2024
@cmaglie
Copy link
Member

cmaglie commented Dec 10, 2024

I see your point, it may work in your case with your specific board/platform combination, but it's not guaranteed to work in general.

The intended use case is to:

  • compile with arduino-cli compile -b .... --output-dir path/to/compile/output
  • upload with arduino-cli upload -b ... --input-dir path/to/compile/output
    where path/to/compile/output is a directory
$ arduino-cli compile -h | grep output-
      --output-dir string                     Save build artifacts in this directory.
$ arduino-cli upload -h | grep input-
      --input-dir string              Directory containing binaries to upload.
  -i, --input-file string             Binary file to upload.

In general, the compiled artifacts may be more than one file (for example some platforms produce a filesystem image, or a cryptographic signature together with the binary that are all required for upload). That's why there is an --output-dir flag but not an --output-file flag.

We added the --input-file flag as a convenience shortcut but it has some limitations:

  • It works only if the upload needs a single binary
  • The artifact has to be of the same format expected by the uploader

Inside the arduino-cli we don't know if the tool used to upload will work with another file format (because the platform is developed by a third party independent from Arduino). It may be risky to force it because using another format may require adding an offset flag (and failing to do so could brick the board). I am therefore inclined to decline this feature request.

In your case, the workaround is to save the .bin from the compilation output instead of the .hex, or better to save the whole output directory and use the --input-dir flag instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants