Commit b6a2e5c4 authored by Alessandro Rubini's avatar Alessandro Rubini

on-switch-tests: removed most of them as obsolete

parent 719b76b7
......@@ -133,12 +133,9 @@ editing this file, please add your name in all the proper places.
@item on-switch-tests/
Tests that are meant to be run on the switch itself.
The directory has been copied from @code{software/tests}
as it appeared in the @i{svn} repository; it has not been
recompiled or verified in any way. In this version, only
wr_mon had been made to compile, the other tests still include
@code{build.sh} that sources @code{../../settings}, in the old
way that is now deprecated.
As of March 2012 only a few tests remain, as older ones
only applied to V2, and the switch testing is not a
different project.
@item robustness/
The robustness demo program, copied from @i{svn} and
......
This directory includes tests that are meant to be run on the switch
itself.
This directory used to include tests that are meant to be run on the
switch itself. Now only rtu_test remains, even though it's not
included in the Makefile rules.
The directory has been copied from @code{software/tests} as it
appeared in the @i{svn} repository; it has not been recompiled or
verified in any way. In this version, only wr_mon had been made to
compile, the other tests still include @code{build.sh} that sources
@code{../../settings}, in the old way that is now deprecated.
If you "make" here, only libwripc and wr_mon is compiled.
\ No newline at end of file
If you "make" here, only libwripc and wr_mon are compiled, but
wr_mon must be ported to V3.
CC=$(CROSS_COMPILE)gcc
OBJS = ad9516_test.o
LDFLAGS = -lswitchhw -L../../libswitchhw
CFLAGS = -I. -O2 -I../../include -DDEBUG
OUTPUT = ad9516_test
EXTRAFILES = regs.txt
all: $(OBJS)
${CC} -o $(OUTPUT) $(OBJS) $(LDFLAGS)
%.o: %.c
${CC} -c $^ $(CFLAGS)
run:: all
scp $(OUTPUT) $(EXTRAFILES) root@$(T):/tmp
- ssh -t root@$(T) "/tmp/$(OUTPUT)"
clean:
rm -f $(OUTPUT) $(OBJS)
\ No newline at end of file
#include <stdio.h>
#include <hw/switch_hw.h>
#define NUM_LEDS 4
uint32_t clkgen_rval(void *clkctl, unsigned int addr);
#define AD9516_MAX_REGS 1024
struct ad9516_regs {
struct {
uint16_t addr;
uint8_t value;
} regs[AD9516_MAX_REGS];
int nregs;
};
int ad9516_load_regset(const char *filename, struct ad9516_regs *regs)
{
FILE *f;
char str[1024], tmp[100];
int start_read = 0, n = 0;
uint32_t addr, val;
f = fopen(filename ,"rb");
if(!f)
{
TRACE(TRACE_ERROR, "can't open AD9516 regset file: %s", filename);
return -1;
}
while(!feof(f))
{
fgets(str, 1024, f);
// printf("%s\n",str);
if(!strncmp(str, "Addr(Hex)", 8)) start_read = 1;
if(start_read)
{
if( sscanf(str, "%04x %08s %02x\n", &addr, tmp, &val) == 3)
{
TRACE(TRACE_INFO, " -> ad9516_reg[0x%x]=0x%x", addr, val);
regs->regs[n].addr = addr;
regs->regs[n].value = val;
n++;
}
}
}
regs->nregs = n;
fclose(f);
return 0;
}
int ad9516_set_state(struct ad9516_regs *regs)
{
int i;
TRACE(TRACE_INFO, "Loading AD9516 state (%d registers)", regs->nregs);
for(i=0;i<regs->nregs;i++)
clkgen_write(NULL, regs->regs[i].addr, regs->regs[i].value);
clkgen_write(NULL, 0x232, 1);
for(i=0;i<regs->nregs;i++)
{
uint8_t v = clkgen_rval(NULL, regs->regs[i].addr);
if(regs->regs[i].value != v) printf("%x:%x/%x\n", regs->regs[i].addr, regs->regs[i].value, v);
}
}
main()
{
char s[2000];
int addr;
int val;
unsigned int i=1;
trace_log_stderr();
shw_init();
ad9516_spi_init();
struct ad9516_regs r;
// shw_pio_set0(PIN_ad9516_refsel);
ad9516_load_regset("/tmp/regs.txt", &r);
ad9516_set_state(&r);
}
#!/bin/sh
. ../../../settings
t=`pwd`
cd ../../libswitchhw
./build.sh clean
./build.sh
cd $t
make CROSS_COMPILE=$CC_CPU $1 $2 $3 $4
AD9516/17/18 Register Map File, Rev 1.0
Addr(Hex) Value(Bin) Value(Hex)
0000 00011000 18
0001 00000000 00
0002 00010000 10
0003 11000011 C3
0004 00000000 00
0010 01111100 7C
0011 00000001 01
0012 00000000 00
0013 00000110 06
0014 00001000 08
0015 00000000 00
0016 00000100 04
0017 00000000 00
0018 00000111 07
0019 00000000 00
001A 00000000 00
001B 00000000 00
001C 00000110 06
001D 00000000 00
001E 00000000 00
001F 00001110 0E
00A0 00000001 01
00A1 00000000 00
00A2 00000000 00
00A3 00000001 01
00A4 00000000 00
00A5 00000000 00
00A6 00000001 01
00A7 00000000 00
00A8 00000000 00
00A9 00000001 01
00AA 00000000 00
00AB 00000000 00
00F0 00001010 0A
00F1 00001010 0A
00F2 00001010 0A
00F3 00001010 0A
00F4 00001010 0A
00F5 00001000 08
0140 01000010 42
0141 01000010 42
0142 01000010 42
0143 01011010 5A
0190 00000000 00
0191 10000000 80
0192 00000000 00
0193 00110010 32
0194 00000000 00
0195 00000000 00
0196 00110010 32
0197 00000000 00
0198 00000000 00
0199 00110010 32
019A 00000000 00
019B 00010001 11
019C 00100000 20
019D 00000000 00
019E 00110010 32
019F 00000000 00
01A0 00010001 11
01A1 00100000 20
01A2 00000000 00
01A3 00000000 00
01E0 00000000 00
01E1 00000010 02
0230 00000000 00
0231 00000000 00
0232 00000000 00
CC=$(CROSS_COMPILE)gcc
OBJS = blink_leds.o
LDFLAGS = -lswitchhw -L../../libswitchhw
CFLAGS = -I. -O2 -I../../include -DDEBUG
OUTPUT = blink_leds
all: $(OBJS)
${CC} -o $(OUTPUT) $(OBJS) $(LDFLAGS)
%.o: %.c
${CC} -c $^ $(CFLAGS)
run: all
scp $(OUTPUT) root@$(T):/tmp
- ssh -t root@$(T) "/tmp/$(OUTPUT)"
install: all
mkdir -p ../../rootfs_override/root/tests
cp $(OUTPUT) ../../rootfs_override/root/tests
clean:
rm -f $(OUTPUT) $(OBJS)
\ No newline at end of file
#include <stdio.h>
#include <hw/switch_hw.h>
#define NUM_LEDS 8
main()
{
unsigned int i=0,di=1,previ=0;
trace_log_stderr();
shw_request_fpga_firmware(FPGA_ID_MAIN, "board_test");
shw_init();
for(;;)
{
shw_set_fp_led(previ, LED_OFF);
shw_set_fp_led(i, LED_GREEN);
usleep(30000);
shw_set_fp_led(i, LED_RED);
usleep(30000);
previ=i;
i+=di;
if(i == 0 || i==(NUM_LEDS-1)) di=-di;
}
}
#!/bin/sh
. ../../../settings
#cd ../../libswitchhw
#./build.sh
#cd ../tests/blink_leds
make CROSS_COMPILE=$CC_CPU $1 $2 $3 $4
include ../../../Makedefs
CC=$(CROSS_COMPILE_ARM)gcc
OBJS = calibrator_test.o term.o
LDFLAGS = -lswitchhw -L../../libswitchhw
CFLAGS = -I. -O2 -I../../include -DDEBUG -I../../../kernel/include
OUTPUT = calibrator_test
all: $(OBJS)
make -C ../../libswitchhw
${CC} -o $(OUTPUT) $(OBJS) $(LDFLAGS)
%.o: %.c
${CC} -c $^ $(CFLAGS)
run: all
scp $(OUTPUT) ../../drivers/bin/*.ko root@$(T):/tmp
- ssh -t root@$(T) "/tmp/$(OUTPUT)"
install: all
mkdir -p ../../rootfs_override/root/tests
cp $(OUTPUT) ../../rootfs_override/root/tests
clean:
rm -f $(OUTPUT) $(OBJS)
\ No newline at end of file
#!/bin/sh
. ../../../settings
make CROSS_COMPILE=$CROSS_COMPI_CPU $1 $2 $3 $4
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <sys/time.h>
#include <signal.h>
#include <hw/switch_hw.h>
#include <hw/clkb_io.h>
#include <hw/minic_regs.h>
#include <hw/endpoint_regs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
//#include <net/if.h>
#include <asm/types.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <linux/net_tstamp.h>
#include <linux/sockios.h>
#include <linux/errqueue.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <hw/dmtd_calibrator_regs.h>
#include <hw/endpoint_regs.h>
#include <hw/phy_calibration.h>
main()
{
int i, rval;
system("/sbin/rmmod /tmp/wr_minic.ko");
system("/sbin/rmmod /tmp/wr_vic.ko");
trace_log_stderr();
shw_init();
system("/sbin/insmod /tmp/wr_vic.ko");
system("/sbin/insmod /tmp/wr_minic.ko");
system("/sbin/ifconfig wru1 hw ether 00:50:fc:96:9b:0e");
system("/sbin/ifconfig wru1 up 192.168.100.100");
_fpga_writel(FPGA_BASE_MINIC_UP0 + (1<<14) + EP_REG_PHIO, EP_PHIO_ENABLE);
_fpga_writel(FPGA_BASE_MINIC_UP1 + (1<<14) + EP_REG_PHIO, EP_PHIO_ENABLE);
shw_hpll_switch_reference("wru1");
while(!shw_hpll_check_lock());
shw_dmpll_switch_reference("wru1");
while(!shw_dmpll_check_lock());
shw_cal_enable_feedback("wru1", 1, PHY_CALIBRATE_RX);
double phase_rx;
for(;;)
{
while(!(rval = shw_cal_measure(&phase_rx)));
if(rval < 0)
{
printf("error measuring RX delay\n");
return -1;
}
printf("rval = %d, deltaRX(uncorrected) = %.3f ns\n", rval, phase_rx);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <poll.h>
struct termios oldkey, newkey;
int term_restore()
{
tcsetattr(STDIN_FILENO,TCSANOW,&oldkey);
}
void term_init()
{
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
tcgetattr(STDIN_FILENO,&oldkey);
memcpy(&newkey, &oldkey, sizeof(struct termios));
newkey.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;
newkey.c_iflag = IGNPAR;
newkey.c_oflag = OPOST |ONLCR;
newkey.c_lflag = 0;
newkey.c_cc[VMIN]=1;
newkey.c_cc[VTIME]=0;
tcflush(STDIN_FILENO, TCIFLUSH);
tcsetattr(STDIN_FILENO,TCSANOW,&newkey);
atexit(term_restore);
}
int term_poll()
{
struct pollfd pfd;
pfd.fd = STDIN_FILENO;
pfd.events = POLLIN | POLLPRI;
if(poll(&pfd,1,0)>0)return 1;
return 0;
}
int term_get()
{
unsigned char c;
int q;
if(read(STDIN_FILENO, &c, 1 ) == 1)
{
q=c;
} else q=-1;
return q;
}
void clear_screen()
{
printf("\033[2J\033[1;1H");
}
\ No newline at end of file
include ../../../Makedefs
CC=$(CROSS_COMPILE_ARM)gcc
OBJS = dmpll_test.o term.o
LDFLAGS = -lswitchhw -L../../libswitchhw
CFLAGS = -I. -O2 -I../../include -DDEBUG -I../../../kernel/include
OUTPUT = dmpll_test
all: $(OBJS)
make -C ../../libswitchhw
${CC} -o $(OUTPUT) $(OBJS) $(LDFLAGS)
%.o: %.c
${CC} -c $^ $(CFLAGS)
run: all
scp $(OUTPUT) ../../drivers/bin/*.ko root@$(T):/tmp
- ssh -t root@$(T) "/tmp/$(OUTPUT)"
install: all
mkdir -p ../../rootfs_override/root/tests
cp $(OUTPUT) ../../rootfs_override/root/tests
clean:
rm -f $(OUTPUT) $(OBJS)
\ No newline at end of file
#!/bin/sh
. ../../../settings
make CROSS_COMPILE=$CC_CPU $1 $2 $3 $4
#include <stdio.h>
#include <stdlib.h>
#include <hw/dmpll_regs.h>
int sign_extend(uint32_t val, int nbits)
{
if(val & (1<<(nbits-1))) return (0xffffffff ^ ((1<<nbits)-1)) | val; else return val;
}
main(int argc, char *argv[])
{
if(argc < 3) return -1;
FILE *fin, *fout;
uint32_t r0, r1,r2,r3;
int npoints;
int i = 0;
fin = fopen(argv[1], "rb");
fout = fopen(argv[2], "wb");
npoints = atoi(argv[3]);
while(!feof(fin) && (++i < npoints))
{
fread(&r0, 4, 1, fin);
fread(&r1, 4, 1, fin);
fread(&r2, 4, 1, fin);
fread(&r3, 4, 1, fin);
fprintf(fout, "%d %d %d %d\n", i,
sign_extend(DMPLL_RFIFO_R0_ERR_VAL_R(r0), 18),
DMPLL_RFIFO_R3_DAC_VAL_R(r3),
// DMPLL_RFIFO_R1_TAG_REF_R(r1) - DMPLL_RFIFO_R2_TAG_FB_R(r2),
r0 & DMPLL_RFIFO_R2_FP_MODE ? 60000 : 0);
}
}
\ No newline at end of file
#include <stdio.h>
#include <inttypes.h>
#include <sys/time.h>
#include <signal.h>
#include <hw/switch_hw.h>
#include <hw/clkb_io.h>
#include <hw/dmpll_regs.h>
#define MAX_MEAS 120000
#define DMPLL_CHANNEL_LOCAL 0
#define DMPLL_CHANNEL_UP0 1
#define DMPLL_CHANNEL_UP1 2
uint32_t rec_buf[MAX_MEAS * 4];
int n_meas = 0;
static void dmpll_purge_rfifo()
{
for(;;)
{
shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_R0);
}
}
static void dmpll_poll_rfifo()
{
for(;;)
{
if(shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_CSR) & DMPLL_RFIFO_CSR_EMPTY) return;
if(n_meas < MAX_MEAS) {
rec_buf[4*n_meas] = shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_R0);
rec_buf[4*n_meas+1] = shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_R1);
rec_buf[4*n_meas+2] = shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_R2);
rec_buf[4*n_meas+3] = shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_RFIFO_R3);
n_meas++;
}
}
}
static void dmpll_setup_deglitcher(uint32_t reg, int hi, int lo, int glitch)
{
shw_clkb_write_reg(CLKB_BASE_DMPLL + reg, DMPLL_DGCR_IN0_THR_HI_W(hi) |
DMPLL_DGCR_IN0_THR_LO_W(lo) |
DMPLL_DGCR_IN0_THR_GLITCH_W(glitch));
}
static void dmpll_set_phase_shift(int channel, int ps_shift)
{
switch(channel)
{
#if 0
case DMPLL_CHANNEL_LOCAL:
shw_clkb_write_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_LOCAL, ps_shift);
break;
case DMPLL_CHANNEL_UP0:
shw_clkb_write_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_0, ps_shift);
break;
#endif
case DMPLL_CHANNEL_UP1:
shw_clkb_write_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_IN0, ps_shift);
break;
}
}
static int dmpll_shifter_busy(int channel)
{
switch(channel)
{
/* case DMPLL_CHANNEL_LOCAL:
return shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_LOCAL) & (1<<31);
case DMPLL_CHANNEL_UP0:
return shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_UP0) & (1<<31);*/
case DMPLL_CHANNEL_UP1:
return shw_clkb_read_reg(CLKB_BASE_DMPLL + DMPLL_REG_PSCR_IN0) & DMPLL_PSCR_IN0_BUSY;
}
return 0;
}
void sighandler(int sig)
{
fprintf(stderr,"Saving: %d", n_meas);
FILE *f=fopen("/tmp/dmpll_meas.dat","wb");
fwrite(rec_buf, 8, n_meas, f);
fclose(f);
exit(0);
}
main()
{
int i;
int ps_shift = 16000;
int ps_new_shift = 0;
trace_log_stderr();
shw_init();
printf("Waiting for Helper PLL lock...\n");
while(!shw_hpll_check_lock()) usleep(10000);
/*
for(i=0;i<30;i++)
{
shw_hpll_update(); usleep(100000);
}*/