Fighting with computers

Computers are not always friendly.

Sunday, January 08, 2006

Running rabbits

One of my current projects requires to provide IP connectivity for an electronic system. Some power can be borrowed from the base system it will be plugged into. A small, low-power system will do it. So after considering several options (like Lantronix Xport) and provided I needed at least two serial ports, I settled with a Rabbit Semiconductor core module.
They offer different prebuilt cards you can plug into your design. Rabbit core modules can be programmed using Dynamic C. They include a TCP/IP library so you can program them using an ad-hoc sockets interface. Sample source code is provided and it generally is quite straight forward. I did have a problem when using a non specified (zero) source port for several destination ports different than 80 or 23, I do not know why.
Rabbit 2000 and 3000 processors are both successors of the ancient Z80, an eight-bit microprocessor developed by Zilog (a company founded by some former Intel engineers that decided to do a better 8080). Z80 was found on both ZX81 and ZX Spectrum computers made by Sinclair.
Dynamic C is not just a compiler but a programming environment (IDE) that includes a boot loader so generated code is loaded into the Rabbit core module through a serial port and a special programming cable (which is a signal level adapter). They use a special feature of the processor that allows it to be commanded by one of the serial ports on boot, so boot loader code is loaded each time to load the user code afterwards. Basic loader is loaded at 2400 bps and later on, a faster speed is used to speed up the rest of the load process. Then your program runs while a debug window on the PC is used as the console for those printf and scanf commands. This all means an emulator or a hardware programmer are not required to develop with Rabbits. And a basic development system is quite cheap.
As usual, some extra problems use to appear: Dynamic C is a Windows program and there is not a Linux version. Though it can happily run under Wine. However, serial communication fails under Wine, so the thing is pretty useless as code download to the target system is done by means of a serial connection and a special programming cable. Alternatively, you can run it over a Windows guest on VMware. It also works ok, but, again, serial communication fails (maybe due to a critical timing, I do not know).
Almost giving up, I decided to try one more thing: The use of a USB-serial adapter with VMware. My cable is based on pl2303 chip, which used to be supported under Windows but not under Windows XP. The problem is that it works under Linux, so as soon as you plug it in, the Linux driver will be loaded. In order to make it work under the Windows guest hosted in VMware you need to unload the linux driver rmmod pl2302 will do it. Next you have to attach this USB device to your Windows virtual machine. A new device will be detected but, because XP does no have the driver you still will need to search for it on the net. Once the driver is installed, you have a new serial port. This new serial port will work well with Dynamic C (just do not check the "use a USB-serial adapter" on Dynamic C configuration).
I guess the download times are slightly longer than those of using just Windows XP and a regular serial port, but if you do not have a "real" Windows setup and you have a VMware one, then it's a simple approach.
Ok, you do not have a USB-serial cable. Then, you should go to eBay and get one as they are really cheap, usually under $1 (but shipping will cost you $6 to $10 more).

7 Comments:

  • At 9:50 am, Blogger Hiroshi Ikeda said…

    I think you could not live without these tricky challenges, please keep us updated.
    Thank you for your weblog!!!

     
  • At 10:23 am, Anonymous Nickolay Kondrashov said…

    Thank you very much :)! I have an identical setup (I was even lucky to have pl2302-based cable) and now am able to happily hack OP6800, while staying in my beloved Debian GNU/Linux :)

     
  • At 12:03 pm, Blogger Miguel Sánchez said…

    Glad to be useful.

    Thanks for your comment,

    Miguel

     
  • At 12:22 am, Blogger N8DNX said…

    I just happen to run across your weblog about communicating with Rabbit core modules under VMWare. It's always distressed me that I can't do Rabbit development under Linux, which pretty much means I don't. I spent considerable time with both VMWare support and the Dynamic C people about a year ago and could never successfully talk to the modules.

    Don't know why I dragged this all back out today, but thought I'd give it another try. I did try unloading the pl2303 driver and loading the USB drivers for a USB to Serial adapter in a Windows VM. While it does try and there is communications back and forth for a few seconds, it's never successful. I don't know if this is my current environment (VMWare 6.0 Beta & Ubuntu 6.10) but still no luck. Also tried every configuration change in the book.

    I pretty much live in Linux and my current primary machine is not setup for dual boot (why should it when I have VMWare?). I also have had problems using serial under Windows for programming some communications equipment I work with. Some work and some don't. I'm convinced that this is all due to irregular serial timing when communicating from within a VM but nobody seems to be able to find the magic combination to make it work for me.

    In any case, just thought I'd pass this along and add it to the blog. If anyone has any ideas, I'm all ears (get it... rabbits... ears... never mind).

    Chuck

     
  • At 10:29 am, Blogger Miguel Sánchez said…

    Hi Chuck,

    I'm not sure what happens with newer versions of VMware (they should improve upon previous ones, shouldn't they?).

    From your post it seems that you rushed to try to get Dynamic C to download code to your target Rabbit core. But ... did you check serial comms are actually working ok at all? I mean if the pl2303 driver is properly handling that serial port.

    From what I have read it seems that serial-USB is not always working ok (extra delay?, poor implementation?) for all application software.

    I've used VMware workstation 4.5 under Suse Linux 9.3 to get that working. I might easyly try the VMPlayer that comes with Ubuntu 6.06 if you need it to. (Still, our converters' hardware might be different).

    At any rate, thanks for post, and keep in mind that, even you get it working, communication speed is not great. I would say it takes three times the download time it takes on plain Windows over a real serial port.

     
  • At 8:54 pm, Blogger mfreitas said…

    Hi Miguel, another Miguel here ;)

    I almost got it working under wine with a plain serial port. I patched some wine functions to wait a bit (in particular, waiting for output data to be completely sent) and it now detects the processor and upload the loader/pilot/etc.

    I get some strange errors but they seem to be related to compilation. maybe the IDE is not waiting the compilation to complete or something because is not deterministic...

    I'm posting this in case somebody wants to give it a try, perhaps we may be able to make it work 100%.

    Miguel Freitas
    (mfreitas at gmail)

     
  • At 10:03 pm, Blogger Miguel Sánchez said…

    Hi Miguel:

    Could you please tell us which Dynamic C version you are using and maybe a link for the patch we need to apply to wine to get it working?

    Thanks a lot.

     

Post a Comment

<< Home