About Mega2560 and Optiboot: What is the starting address

We are planning to use a Linux SBC to upload program to an Mega2560. STK_LOAD_ADDRESS is used I think. What is user address space in Mega.

By the way, a startup Led is mentioned. Is it in Arduino pin 13, chip pin 26/PB7. Is there no other indication that the bootloader is ready.

Is the ? character on your keyboard broken? Your statements are pretty confusing. What does a SBC, address space and the stack load address have to do with uploading? Nothing at all.

Why don’t you back up and explain what you’re actually doing? Are you trying to install Opiboot onto a chip or just uploading to a chip that already has it installed?

I want to know how to use Optiboot to upload code to controller.

avrdude -p atmega2560 -c arduino -P /dev/ttyUSB0 -b 115200 -D -Uflash:w:program.hex:i

Assuming your USB to serial adapter is /dev/ttyUSB0 and the upload baud rate is 115200

Thank you.

If our Linux single board computer does not have or will not run Avrdude, what is the procedure then?
The board has some free IO and off course serial bus. That is, can we make the programming with our own sw.

I don't see why you wouldn't run avrdude? Or do you want to re-invent the wheel? I believe you can use the physical UART pin on the SBC for programming as long as you can generate some kind of reset pulse like the DTR line on a USB to serial adapter.

Why on earth can't you get avrdude for the SBC? Even if you have to compile it yourself, that would be far less work than reimplementing the STK500v2 protocol yourself. Don't reinvent the wheel if you don't have to.

Let's see...

  • The Mega2560 normally runs stk500boot_v2_mega2560, not optiboot.
  • In either case, details like the STK_LOAD_ADDRESS are either irrelevant, built into the .hex file, or built into the makefile if you're compiling the bootloader from source.
  • But you'll also need the fuse settings. Those are built in to the boards.txt description of each board, or the bootloader makefile, or you can derive them from first principles.
  • If you are running a SBC that runs linux, you should be able to build avrdude for it. Note that avrdude is also used to upload arduino sketches AFTER the bootloader has been programmed.
  • If you can't compile avrdude for your SBC, you will need to find or write some other program for talking to the bootloader and/or AVR Chip programmer (or potentially, to the AVR pins themselves.) The ArduinoISP sketch might be a good starting point.

westfw:
Let's see...

  • If you can't compile avrdude for your SBC...

That has to be impossible for Linux. Building the kernel requires a C compiler. Building avrdude can be done with that same compiler.

And, there is a plethora of cross-compiling options available. It is within the realm of possibility that avrdude can be built for the target computer using Cygwin on a Windows computer.

if you can't compile avrdude for your SBC...

That has to be impossible for Linux.

I can vaguely envision a linux with no built-in support for USB CDC/ACM, where the only serial port is dedicated to console use...

westfw:
Let's see...

  • The Mega2560 normally runs stk500boot_v2_mega2560, not optiboot.
  • In either case, details like the STK_LOAD_ADDRESS are either irrelevant, built into the .hex file, or built into the makefile if you're compiling the bootloader from source.
  • But you'll also need the fuse settings. Those are built in to the boards.txt description of each board, or the bootloader makefile, or you can derive them from first principles.
  • If you are running a SBC that runs linux, you should be able to build avrdude for it. Note that avrdude is also used to upload arduino sketches AFTER the bootloader has been programmed.
  • If you can't compile avrdude for your SBC, you will need to find or write some other program for talking to the bootloader and/or AVR Chip programmer (or potentially, to the AVR pins themselves.) The ArduinoISP sketch might be a good starting point.

Thank you.
Using the bootloader is not as simple as I hoped. I'll let the SW designers take care the rest of this.