OpenWrt Forum Archive

Topic: BCM4704 and DSP instructions

The content of this topic has been archived on 7 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I try to test the DSP Application Specific Extension (MIPS DSP ASE), which should be included in the BCM4704 chip based on MIPS architecture. This chip is the core of the router WL-500g Premium.

I compile my test function with MIPS DSP Built-in Functions by a cross-compiler on my PC with parameters for WL-500gP:

-march="mips32r2" -mtune="mips32r2" -mdsp ...

The compilation is OK. Then I try to run the compiled program on WL-500g Premium. It starts to run, but when the program comes to the DSP instruction, it stops with this message:

Illegal instruction

Does anybody know what to do? Shoud I first allow the DSP ASE, e.g. by configuring some register? Or does it mean that the DSP ASE, which is promised by Broadcom to be present, insn't available?

electro.rob wrote:
-march="mips32r2" -mtune="mips32r2" -mdsp ...

Does anybody know what to do? Shoud I first allow the DSP ASE, e.g. by configuring some register? Or does it mean that the DSP ASE, which is promised by Broadcom to be present, insn't available?

Do you really think, that CPU supports "mips32r2" ("Revision 2 of the ASE was introduced in the second half of 2006")?

Bit.MX in StatusRegister enables DSP or MDMX instruction set extensions.
FIR (floating point implementation register) bit.3D and bit.PS indicates what optional instruction set extension implemented.

See MIPS Run Linux. Dominic Sweetman

Thanks, constz.
"mips32r2" isn't revision 2 of the DSP ASE (Appication Specific Extension), but revision 2 of the MIPS32 ISA (Instruction Set Architecture). With only:

-march="mips32" -mtune="mips32" -mdsp

the compiler says:

Assembler messages:
Warning: mips32 ISA does not support DSP ASE

For DSP revision 2 there is parameter -mdspr2, but it doesn't go in GCC.


After your reply I found the answer also in the official MIPS documentation:

7.3 Software detection of the DSP ASE
     You can find out if your core supports the DSP ASE by testing the Config3[DDSP] bit (see notes to Figure 2.4).
     Then you need to enable use of instructions from the MIPS DSP ASE by setting Status[MX] to 1.

Programming the MIPS32® 24KE™ Core Family, p. 73


So I wanted to make detection, whether the DSP ASE is present on the chip, by reading the Config3 register:
dsp.c:

/*
MIPS DSP ASE test
*/
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
  unsigned int k;

  printf("\n\nDSP instructions test\n\n");

  /*
  Get the contents of Config3 register (CP0[16,3])
  */
  printf("Trying to read Config3 register ...\n");

  k=({ int __res; \
        __asm__ __volatile__(    \
        "mfc0\t%0,$16,3\n\t"    \
        : "=r" (__res));    \
        __res;});

  printf("Config3 register: %x",k);
  exit(0);
}

Makefile:

TARGET = dsp

SHELL = /bin/sh

CCDIR = /opt/slug/optware/toolchain/mipsel-linux-uclibc/gcc-4.1.1-uclibc-0.9.28
MIPSCC = $(CCDIR)/bin/mipsel-linux-uclibc-gcc

SOURCE = $(TARGET).c

PARAMS = -march="mips32r2" -mtune="mips32r2" -mdsp -static

$(TARGET) : $(SOURCE)
    $(MIPSCC) $(SOURCE) -o $(TARGET) $(PARAMS)
    @echo "OK."

asm : $(SOURCE)
    $(MIPSCC) $(SOURCE) -o $(TARGET).asm $(PARAMS) -S
    @echo "ASM OK."

Compilation is OK, but when I try to run the program on my router, the message is still same:

Illegal instruction


It is maybe more global problem. Should I have some special permission of the operating system?

(Last edited by electro.rob on 10 Dec 2008, 21:30)

electro.rob wrote:

So I wanted to make detection, whether the DSP ASE is present on the chip, by reading the Config3 register...

Perhaps, Config3 register is not implemented or usermode access disabled?

Try Config1 bit.5 (old MDMX ASE) or FIR register (mfc1 at,0) bits.18,19 to check what DSP instructions implemented.

...find out smth more:

Diminic Sweetman wrote:

MDMX: Another old extension... It adds a large set of SIMD arithmetic operations using FP register set... few implementations survive: Broadcom's CPUs seem to be the only ones.
See MIPS run Linux

(Last edited by constz on 24 Dec 2008, 13:14)

The discussion might have continued from here.