I thought of a new slogan for cups…
May 28, 2009 Leave a comment
Making the not possible, possible
Colored Hat. New post roughly every other Friday
May 26, 2009 Leave a comment
This is an entry including a final project for CS504.
In CS 504:Real Time Operating Systems, the class built a functional Real Time Operating system based on the UIK API. In my implementation, I heavily relied on the source code of FreeRTOS. The process focused primarily on demonstrating the atmel processor, multitasking, and basic interprocess communication, which are fundamental parts of an RTOS.
In this project, the same problems are achieved with a very different architecture. Namely, all the first programming projects – generating a sound wave, counting LEDs, timing how long buttons were pressed, and handling hardware events – were programmed similarly and multi-tasked on the propeller chip. This project included interfacing with the ntsc and peripheral drivers, writing a sound driver, learning spin and propeller assembly, and comprehending the propeller architecture.
May 8, 2009 Leave a comment
This is a topic that’s been covered a lot. However, it took a bit of research to find a solution that worked for me, so I thought I’d write about it here.
I am doing some research that involves a *lot* of google searches. Because this research involves a significant number of directed queries, it seems logical to hide this information as much as practical. If there is a web host who notices sequential names in a Google referer URL repeatedly, this might raise suspicion or alter behavior which could skew results. Similarly, it is desirable to hide IP information from both the web host (for similar reasons) and possibly even search engines.
First, to avoid any changes to usual browsing, a new firefox profile was created using:
firefox -ProfileManager
Additionally, to run both firefox profiles at once, the first was run as normal, which the second has the additional options:
firefox -P <new-profile> -no-remote
I add this to my taskbar alongside the regular old firefox %u so I can choose a profile with a click.
To hide the HTTP referer, a firefox extension called RefControl was selected https://addons.mozilla.org/en-US/firefox/addon/953. This simply replaces the referer for every query with one that is configurable. Although this is certainly possible with a more traditional proxy (like paros), RefControl’s ease of use is essential with the shear number of queries that were performed for this research. For this research, I changed the referer passed several times from names like “yahoo.com”, “cnn.com”, etc. Although the traffic patterns may still seem suspicious to an administrator who carefully monitors his logs, it reveals virtually no information about what it is that is being searched for.
To obfuscate the IP address, tor and privoxy were used. Tor bounces the HTTP requests around a distributed network of relays all around the world. An in depth discussion of Tor is out of the context here, but in a nutshell “it prevents somebody watching your Internet connection from learning what sites you visit, and it prevents the sites you visit from learning your physical location” http://www.torproject.org/. Privoxy is additionally used to prevent applications like flash or dns from leaking information. Since both privoxy and tor are required, you need to install these:
apt-get install tor privoxy
and to get privoxy to work with tor, I uncommented the following line (if it’s not there just add it):
forward-socks4a / localhost:9050 .
Despite the advantages, this did make browsing for names quite slow. I really like torbutton. In the not so distant future I remember having to modify proxy settings every time I wanted to go back and forth using tor. With tor
Lastly, the noscript firefox plugin was used to mitigate all javascript based attacks that might be used to obtain IP information http://noscript.net/.
May 4, 2009 Leave a comment
The purpose of this assignment is to get further practice using interrupts, particularly concurrent interrupts. A musical “note” is a waveform that has a certain fundamental frequency. For example, the “A” above middle C on a piano has a frequency of 440 Hz, and middle C itself is approximately 261 Hz. On an equally tempered scale, each of the twelve notes is related to each other by a factor of 2 12 . A note that is an octave above another note is double the frequency of the lower note. A perfect sine wave consists only of the fundamental frequency, and sounds very “pure” or mellow, like a flute. Most waveforms consist of a fundamental and harmonics or overtones, which are additional frequencies above the fundamental. For instance, a square wave consists of the fundamental and multiples of the fundamental in decreasing amplitude. The distinctive sound of a violin is mostly a sawtooth wave (created as the rosin on the bow catches the string, then releases it), with other overtones (called dissonant overtones, due to the fact that they are not multiples of the fundamental) created by resonances in the wood.
For this assignment, you are to use interrupts to generate the notes of a musical scale, while at the same time using another interrupt to update a count. We will generate square waves by toggling a bit within a port on and off. Specifically, your program should play the notes from middle C to the next higher C, each of approximately one second in duration. These notes should be playing at the same time that an 8-bit binary count is being displayed in the LED’s, updating at approximately 1/4 second. As before, determine the code sizes, and estimate the percentages of time your ISR’s and “main” program takes of the total execution time. Also, for each note, estimate its accuracy – that is, how close is the note your program plays to the calculated frequency for the note.
This code requires avrdude, avr-gcc, and objcopy are installed
To compile, type:
make
After it’s compiled, to install to a connected and powered on atmega16 board, type:
make install
Note Makefile may require some modification depending on your environment.
This program includes a demo called homework3_demo.avi.
The ATmega16 provides 16K bytes of Programmable Flash Program Memory, 512 bytes eeprom, and 1K byte SRAM
make gives a 3982 byte executable. It contains the following headers:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000074 000248 00 AX 0 0 2
[ 2] .data PROGBITS 00800060 0002bc 000020 00 WA 0 0 1
[ 3] .bss NOBITS 00800080 0002dc 000002 00 WA 0 0 1
[ 4] .stab PROGBITS 00000000 0002dc 000378 0c 5 0 4
[ 5] .stabstr STRTAB 00000000 000654 000054 00 0 0 1
[ 6] .shstrtab STRTAB 00000000 0006a8 00003b 00 0 0 1
[ 7] .symtab SYMTAB 00000000 00084c 000450 10 8 17 4
[ 8] .strtab STRTAB 00000000 000c9c 0002f2 00 0 0 1
#without space optimization
Program: .text + .data + .bootloader == 618 bytes (3.8% Full)
Data: .data + .bss + .noinit == 34 bytes (3.3% Full)
Here is most the code
/* http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106
* was a big help understanding the timer syntax
*
* also relied on the atmega16 manual and the #defines located in /usr/avr/include/avr */
#include <avr/io.h>
#include <avr/interrupt.h>
/*counter keeps track of how many overflows in timer0 = about a second */
int counter = 0;
/*number of ticks to make a note at 1 MHz*/
/*
At 1MHz, these are the number of ticks it takes to equal a given note
const int C_l = 3817/2;
const int D = 3401/2;
const int E = 3030/2;
const int F = 2865/2;
const int G = 2551/2;
const int A = 2272/2;
const int B = 2024/2;
const int C_h = 1912/2; */
//const long int notes[8] = {3817, 3401, 3030, 2865, 2551, 2272, 2024, 1912};
const long int notes[8] = {1908, 1700, 1515, 1432, 1275, 1136, 1012, 956};
void port_init() {
/*PORTC is connected to the amplifier */
/*PORTB is connected to the LEDs */
DDRB = 0xff; /*11111111 for all output */
DDRC = 0xff;
PORTC = 0xff; /*all lights turned off */
PORTB = 0xff; /*all lights turned off */
}
void init_timer1() {
/*setup timer1, this will measure the notes */
TCCR1B |= (1 << WGM12);
/*Enable CTC interrupt */
TIMSK |= (1 << OCIE1A);
/* OCR1A = 15625;*/
OCR1A = notes[0]; /* Set CTC value to middle C to begin with */
/*timer runs with a 1MHz resolution */
TCCR1B |= (1 << CS10);
}
void init_timer0() {
/*prescaler/64*/
TCCR0 |= ((1 << CS01) | (1 << CS00));
/*overflow mode - about every 1/61 seconds */
TIMSK |= (1 << TOIE0);
}
void main (void) {
port_init();
init_timer0();
init_timer1();
/*Enable global interrupts */
sei();
while(1) {
/*most logic is handled by the interrupts */
}
}
/* toggle the LED for now, this is the musical note */
ISR(TIMER1_COMPA_vect) {
/*toggle the output */
PORTC = ~PORTC;
}
ISR(TIMER0_OVF_vect) {
counter += 1;
if (counter == 61) {
/*count up to 8 for all 8 notes*/
if (PORTB == 0xf8) {
PORTB = 0xff;
}
else {
PORTB--;
}
//OCR1A = notes[~PORTB];
OCR1A = notes[~PORTB];
counter = 0;
}
}
Here is a short video demonstration: