add test program

This commit is contained in:
Lu
2024-01-23 01:46:24 +00:00
parent 5fcb6604a4
commit 8b0aa0ef02
31 changed files with 55762 additions and 25 deletions

View File

@@ -76,3 +76,4 @@ CONFIG_TARGET_PACKAGE_RAMSPEED=y
CONFIG_TARGET_PACKAGE_UDPCAST=y
CONFIG_TARGET_PACKAGE_UNRAR=y
CONFIG_TARGET_PACKAGE_ALSA=y
CONFIG_TARGET_PACKAGE_WIRELESS_TOOLS=y

View File

@@ -14,12 +14,12 @@
reg_names = "core_mem";
src-frequency = <375000000>;
min-frequency = <400000>; // 400Khz
max-frequency = <50000000>; // 50Mhz
//max-frequency = <50000000>; // 50Mhz
//max-frequency = <45000000>; // 45Mhz
//max-frequency = <40000000>; // 40Mhz
//max-frequency = <35000000>; // 35Mhz
//max-frequency = <30000000>; // 30Mhz
//max-frequency = <25000000>; // 25Mhz
max-frequency = <25000000>; // 25Mhz
//max-frequency = <20000000>; // 20Mhz
//max-frequency = <15000000>; // 15Mhz
//max-frequency = <10000000>; // 10Mhz

View File

@@ -151,8 +151,8 @@ CONFIG_FB_CVITEK=m
CONFIG_SOUND=y
CONFIG_SND=y
# CONFIG_SND_SUPPORT_OLD_API is not set
# CONFIG_SND_PROC_FS is not set
# CONFIG_SND_DRIVERS is not set
CONFIG_SND_PROC_FS=y
CONFIG_SND_DRIVERS=y
CONFIG_SND_HDA_PREALLOC_SIZE=1
# CONFIG_SND_SPI is not set
# CONFIG_SND_USB is not set
@@ -287,4 +287,4 @@ CONFIG_IP_MULTICAST=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_BACKLIGHT_GPIO=y
CONFIG_USB_GADGET_VBUS_DRAW=500
CONFIG_USB_GADGET_VBUS_DRAW=500

View File

@@ -209,6 +209,8 @@ if not working, please check step 2, then execute step 3
# camera
```
/opt/camera.sh 1 # initial sensor
/opt/camera2lcd.sh
```
# your custom config file

View File

@@ -42,7 +42,7 @@ int cvi_board_init(void)
val &= ~(1 << 26); // set level to low
mmio_write_32(0x03020000, val);
suck_loop(50);
suck_loop(200);
val = mmio_read_32(0x03020000); // signal level
val |= (1 << 26); // set level to high

View File

@@ -1 +0,0 @@
just overwrite dropbear package's symlink

View File

@@ -3,8 +3,6 @@
case "$1" in
start)
printf "mount: "
mount -t tmpfs tmpfs /tmp/
mount -t tmpfs tmpfs /run/
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)

View File

@@ -1,8 +1,16 @@
#!/bin/sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/system/lib
# because audio en pin also use for lcd
/opt/fb_load.sh
if [ -z "$1" ]
then
echo "usage: $0 count"
exit 1
fi
seq 1 $1 | while read line
do
echo "Now record sound"
arecord -Dhw:0,0 -d 5 -r 48000 -f S16_LE -t wav /tmp/ramdisk/test.wav
echo "Now play sound"
aplay -D hw:1,0 -f S16_LE /tmp/ramdisk/test.wav
done

View File

@@ -1,7 +1,6 @@
#!/bin/sh
insmod /mnt/system/ko/aic8800_bsp.ko
insmod /mnt/system/ko/aic8800_fdrv.ko
/opt/wifi.sh
insmod /mnt/system/ko/cmac.ko
insmod /mnt/system/ko/ecc.ko
insmod /mnt/system/ko/ecb.ko
@@ -14,5 +13,9 @@ insmod /mnt/system/ko/rfcomm.ko
insmod /mnt/system/ko/btintel.ko
insmod /mnt/system/ko/hci_uart.ko
insmod /mnt/system/ko/bnep.ko
hciattach ttyS1 any 1500000
hciconfig hci0 up
hciconfig | grep hci0
if [ $? -ne 0 ]
then
hciattach ttyS1 any 1500000
hciconfig hci0 up
fi

