January 23rd, 2006

1) I’ve updated my resume for those of you who care about such things. It’s at http://www.sheer.us/resume/SheerResume-ascii-wa.txt

2) Below please find a bootloader for a Atmel AVR AtMega8 which accepts a binhex file uploaded via windows terminal (or however else you would like). I’m releasing this code to the public domain at this point. Feel free to do whatever you like with it, or not, as appropriate. It could probably easily be modified for any AVR CPU

start_bld:
cli
ldi ZL, LOW(RAMEND)
ldi ZH, HIGH(RAMEND)
out SPL, ZL
out SPH, ZH ; set up the stack

rcall init_bld ; set up some hardware stuff
rcall idle_timer2_bld ; start timer2 ticking
rcall set_system_clock_bld ; setup the system clock for 7.2738Mhz

; check and see if there is a serial console present

sbis RS232_INVALID_IN_PORT, RS232_INVALID
rjmp bld_do_boot ; if no console, boot

ldi uart_char, XON ; send welcome banner
rcall uart_put_char_bld
ldi uart_char, ‘B’
rcall uart_put_char_bld
ldi uart_char, ‘l’
rcall uart_put_char_bld
ldi uart_char, ‘d’
rcall uart_put_char_bld
ldi uart_char, ‘>’
rcall uart_put_char_bld

rcall uart_get_char_bld_to ; get a char, or timeout and fall through
brts bld_do_boot
cpi uart_char, ‘B’ ; if ‘B’, then boot right now
breq bld_do_boot
cpi uart_char, ‘U’ ; if ‘U’, then go into upload mode
breq bld_do_upload ; todo: authentication

bld_do_boot:
jmp ivec_reset

; ‘stubbies’ used to make short relative jumps work okay

bld_do_upload_crc_special1:
rjmp bld_do_upload_crc_special

bld_do_flush1:
rcall bld_do_flush
rjmp bld_do_upload

bld_do_upload_err1:
rjmp bld_do_upload_err

; ******* Upload routine. Decodes lines of Intel Hex, writes them to the flash
; displays a error for bad lines

bld_do_booty:
rcall bld_do_flush
rjmp bld_do_boot

bld_do_upload:
; for now, fetch a line, check its checksum, report back good or bad, wash, rinse, repeat
rcall crlf_bld
ldi ZL, LOW(STRING_SCRATCH)
ldi ZH, HIGH(STRING_SCRATCH)

rcall uart_get_string_bld
ldi uart_char, XOFF ; send XOFF in case this
rcall uart_put_char_t_bld ; takes a while
rcall crlf_bld ; debugging
ldi ZL, LOW(STRING_SCRATCH)
ldi ZH, HIGH(STRING_SCRATCH)

clr XL
clr sample_cnt

ld uart_char, Z
cpi uart_char, ‘:’
breq bld_do_upload_ok
cpi uart_char, ‘F’
breq bld_do_flush1
cpi uart_char, ‘B’
breq bld_do_booty
cpi uart_char, CR
breq bld_do_upload
cpi uart_char, LF
breq bld_do_upload
rjmp bld_do_upload_err1
bld_do_upload_ok:
rcall ascii_to_bin_hex_bld ; convert first 4 bytes of input
; (should be length and high addr)

sts LINE_LEN, TempH ; save length in RAM
mov Temp2, TempH ; store byte count in temp register

sub XL, TempH
sub XL, Temp ; compute checksum

sts LINE_ADDR_H, Temp ; store high byte of address

rcall ascii_to_bin_hex_bld ; convert second 4 bytes of input

sts LINE_ADDR_L, TempH ; store low byte of address
sts LINE_TYPE, Temp ; store line type

sub XL, TempH ; compute checksum
sub XL, Temp

; fetch data, store in line

; hopefully data is even, but no guarentee

ldi YL, LOW(LINE)
ldi YH, HIGH(LINE)

cpi Temp2, 0
breq bld_do_upload ; if zero length record, skip

dec Temp2 ; LENGTH is +1, from dec standpoint

bld_do_upload_loop:
rcall ascii_to_bin_hex_bld ; translate ascii to binary

st Y+, TempH ; store bytes (high)
st Y+, Temp ; store bytes
sub XL, TempH ; compute checksum
sub XL, Temp

dec Temp2 ; LEN was given in bytes
breq bld_do_upload_crc_special1 ; special case: odd number of bytes
dec Temp2 ; but we do words so need 2 decs
brne bld_do_upload_loop ; go around again?

rcall ascii_to_bin_hex_bld ; grab CRC
sts LINE_CHECK, Temp ; store CRC
bld_do_crc_check:

lds TempH, LINE_TYPE

; ldi uart_char, ‘0’
; add uart_char, TempH
; rcall uart_put_char_bld

cpi TempH, LINETYPE_HDR
breq bld_do_upload

cp Temp, XL ; compare CRC to stored
brne bld_do_upload_err1 ; if it doesnt’ match, err

; matches, so program part

