quarta-feira, 18 de abril de 2012

uClinux - Part II

More wires

Having a working kernel image and a serial port is just not enough! I needed peripherals...
Old peripheral chips are hard to find and I din't have any around, but I had in my junk box some old FPGA from Xilinx. It's a XC4010E in a PGA package with 191 pins and it runs from 5V... perfect!

Also, since I need to add more features to the system I also need more ram and flash. I've brought 4x 512Kb cheap (around 3€ each) SRAM and replaced all the ram in the breadboard. Also bought 2x512Kb FLASH and replaced the old (smaller) FLASH chips.
Ended up with 2Mb RAM and 1Mb FLASH memory. This should be enough to start porting kernel 2.4.x. for the board.

After some long hours of coding and re-coding it finally booted!
I've used the latest pre-compiled GCC toolchain (4.2.4) and the latest (at that moment)  uClinux-dist (20111111). Re-used most of the code from the Motorola Dragonball family (MC68328).

So, having a nicer and newer kernel booting and running up, I decided to wire up that old FPGA.
My first attempts were just to see if that thing was still alive. The big headache was to wire all those ground and vcc pins. After finally finished, I've coded up a very simple verilog counter and programmed that old silicon piece using the JTAG port. And there it was, counting up (like it was supposed to be).

The FPGA can be programmed as if it is a simple 8-bit parallel peripheral. I've wired up the 8 data bits directly to the cpu databus, the address decoded feeds the FPGA chip select pin and the write/read pins are connected to the respective pins in the system (provided by one of the GALs). This way, the FPGA is seen by the CPU as a 1 byte memory location.
To program the FPGA all that is needed it so send byte by byte the generated bitstream. If everything ok, the DONE led goes bright.

4GB SDHC card

Mass storage memory is so cheap these days. Having a large amount of memory available in my system will allow me to move most of the romfs contents to the sdcard and more important at the moment, whenever I want to try new stuff, simply compile in the laptop and copy to the SDcard.

The new cards are 3.3V parts. I needed a voltage converter to wire the sdcard to the system so I used a simple 5V to 3.3V converter. Only the signals that go to the SDcard get converted because the FPGA can nicely handle 3.3V signals (just set the voltage thresholds to TTL in the FPGA config).

Having everything wired up, I wrote a simple verilog SPI master module.
The module when receiving a byte from the CPU, dumps the byte to the SPI mosi pin while at the same time, samples the miso pin. When reading the FPGA the CPU gets the last sampled byte.

The clock source for the FPGA is an oscilator module I had around rated at 35MHz.
I divide the clock by 2 in the FPGA and feed the CPU with a magnificent 17.5MHz clock! (remember that this is a 8MHz rated CPU). I've also tried using a 40MHz module, but if I sneeze or take a deeper breath, the system hangs!

Here is a video showing the kernel boot, mounting the sdcard and running some shell commands.

Next step is to add connectivity to the world: the internet!

Sem comentários:

Enviar um comentário