2010-02-19

Weller WTCP-S Repair

This week as I was about to start soldering my boards my old trusted Weller WTCP-S started to fail, first ocasionally it wouldn't heat up until shaken, lattely not at all.
Wanting to fix it (if possible) I opened it to check the famous "Magnastat", these Soldering Irons operate on the principle of the Curie Temperature, where a magnet loses its magnetic properties at a certain temperature point.
Inside the casing there's a ferromagnetic piston and the tip is also magnet with a predetermined Curie point (the number on the bottom of the tip), when the temperature is reached the magnet losses its properties, the piston is no longer pulled and the contact at the bottom opens, opening the heating circuit.

I had to open the contact casing and clean the contacts, put it back together and test....

While cleaning the contacts the wiring came loose, so now I was facing a chicken'n'egg problem, how to solder a soldering iron?, the local hackerspace was the answer, I meet some really nice people in really nice location and they had a spare soldering iron I could use in their "electronics shack".
Anyway got home, tested it and it works for now... but I expect it to fail again soon... I'm ordering a replacement today...

2010-02-17

SolarLight (5) - PCBs!!!

I finally had the time to pick my PCBs at the mail. I was thrilled to see who it went... My first linux made PCBs!
Everything went ok, except for a few minor point where I'm the only one to blame...
Here are the pics to the solarlight board and the others, the last one is the RFadaptor that didn't go as well as I expected, but I'm the only one to blame....
Here is the one where the wholes are just the size of the pins (just not enough for them to get through)...

I'll post how to get from PCB design to send them to Olimex (for example) for production. It's not that difficult but you need to follow some steps.

2010-02-10

Next Project Minimal CP/M 68k

The Solarlight project has been taking more than normal, but the truth is I haven't had much time lately...so I decided to announce my next project, revive a minimal CP/M-68k system and document the process. The main components are a MC68008 CPU, a MC68901 MPU, 512K of SRAM, 32k EPROM, and a IDE/ATA connector. The MPU (multi-peripheral unit) will serve as UART and probably as basic memory manager, the IDE interface will probably be based in GIDE or something similar. While I'm still working on the schematics, I've already built the base circuit from my hand written schematics... here's a picture.

The sources and documentation of the code are available in Gaby's site. This site used the sources to build a VAX version, so the sources appear not to have suffered from too much of "bit rot".
For cross compiling and debugging I'll try to use binutils/gcc/gdb in remote mode. I'll try to build the cross tools (elf format, coff has been since long time killed) and a remote gdb-stub to download and debug some initial code... we'll see how it goes..
Here I've already built the cross-compiler toolchain for m68k-elf (binutils-2.20, gcc-core-3.4.6, gdb-6.8 and newlib 1.18.0), I didn't use a more recent one because from searching gcc-3.x.x is easier to cross compile with the newlib, and I wanted to use a smaller libraries than libc.
Download the sources from the gnu ftp site (except for newlib that is here), I followed this guide because not only it appeared simpler (no "bootstrap compiler" step) but also it is dedicated to embedded systems. Don't forget to move newlib and libgloss inside the gcc directory and after the binutils compile put them in the path. I also used gnu gdb instead of insight but no other than that.
Finally set the path in your .profile for your convenience, see here for details on OpenSuse.
My first objective after building the system on a breadboard is to download a small m68k assembly program to the EPROM EMULATOR and see it run, then a small C program and finally a gdb-stub. Then I'll have to repeat the process since from that point on there must be a change in the linker file as programs stop being linked to ROM but linked to RAM.
I've successfully assembled a "loop:nop,nop,bra.s loop" but a few problems or "unknowns" remain...
I've created my simple assembly file called test.S

/*
* test.S -- test file for assembler output
*/

#include "asm.h"
.title "test.S - test file for assembler output m68k-elf-as"
#define STACKSIZE 0x4000

.data

.text

.extern __stack

.global SYM (_start)
SYM (_start):
nop
nop
bra.s _start

I assemble it with "m68k-elf-gcc -c test.S -o test.o" then link it still with gcc "m68k-elf-gcc test.o -o test.x -nostartfiles -nostdlib -v -fpic -WL,Ttest.ld"
I had to include the -nostartfiles and -nostdlib to remove the standard crt0 and the global constructors for C++.
My current linker file is very simple and probably some things are missing for a full C program compilation but for now things appear to be ok.

/* ld file for rom programs */
/* for 8 cycles rom is at 0x00000 (fetch SP and PC), from then on 0x80000
/* STARTUP(crt0.o) - no startup file*/
OUTPUT_ARCH(m68k)
OUTPUT_FORMAT(srec)
SEARCH_DIR(.)
/*
*Setup the memory map of mini68k, stack grows down from high memory.
*/
MEMORY {
ram (rwx) : ORIGIN = 0x01000, LENGTH = 0x80000-0x01000
rom : ORIGIN = 0x80000, LENGTH = 64K }
/*
* allocate the stack to be at the top of memory, since the stack
* grows down, also PUSH => -(SP) = xx, i.e. predecrement therefore
* first stack address never gets written
*/

