Nov 232010
 

The guys at KPIT Cummins provide a well working GCC tool chain for all kind of Renesas CPUs. Takes a lot out of the pain of using those.

For the longest time I used the Linux 10.02 GCC chain for H8. Worked right from the start. Yesterday I thought about updating to 10.03. Should be no problem. So as usual this is what I did:

  1. get the Linux (32 bit) RPM from their site
  2. alien -t gnuh8300_v10.03_elf-1-1.i386.rpm
  3. tar  -x  -v -C / -f gnuh8300_v10.03_elf-1.tgz

Then change my PATH to include the resulting /usr/share/gnuh8300_v10.03_elf-1/bin directory, and then…cc1 failed with libelf.so.1 missing:

/usr/share/gnuh8300_v10.03_elf-1/libexec/gcc/h8300-elf/4.5-GNUH8_v10.03/cc1: error while loading shared libraries: libelf.so.1: cannot open shared object file: No such file or directory

and

harald@v3k7$ ldd
/usr/share/gnuh8300_v10.03_elf-1/libexec/gcc/h8300-elf/4.5-GNUH8_v10.03/cc1
         linux-gate.so.1 =>  (0xf77ca000)
         libdl.so.2 => /lib32/libdl.so.2 (0xf77a4000)
         libelf.so.1 => not found
         libc.so.6 => /lib32/libc.so.6 (0xf7649000)
         /lib/ld-linux.so.2 (0xf77cb000)


Since this is a 32 bit compiler chain and you can see above and below:

harald@v3k7$ file /usr/share/gnuh8300_v10.03_elf-1/bin/h8300-elf-gcc
/usr/share/gnuh8300_v10.03_elf-1/bin/h8300-elf-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped


the library should be in /lib32/, but although I have ia32-libs installed, there is no /lib32/libelf* at all.
The fix is as simple as can be: get a working libelf.so.1 into /lib32/:

cd /tmp
wget http://ftp.jaist.ac.jp/pub/Linux/ubuntu//pool/main/e/elfutils/libelf1_0.147-2_i386.deb
alien -t libelf1_0.147-2_i386.deb
sudo cp usr/lib/libelf-0.147.so /lib32/
cd /lib32
sudo ln -s libelf-0.147.so libelf.so.1

That adds a 32 bit libelf into /lib32. Now cc1 is happy again:

harald@v3k7$ ldd /usr/share/gnuh8300_v10.03_elf-1/libexec/gcc/h8300-elf/4.5-GNUH8_v10.03/cc1
         linux-gate.so.1 =>  (0xf7784000)
         libdl.so.2 => /lib32/libdl.so.2 (0xf775e000)
         libelf.so.1 => /lib32/libelf.so.1 (0xf7748000)
         libc.so.6 => /lib32/libc.so.6 (0xf75ed000)
         /lib/ld-linux.so.2 (0xf7785000)

Nov 072010
 
Aki-H8 - What Works

This weekend was surprisingly successful. Here the list of things working:

  1. LCD output. I finally got the timing right: 37μs after E went low you can send another command. Clear and Home command take 1.52ms
  2. Output on Port A and B (with the exception of PB.4 which is used for /CAS for the 16MBit DRAM
  3. SPI using a HC595 (8-bit serial-in, serial or parallel-out shift register with output latches)
  4. I2C using PB.0/PB.2 for PCF8574A (8 bit quasi-bidirectional I2C port expander)
  5. I2C using P6.0/P6.1 for PCF8574A (addr 0x70) as well as 24LC256 (addr 0xA0)
  6. I2C scanning
  7. 24LC256 EEPROM reading/writing
  8. PWM using 16-bit timer ITU1 for dimming a LED
  9. Scheduling regular tasks (a la TimedAction from Arduino), which allows to run a function in regular intervals (e.g. once per second, or every 50ms, down to 1ms resolution). Not as nice as full multitasking, but it makes unrelated tasks so much easier to run.

Regarding this ‘task scheduler’, here how to use it:

initTasks();
createTasks(0, 50, knight_rider);
createTasks(2, 700, led2_blink);
createTasks(3, 5, check_key);
createTasks(4, 1000, display_something);
wait(500);
createTasks(1, 1000, eeprom);

while(!global_exit) {
  checkTasks();
}

What is does is call knight_rider() every 50ms, call led2_blink() every 700ms etc.

As an example of one of those functions:

void led2_blink(void)
{
  static int led2=1;

  LCD.BIT.LED2=led2;
  led2=!led2;
}

Next step planned: FreeRTOS port. 2 reasons:

  1. There already is a H8S port (H8S is the successor of H8/300H)
  2. There’s a TCP/IP stack for FreeRTOS available (actually several, one of them uIP and lwIP), and some of those support RTL8019AS too

Choices I dropped:

  1. eCOS. RedBoot is great and it works as a great bootloader, but it needs an old GCC tool chain and it has odd boundary requirements. The gcc toolchain I use currently just works too well to drop it.
  2. NuttX. I like it, but no RTL8019AS support and I just don’t understand how to port it to the H8/300H.
  3. MES is originally the OS running on the AKI-H8 board(s), but it depends on an old gcc tool chain and is no longer developed. MES2 only runs on more recent CPUs (SuperH and ARM). It would also not allow me to keep on using RedBoot.