Results 1 to 10 of 10

Thread: BCM4704 and DSP instructions

  1. #1
    Join Date
    Dec 2008
    Location
    Czech republic, Europe
    Posts
    7

    BCM4704 and DSP instructions

    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-500gP.

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

    Code:
    -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:

    Code:
    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?
    Last edited by electro.rob; 01-12-2008 at 21:30.

  2. #2
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    I don't think the processer is from there actually...
    I guess you just need the broadcom SDK, dunno what you exactly want to do

  3. #3
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    electro.rob
    Can you attach a small sample source?
    Which toolchain you use?

  4. #4
    Join Date
    Dec 2008
    Location
    Czech republic, Europe
    Posts
    7
    I found the answer 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:

    Code:
    /*
    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:

    Code:
    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?


    I use Optware compiler (uClibc). I got it from nslu2-linux.org. Instalation instructions are in the middle of the page under heading And what if the program I need is not available in the existing packages?

    My router runs on Oleg firmware.
    Last edited by electro.rob; 10-12-2008 at 21:48.

  5. #5
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    I got same result - "Illegal instruction (core dumped)"

    Result of preliminary analysis:
    1. Our CPU is 4KE, not 24KE
    2. read/write Config3 register isn't possible from user space (from kernel space on my Wl500gp V1 Config3=0x3ed96c82)
    3. Kernel 2.4 (ASUS & Oleg firmwares) can't init DSP, can't handle DSP registers on context switching, so you have to try 2.6 branch (DD-WRT, OpenWRT firmwares).
    Last edited by lly; 14-12-2008 at 00:49.

  6. #6
    Join Date
    Dec 2008
    Location
    Czech republic, Europe
    Posts
    7

    Illegal instruction

    Illy:
    1. Our CPU is 4KE, not 24KE
    I think it must be 24KE, see: www.broadcom.com/products/Wireless-LAN/802.11-Wireless-LAN-Solutions/BCM4704


    3. Kernel 2.4 (ASUS & Oleg firmwares) can't init DSP, can't handle DSP registers on context switching, so you have to try 2.6 branch (DD-WRT, OpenWRT firmwares).
    I installed OpenWRT, but the result is still the same: Illegal instruction


    The operating system doesn't know that it has DSP ASE. Never mind, but I cannot use any assembler instruction.


    2. read/write Config3 register isn't possible from user space (from kernel space on my Wl500gp V1 Config3=0x3ed96c82)
    Unfortunately, you may be right. Do you know, how can I switch to kernel in my C program?

  7. #7
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    Quote Originally Posted by electro.rob View Post
    I installed OpenWRT, but the result is still the same: Illegal instruction

    The operating system doesn't know that it has DSP ASE. Never mind, but I cannot use any assembler instruction.
    Too bad, I hope, it recognizes ASE
    Unfortunately, you may be right. Do you know, how can I switch to kernel in my C program?
    I don't know Linux kernel well yet. I simply patch arch/mips/kernel/cpu-probe.c with my code, prints out results with printk() and look at syslog (or system console if kernel crashes).
    Of course, firmware recompilation is required and, in case of total fail, firmware restoration by TFTP.

  8. #8
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    I found Czech resource on that reported DSP is present and working, have you contact them ?
    http://www.microdesignum.cz/clanky/E...eployment.html

    P.S. For others - same topic on OpenWRT forum: http://forum.openwrt.org/viewtopic.php?id=17898

  9. #9
    Join Date
    Jan 2008
    Location
    SPb
    Posts
    20
    Quote Originally Posted by lly View Post
    ...from kernel space on my Wl500gp V1 Config3=0x3ed96c82..
    It's seems to be Config.1:
    TLB - 32, Icache - (3,3,1), Dcache - (3,3,1), JTAG,
    but not Config.3:
    DSP rev.2, DSP rev.1, LargePhysicalAddress, SmartMIPS - pretty cool core for cheap embedded system!

  10. #10
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    Quote Originally Posted by ConstZ View Post
    It's seems to be Config.1:
    TLB - 32, Icache - (3,3,1), Dcache - (3,3,1), JTAG,
    but not Config.3:
    DSP rev.2, DSP rev.1, LargePhysicalAddress, SmartMIPS - pretty cool core for cheap embedded system!
    Unfortunately, I haven't read MIPS documentation carefully when writing this letter
    Nowadays, I can confirm that there is no Config2, Config3 registers in BCM4704. So, there is no true DSP in it, only cryptoprocessor on internal bus.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •