Please explain usage of the header file and macros

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

How do I use routines in http://nongnu.org/avr-libc/ to the gcc-compiler. It would be nice if some one can explain the usage of the header file and macros.

 

#define 

BOOTLOADER_SECTION   __attribute__ ((section (".bootloader")))

 

Where should I define it if I am using a arduino IDE to develop my boot loader ?

What is the word "_attribute _" stands for ? 

What is the word "_section_" stands for ?

Will it create a section called .bootloader or will the data move to a file called .bootloader ?

 

 

 

Thanks,

Srinivasa Varadhan

Last Edited: Fri. Feb 5, 2016 - 09:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

srinivardhan wrote:
It would be nice if some one can explain the usage of the header file and macros.

For general information on then concepts of header files and macros, any C textbook or tutorial will do. There are a lot of them out there.

 

For specific information on avrlibc the documentation is the place to go.

 

If you want to use the facilities of avrlibc, then the Arduino IDE might not be suitable. Go for Atmel Studio instead.

 

Developing a bootloader with the Arduino IDE seems a bit weird (e.g. because it hides, or even makes inaccessible, option setting for the specifics you ask about). Also, if relying on the Arduino run-time support, the bootaloder binary might become a bit bloated. That is not something you want with a bootloader, since the bigger it gets the less flash will be left for the application proper.

 

Do you realize you've awakened a thread that has been sleeping for almost seven years? Things mentioned in this thread might be outdated..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have an example tutorial of using a avr-gcc toolchain to write a boot loader ?

Thanks,

Srinivasa Varadhan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a bootloader tutorial in the Tutorials forum here at AVRfreaks.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read the Bootloader FAQ in the tutorial forum. As I wrote there the macro "BOOTLOADER_SECTION" is a TERRIBLE name as it has NOTHING to do with writing a bootloader. That macro is for when you are writing an app thst just needs to be able to write to some of the flash to use as data storage. To do that, while the main application code is located down near address 0 you need one or two of your functions to be placed in high memory so they can issue the SPM command. To get those functions placed high you use BOOTLOADER_SECTION to say "I want this function placed in the high memory that is known as the "Bootloader Section". Apart from the fact that this does involve using SPM this really has nothing to do with true bootloaders.

 

A bootloader is a complete program (reset jump, vector table, C Run Time and all the code) that is all moved to the high address. You do not do this using BOOTLOADER_SECTION. As the FAQ will reveal you do this by using -Wl,-section-start=.text=01234 (replacing 0x1234 with the address of the Bootloader Section). The shortened form of that command is just -Wl,-Ttext=0x1234 - it may be easier to just use that (less typing!).

 

Anyway go to the tutorial forum, find and read the Bootloader FAQ and it should tell you all you need to know to write a bootloader.

 

(Having said all that do you REALLY need to write a bootloader from scratch? There must be 1,000 or more existing ones to choose from, probably 80% (maybe more) of those written for avr-gcc. Only bother writing one from scratch if you have some very unusual requirement not already covered by existing, tried and tested code).