PDA

Bekijk de volledige versie : BCM4704 and DSP instructions



electro.rob
01-12-2008, 21:02
I try to test the DSP Application Specific Extension (MIPS DSP ASE (http://www.mips.com/products/processors/architectures/mips-dsp-ase/)), which should be included in the BCM4704 (http://www.broadcom.com/products/Wireless-LAN/802.11-Wireless-LAN-Solutions/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 (http://gcc.gnu.org/onlinedocs/gcc/MIPS-DSP-Built_002din-Functions.html) 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?

wpte
04-12-2008, 22:56
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:p

lly
05-12-2008, 21:24
electro.rob
Can you attach a small sample source?
Which toolchain you use?

electro.rob
10-12-2008, 21:29
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:


/*
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?


I use Optware compiler (uClibc). I got it from nslu2-linux.org (http://www.nslu2-linux.org/wiki/FAQ/Optware-uClibcBuild). 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.

lly
13-12-2008, 12:33
I got same result - "Illegal instruction (core dumped)"

Result of preliminary analysis:
Our CPU is 4KE, not 24KE
read/write Config3 register isn't possible from user space (from kernel space on my Wl500gp V1 Config3=0x3ed96c82)
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).

electro.rob
19-12-2008, 18:53
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 (http://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
http://www.microdesignum.cz/_d/openwrt.png

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?

lly
20-12-2008, 09:43
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.

lly
29-12-2008, 10:46
I found Czech resource on that reported DSP is present and working, have you contact them ?
http://www.microdesignum.cz/clanky/Exploring-commodity-hardware-as-a-platform-for-embedded-DSP-development-and-deployment.html

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

ConstZ
08-03-2009, 00:11
...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! :confused:

lly
08-03-2009, 11:10
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! :confused:
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.