TODOPIC
Otros Microcontroladores / Dispositivos programables => Microcontroladores 8 bits => Mensaje iniciado por: agauss en 09 de Octubre de 2014, 10:19:29
-
Saludos compañeros del foro, les tengo una consulta para aquellos conocedores del los ATMEGA AVR. Resulta que deseo proteger las memorias FLASH y EEPROM de un ATMEGA48 y un ATMEGA88, estoy usando el usbasp con el hardware AVR8 Burn-O-Mat v2. Si alguien pudiera proporcionarme alguna infiormacion al respecto, o tal vez con algun otro hardware que se pudiera hacer. Ojala puedan ayudarme. Saludos a todos...
-
Hola Agauss,
de este tema se hablo muchos por http://www.todopic.com.ar/foros/index.php?topic=27420.40
nunca le he hecho, porque al proteger la eeprom y la flash con el LOCKBITS creo que al programarlo ya es micro no los podra programar mas. ojo nunca lo he hecho,
ahora te pregunto para que quiere proteger la Flash y la Eeprom?
las forma sencilla de hacerlo seria hacer un bootloader que para gravar el micro pida una contraseña o usar mas opciones.
si consigue hacerlo de la forma que sea seria muy bueno mostrarlo por aqui.
Saludos
-
Los Locks Bits ( Bits De Candado)
Pueden Ser Borrados Con Una Operacion De CHIP ERASE
La Unica Manera De Poder Reprogramar El Micro Impone Un Chip Erase
Antes De Cualquier Accion De Reprogramacion o Reutilizacion
2. OJO!! Only on ATmega88/168.
The Lock Bits can only be erased to “1” with the Chip Erase command.
Estos Bits Se Pueden Programar Pero Tiene Que Ser A Traves Del Codigo
Que Vayas A Gravar Al Micro
Seguridad De la Aplicacion : Tipo De Protecion
***************************
Bootlock02, Bootlock01 : :Se Tratan De Fusibles Destinados A Controlar Los Derechos De Accesos A
A La Seccion De Aplicacion ( Zona De Programa Principal) Con Las Intruciones SPM (Store Program Memory)
Y LPM (Load Program Memory)
..................
BLB02 . BLB01 .
..................
1 . 1 . Sin Restriciones En Las Instruciones SPM o LPM Para El Acceso
.................. A La Seccion De La Aplicacion
. .
1 . 0 . SPM No Esta Permitido Para Escribir En La Seccion De La Aplicacion
..................
0 . 0 . Igual A Lo Anterior Y Posterior Pero Juntos
..................
0 . 1 . LPM Ejecutada En El BootLoader No Esta Permitida Para Leer
. Desde La Seccion De La Aplicacion
. Si Un Vector De Interupcion Es Puesto En La Seccion Del BootLoader
. La Interupcion Esta Deshabilitada Mientra Se Ejecuta Desde La Seccion De La Aplicacion
..................
...
Seguridad De la Seccion Del Bootloader : Tipo De Protecion
***************************************
Bootlock12, Bootlock11 :Se Tratan De Fusibles Destinados A Controlar Los Derechos De Accesos A
La Seccion Del BootLoader Con Las Intruciones SPM (Store Program Memory) Y LPM (Load Program Memory)
..................
BLB12 . BLB11 .
..................
1 . 1 . Sin Restriciones En Las Instruciones SPM o LPM Para El Acceso A La Seccion Del BootLoader
..................
. .
1 . 0 . SPM No Esta Permitido Para Escribir En La Seccion Del BootLoader
..................
0 . 0 . Igual A Lo Anterior Y Posterior Pero Juntos
..................
0 . 1 . LPM Ejecutada En La Aplicacion No Esta Permitida Para Leer
. Desde La Seccion Del BootLoader
. Si Un Vector De Interupcion Es Puesto En La Seccion De La Aplicacion
. La Interupcion Esta Deshabilitada Mientra Se Ejecuta Desde La Seccion Del BootLoader
..................
...
Bootlock2, Bootlock1 :Se Tratan De Fusibles Destinados A Controlar Los Derechos De Accesos A La Memoria FLASH Y EEPROM
..............
LB2 . LB1 .
..............
1 . 1 . Sin Habilitar La Protecion De La Memoria
..............
1 . 0 . Deshabilita Futuras Programacion De La Flash Y EEprom En Los Modos Paralelo Y Serial
.............. Los Bits De Los Fusibles De Programacion Estan Asegurados En Ambos Modos
. .
0 . 0 . Igual Al Anterior Y Tambien Se Deshabilita La Verificacion
..............
Para Programar Los Bits De Candado Hace Falta Gravar Los Bits Correcto
En El Registro R0, Poner A 1 BLBSET Y SPMEN Y Ejecutar SPM.
El Registro SPMCSR Contiene Los Bits Para Controlar Las Operaciones
De Carga Del Programa En La Memoria Flash En Modo " BOOT"
BLBSET : Boot Lock Bit
Si Este Bit Esta A 1 Al Mismo Tiempo Que SELFPRGEN
La Instrucion Siguiente SPM Despues De 4 Ciclos De Reloj Escribiendo los Datos Guardados En R0
Los Datos En R1 Y La Direcion En El Registro Z Seran Ignorados
El Bit BLBSET Sera Puesto Automaticamente a 0 Al Terminar
Te Lo Eexplico De Otra Manera
;Registro SPMCSR
;Bits: |***BLBSET SELFPRGEN (Boot Lock Bit Set)
;|--7--|--6---|--5---|--4---|--3---|--2--|--1--|-----0----|
;|-----|------|------|------|------|-----|-----|----------|
;|SPMIE|RWWSB | _ |RWWSRE|BLBSET|PGWRT|PGERS|SELFPRGEN |
;|-----|------|------|------|------|-----|-----|----------|
; 0 0 0 0 1 0 0 1 | = LDI R17,0x09
LDI R17,0x09 ;Configura El Boot Loader Lock Bits Con SPM En R17
OUT SPMCSR,R17 ;Copia Los Datos En SPMCSR
SPM ;Ejecuta SPM
RCALL EsperaSPM ;Espera SPM Y Vuelve Aqui
;......................................................................................
EsperaSPM: ;4 Ciclos De Reloj
IN R17,SPMCSR
SBRC R17,0 ;Salta A La Siguiente Instrucion Si r17 = 0
RJMP PC-0x0002 ;Salta SPMCSR Si r17 Es Positivo
RET
;....................................................................................
-
( LOCK BITS) Vienen Desde La Fabrica Sin Programar ( Todos En 1 Logico)
Todos Los Avr Contienen 2 Bits De Bloqueo Que Se LLaman LB1 y LB2.
Programando Estos ("0") Agregara La Proteccion A Los Contenidos Escritos En Flash Y EEprom
Segun La Tabla
..............
LB2 . LB1 .
..............
1 . 1 . Sin Habilitar La Protecion De La Memoria
..............
1 . 0 . Deshabilita Futuras Programacion De La Flash Y EEprom En Los Modos Paralelo Y Serial
.............. Los Bits De Los Fusibles De Programacion Estan Asegurados En Ambos Modos
. .
0 . 0 . Igual Al Anterior Y Tambien Se Deshabilita La Verificacion
..............
El Nivel De Proteccion Se Divide En 3 Modos
El Modo 1 No Ofrece Ninguna Proteccion
El Modo 3 Ofrece La Maxima Proteccion
Es Posible Cambiar De Nivel A mayor Proteccion Mediante La Reprogramacion De Los Bits De Bloqueo
El AVR Permite Cambiar Los Bits "Alto" a "Bajo" Pero No Al Reves
NO Es Posible Cambiar Un Bit De Bloqueo De "Bajo" a "Alto" Lo Que Disminuye El Nivel De Proteccion
Para Eso Se Requiere Un Borrado Completo Lo Que Borrara La Memoria Flash
Para Programar Los Bits De Bloqueo (Boot Lock Bit)Se Tiene Que Cargar Los Bits Correcto En R0
Poner A 1 BLBSET y SELFPRGEN Y Ejecutar SPM
Si Los Bits 5....0 en R0 Estan a (0) Programming these (“0”)
El Correspondiente Boot Lock Bit Y En General Los Bits De Bloqueo
Seran Programados Si Se Ejecuta La Instrucion SPM Dentro De Los Cuatros Ciclos De Reloj
Despues De Que BLBSET y SELFPRGEN Se Establezcan En El Registro SPMCSR.
; 25.2.2 Escribe Los Fusibles De Los Bits De Bloqueo Desde El Software
;|--7--|--6---|--5---|--4---|--3---|--2--|--1--|--0--|
;|-----|------|------|------|------|-----|-----|-----|
;| 1 | 1 |BLB12 |BLB11 |BLB02 |BLB01| LB2 | LB1 |
;|-----|------|------|------|------|-----|-----|-----|
; 1 1 1 1 1 1 0 0 |LDI R17,0xFC
; programmed
;BLB12 |BLB11 No Estan Programados
;BLB02 |BLB01 No Estan Programados
; LB2 | LB1 Igual Al Anterior Y Tambien Se Deshabilita La Verificacion
;..................................................................................
LDI R17,0xFC ;Carga El Valor FC En r17
MOV R0,R17 ;R0 = FC