ldi YL, LOW(LINE) ; use Y ptr to access
ldi YH, HIGH(LINE) ; stored data for this line
lds Temp2, LINE_LEN ; Temp3 contains countdown
lds ZL, LINE_ADDR_L ; Z ptr is address in flash
lds ZH, LINE_ADDR_H
ldi XL, LOW(BOOTLOAD_START*2) ; X ptr is max flash addr to write
ldi XH, HIGH(BOOTLOAD_START*2) ; keeps us from writing bootloader
; which would put is in NWRW state
; and be bad

bld_do_program_loop:
cp XL, ZL ; check to see if we’re
cpc XH, ZH ; outside of the bootloader
brlo bld_do_program_loop_end ; do not program bootloader
; even if it is in file
mov TempH, ZH ; grab the page
mov Temp, ZL ;
andi Temp, 0xC0 ; skip off the byte address
; leaving only the page address

lds Temp3, LAST_PAGE_L ; compare against
cp Temp, Temp3 ; the last page that
lds Temp3, LAST_PAGE_H ; we used and
cpc TempH, Temp3 ; if it’s different
breq bld_do_program_skip_write ; then we need to write that page

; if we get here, then we must
push ZL ; preserve Z
push ZH

lds ZL, LAST_PAGE_L ; restore previous Z (page we
lds ZH, LAST_PAGE_H ; want to write)

rcall wait_spm_bld ; wait for SPM to clear

