Jump to content
ELFORUM - Forumul electronistilor

Vreau sa-mi fac un bootloader


claudio
 Share

Recommended Posts

Salutare,Vreau sa-mi fac un bootloader simplu, fara prea multe complicatii.Am studiat pe net diferite variante si mi-am facut o idee.Acum e partea in care vreau sa-l implementez.Ca si suport folosesc AVRStudio5, ExtremeBurner, USBasp.Pentru inceput o sa fac o aplicatie care va fi scrisa la adresa de boot si la rulare sa aprinda un LED.Cum procedez ca acest program (HEX) sa fie scris in boot si nu la adresa 0x0000?Mutlumesc.

Link to comment
Share on other sites

  • 2 weeks later...

Salutare,

 

Am reusit sa fac ce mi-am propus, iar mai jos sunt explicatii pentru cei care au nevoie de ajutor.

 

La pornire uC va rula aplicatia din bootloader (BlinkLED-boot.c) astfel ledul de pe un PORTA va licarii de 32 ori la 100ms, face o pauza de 1sec apoi porneste aplicatia propriu-zisa (BlinkLED-main.c) in care ledul va licarii la 500ms.

 

Sursa BlinkLED-boot.c

#define F_CPU 16000000UL#include <avr/io.h>#include <util/delay.h>int main(void){	DDRA=0xFF;	PORTA=0x00;	while(1)	{		for (uint8_t i=0; i<32; i++)		{			PORTA=0xFF;			_delay_ms(100);			PORTA=0x00;			_delay_ms(100);		}		_delay_ms(1000);		asm("jmp 0x0000");	}}
Inainte de compilare trebuie sa faceti urmatoarea setare in AVRStudio5:

1. Click dreapta pe proiect -> Properties

2. la Memory trebuie completat:

MemoryType: Flash

Name: .text

Address: 0x3C00

 

Sursa BlinkLED-main.c

#define F_CPU 16000000UL#include <avr/io.h>#include <util/delay.h>int main(void){	DDRA=0xFF;	PORTA=0x00;	while(1)	{		for (uint8_t i=0; i<8; i++)		{			PORTA=0xFF;			_delay_ms(500);			PORTA=0x00;			_delay_ms(500);        	}		_delay_ms(1000);	}}

Pentru a obtine un singur fisier HEX, am concatenat cele doua HEX-uri obtinute, folosind Srecord http://srecord.sourceforge.net/ prin comanda "srec_cat BlinkLED-main.hex -intel BlinkLED-boot.hex -intel -o APP.hex -intel".

 

Bitii "Fusebits" au valoriile:

LF: 0xFF

HF: 0xDA

 

Microcontrolerul este ATmega32.

Link to comment
Share on other sites

  • 5 weeks later...

Acum m-am lovit de urmatoarea problema: cum scriu fuse bytes prin bootloader?Pana in momentul de fata am reusit sa-i citesc si sa-i afisez in Hyperterminal.Pe net sunt ceva documentatii, dar sunt doar pentru LOCK BITS.Oare nu se poate scrie LOW FUSE, HIGH FUSE si EXTENDED FUSE prin bootloader?Multumesc.

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.

 Share

×
×
  • 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