I am working on a fresh arduino mega rev3 device.
I want to understand how it works and i need to disassemble flash memory dump.
I have seen that bootloader starts at address 0x3E000
What i want to know now is where does the main program starts in memory.
Thanks
Where the bootloader starts (if it's used) depends on fuse settings. If you have compact bootloader, you can use smaller BOOTSZ. If you're using ICSP header for uploading user program, you don't even need bootloader at all.
Anyway, program starts at 0x0000 on this chip.
Related
I have an Arduino Uno and I am using arduino 1.0.5 IDE. I followed he procedures for bootloading an atmega328P-PU on a breadboard.
I uploaded the ArduinoISP sketch first, made the connections(using the External Oscillator) and then wired it up. Then, I selected the programmer as Arduino as ISP, selected the board as Arduino duemilanove w/ Atmega328P. Then I selected the correct serial port and clicked Burn Bootloader.
I got the following errors:
avrdude.exe: stk500_program_enable(): protocol error, expect=0x14,
resp=0x50avrdude.exe: initialization failed, rc=-1 Double
check connections and try again, or use -F to override
this check.avrdude.exe: stk500_disable(): protocol error, expect=0x14,
resp=0x51
How to solve this issue? Also, can I upload the bootloader directly by using it on the Uno in place of the original chip. If so, how?
to my understanding the error you have indicates a bad reading from the chip. I experienced that with chips that were either dead or not properly connected, especially to power supply.
You may find more detailed information in th tutorial : https://www.arduino.cc/en/Tutorial/ArduinoISP
Especially those things :
Note for Arduino 1.0: you need to make one small change to the
ArduinoISP code. Find the line in the heartbeat() function that says
"delay(40);" and change it to "delay(20);".
Select the items in the
Tools > Board and Serial Port menus that correspond to the board you
are using as the programmer (not the board being programmed).
Instead of arduino built-in boot loader just go through below link and it will be great for uploading boot loader and verifying board status info
I am replying you this because same issue I got long back and it saved me.
One more thing for arduino boot loader: for atmega328 you need to put capacitor between reset and gnd( in case you missed)
For gammon bootloader you don't need it.
Be Innovative.
For reset line you might me using 100nf(thats what stated in documentation )...but sometimes it doesn't work...try something like 4.7uf, 22uf or 47uf or close values
I had a similar problem and the issue was that my programmer was a bit slow, I used the -B flag for avrdude to slow down the bitrate and it started working, I set the -B20 and works like a charm every time, but I use the USBTinyISP programmer, not the stk500 one, so this might not work for you.
In case someone stuck at this as I did and nothing like changing the cap value helped. Make sure you are using your USB-TTL adapter in a 5v mode (obviously for a 5v powered chip). I always used it in a 3.3v mode in order not to accidentally burn my 3.3v chips and it always worked. Until today, I was trying to flash my custom atmega8 board and everything worked with the ISP but I was having a hard time using the bootloader and after half a day searching and trying different stuff the 5v setting to the rescue.
I am trying to burn my atmega16 with arduino as ISP. So far the codes have been uploaded to my arduino flawlessly. I have uploaded arduino as ISP codes to my arduino, I have burnt bootloader of atmega16 using arduino IDE. As I sent the core working code from arduino IDE this went flawlessly. But the atmega is not showing the response, i.e. hardware is not working. And that is my (case I) issue. Case II: Furthermore, when I tried sending hex file (core working code) with avrdude compiler, it says ser_open() ... can't find lpt1. Is this the problem of avrdude's compiler? In case II there it didn't even uploaded the code, let alone the working of hardware. Please help.
The fact that it's trying to send it to the LPT1 parallel port suggests you haven't specified "Arduino as ISP" as your programmer. Also make sure you do a Control-Shift-U (upload via programmer) instead of Control-U (upload via the bootloader). Finally keep in mind that uploading code via an external programmer will overwrite the bootloader so you won't be able to upload via USB after that unless you reflash the bootloader or do it via the command line.
I am using arduino uno r3 board and arduino 1.6.5 on windows 8. When Itried to upload my program on ATMEGA328 microcontroller it is showing:
avrdude:stk500_getsync not in sync:resp=0x87.
help me to solve this error
This boils down to 3 problems usually..
The bootload on the chip is missing (unlikely if you purchased the board from Arduino).
The serial connection between the arduino and the computer is disconnected or interrupted.
You've simply selected the wrong board type or port when programming, and thus the IDE is searching for a signal that the arduino isn't coming back with.
This problem is most likely due to option 3, however it can occur in odd situations especially on the Arduino Micro where the board does all USB comms on chip and can be flooded by main without an appropriate delay to the point it can't communicate with the IDE. However this is just most likely a bad board selection or a bad port selection.
I've tried many things but this worked for me. If you have a working Arduino lying around (in my case Uno) you can use it as an intermediate in-system programmer (ISP).
Follow this guide to first load the ISP sketch into your working Arduino.
Once you are done, for your non-working Arduino, select from the Tools > Programmer menu and choose Arduino as ISP, and set Board and Processor accordingly. To program choose Sketch > Upload using programmer.
Hope this works.
I think the reason that this work is that it will bypass the CH340/FTDI chip, and all those synchronization issue. Given that that is your problem.
Whenever I need to upload the bootloader to my Arduino Mega (ATMEGA2560) I use an AVRISP MKII with the fuses/lock bits described in boards.txt file. Doing this I am able to burn arduino sketches by serial connection with my FTDI.
My question is: is it possible to burn arduino sketches (.hex files) with the AVRISP but keeping the bootloader? Whenever I try to do that (I use the same avrdude command I use to program the bootloader but changing the bootloader .hex file to the sketch .hex file) I am no longer able to program the processor with FTDI (and then I need to program the bootloader again).
I think (of course I can be wrong) this problem occurs due to the fuse and lock bits settings that cannot be the same as those used to program the bootloader.
This is the fuse settings I use (from boards.txt file under Arduino folder)
mega2560.name=Arduino Mega 2560 or Mega ADK
mega2560.upload.protocol=wiring
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200
mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F
mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino
mega2560.build.variant=mega
Can you help me?
Thanks in advance.
Some controllers like the AT*X*MEGA series support individual flash sections that can be programmed/erased independently. However, with the ATMEGA2560 this is not possible.
One way would be to concatenate the .hex files as part of the build process. This can be achieved with some modifications to the makefile.
Something similar to this
all: $(TARGET).hex
srec_cat bootloader.hex -intel $(TARGET).hex -intel -o combined.hex -intel
Flashing the ´combined.hex´ would then include both, main application and boot loader. There is a related discussion on AVRFreaks.
Regarding the fuses, you just have to make sure that the boot loader (address) stays configured as the entry point.
EDIT: You can use this fuse bit calculator to verify fuse settings. Select your device and make sure "Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]" is enabled with your current high fuse value.
You currently use
mega2560.bootloader.high_fuses=0xD8
so that seems fine.
I downloaded several software that provide virtual COM ports. These COM ports do appear in the Device Manager and can be selected for upload from the Arduino IDE, menu Tools -> Serial Port -> COM3. It starts uploading and reaches 90% and then it either times out or just does nothing.
I want to upload onto the virtual COM port so I could then read the compilation output files in another program. I don't want to use my Arduino at all, and I don't want to manually get the verbose output files when uploading. This problem doesn't happen when I upload on the real Arduino.
The application should work on all platforms. This task seems easy on Linux, and I am facing the stated problem on Windows and any help with Mac would also be useful.
The application will be an educational tool for hardware simulation and visualization trying to give a more hands-on experience for users than other simulators out there. So may be this will give you an idea of why I want to do so.
How can I get started?
I think you might be assuming that uploading code to Arduino is one-way communications: this would be like putting strawberries in a blender, and a Daquiri comes out. If that was true, you could just take whatever the IDE dumps to the serial port, save it to a file, and you have an Arduino binary. (Skip to TL;DR if not interested in details. Upshot: this assumption is not correct).
The 1-way communication assumption is not entirely correct: there is a program on the Arduino (called "a bootloader") which is responsible for communicating with the programmer ("programmer": a program that programs the Arduino, assume it is the Arduino IDE for now). In their most "natural" state, the Arduino CPUs cannot be programmed across serial lines. Rather these chips are programmed either via the in system programming (ISP) or via the JTAG protocol. The bootloader is a program that runs on an Arduino CPU and loading of sketches/programs over the serial port. This program runs at startup and looks for programming commands over the serial port.
If it discovers that a programmer is trying to communicate programming information, it will read the compiled Arduino binary coming over the serial link, store it in flash memory, send it back to over the serial link for verification, and if everything is successful, exit and launch the stored sketch. If no programming information appears on the serial port, that is, no programmer is trying to write a new sketch, then the bootloader simply quits and launches the program already stored in flash.
TL;DR: In order to implement a pseudo-Arduino on your serial port you must write a program some code that simulates an Arduino (bootloader) on the other end of your virtual serial port. So when a programmer/IDE says to Arduino "are you there?" your program will respond "yes!", just like an Arduino would.
The default Arduino bootloader is STK-500 compatible: that means that it implements STK-500 commands - the reference for which can be found here. If you decide to do this, then the easiest thing might be to start with an existing bootloader, such as Arduino's or AdaFruit's (there are others too), and modify it. Such a bootloader would have all the commands already implemented, and since it is written in C (I wouldn't choose an assembly bootloader to modify :), it should be easy enough to modify.
Alternatively, you might decide that STK-500 is too difficult to implement. If this is the case, you can use any programmer protocol that Avrdude supports: Avrdude is a program for programming AVR chips, and Arduino IDE uses Avrdude internally to send the sketch to the Arduino. If you do this, then you'd have to change the settings in Arduino IDE for which programmer you are using.
Personally, I think STK-500 compatible is the best option for this, but YMMV.