Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Bootloader Frustration

2007-07-12 by Dave VanHorn

Hmm.. Having much fun trying to implement this..

The basics of the Xmodem transfer protocol are working, and I get 128 
byte packets from the host.

But putting them into program memory isn't working out right.

I have a register that counts packets from the host, of course it 
rolls at 255, so I grab another register that counts rollovers.  1024 
packets of 128 bytes fills a M128.  Here's how I translate the packet 
count to the write address:

;
;***********************************************************
;
; Create the page pointer in three DIFFERENT registers.
; from the Xmodem packet count, and ITEMP, which is used
; as the high byte, since we have no INTS at this point.
;
Loader_MakePage:
	lds	TEMP,XmodemBlk		;
	call	Pong			;

	clr	ZL			;
	out	RAMPZ,ZL		;
	;   RAMPZ       ZH       ZL
	;00000000 xxxxxxxx 00000000

	lds	ZH,XmodemBlk		;The packet number
	;00000000 pppppppp 00000000

	dec	ZH						;
	;packet 1 goes to block zero
	;00000000 bbbbbbbb 00000000

	lsr	ZH					
	;shifts a 0 into MSB of ZH
	ror	ZL					
	;shifts carry into MSB of ZL
	;   RAMPZ       ZH       ZL
	;00000000 0bbbbbbb b0000000
	;       |          ||    ||
	;       |          ||    |\----- Which byte within word
	;       |          |\----\------ Words within page
	;	\----------\------------ Pages

	mov	TEMP,ITEMP	;UGLY fix for how they bastardized the
	andi	TEMP,$03	;000000xx
	breq	MakePage_NOZ	;If neither bit is set, then done.

	sbrc	TEMP,0		;If lsb is set, then set MSB of ZH
	ori	ZH,$80		;dosen't touch TEMP
	;00000000 Bbbbbbbb b000000

	sbrs	TEMP,1		;if b1 is set, then set B0 of RAMPZ
	rjmp	MakePage_Noz	;
	ldi	TEMP,$01	;
	out	RAMPZ,TEMP	;

	;00000001 Bbbbbbbb b0000000
	;       |          ||    ||
	;       |          ||    |\----- Which byte within word
	;       |          |\----\------ Words within page
	;       \----------\------------ Pages

MakePage_Noz:
	in	TEMP,RAMPZ	;So I can see the adrs on the LA
	call	PONG
	mov	TEMP,ZH
	call	Pong
	mov	TEMP,ZL
	call	Pong
	ret
;
;***********************************************************
;

What's happening, is that it seems to be erasing EVERY page, but 
writing every OTHER page, although I can't tell if it's wrapping, or 
exactly what is going on..  The "pong" statements are my byte in PWM 
output on a single pin, and that shows me what I expect as the 
packets come in.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.