Downloading Bin but not uploading bin?

Hello, One thing I noticed about the Bin files. I can download a compiled blink sketch for my arduino uno in the IDE. I can not find a way to upload a Bin file through the IDE. Is there a way to upload a bin file?

not sure the purpose Of downloading a bin but not able to upload a bin file to the board. Can someone please help make sense of all this?

Joseph

the Arduino IDE compiles a program composed of one or more files into a (binary) .elf file and then translates that into a ASCII .hex file. (look under /cygdrive/c/Users/lenovo/AppData/Local/Temp/arduino_build_259140 on your PC)

The IDE then uses avrdude to program (up/download) an Arduino board with the .hex file. i believe the avrdude interfaces with the bootloader on the Arduino board to program to program flash memory on the avr chip with the program in the .hex file

as far as i know, avrdude does not have options to read the flash memory back into a file on the PC

might be interesting to write an Arduino program that reads the flash memory

It does it every time after you upload and compares to see if the code was uploaded correctly.

The command to read one out would be something like:

/usr/bin/avrdude -C/etc/avrdude.conf -v -V -patmega1284p -carduino -P/dev/ttyACM0 -b19200 -D -Uflash:r:/home/david/robot/RobotMainBrain/build-1284/RobotMainBrain.hex

That should read flash memory from a 1284P and store it in the file RobotMainBrain.hex

To write a hex file to the chip just use w instead of r.

/usr/bin/avrdude -C/etc/avrdude.conf -v -V -patmega1284p -carduino -P/dev/ttyACM0 -b19200 -D -Uflash:w:/home/david/robot/RobotMainBrain/build-1284/RobotMainBrain.cpp.hex

Be sure to change the port and part to match what you have.

thanks

i had to do the following to read back in .hex format

i executed the following from Arduino/hardware/tools/avr/bin

avrdude -C../etc/avrdude.conf -v -V -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:r:/download/avr.hex:i
  • changed process to 328p
  • port to COM4
  • change speed to 115200
  • add .hex format option, the ":i" at the very end

Oh yeah. I forgot about the i. That tells it to use intel hex format.

Note that the speed will depend on the particular bootloader you have installed. This isn't always as easy to find out as the part number and the port. If you turn on verbose upload then you can initiate an upload to the chip normally and examine the AVRDude command that the IDE uses to get that information.

i enabled verbose output during upload to program the board to see the options used by the IDE

I find this very interesting. I never known Can do command line to upload a hex. I heard things about There is a hex file it converts the sketch and libraries to a hex file and it uploads to the board. but I never know you can use command or terminal to upload that hex file.

so my question is it possible to upload the bin file to the board? I know in boards such as the esp8266 and the esp32 you can use aflasher program to upload a bin file. But is it possible on aavr uno board to do the same in command line?

The esp boards use a python program called esptool. Again, if you will turn on verbose mode and do an upload you will see all of the commands that the IDE calls. It's not doing anything that you can't do yourself in a terminal.

The ESP and the AVR take different formats I think. For an AVR you want an intel hex file. It will usually have the extension .hex. I'm not sure what format the ESP boards use.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.