Mega 2650 Bootloader Newb

I'm getting started with Arduino's. I picked up my first, a Mega 2650 and a few sensors and such. I got things going quickly, no issues with the programming.

Now, the bootloader? Heh. I get what it does. I get why it is needed. But, short of getting another Arduino to "program" the bootloader in the Mega, how in the hell do you program the bootloader? I'm getting the feeling, that certain models are easier to install the bootloader, then with that, it can be used to program the "not so friendly" models.

So, I'm needing help, figuring out the most simplistic method of getting the bootloader on this, and, for the future, that is the most flexible.

I come from the world of IT, so linux, cli, working with various code and manufacture's BS is part of my skillset. Fire away! (and Thanks!)

Mark

the Mega has a bootloader from factory. why do you want to burn a bootloader?
you need a programmer to do it or other ATmega Arduino can be used as programmer with the "Arduino as ISP" sketch

It does! Nice. Ok, so when I upload my "sketch" to the board, it works fine. However, when I unplug the usb, and back in (still connected to the computer), the "sketch" doesn't run.

My theory is, if it has a bootloader, being connected to the computer via the usb is preventing it from booting (ie: in program mode?) If so, I would assume it would boot fine connected via a usb charger of sorts, or would I need to power via the dc input?

n5yzv:
If so, I would assume it would boot fine connected via a usb charger of sorts,

That would be a "no" with a usb battery pack . . .

USB chargers give 5 V, but the barrel jack or Vin pin are input of a regulator and require a higher voltage.
Arduino Mega 2560 Rev3 — Arduino Official Store see the Tech Spec tab

Ah, good to know regarding the Barrel Jack or VIN.

In short, I made a sketch (simple, read temp/humidity) in a loop every 5 seconds. I pushed it to the board, all good. I pull the usb, reconnect and it doesn't run. I have tried this connected to a usb battery pack and my computer. My initial thought is it doesn't have a bootloader. But, I'm not sure, as JuraJ noted, it comes with one from the factory. Please advise! (thanks for the responses!)

If you can upload, the Mega has a bootloader. That's all the bootloader is used for. Forget about the bootloader. It has nothing to do with your problem.

n5yzv:
I pull the usb, reconnect and it doesn't run.

Please explain exactly what you mean by "it doesn't run"?

In the Arduino IDE, I "push" the sketch via usb to the mega. It runs great. When it does, I see the TX LED flash, every 5 seconds when it polls the sensors. Again, exactly what I want it to do.
Then, I pull USB power. Arduino IDE (1.8.9) and Serial monitor are closed (not running). I never see the TX LED light up or blink.
To me, it seems like the sketch never initializes. The LED's that are on are the "on" and an LED near digital pin 13/GND.

If I quick press the button, the LED near the Digital pin 13/GND blinks once. That's it. If I open the IDE and open the serial window, nothing.

So, in this state, I opened the IDE, opened the serial port and it is working perfectly. I am an idiot.

Seems that "TX" LED is just the xmit of the serial data and has nothing to do with the running sketch commands. Sorry. I'm learning. Enjoy the laugh!

Thanks for all the help.

upload Blink example

Yeah, I think I'll grab some of it's blink code and make it blink when it executes the sensor check.

Thanks again!

n5yzv:
In the Arduino IDE, I "push" the sketch via usb to the mega. It runs great. When it does, I see the TX LED flash, every 5 seconds when it polls the sensors. Again, exactly what I want it to do.
Then, I pull USB power. Arduino IDE (1.8.9) and Serial monitor are closed (not running). I never see the TX LED light up or blink.
To me, it seems like the sketch never initializes. The LED's that are on are the "on" and an LED near digital pin 13/GND.

If I quick press the button, the LED near the Digital pin 13/GND blinks once. That's it. If I open the IDE and open the serial window, nothing.

So, in this state, I opened the IDE, opened the serial port and it is working perfectly. I am an idiot.

Seems that "TX" LED is just the xmit of the serial data and has nothing to do with the running sketch commands. Sorry. I'm learning. Enjoy the laugh!

Thanks for all the help.

the RX and TX LED are LEDs of the USB chip. if the USB chip has no connection to PC the LEDs will not blink