section type conflict for bootloader

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

I've got a bootloader that works fine and am trying to combine it in a build with my main program. I have added the following to the makefile:
LDFLAGS+=-Wl,--section-start=.bootloader=0x1FC00.

Here are my two h files for the bootloader section:
bootloader.h
void BootMain(void); __attribute__ ((section (".bootloader")))
void BootLoad(void); __attribute__ ((section (".bootloader")))
void GetPageNumber(void); __attribute__ ((section (".bootloader")))
void ExecCode(void); __attribute__ ((section (".bootloader")))
char GetPage(void); __attribute__ ((section (".bootloader")))
void WriteFlash(void); __attribute__ ((section (".bootloader")))
char CheckFlash(void); __attribute__ ((section (".bootloader")))
unsigned char IsChar(void); __attribute__ ((section (".bootloader")))
unsigned char RxChar(void); __attribute__ ((section (".bootloader")))
void TxChar(unsigned char ch); __attribute__ ((section (".bootloader")))

and assembly.h
void write_page (unsigned int adr, unsigned char function); __attribute__ ((section (".bootloader")))
void fill_temp_buffer (unsigned int data,unsigned int adr); __attribute__ ((section (".bootloader")))
unsigned int read_program_memory (unsigned int adr,unsigned char cmd); __attribute__ ((section (".bootloader")))
void enableRWW(void); __attribute__ ((section (".bootloader")))
void fv_wait(void); __attribute__ ((section (".bootloader")))

I get a message that BootLoad causes a section type conflict.

Any clues to what I am doing wrong?

Thanks

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

Not off hand, however, did you know that avr-libc has a ? Which already has macros that generate inline assembly that does the things in your assembly.h, and you can call them from your C code bootloader. It also has a define:
#define BOOTLOADER_SECTION __attribute__ ((section (".bootloader")))
which makes it faster to write your prototypes.

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

Eric,
Thanks, I'll take a look at your boot.h and see if I can simplify things. Also I think I have the answer to my own question. I had some global variables in the original bootloader code and I tried to do the following when I combined them with another program.

int a_global_variable; __attribute__ ((section (".bootloader")))

Which apparently did not make the linker very happy. So is there a way to make a variable that just has the bootloader section as its scope?, or do I just have to pass the variables from routine to routine?
I can think of ways to define the scope with C++, but not with C.