ldi Temp, (1<=? Then non-digit char, end

ascii_to_bin_hex_cont_bld:

adiw ZH:ZL, 1
movw mp16uH:mp16uL, YH:YL

ldi mc16uL, 16 ; load 16
clr mc16uh ; into multiplier

rcall mpy16u_bld ; and multiply

add m16u0, XH ; Add current value to stack
clr XH
adc m16u1, XH ; carry as needed

movw YH:YL, m16u1:m16u0

dec XL ; This keeps us from
brne ascii_to_bin_hex_loop_bld

ascii_to_bin_hex_end_bld:
movw TempH:Temp, YH:YL
pop YH
pop YL
pop Temp2
pop XL
pop XH
ret

uart_put_string_bld:
; put a null-terminated string to the uart
; Z should be pointing to the beginning of the string in RAM
clr uart_char
st Z, uart_char
ldi ZL, LOW(STRING_SCRATCH)
ldi ZH, HIGH(STRING_SCRATCH)

uart_put_string_loop_bld:
ld uart_char, Z+
cpi uart_char, 0
breq uart_put_string_done_bld
rcall uart_put_char_bld
rjmp uart_put_string_loop_bld

uart_put_string_done_bld:
ret

crlf_bld:
ldi uart_char, CR
rcall uart_put_char_bld
ldi uart_char, LF
rcall uart_put_char_bld
ret

uart_put_char_t_bld:
sbis RS232_INVALID_IN_PORT, RS232_INVALID
rjmp uart_put_char_t_done_bld

push Temp
in Temp, UCSRA
sbr Temp, (1<

Just in case OMCN or JC reads this..

January 21st, 2006

Could one of you please explain why my ‘saying’ was ‘I am not god’?

Also, does anyone remember what OMCN’s was?

S.

For those of you keeping track..

January 21st, 2006

I’m currently in South Orange County, CA..

A political thought..

January 18th, 2006

Perhaps, since the youngest voters have to deal with the consequences of any actions taken for the longest, we should have a weighting system for voting, set up so the longer you were going to be on the planet after your vote, the more it counted for. I realize this runs contrary to the conventional wisdom that the older voting public are wiser. However, I think it’s possible they’re also more cynical, more bitter, or more corrupted.

Just a thought.

I have a whole list of thoughts I had in the middle of the night the other night concerning how to make a open source, verifiable, trustworthy voting network. I’ll post them sometime later.

January 4th, 2006

Recently a talk-radio personality on a certain radio show that will remain nameless asked, ‘Where do rights come from?’. After very careful consideration, I’ve determined that they generally come from might.

That isn’t a particularly desirable situation, but it does seem to be how things are.

For example, what gives God the right to send me to hell, presuming that (a) there’s a God and (b) He/She/It* does such things? The ability to do so, is pretty much the only answer that I can come up with. What gives the legislature of the state of Utah the right to imprison a girl for having sex? Again, being armed with superior firepower is pretty much the only answer I can come up with.

I’m pretty disguisted with the universe right now. Yes, it’s got lots of beautiful little bits but people keep doing things to other people against their wills for no reasonable reason all over the place.

Another question one might ask is why is any of this any of my business? You could certainly make the case that Sheer isn’t affected by the war in Iraq – after all, I’m not that likely to be killed (my friend Chief Smoke could be, but after all he did choose to be in the Army and that is kind of a occupational hazard).

I guess the only answer I can come up with is that every time someone (like that aforementioned 13 year old who’s in jail for having sex) is wrongfully imprisoned, everytime someone innocent is killed, every time someone is treated unfairly, it makes us all a little less free, a little bit more in a position to huddle in fear inside our locked houses, more inclined to hide things, more inclined to trust our fellow man less.

In other words, I care because by being within a few thousand miles of the people who are wrongfully imprisoning that girl, I’m made less free. My soul is somehow vaugely tainted by her unhappiness.

I’ll be the first to support cops and other government figures when they’re stopping someone from stealing someone else’s belongings, or stopping someone from hurting someone else. But they should keep their laws off my morality. Let me state this as clearly as possible: it is not moral to legislate morality. It is not moral to enforce your morals on other people, and it is not clear that anything is morally ‘right’ or ‘wrong’ because I, you, or anyone else says it is. And even if something is immoral, well, imprisoning someone is immoral too. Do two wrongs make a right? Apparently in modern thinking they do..

I accept that I’m powerless. I accept that I can change nothing. I accept that all I can do is sit here and stare at the brokenness and wonder how on earth it got so broken. I accept that I’m probably a part of the brokenness – that by existing, I probably make things worse.

* = I’m leaning towards he, but only because it’s the majority opinion.

Gotta love utah..

January 4th, 2006

http://kutv.com/utahwire/UT–SexOffender-en/resources_news_html

This really irks me.

What business of the government’s – which is just a collection of people after all – is it if a couple of kids want to have sex? Yes, they should have been taught about the whole contraception thing, yes, they’re a little young.. but to lock them up for something that just about everyone wants to do? It’s beyond pathetic and somewhere deep into shameful. Whoever did the locking up oughta be the one locked up, in my view. Or, as Eddie from Callahan’s observed, ‘this world sucks.’

Well, okay, it could be worse. But this particular aspect of it sucks the big one.

Honestly, isn’t getting pregnent enough punishment?

Emerge and infinity..

December 28th, 2005

One of the popular reasonably-new* linux distributions uses the command ’emerge’ to download and install packages. This seems a unusually apt choice of words when you consider my inifinity argument, which I’ll repeat here even though you all have heard it a billion times before.


All of the wonderful software and music and our DNA and, well, basically, everything is lurking inside infinity waiting for us to find it. That album Mischief Committee did already existed, in mp3, ogg, and wav formats, long before we ever recorded it – lurking inside infinity. Copyrighting digital media is like copyrighting addresses on a number line. What we programmers and musicians do is emerge peices of infinity that were already there.

I’d like to make it clear that this isn’t neccesarily my final answer on this .. my opinions, as on all things, may change as I grow. But it’s where I sit right now.

* = compared with, say, slackware

A script for parsing dhcp stuff..

December 27th, 2005

Should anyone happen to use ISC’s dhcp server and need a script for parsing the leases file..

blah

The tragedy that is law.. (more lofty thoughts)

December 27th, 2005

As per this document, the government once considered Einstien to be a felon because he supported Communism.

I really get angry whenever I think about the ’50s and communism. First of all, the U.S. is supposed to be based on freedom – ostensibly, freedom of speech, freedom to peacefully assemble, freedom of religion – and the state religion is capitolism, this we know, but, why should it have ever been a felony to hold a economic ideal contrary?

In fact, it seems likely that armed with good computer networks, you could make communism work. The basic idea is just ‘everybody works, everybody eats’ – it’s just the implimentation that gets tricky.

In any case, I’m glad that I can now be a member of the comunist party if I want to without fear of government repraisals. (Well, unless the NeoCons get their way, in which case I will be thrown in jail for a list of offenses too long to mention here, almost all of them informational in nature)

The FBI has a long history of chasing down people that the public likes – Einstien and John Lennon are a couple that jump to mind, but there are a lot of them. I’ve come to think of the U.S. government as basically evil on all fronts, a beast that must be put up with because there is no way to get rid of it that doesn’t cost more blood, sweat, and tears than it is worth. I hope that over time, the next generation, which has grown up with many tools and ideas that the last generation did not have, will replace the government with something that’s worth having – somethign that doesn’t lie, doesn’t define actions as crimes unless they hurt other people, something that tries to minimize the number of laws and always go for simplicity in defining them, something that doesn’t permit corperations to put acquisition of wealth above the needs of their human components..

I don’t know. I really hope that things continue to get better with time. But I see Dubya. And he lied, and everyone.. liberals, conservatives.. everyone.. knows that he lied, he started a war on false pretenses, killed thousands of innocent people – and nothing bad is happening to him. Nothing bad will happen to him. He’ll get rich, and other people will get the idea that what he did is right and good and proper.

I mean, the only way I can make dubya make sense is if we’re all living in the matrix and he just exists to try to make me angry so that I’ll generate more energy. I can’t understand why no one is stopping him.. why soldiers are still willing to fight.. why people are deluding themselves that this battle is morally right – or neccesary – or economically wise.

[sigh]

Next problem: Kayti wants to move back to Colorado – and I don’t – but I don’t want to break up with her. I don’t want to give up the band, and the good sushi, and all my friends in Seattle. But… argh.. it’s very upsetting.

I want one..

December 25th, 2005

http://www.thinkgeek.com/gadgets/watches/6e72/