View File

@@ -12,7 +12,7 @@ echo "snsr_on 0 1 4" > /proc/mipi-rx
SENSOR_TEST=/opt/sensor_test_gc4653
cd /tmp/
cd /tmp/ramdisk/
if [ -z "$1" ]
then
@@ -28,6 +28,6 @@ do
0
1
255" | $SENSOR_TEST
rm -rf /tmp/*.raw
rm -rf /tmp/*.yuv
rm -rf /tmp/ramdisk/*.raw
rm -rf /tmp/ramdisk/*.yuv
done

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# 7inch
#sample_dsi --panel=ZCT2133V1
sample_dsi --panel=ZCT2133V1
# 5inch
#sample_dsi --panel=ST7701_DXQ5D0019B480854
# 2inch
@@ -17,8 +17,7 @@ insmod /mnt/system/ko/cfbcopyarea.ko
insmod /mnt/system/ko/cfbfillrect.ko
insmod /mnt/system/ko/cfbimgblt.ko
# 32bit RGB888
insmod /opt/ko/huashanpai/cvi_fb.ko
insmod /opt/ko/huashanpai/cvi_fb.ko option=1
# 16bit RGB1555
#insmod /opt/ko/v4.1.0_181x_fb_ko_debug/cvi_fb.ko

View File

@@ -0,0 +1,10 @@
CROSS ?= riscv64-unknown-linux-musl-
CC = $(CROSS)gcc
CFLAGS += -mcpu=c906fdv -march=rv64imafdcv0p7xthead -mcmodel=medany -mabi=lp64d
CFLAGS += -O3 -g3 -Wall -Wextra -static -flto -fanalyzer
all:
$(CC) $(CFLAGS) vendortest.c -o vendortest
clean:
rm -fv vendortest *.out

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,472 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <string.h>
#include <time.h>
#include <signal.h>
// vendor test
// use tcl/tk write this program may be a good choise
// but xorg is not ready for this system
struct fb_fix_screeninfo fb_finfo;
struct fb_var_screeninfo fb_vinfo;
uint8_t *fb = NULL;
#define BLUE (0xFF << 0)
#define GREEN (0xFF << 8)
#define RED (0xFF << 16)
#define WHITE (BLUE | GREEN | RED)
#define BLACK (0x00)
#define YELLO (REG | GREEN)
#define AFULL (0xFF << 24)
static inline void draw_pixel(int x, int y, uint32_t data) {
uint8_t *p;
p = fb;
p += y * fb_finfo.line_length + x * 4; // 32bit framebuffer
uint32_t *p32;
p32 = (uint32_t *)p;
*p32 = data;
}
static inline void draw_xline(int xmin, int xmax, int y,
uint32_t data) {
for (; xmin <= xmax; xmin++) {
draw_pixel(xmin, y, data);
}
}
static inline void draw_yline(int ymin, int ymax, int x,
uint32_t data) {
for (; ymin <= ymax; ymin++) {
draw_pixel(x, ymin, data);
}
}
static inline void draw_rect(int xmin, int ymin,
int xmax, int ymax,
uint32_t data) {
draw_xline( xmin, xmax, ymin, data);
draw_xline( xmin, xmax, ymax, data);
draw_yline( ymin, ymax, xmin, data);
draw_yline( ymin, ymax, xmax, data);
}
static inline void draw_solid(int xmin, int ymin,
int xmax, int ymax,
uint32_t data) {
for (; ymin <= ymax; ymin++) {
draw_xline(xmin, xmax, ymin, data);
}
}
#include "uni_vga.h"
// fallbback, no font
#ifndef FONT_H
#define FONT_H 0
#endif
#ifndef FONT_W
#define FONT_W 0
#endif
#ifndef FONT_CODE_POINTS
#define FONT_CODE_POINTS 0
#endif
static inline void draw_char(int x, int y,
uint32_t fg, uint32_t bg,
int c) {
int i;
int found = 0;
// todo, replace by binary search
for (i = 0; i < FONT_CODE_POINTS; i++) {
if (c == font_default_code_points[i]) {
found = 1;
break;
}
}
if (!found) {
return;
}
int xf, yf;
for (yf = 0; yf < FONT_H; yf++) {
for (xf = 0; xf < FONT_W; xf++) {
if (font_default_data[i][yf] & (1 << (FONT_W - xf))) {
draw_pixel(x + xf, y + yf, fg);
} else {
draw_pixel(x + xf, y + yf, bg);
}
}
}
}
static inline void draw_str(int x, int y,
uint32_t fg, uint32_t bg,
char *s) {
int i = 0;
while(s[i] != '\0') {
draw_char(x, y, fg, bg, s[i]);
x += FONT_W;
i++;
}
}
static inline void draw_progress(int xmin, int ymin,
int xmax, int ymax,
uint32_t fg, uint32_t bg,
int per) {
ymin -= 2;
ymax -= 2;
draw_solid(xmin, ymin, xmax, ymax, bg);
xmin += 1;
ymin += 1;
xmax -= 1;
ymax -= 1;
float xshow;
xshow = xmax - xmin;
xshow = xshow * ((float)per / 100.0);
draw_solid(xmin, ymin, xmin + xshow, ymax, fg);
}
int main(void) {
int fbfd = -1;
char *fbdev = "/dev/fb0";
char *s;
s = getenv("FRAMEBUFFER");
if (s != NULL) {
fbdev = s;
}
fbfd = open(fbdev, O_RDWR);
if (fbfd < 0) {
perror("can't open framebuffer device");
exit(EXIT_FAILURE);
}
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fb_finfo) < 0) {
perror("can't get framebuffer finfo");
exit(EXIT_FAILURE);
}
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &fb_vinfo) < 0) {
perror("can't get framebuffer vinfo");
exit(EXIT_FAILURE);
}
fb = mmap(NULL, fb_finfo.smem_len, PROT_READ | PROT_WRITE,
MAP_SHARED, fbfd, 0);
if (fb == MAP_FAILED) {
perror("mmap");
exit(EXIT_FAILURE);
}
memset(fb, 0, fb_finfo.smem_len);
int touchfd = -1;
touchfd = open("/dev/input/event0", O_RDONLY);
// fb_vinfo.xres // screen x max
// fb_vinfo.yres // screen y max
int xmin, ymin;
int xmax, ymax;
int ystep, xstep;
int xmin_save;
int ymin_save;
int xmax_save;
int ymax_save;
int xstep_save, ystep_save;
int ret;
// div 16
ystep = fb_vinfo.yres >> 3;
xstep = fb_vinfo.xres >> 3;
uint32_t bg = WHITE | AFULL;
uint32_t fg = BLACK | AFULL;
// draw RED GREEN BLUE WHITE BLACK block
xmin = 0;
ymin = 0;
xmax = xmin + xstep;
ymax = ymin + ystep;
draw_solid(xmin, ymin, xmax, ymax, BLACK | AFULL);
draw_str(xmin, ymin, fg, bg, "BLACK");
xmin += xstep;
xmax += xstep;
draw_solid(xmin, ymin, xmax, ymax, WHITE | AFULL);
draw_str(xmin, ymin, fg, bg, "WHITE");
xmin += xstep;
xmax += xstep;
draw_solid(xmin, ymin, xmax, ymax, RED | AFULL);
draw_str(xmin, ymin, fg, bg, "RED");
xmin += xstep;
xmax += xstep;
draw_solid(xmin, ymin, xmax, ymax, GREEN | AFULL);
draw_str(xmin, ymin, fg, bg, "GREEN");
xmin += xstep;
xmax += xstep;
draw_solid(xmin, ymin, xmax, ymax, BLUE | AFULL);
draw_str(xmin, ymin, fg, bg, "BLUE");
xmin += xstep;
xmax += xstep;
// draw v line
xmin_save = xmin;
for (;xmin < xmax;xmin++) {
if (xmin & 1) {
draw_yline(ymin, ymax, xmin, fg);
} else {
draw_yline(ymin, ymax, xmin, bg);
}
}
xmin = xmin_save;
draw_str(xmin, ymin, fg, bg, "VLINE");
xmin += xstep;
xmax += xstep;
// draw h line
ymin_save = ymin;
for (;ymin < ymax;ymin++) {
if (ymin & 1) {
draw_xline(xmin, xmax, ymin, bg);
} else {
draw_xline(xmin, xmax, ymin, fg);
}
}
ymin = ymin_save;
draw_str(xmin, ymin, fg, bg, "HLINE");
xmin += xstep;
xmax += xstep;
// draw chess board
xmin_save = xmin;
ymin_save = ymin;
for (;ymin < ymax;ymin++) {
for (xmin = xmin_save;xmin < xmax;xmin++) {
if ((xmin + ymin) & 1) {
draw_pixel(xmin, ymin, fg);
} else {
draw_pixel(xmin, ymin, bg);
}
}
}
xmin = xmin_save;
ymin = ymin_save;
draw_str(xmin, ymin, fg, bg, "CHESS");
// gap
xmin += 3;
xmax += 3;
ymin += 3;
ymax += 3;
xmin_save = xmin;
xmax_save = xmax;
ymin_save = ymin;
ymax_save = ymax;
xstep_save = xstep;
ystep_save = ystep;
// -1 is not data
int eth_rx_time = -1;
int wifi_rx_time = -1;
int touch_xmove = -1;
int touch_ymove = -1;
int touch_btn = -1;
int font_fg;
int font_bg;
FILE *logfp;
logfp = popen("tail -f /tmp/ramdisk/vendor_test.log", "r");
if (logfp == NULL) {
perror("can't open log");
exit(EXIT_FAILURE);
}
struct {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int val;
} touchdata;
if (touchfd >= 0) {
switch(fork()) {
case -1:
perror("fork");
exit(EXIT_FAILURE);
case 0:
while(1) {
if (read(touchfd, &touchdata, sizeof(touchdata))
== sizeof(touchdata)) {
switch(touchdata.code) {
case 53:
touch_xmove = touchdata.val;
break;
case 54:
touch_ymove = touchdata.val;
break;
case 330:
touch_btn = touchdata.val;
break;
}
}
fg = WHITE | AFULL;
if (touch_btn == 0) {
touch_xmove = 0;
touch_ymove = 0;
}
int touch_xmax;
int touch_xmin;
int touch_ymax;
int touch_ymin;
#define CURSIZE 10
if (touch_btn > 0) {
if (touch_xmove > (((int)fb_vinfo.xres) - 1)) {
touch_xmove = (((int)fb_vinfo.xres) -1);
}
if (touch_ymove > (((int)fb_vinfo.yres) - 1)) {
touch_ymove = (fb_vinfo.yres - 1);
}
if (touch_xmove < 0) {
touch_xmove = 0;
}
if (touch_ymove < 0) {
touch_ymove = 0;
}
touch_xmax = touch_xmove + CURSIZE;
if (touch_xmax > (((int)fb_vinfo.xres) - 1)) {
touch_xmax = fb_vinfo.xres - 1;
}
touch_xmin = touch_xmove - CURSIZE;
if (touch_xmin < 0) {
touch_xmin = 0;
}
touch_ymax = touch_ymove + CURSIZE;
if (touch_ymax > (((int)fb_vinfo.yres) - 1)) {
touch_ymax = fb_vinfo.yres - 1;
}
touch_ymin = touch_ymove - CURSIZE;
if (touch_ymin < 0) {
touch_ymin = 0;
}
draw_rect(touch_xmin, touch_ymin,
touch_xmax, touch_ymax,
fg);
draw_xline(touch_xmin, touch_xmax,
touch_ymove, fg);
draw_yline(touch_ymin, touch_ymax,
touch_xmove, fg);
}
}
}
}
time_t start_time;
start_time = time(NULL);
char buf[128];
buf[0] = '\0';
while(1) {
if (strstr(buf, "wifi rx 10MiB test (s): ")
!= NULL) {
strtok(buf, ":");
s = strtok(NULL, "\n\r");
if (s != NULL) {
wifi_rx_time = atoi(s);
} else {
;
}
} else if (strstr(buf, "eth rx 10MiB test (s): ")
!= NULL) {
strtok(buf, ":");
s = strtok(NULL, "\n\r");
if (s != NULL) {
eth_rx_time = atoi(s);
} else {
;
}
}
fg = BLACK | AFULL;
bg = WHITE | AFULL;
font_fg = WHITE | AFULL;
font_bg = 0x00; // nothing
xmin = xmin_save;
ymin = ymin_save;
xmax = xmax_save;
ymax = ymax_save;
xstep = xstep_save;
ystep = ystep_save;
// next
xstep = fb_vinfo.xres >> 1;
xmin = 2;
xmax = xmin + xstep;
ymin += ystep;
ystep = FONT_H + 2;
ymax += ystep;
snprintf(buf, 127, "ETH RX 10MiB TEST (S): %d ",
eth_rx_time);
if (eth_rx_time > 3) {
font_fg = RED | AFULL;
} else if (eth_rx_time == -1) {
font_fg = WHITE | AFULL;
} else {
font_fg = GREEN | AFULL;
}
draw_str(xmin, ymin, font_fg, font_bg, buf);
ymin += ystep;
ymax += ystep;
snprintf(buf, 127, "WIFI RX 10MiB TEST (S): %d ",
wifi_rx_time);
if (wifi_rx_time > 15) {
font_fg = RED | AFULL;
} else if (wifi_rx_time == -1) {
font_fg = WHITE | AFULL;
} else {
font_fg = GREEN | AFULL;
}
draw_str(xmin, ymin, font_fg, font_bg, buf);
ymin += ystep;
ymax += ystep;
// show tested time
snprintf(buf, 127, "TIME (S): %ld ",
time(NULL) - start_time);
font_fg = WHITE | AFULL;
draw_str(xmin, ymin, font_fg, font_bg, buf);
ymin += ystep;
ymax += ystep;
// wait draw
ioctl(fbfd, FBIO_WAITFORVSYNC, &ret);
// next result
fgets(buf, 127, logfp);
buf[127] = '\0';
}
}

View File

@@ -0,0 +1,15 @@
#!/bin/sh
while true
do
# ntp will broken test
killall crond
/opt/audio.sh 1
sleep 1
if [ $? -ne 0 ]
then
echo "audio test failed"
else
echo "audio test running"
fi
done

View File

@@ -0,0 +1,87 @@
#!/bin/sh
while true
do
# ntp will borken test
if [ -e `which ntpdate` ]
then
mv `which ntpdate` /ntpdate
fi
killall udhcpc
killall wpa_supplicant
ifconfig wlan0 down
ifconfig eth0 up
udhcpc -i eth0 -b -T 1
# retry 3
count=3
while [ $count -gt 0 ]
do
sleep 1
start_time=$(date +%s)
wget -O /dev/null http://192.168.0.104:8000/rand10MiB
if [ $? -ne 0 ]
then
count=$((count - 1))
continue;
fi
end_time=$(date +%s)
a=$((end_time - start_time))
echo "eth rx 10MiB test (s): $a" | tee -a /tmp/ramdisk/vendor_test.log
if [ $a -ge 3 ]
then
echo "eth rx test failed" | tee -a /tmp/ramdisk/vendor_test.log
else
echo "eth rx test ok"
fi
break;
done
killall crond
killall wpa_supplicant
killall udhcpc
touch /etc/wpa_supplicant.conf
cat /etc/wpa_supplicant.conf | grep Sipeed_Guest
if [ $? -ne 0 ]
then
echo '
network={
ssid="Sipeed_Guest"
psk=280517f8e2cfd7a605a767d8d9a102f36ac356e68fc777d51f963d20c8817909
}
' > /etc/wpa_supplicant.conf
fi
ifconfig eth0 down
ifconfig wlan0 up
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
udhcpc -i wlan0 -b -T 1
# retry 5
count=5
while [ $count -gt 0 ]
do
if [ ! -e /sys/class/net/wlan0 ]
then
echo "no wifi hardware"
break;
fi
sleep 1
start_time=$(date +%s)
wget -O /dev/null http://192.168.0.104:8000/rand10MiB
if [ $? -ne 0 ]
then
count=$((count - 1))
continue;
fi
end_time=$(date +%s)
a=$((end_time - start_time))
echo "wifi rx 10MiB test (s): $a" | tee -a /tmp/ramdisk/vendor_test.log
if [ $a -ge 10 ]
then
echo "wifi rx test failed" | tee -a /tmp/ramdisk/vendor_test.log
else
echo "wifi rx test ok" | tee -a /tmp/ramdisk/vendor_test.log
fi
break;
done
done

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# ntp will broken test
killall crond
/opt/wifi.sh
nice -n 2 /opt/stress-test/net-stress-test.sh &
mkdir -pv /tmp/ramdisk/
mount -t tmpfs tmpfs /tmp/ramdisk
touch /tmp/ramdisk/vendor_test.log
/opt/fb_load.sh
(/opt/camera2lcd.sh &> /dev/null) &
sleep 5
/opt/touch.sh
nice -n 1 /opt/vendortest

View File

@@ -0,0 +1,11 @@
#!/bin/sh
while true
do
# ntp will borken test
killall crond
killall nn_runner
cd /opt/nn_runner_test/
nn_runner_test_time=$(/opt/nn_runner_test/run.sh 1 | grep 'forward image success' | awk -F':' '{print $2}' | awk -F'us' '{print $1}')
echo "nn runner test time (us): $nn_runner_test_time" | tee -a /tmp/ramdisk/vendor_test.log
done

View File

@@ -0,0 +1,3 @@
#!/bin/sh
insmod /mnt/system/ko/3rd/gt9xx.ko

View File

@@ -4,5 +4,5 @@ insmod /mnt/system/ko/3rd/aic8800_bsp.ko
insmod /mnt/system/ko/3rd/aic8800_fdrv.ko
ifconfig wlan0 up
touch /etc/wpa_supplicant.conf
wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0 -B -g/tmp/wpa
wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0 -B -g/tmp/ramdisk/wpa
udhcpc -i wlan0 -b &

View File

@@ -66,4 +66,5 @@ source "../ramdisk/rootfs/public/p7zip/Kconfig"
source "../ramdisk/rootfs/public/ramspeed/Kconfig"
source "../ramdisk/rootfs/public/udpcast/Kconfig"
source "../ramdisk/rootfs/public/unrar/Kconfig"
source "../ramdisk/rootfs/public/alsa/Kconfig"
source "../ramdisk/rootfs/public/alsa/Kconfig"
source "../ramdisk/rootfs/public/wireless-tools/Kconfig"

View File

@@ -66,3 +66,4 @@ include $(TOP_DIR)/ramdisk/rootfs/public/ramspeed/target.mk
include $(TOP_DIR)/ramdisk/rootfs/public/udpcast/target.mk
include $(TOP_DIR)/ramdisk/rootfs/public/unrar/target.mk
include $(TOP_DIR)/ramdisk/rootfs/public/alsa/target.mk
include $(TOP_DIR)/ramdisk/rootfs/public/wireless-tools/target.mk

View File

@@ -0,0 +1,5 @@
config TARGET_PACKAGE_WIRELESS_TOOLS
bool "Target wireless-tools"
default n
help
target wireless-tools

View File

@@ -0,0 +1,3 @@
ifeq ($(CONFIG_TARGET_PACKAGE_WIRELESS_TOOLS),y)
TARGET_PACKAGES += wireless-tools
endif