PROVIDE (__stack = 0x80000);

SECTIONS
{
.text :
{
_stext = .;
*(.text .text.*)
. = ALIGN(0x4);
_etext = .;
} > rom

.data :
{
*(.data .data.*)
_edata = .;
} > ram

.bss :
{
. = ALIGN(0x4);
__bss_start = . ;
*(.bss .bss.*)
_end = ALIGN (0x8);
__end = _end;
} > ram
} /* missing in the initial file - causes an error ld does not complain! - beware */

Then I can also successfully convert the object file test.x to a SRECORD file with the command "m68k-elf-objcopy -O srec test.x test.S19" and then revert the intermediate object file test.x to assembler with "m68k-lef-objdump -d -X test.x > test.dis"
After successfully removing all the initialization code gcc attaches to your code (with -nostartfiles -nostdlib(p.s. you only need the first one since you don't add any library function)) I was left with one question, why is my code placed at absolute address 0x80000054?? when I told in the linker file to put it at 0x80000 (less a few zeros in the middle) Here is the disassembly:

test.x: file format elf32-m68k

Disassembly of section .text:

80000054 <_start>:
80000054: 4e71 nop
80000056: 4e71 nop
80000058: 60fa bras 80000054 <_start>

Ok, this was a bug. I forgot a } in the memory definitions of the linker file *.ld... After adding it the code was located at the correct place 0x80000.
Well there are still some hurdles to overcome, namely:
- placing the start SP and start address in vectors 0 and 1;
- place the other vector in ram
- place the code in proper ROM addresses (and the initial SP,PC)
- download the code and see it run...
... the path through cross-gcc appears to be hard ...

Reverse Engineering a EPROM emulator

While I'm waiting for the SolarLight PCBs to arrive I went on think about other projects...
I had an old EPROM emulator that I bought a long time ago in ePay. It is quite small and it doesn't consume much power but it worked from the parallel port and the old DOS software was reluctant to work even under WinXP.
I had to redone the parallel port interface board, as a soldered IC (74125) blew up when I powered the PC after the target board (note to self: power first PC then target). It was quite simple to draw up the schematic and redo the circuit on a perfboard. When I tried the DOS software with my new board all worked OK, I was sure that the schematic and hardware were correctly reverse engineered.
Of the 5 signals coming out of the parallel port, Reset and Output Enable were easy to spot, the others I suspected downloaded the data serially.


Reverse engineering software, on the other hand is far from trivial. I first tried my two channel xscope, but since there are actually three important variables it was difficult to really discover what was the sequence of events. Furthermore there was a start sequence where transitions where at the millisecond range and a program sequence where things happened at the microsecond range.
Then I remembered I had a PICKIT 2, a tool I bought and used about two years ago to do a short Microchip PIC development (and re-learning since when I first learned about PICs the 16C84 was the craze, obsolete today). PICKit 2 was not only relatively cheap, programmed most of the devices, it also included a logic analyzer and a UART for remote debugging, all connected to a USB port. I must give a note of remark to Microchip that this was a stroke of genius, a scope is a an expensive tool, but by adding this functionality to a device-programmer is a well needed help in many non-working projects.
I created a fixed intel hex file with 3 bytes 0x22,0xAA,0x44 than ran the program in a dosbox in windows (and using a parallel port access - Windows bypass - tool) waited for the signals to come out on the other side. Sometimes it worked, others it didn't but I registered the ones that did.

This in the above waveform the real data download is pictured, in this particular case I shifted the data to position 0x0001. From here it was easier to identify the signals, first is the clock, second data and third advance to next memory address.
Then to capture the initial reset sequence I downloaded bigger programs, just to measure the timings of the sequence.

As you can see the waveforms are very detailed and although one cannot read signals above 500Khz chances are 99% of hobby projects will never need more than that.
The code will be published or given as soon as I finish the other source file interpreters (S-Record, Binary and hex) for now only intel-hex works, I will also try to clean up the code and have it hosted in google code or similar as soon as I understand properly how to use it. I'll try to host all the software produced under a single project otherwise it is a waste of google's space.
So that people that still have a similar eprom emulator, the name of the package was "MicroRom Eprom Emulator" and produced or sold by "Squarewave Electronics". Here is a picture of my test bench, the Eprom emulator is the big fat thing on the left, the top LEDs are the data out, the lower green leds the four LSBits, the selector on the top right corner is a BCD selector and finally the yellow led on its right is the reset signal.