Pages

2011-11-22

Linux Framebuffer Drivers

I am working on building a framebuffer driver for my own custom VGA hardware module. It only runs at 640x480 and has a dedicated video buffer in the FPGA.  Linux is being run on Microblaze, I am using petalinux because that is what I have to use (This is an academic project).

I ran into a problem with it saying that the register_framebuffer and unregister_framebuffer functions were undefined. The kernel also refused to load the module for obvious reasons.

After chasing my tail for hours trying to link against fbmem.o I realized that it wasn't even generating the object file. I also concluded that it probably needed to enable it in the kernel. So one last make menuconfig and enabled framebuffer support. "Kernel/Library/Defaults Selection>Customize Kernel Settings" then "Device Drivers>Graphics Support>Support for frame buffer devices"

http://xkcd.com/979/

2011-07-08

Tip of the Day: Backup single file in folder with CrashPlan

I played with Bitcoin a while ago and while I have very little in my wallet I still think it would be a shame for it to be gone forever. So I wan't to keep it backed up while not backing up the constantly changing gigs of other files (I don't understand why they are in roaming...).

So here is a simple regex to backup a single file:

.*/AppData/Roaming/Bitcoin/(?!wallet.dat).*

Does not work:
.*/AppData/Roaming/Bitcoin/(?!wallet.dat)

It uses negative lookahead to not match the wallet.dat, it doesn't consume any characters so the .* consumes anything left over. It is worth noting that this also matches any files starting with wallet.dat so you could also use this to exclude all files except ones prefixed with something or exclude everything except a specific folder.

2011-06-02

Progress: Better late than never.

So I've been working around the clock trying to get this project done by the end of the term.  Still a ways to go but it may be possible to achieve "Functional" by the end of this weekend. You never know, if I am a god I may pull off feature complete as well. There is no way however a single item on the wishlist is going to make it.

So here are the highlights of what I've been doing since I last posted:

I completed the emulator for the coach side of the thermostat. It has led's for heat, ac, high and low fan in the two zones as well as a button to indicate the zone is shedding. There is a nice metal power connector on top providing the important 12V to run the communication line which is connected over BNC. The choice to use BNC has made it look so good. Maybe too good because my roommate insists I take it as carry on at the closest airport, I disagree.

I completed the daughter board for the DE-0. This has all the circuitry for the temperature sensors, real-time clock(in red) and the communication line to the emulator.  The capacitor and neighboring diode provide 12V to this board to run the voltage comparators, the DE-0 only supplies 5V & 3.3V.  The empty space up top is for the analog to digital converter for temperature.  I purchased the wrong one MAX110 and wanted a MAX111, I could make due with the one I had but a wiring mishap let the smoke out shortly after seeing the temperature on screen (go figure). I have received the new part and it is working wonderfully as seen in the picture at the top of this post.

Changes to code:

  1. Abandoned the use of the SD card. While communication with the card worked great, endian issues with open source FAT implementations made it not worthwhile with time constraints. Images are now stored in the ROM.
  2. Implemented libpng. We emulate files using a library and use the custom IO functionality in libpng to make it all work. A simple malloc/free setup was also added.
  3. Not really changed. We are using the wrong toolchain, I tried several more times to get the newlib toolchain to work as desired in cygwin with no success. Gave up.
  4. Struggled with interrupt oddity.  The A/D interrupt input wasn't latched and at random would violate setup times on the OR1200 causing undefined (The return address would get corrupted) to occur. This is now latched on negative edge.
  5. Struggled with odd interrupt clearing behavior. Turns out I misread the OR1200 spec and was doing it as described in OR1000.
  6. Implemented some of the touchscreen code.

Todo:
  1. De-bounce touchscreen. This was Dependant on the interrupt bugs which I resolved today.
  2. Implement user interface buttons
  3. Make main screen of UI
  4. Make set time screen of UI
  5. Time Permitting: Make schedule screen of UI
  6. Get it checked off
  7. Do paperwork
  8. Throw in closet & forget about it
  9. Pull out of closet fight with SD card more.
As always code is at:

2011-04-24

It's about time!

Here is what I have been working on the last few/several days. Another scrolling gradient but this time it is fully stored in the SD RAM. Double buffering wouldn't be too hard at this point but I will avoid it if I can.  A custom DMA controller has priority on the bus and transfers the next line on horizontal sync.  A number of tiny issues kept me from calling this done, subtle timing issues caused the image to be shifted right 2 pixels. Fixing some bugs made it appear worse even though it was closer to correct.

My colleague who is also using the OR1200 has been kind enough to keep a record of issues he had with building the toolchain (additional packages needed, using git for the first time, etc). I will be working with him to revamp my earlier post. I will also later be checking in code for this and finally be able to move onto implementing the SDCard.

2011-04-11

Picture Time

This is an old program on the board (before the inclusion of the processor) it just shows the touch position.
This is the current program. The gradient is scrolling from right to left. Also note how the screen is upside down. This is due to the way Terasic setup the headers, it will only sit flat upside down relative to the development board.
Lastly the DE0 development board. You can see the SDCard slot that I have yet to implement as well as the ribbon cable leading to the touchscreen. I also find it odd that they cut the plastic shield such that it covers two of the momentary contact switches.

2011-04-10

OR1200, Cygwin, SDRAM, Interrupts & the Red zone

So I didn't quite reach my goal of procedural images on the touch screen. I did run into some setbacks along the way that slowed me down but all of that is now resolved and I will go into that more below. The highlights of the week have been getting the SDRAM working, Getting interrupts enabled on the processor, learning about the red zone and just moments ago compiling the toolchain on Cygwin.

SDRAM


After much frustration I was unable to get a core from OpenCores that worked with the SDRAM. I had to port a bunch of code to compile on Quartus since it's Verilog support is incomplete. But all was for nothing since it didn't work at all. In the end I ripped the SDRAM module out of the DE0 SPOC example. The issue with that is that it is for the Avalon bus and a 16 bit one at that. With some finagling I built a bridge between it and the wishbone bus that takes care of most everything. There is still a bug in reads that causes more transactions to the ram than needed but I will look into that later. I will also probably need to use a wishbone-wishbone bridge to run the ram at 100MHz since at present it is taking 9 clock ticks to do a read. I am unsure if this will be fast enough to operate the ping-pong buffer for the touch screen but only time will tell.

Interrupts


I am not certain but it would appear that interrupts 0 and 1 are non-maskable. However unmasking them in the PICMR (Programmable Interrupt Controller Mask Register) is not enough. Interrupts in general must be enabled in the Supervisor Register. It is worth noting that the supervisor register can only be modified using a Read, Modify, Write method. Thus use GREAT CARE if you ever decide you need to modify a setting in the register. You need to be careful that you do not modify the register in an interrupt or exception whilst a lesser priority interrupt or the normal flow of execution is also modifying it (Your changes will be lost). My recommendation is set it and forget it. After that, only modify the register for critical sections (disable/enable interrupts) and everything will be fine.

Red zone


It is a little known fact (I didn't know it till 4AM this morning) that the OR1200 toolchain utilizes a Red zone. This means that code is free to use 128bytes beyond the stack pointer for temporary data. Which also means that your interrupt/exception handlers need to decrement the stack pointer by 128 on entry or you will screw something up (makes for a psychedelic experience on my touch screen). This isn't really documented and only after I asked the IRC about why GCC was generating negative stack references did I find out about it.

Cygwin


I got back to trying to make Cygwin work, I had long abandoned the subversion repository in favor of the one in GIT for my compilation on my laptop. I tried this on Cygwin and the results were less than satisfying. After some digging I found out why.

So heres how to get a working toolchain in Cygwin that can compile both c and c++ for the OR1200.
[Check comments for better tips on setting up cygwin from scratch]

Clone the GIT repository (Do not build!) following the instructions at http://openrisc.net/toolchain-build.html

It is about 600MB so it will take a while.

Now we need to patch the uClibc build process.

So modify Makefile.in in the uClibc folder.


This bug has the lines that need to be changed.

Make sure you have the flex package in Cygwin

Now run "make". Thats it, no command line parameters.

Wait 1-3 hours.

When it is done the toolchain-out directory should have everything you need. I am still refining my makefile so there may still be kinks in that department.

Conclusion


DO NOT USE THE VMWARE IMAGE EXAMPLE

That is basically the conclusion, don't do it. I have made so many subtle changes to the example it isn't even funny. BootReset.S in my firmware directory is the modified/fixed/hacked remanence of that example. At the very least take it but I recommend salvaging as much of the helper stuff from my code as much as possible. I am still working on it so I should improve over the next month and a half.

As always you can find my latest code here:

https://github.com/Deathbobomega/thermostat
Till next time,

Thomas

2011-04-04

OR1200, Github, Touchscreen

I worked out the kinks that I was tracking down. Turns out that while I was going to change the clock edge of my RAM after I found the kink I should have just done it anyway. I was corrupting random memory with every write, fun times.

So here is where I am placing code now: https://github.com/Deathbobomega/thermostat

I am using the TerASIC Touch Screen for my user interface. This is finally hooked to the processor in some fashion. At time of writing the ping pong buffer is only partially implemented and the off chip ram is not yet used at all. This means it just displays one line of the screen across the entire screen. It also does a small animation to make sure it is working.

I hope to have the off chip RAM and procedural images by the end of the week. Then I can move onto the SD Card and PNGs.