Skip to content

bootloader gets destroyed every time #155

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

Closed
1inguini opened this issue Feb 25, 2019 · 9 comments
Closed

bootloader gets destroyed every time #155

1inguini opened this issue Feb 25, 2019 · 9 comments
Assignees
Labels
status: waiting for information More information must be provided before work can proceed type: imperfection Perceived defect in any part of project

Comments

@1inguini
Copy link

1inguini commented Feb 25, 2019

I can upload sketch, but once I do that the arduino stops getting detected by the computer.
I can fix it by burning arduino bootloader to it (arduino-ide seems to work fine), but if I upload sketch again the same thing happens.
My arduino is a clone of SparkFun pro micro.

@per1234
Copy link
Contributor

per1234 commented Feb 26, 2019

Which version of arduino-cli are you using?

Please provide the arduino-cli commands you are using to compile and upload.

@1inguini
Copy link
Author

1inguini commented Feb 26, 2019

command: probably ➤ arduino-cli upload -p /dev/ttyACM0 --fqbn SparkFun:avr:promicro Arduino/FirstSketch/ accrding to my fish's history.

version: arduino-cli version 0.3.4-alpha.preview

@per1234 per1234 added the bug label May 24, 2019
@cmaglie
Copy link
Member

cmaglie commented Sep 12, 2019

Is the Arduino IDE uploading without the issue?
If yes please:

  1. please provide the verbose output of the Arduino IDE
  2. provide the verbose output of the arduino-cli
    so we can compare them.

If you can test also the latest version of the cli (0.5.0) it would be great.

@cmaglie cmaglie closed this as completed Sep 12, 2019
@cmaglie cmaglie reopened this Sep 12, 2019
@cmaglie cmaglie added the status: waiting for information More information must be provided before work can proceed label Sep 12, 2019
@github-actions github-actions bot added the stale label Sep 15, 2019
@masci masci removed stale labels Sep 18, 2019
@bjanders
Copy link

I have the same issue, also with a SparkFun pro micro clone. I used a self compiled arduino-cli, commit 550179e

@ubidefeo
Copy link

@bjanders when you compile for a target board you also build a version of the firmware with included bootloader.
This is the one you should burn (upload) onto the board.

essentially it becomes a two part operation in which you compile choosing to --export-binaries,
thus creating a local build folder inside your sketch, and then upload with --input-file and passing the build/SparkFun.avr.micro/MySketch.ino.with_bootloader.hex

unfortunately I seem to have found an issue with this particular file in my case, which might be related to an old problem we had with CLI assembling the bootloader binary with the newly created hex.

@cmaglie and I are going to investigate asap

here's a recap of my actions for a sketch named BlinkMe.
I'm inside the BlinkMe folder

arduino-cli compile --export-binaries -b arduino:avr:micro -v
arduino-cli upload -b arduino:avr:micro -v -P arduinoisp --input-file build/arduino.avr.micro/BlinkMe.ino.with_bootloader.hex

@bjanders
Copy link

bjanders commented Mar 21, 2021

Thanks for the information! I verified that the method using --export-binaries and --input-file works. Is this just a work around for the issue you have found?

What I did previously was according to https://arduino.github.io/arduino-cli/latest/getting-started/:

arduino-cli compile -b SparkFun:avr:promicro
arduino-cli upload -p COMx -b SparkFun:avr:promicro 

Will this work when the issue has been fixed?

Is the problem only for avr:micro or other boards as well?

@ubidefeo
Copy link

@bjanders
this discussion is related to using a programmer to upload the firmware, so you'll have to pass in -P and the specific programmer supported by the platform.
It should work after the files are correctly combined, but not sure when this will happen right now.

I remember we fixed it for the SAMD21 a while back, but I need someone to look into this

@bjanders
Copy link

bjanders commented Mar 22, 2021

I'm sorry, I'm not able to follow what you mean. Which discussion is related to using a programmer are you referring to?

The problem I have, i.e the bootloader getting corrupted, manifests itself when I'm not using a programmer, but flashing using the USB bootloader. And it does not manifest itself when I flash with_bootloader.hex when I'm not using a programmer, but again using the USB bootloader. So in my case the issue is never related to a programmer.

So, to be specific with an example. The following corrupts the bootloader:

arduino-cli compile -b SparkFun:avr:promicro
arduino-cli upload -p /dev/ttyACMx -b SparkFun:avr:promicro 

My assumption is that the above should not corrupt the bootloader. (And I'm guessing it gets corrupted because the command will start writing on the bootloader region instead of the actual program region where I assume it is supposed to.)

The following does not corrupt the bootloader, and the program works as expected:

arduino-cli compile --export-binaries -b SparkFun:avr:promicro
arduino-cli upload -b SparkFun:avr:promicro -p /dev/ttyACMx --input-file build/SparkFun.avr.promicro/Test.ino.with_bootloader.hex

(Guessing this works, since it will write in the same region as the first corrupting command, but this time it contains the bootloader as well, so it doesn't matter as long as you are ok with replacing the bootloader. I assume this should corrupt the program, as I assume this would write the bootloader in the program region if it wasn't for the bug.)

Should this ticket be reopened, since it's still reproducible with the latest version from git?

@bjanders
Copy link

bjanders commented Mar 22, 2021

It seems I was wrong. Flashing with the above working command only worked as long as I kept it powered.

per1234 added a commit that referenced this issue Aug 9, 2021
…erns

Make platform JSON schema regexes support property references
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for information More information must be provided before work can proceed type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

6 participants