Stuck and Confused (Boot Flash/Firmware/StartUp File)

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Before I ask my question I just wanted to list the sources of which i've used in trying to answer my own questions before coming here.

 

-ATmega328P Xplained Mini User Guide (http://www.atmel.com/tools/MEGA328P-XMINI.aspx?tab=documents)

-User Guide EDGB (http://www.atmel.com/Images/Atmel-42096-Microcontrollers-Embedded-Debugger_User-Guide.pdf)

-ATmega328P Datasheet

-AVR Assembler User Guide (http://www.atmel.com/Images/doc1022.pdf)

-Beginners Intro to the Assembly Language of ATMEL-AVR Microprocessors (http://www.avr-asm-download.de/beginner_en.pdf)

-AVR Microcontroller and Embedded Systems by Muhammad Ali Mazidi, Sarmad Naimi, Sepehr Naimi (http://www.amazon.com/gp/product/0138003319/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1)

 

NOTE:

My questions are in relation to the ATmega328P Xplained Mini Board coding in assembly. I have taken a class in assembly so I am familiar with basic fundamental concepts.

 

-----------------------------------------------------------What i'm trying to achieve---------------------------------------------------------------------------------------------------

 

I'm familiarizing myself with the chip set and have purchased a ATmega328PXplainedMini board here (http://www.atmel.com/tools/mega328p-xmini.aspx) to do so. I've written several basic .asm programs using the simulator on Atmel Studio but I have not actually uploaded anything yet to my board because I don't completely understand the concepts below. Feel like i'm having trouble understanding what software needs to reside where in order to burn my code to the chip. Reading all these technical docs gets confusing. 

 

---------------------------------------------------------------My Questions-----------------------------------------------------------------------------------------------

 

When I read the datasheet for the chip it talks about example bootloader programs and In-System Reprogrammable Flash Program Memory where a small chunk is set off for Boot Flash. This confuses me cause I don't know if I need to downloard/upload a boot program, write one myself or use this In-System Reprogrammable option (i'm assuming this In-System... feature is optional). My user guide for my board says I have a mEBDG debugger/programmer so maybe I don't even need to worry about it but the datasheet confused me when it mentioned all that. 

 

When I plugged my XplainedMini board into my pc for the first time it downloaded firmware. Is that firmware on my 328P chip or somewhere else?

 

From my understanding and classes i've already had on assembly the startup file is where I put my interrupt vector addresses, initialize the stack pointer, and port declaration or so i've intrepreted this whole time. The vibe i got off several tutorials online don't really use the word startup file like thats not the correct vocabulary. Before i've just included these directives and instructions right before my main code so why do they call it a file since its already included in my .asm file with my other code?

 

I've looked through the .INCLUDE file for my chipset. It listed macros, memory allocations, register definitions and much more. I don't have much confusion on this but through some tutorials it was like the startup file was being referred to the .include file which really confused me and drove me to writing the post.

 

 

This topic has a solution.

~regnar86

Last Edited: Sat. Jan 17, 2015 - 04:21 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

having read the top link there I'm not surprised you are "stuck and confused". The Atmel documentation is atrocious! It talks about programming the 328P then it goes on to talk about this mysterious 32U4 that you can either program with an ISP/JTAG or Flip/DFU bootloader withough actually explaining what the 32U4 is even doing there or why you would want to reprogram it!

 

The bottom line is that you have a "totally empty" 328P on that board to program in whatever way you like. Forget about bootloaders and other stuff like that it is of no concern to you if all you want to do is program/debug Asm in the 328P.

 

If you hunt around on the Atmel site about the 328P Xplain Mini one of the links you'll find is to a .zip file which contains design documents.  Within that is ATmega328P_Xplained_Mini_design_documentation.PDF which contains schematics so you can see what's actually on the board. if you study the circuit (and know a bit about AVR) you can see that the 32U4 is the thing doing "EDBG". So it's the chip that talks "USB" to the PC/Studio and then can do ISP or debugWire on to the 328P chip. While it *can* be reprogrammed I have no idea why a "normal" user would ever want to do that. So forget all the rubbish in the "user manual" about reprogramming the 32U4 using either ISP/JTAG or Flip/bootloader.

 

Just connect up the 328P Mini board to your PC and as the manual says Studio (and Windows) will "see" it as both a UART (USB-CDC) bridge and also as an ISP/debugWire programmer/debugger. Just use "normal procedures" in Studio to send your code to it via ISp or do debugWire debugging. It is the case that the 32U4 will then be acting as the "debugger/programmer" for you but it's not really necessary for you to know what chip is being used to do that - just treat it as a "black box".

 

I do think, however, that Atmel need to take a SERIOUS look at the documentation for this board. It is confusing in the extreme. They clearly have never given it to a beginner/real user and asked for feedback. At the very least it should explain what the 32U4 is doing there and why (if they can think of a reason) the end user would even be concerned about programming it.

When I plugged my XplainedMini board into my pc for the first time it downloaded firmware. Is that firmware on my 328P chip or somewhere else?

I think that will have been the code for the 32U4 that actually does the programmer/debugger/UART bridge stuff for you.