Jump to content
ELFORUM - Forumul electronistilor
deep-blue

ATmega162 bootloader si avr-gcc

Recommended Posts

Incerc sa-mi produc un bootloader pe compilator avr-gcc si nu stiu cum sa procedez ca sa-mi iasa un .hex care sa inceapa de la adresa 0x1000. (Interfata cu PC-ul e USB via transceiver ISP1581 deci nu prea am de ales decat sa mi-l fac singur)

 

As vrea sa folosesc functiile din . Pe undeva in fisierul respectiv se da un macro :

/** \ingroup avr_boot    \def BOOTLOADER_SECTION    Used to declare a function or variable to be placed into a    new section called .bootloader. This section and its contents    can then be relocated to any address (such as the bootloader    NRWW area) at link-time. */#define BOOTLOADER_SECTION    __attribute__ ((section (".bootloader")))
Nelamuriri:

1. Cum folosesc acest define ? Va trebui sa prefixez fiecare functie cu acest macro ?

2. cum fac relocarea in urmatorul Makefile:

CC=avr-gccCA=avr-asTARGET_MCU=atmega162TARGET_FNAME=o2-bootCC_OPTS=-Wall -O1 -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -mmcu=$(TARGET_MCU) -DF_CPU=12000000ULFILES=assembly.o main.oSHELL=/bin/bashall:        @echo Building bootloader        @echo        $(CC) main.c -c -o main.o $(CC_OPTS)        $(CA) assembly.s -o assembly.o -mmcu=$(TARGET_MCU)        $(CC) -o $(TARGET_FNAME).elf main.o assembly.o        rm main.o assembly.o        @echo        @echo Convert to hex        @echo        avr-objcopy -R .eeprom -O ihex $(TARGET_FNAME).elf "$(TARGET_FNAME).hex"
Link to comment
Share on other sites

Se mai intampla cateodata sa stau 2 zile pe Google si sa citesc manuale ca pe urma sa gasesc raspunsul in 10 minute doar schimband termenii de cautare. :ciuda:

 

Chiar dupa ce am postat am gasit si cum se face:

Functiile trebuiesc sufixate cu BOOTLOADER_SECTION la declararea prototipului, iar linker-ul trebuia sa fie ceva de genul (dupa expandare):

avr-ld --section-start=.bootloader=0x1000  -o o2-boot.elf main.o assembly.o
Se pare ca asternerea ideilor/problemelor, chiar si pe tastatura, are efecte benefice din cand in cand ...
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines