blog.world3.net

Fix Windows 7 not booting due to missing AHCI drivers

29/01/2012 – 15:26

If you change mobo and chipset Windows might not boot due to loading the wrong AHCI drivers at boot time. To speed up booting it only loads the ones it thinks it needs, and once set is not designed to change. To enable them all again go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Msahci and change the Start key value to 0.

By mojo | Posted in windows | Comments (0)

Fix Firefox image decoding performance regression

27/01/2012 – 18:34

For some reason Mozilla changed Firefox to decode imagines only when they are visible, meaning that they now slowly appear as you scroll down a page instead of loading quickly in the background first. Seems like a misguided attempt to save some memory. The fix is to set image.mem.decodeondraw to false.

By mojo | Posted in idiots, software | Comments (0)

Ebay location script fix

27/01/2012 – 18:32

Ebay broke it, I fixed it… Greasemonkey as usual.

// ==UserScript==
// @name           Ebay-Location-Route
// @namespace      www.ebay.co.uk
// @description    Adds a link for the item location on google maps
// @include       http://*ebay.*
// ==/UserScript==
// Version 0.5
// author: knoe/MoJo

//Configuration
var home = "Nowhere"; //home
var blank = false;                   //open link on a blank page?
//Config end

//it looks like ebay changes a lot :)
//var ebayClass= new Array("titlePurchase", "inf_lab");
var ebayClass= new Array("titlePurchase", "sh-DlvryDtl");

for (var j = 0; j < ebayClass.length; j++)
{
    //check each element of the ebayClass
    for (var i = 0; i<document.getElementsByClassName(ebayClass[j]).length; i++)
    {
        //if the location has been found do the link stuff
        var toCheck = document.getElementsByClassName(ebayClass[j])[i].firstChild.data;
        //if (toCheck == "Artikelstandort:" || toCheck == "Item location:")

        if (toCheck.search("Item location") != -1)
        {
            var place = document.getElementsByClassName(ebayClass[j])[i].childNodes[1].innerHTML;
            //the google map route link
            var linkRef = "http://maps.google.co.uk/maps?saddr="+home+"&daddr="+place;

            //create the link
            var link = document.createElement('a');
            link.href = linkRef;
            if (blank)
                link.target="_blank";
            var linkText = document.createTextNode(place);
            link.appendChild(linkText);

            document.getElementsByClassName(ebayClass[j])[i].firstChild.data="Item location: ";
            document.getElementsByClassName(ebayClass[j])[i].removeChild(document.getElementsByClassName(ebayClass[j])[i].childNodes[1]);
            document.getElementsByClassName(ebayClass[j])[i].appendChild(link);
    
            return;
        }
    }
}
By mojo | Posted in Internet | Comments (0)

Gigabyte crapware

19/01/2012 – 14:12

Picked up a cheap ex-display Gigabyte mobo in mint condition. By all accounts it is a good board, but man do Gigabyte love “value added” crapware. Some examples:

Auto Green – Sleep or power down your PC from a Bluetooth device. Since Bluetooth has a range of about 25mm it seems like it would be easier to just walk over to the PC and turn it off, rather than enabling Bluetooth, trying to get in range, pairing, loading the app…

Cloud OC – Tweak and overclock your PC from any internet connected device. What… The… Fuck… So I can remotely crash my PC?

Smart DualBIOS – The dual BIOS idea is a good one, but this utility adds a pointless feature where you can now store very small amounts of data in it. Things like passwords and contact details, in case your hard drive dies. Just in case you are tempted to actually use it there is no way to import/export this data from/to other apps, so you have to copy/paste it all manually.

Q-Share – Duplicates Windows file sharing functionality, only with a less usable interface and less compatibility. Thanks Gigabyte.

No ATA password support in the BIOS though. Sigh…

By mojo | Posted in hardware, idiots | Comments (0)

The Novatech website is shit

19/01/2012 – 10:45

Just popped on to the Novatech site to check some prices and noticed how shit it is. For example, if you look at SSDs there is no capacity category, you can only filter by price range or manufacturer. That was crappy back in 1998, and 14 years later it is pretty much unforgivable.

Novatech isn’t particularly cheap either.

By mojo | Posted in idiots, Internet | Comments (0)

RFM12B bit stream sync issue

22/12/2011 – 16:04

Been working with cheap RFM12B modules at work and discovered something interesting about them. A couple of things actually, the first of which is that the datasheet for the Si4420 IC it uses is much better. The main issue is that the serial data stream you get when receiving is not always aligned to the bytes you transmitted.

The SPI interface only allows you to read 8 bits at a time from the FIFO, but you can pull nFFS low and then clock bits out individually without the need for a read command. The technique I use is to start reading bits that way when the RFM12B pulls its interrupt line low until I have the complete sync pattern. At that point I know I am properly aligned and can start using the SPI bus again.

The ARSSI signal is useful. To make good measurements trigger the ADC immediately after starting an SPI read command. On the ‘scope the level looks flat during receiving, but in reality I have noticed that sometimes I get the first few bytes correctly and then the stream deteriorates into noise. Still investigating that one, there are plenty of parameters to experiment with.

By mojo | Posted in avr, electronics | Comments (0)

Compile time asserts in C

21/12/2011 – 15:48

Assert is a useful function that checks a condition and outputs an error if it is not met at run time. Aside from generating some overhead in the code it is also pretty useless on microcontrollers because the messages go to STDERR and, well, there isn’t one. A much better solution is to do the check at compile time as then there is no overhead and you can see the error messages.

 

Unfortunately the C pre-processor is just a glorified text processor and knows almost nothing about C, so you can’t use things like sizeof(). I found this solution:

 

// compile time static assertions (http://www.pixelbeat.org/programming/gcc/static_assert.html)
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
#define ct_assert(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }

 

If you then write this:

 

ct_assert(sizeof(EEP_CONFIG_t) == 32);

If the condition is not true it will cause a divide by zero error on that line. Not ideal but it seems to work. In this case an EEPROM page happens to be 32 bytes and the struct is padded. Thanks to Pixelbeat.

By mojo | Posted in avr | Comments (0)

Scheduling uTorrent on Windows

03/12/2011 – 19:12

Sometimes I close uTorrent and forget to open it again before going to bed for overnight downloading. It cannot be scheduled via the Task Scheduler in Vista/Server 2008 and above because scheduled tasks can no longer display a GUI. This is a security feature designed to prevent shatter attacks which are a form of privilege escalation. The only solution is to use a task scheduler that runs as a user mode task rather than as a service, and the best one I have found is Firetask.

By mojo | Posted in windows | Comments (0)

XMEGA TWI (I2C) bus pull-ups

24/11/2011 – 16:32

The XMEGA 128A1 and XPLAINED hardware guide both suggest that TWI should work with the internal port pull-up resistors. Those pull ups are 50K+ and don’t pull enough for most devices. In short external pull-ups, say 10K, are essential.

By mojo | Posted in avr, electronics | Comments (0)

Using the XMEGA DMA controller

04/11/2011 – 11:47

Finally got the XMEGA DMA controller on an ATxmega128A3 working. There is not much example code for it and the datasheet is not very clear, so I wrote this.

The datasheet and examples don’t really explain the terminology well. A transaction is the complete cycle of the DMA controller. To start a transaction you load up the control registers and enable the DMA channel. It will then respond to triggers. The transaction ends when TRFCNT * REPCNT bytes have been transferred.

A block is a way of dividing the transaction up to fit your buffer size. If you just want to fill one buffer from start to finish you can set the block size in TRFCNT to the full size of your buffer. There are not many situations where you would want to use blocks smaller than one whole transaction, so for simplicity you can often just ignore them and look at transactions only.

The burst length is the number of bytes copied in one go by the DMA controller and is set with the BURSTLEN bits in CTRLA. Often it is used to read/write 16 bit SFRs such as the ADC result or the DAC output level. You always want to access those 16 bit words in one go rather than as two 8 bit bytes and the burst length lets you do that.

Now comes the poorly documented bit. First we have the single shot mode bit in CTRLA (bit 2 SINGLE). If set every time the DMA channel is triggered it transfers a single burst of data, e.g. 2 bytes if you set BURSTLEN to 2BYTE. If it isn’t set the DMA channel does into free running mode and simply transfers bursts as fast as possible until the transaction ends. So if you want to save ADC readings into a buffer like I am you want single shot mode triggered by the ADC.

Next let’s look at repeat mode. In repeat mode the DMA controller transfers REPCNT blocks of data. To keep it simple let’s say you only have one buffer and intend to fill it in one go, so you set the block size to the buffer size. If you are not in repeat mode the buffer will be filled once and then the transaction will end and the DMA channel will be disabled. If you are in repeat mode the DMA channel will perform REPCNT block transfers, and since you set your block size to the buffer size that means it is the number of times the buffer will be filled consecutively. If you are in repeat mode and you set REPCNT to zero the DMA channel will repeat forever.

Now keep in mind that even with repeat mode enabled the DMA controller still has to be triggered. In normal mode one trigger transfers an entire buffer’s worth of data, and in single shot mode each trigger transfers one burst of data.

Finally we have double buffering mode. Double buffering basically alternates between filling two buffers. When one transaction is complete the DMA channel automatically stops and its partner starts. This action is independent of repeat mode, and will set the transaction complete flag so that you can detect when it happens.

Note 1. You need to look at the transaction complete flags, not the DMA channel active or pending flags, if you want to know when the channel has finished and the buffer is ready for processing.

Note 2. If you want to use a timer to trigger a DMA channel then you must enable that timer’s interrupt. You can give it a null interrupt handler (e.g. ISR(TCC1_OVF_vect){} or just RETI in assembler) but it does have to actually be enabled and triggering, otherwise the DMA channel will not be triggered either. That doesn’t apply to other peripherals such as the ADC, it seems to be just the timers.

PORTA.DIRCLR = PIN7_bm;
PORTA.OUTCLR = PIN7_bm;

ADCA.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc | ADC_CH_GAIN_1X_gc;
ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN7_gc;
adc_wait_8mhz(&ADCA);
ADCA.EVCTRL = ADC_SWEEP_0_gc | ADC_EVSEL_0123_gc | ADC_EVACT_CH0_gc; // event channel 0 triggers ADC channel 0
ADCA.CTRLA |= ADC_ENABLE_bm;

// set TCC1 to 11024Hz overflow, actually 11019.2838Hz (-0.052% error)
TCC1.CTRLA = 0; // stop if running
TCC1.CNT = 0;
TCC1.PER = 0x02D5;

EVSYS.CH0MUX = EVSYS_CHMUX_TCC1_OVF_gc; // trigger on timer overflow

// reset DMA controller
DMA.CTRL = 0;
DMA.CTRL = DMA_RESET_bm;
while ((DMA.CTRL & DMA_RESET_bm) != 0)
;
// configure DMA controller
DMA.CTRL = DMA_CH_ENABLE_bm | DMA_DBUFMODE_CH01_gc; // double buffered with channels 0 and 1

// channel 0
// **** TODO: reset dma channels
DMA.CH0.REPCNT = 0;
DMA.CH0.CTRLA = DMA_CH_BURSTLEN_2BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm; // ADC result is 2 byte 12 bit word
DMA.CH0.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | // reload source after every burst
DMA_CH_DESTRELOAD_TRANSACTION_gc | DMA_CH_DESTDIR_INC_gc; // reload dest after every transaction
DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc;
DMA.CH0.TRFCNT = 2048; // always the number of bytes, even if burst length > 1
DMA.CH0.DESTADDR0 = (( (uint16_t) buffer_a) >> 0) & 0xFF;
DMA.CH0.DESTADDR1 = (( (uint16_t) buffer_a) >> 8) & 0xFF;
DMA.CH0.DESTADDR2 = 0;
DMA.CH0.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RES) >> 0) & 0xFF;
DMA.CH0.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RES) >> 8) & 0xFF;
DMA.CH0.SRCADDR2 = 0;

// channel 1
DMA.CH1.REPCNT = 0;
DMA.CH1.CTRLA = DMA_CH_BURSTLEN_2BYTE_gc | DMA_CH_SINGLE_bm | DMA_CH_REPEAT_bm; // ADC result is 2 byte 12 bit word
DMA.CH1.ADDRCTRL = DMA_CH_SRCRELOAD_BURST_gc | DMA_CH_SRCDIR_INC_gc | // reload source after every burst
DMA_CH_DESTRELOAD_TRANSACTION_gc | DMA_CH_DESTDIR_INC_gc; // reload dest after every transaction
DMA.CH1.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc;
DMA.CH1.TRFCNT = 2048;
DMA.CH1.DESTADDR0 = (( (uint16_t) buffer_b) >> 0) & 0xFF;
DMA.CH1.DESTADDR1 = (( (uint16_t) buffer_b) >> 8) & 0xFF;
DMA.CH1.DESTADDR2 = 0;
DMA.CH1.SRCADDR0 = (( (uint16_t) &ADCA.CH0.RES) >> 0) & 0xFF;
DMA.CH1.SRCADDR1 = (( (uint16_t) &ADCA.CH0.RES) >> 8) & 0xFF;
DMA.CH1.SRCADDR2 = 0;

DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm;
TCC1.CTRLA = TC_CLKSEL_DIV1_gc; // start timer, and in turn ADC

for (i = 0; i < 20; i++)
{
while (!(DMA.INTFLAGS & DMA_CH0TRNIF_bm));
DMA.INTFLAGS = DMA_CH0TRNIF_bm;
TERM_tx_char('A');

while (!(DMA.INTFLAGS & DMA_CH1TRNIF_bm));
DMA.INTFLAGS = DMA_CH1TRNIF_bm;
TERM_tx_char('B');
}

In the example the code outputs ‘A’ or ‘B’ when each buffer is full.

By mojo | Posted in avr, electronics | Comments (0)
Page 1 of 1812345...10...»Last »
たとえ溺れても梦はゆめでしかない
  •  

    January 2012
    M T W T F S S
    « Dec    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031  
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Categories

    • audio (1)
    • avr (19)
    • BBC (1)
    • electronics (29)
    • genius (4)
    • hardware (22)
    • idiots (39)
    • Internet (21)
    • law (20)
    • microcontrollers (12)
    • networking (17)
    • politics (29)
    • privacy (19)
    • Retro Adapter (5)
    • security (17)
    • software (32)
    • Uncategorized (18)
    • windows (25)
  • Archives

    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • July 2011
    • June 2011
    • May 2011
    • March 2011
    • January 2011
    • December 2010
    • November 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • November 2005
  • Links:

    Main site: world3.net

    Electronics: denki.world3.net

WordPress | Sandbox