Skip to content

Commit

Permalink
First tests on real hardware for CVITEK/Sophon
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 25, 2024
1 parent 5cd82af commit 738d9b4
Show file tree
Hide file tree
Showing 18 changed files with 1,895 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
"defines": ["__mips__"],
"compilerPath": "toolchain/mips_xburst-gcc13-musl-3_10/bin/mipsel-openipc-linux-musl-gcc",
"cStandard": "c11"
},{
"name": "riscv64-musl",
"includePath": ["${workspaceFolder}/**"],
"defines": ["__riscv", "__riscv__"],
"compilerPath": "toolchain/riscv64-lp64d--musl--stable-2024.05-1/bin/riscv64-linux-gcc",
"cStandard": "c11"
}
],
"version": 4
Expand Down
13 changes: 9 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/sh
DL="https://github.com/openipc/firmware/releases/download/latest"
EXT="tgz"

toolchain() {
if [ ! -e toolchain/$1 ]; then
wget -c -q $DL/$1.tgz -P $PWD
wget -c -q $DL/$1.$EXT -P $PWD
mkdir -p toolchain/$1
tar -xf $1.tgz -C toolchain/$1 --strip-components=1 || exit 1
rm -f $1.tgz
tar -xf $1.$EXT -C toolchain/$1 --strip-components=1 || exit 1
rm -f $1.$EXT
fi
make -j $(nproc) -C src -B CC=$PWD/toolchain/$1/bin/$2-linux-gcc OPT="$OPT $3"
}
Expand All @@ -31,6 +32,10 @@ elif [ "$1" = "armhf-musl" ]; then
toolchain cortex_a7_thumb2_hf-gcc13-musl-4_9 arm
elif [ "$1" = "mips-musl" ]; then
toolchain mips_xburst-gcc13-musl-3_10 mipsel
elif [ "$1" = "riscv64-musl" ]; then
DL="https://toolchains.bootlin.com/downloads/releases/toolchains/riscv64-lp64d/tarballs"
EXT="tar.xz"
toolchain riscv64-lp64d--musl--stable-2024.05-1 riscv64
else
echo "Usage: $0 [arm-musl|arm9-musl3|arm9-musl4|arm9-uclibc|armhf-glibc|armhf-musl|mips-musl]"
echo "Usage: $0 [arm-musl|arm9-musl3|arm9-musl4|arm9-uclibc|armhf-glibc|armhf-musl|mips-musl|riscv64-musl]"
fi
9 changes: 8 additions & 1 deletion src/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void __assert(void) {}
void backtrace(void) {}
void backtrace_symbols(void) {}
void __ctype_b(void) {}
void __ctype_b_loc(void) {}
void __ctype_tolower(void) {}
void _MI_PRINT_GetDebugLevel(void) {}
void __pthread_register_cancel(void) {}
Expand All @@ -39,10 +40,16 @@ float __expf_finite(float x) { return expf(x); }
int __fgetc_unlocked(FILE *stream) { return fgetc(stream); }
double __log_finite(double x) { return log(x); }

#if !defined(__riscv) && !defined(__riscv__)
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}

void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}
}
#else
void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
return (void*)syscall(SYS_mmap, start, len, prot, flags, fd, off);
}
#endif
6 changes: 3 additions & 3 deletions src/hal/hisi/v1_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int v1_audio_init(int samplerate)
config.expandOn = 0;
config.frmNum = 30;
config.packNumPerFrm = 320;
config.chnNum = 1;
config.chnNum = 2;
config.syncRxClkOn = 0;
if (ret = v1_aud.fnSetDeviceConfig(_v1_aud_dev, &config))
return ret;
Expand Down Expand Up @@ -449,7 +449,7 @@ int v1_video_create(char index, hal_vidconfig *config)
channel.attrib.jpg.maxPic.height = config->height;
channel.attrib.jpg.bufSize =
config->height * config->width * 2;
channel.attrib.jpg.byFrame = 0;
channel.attrib.jpg.byFrame = 1;
channel.attrib.jpg.fieldOrFrame = 0;
channel.attrib.jpg.priority = 0;
channel.attrib.jpg.pic.width = config->width;
Expand All @@ -461,7 +461,7 @@ int v1_video_create(char index, hal_vidconfig *config)
channel.attrib.mjpg.maxPic.height = config->height;
channel.attrib.mjpg.bufSize =
config->height * config->width * 2;
channel.attrib.mjpg.byFrame = 0;
channel.attrib.mjpg.byFrame = 1;
channel.attrib.mjpg.mainStrmOn = 1;
channel.attrib.mjpg.fieldOrFrame = 0;
channel.attrib.mjpg.priority = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@ int v4_sensor_init(char *name, char *obj)
if (v4_snr_drv.handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL))
break;
} if (!v4_snr_drv.handle)
HAL_ERROR("v4_snr", "Failed to load the sensor driver");
HAL_ERROR("v4_snr", "Failed to load the sensor driver\n");

if (!(v4_snr_drv.obj = (v4_snr_obj*)dlsym(v4_snr_drv.handle, obj)))
HAL_ERROR("v4_snr", "Failed to connect the sensor object");
HAL_ERROR("v4_snr", "Failed to connect the sensor object\n");

return EXIT_SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion src/hal/plus/cvi_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ static enum ConfigError cvi_parse_sensor_config(char *path, cvi_config_impl *con
enum ConfigError err;

// load config file to string
if (!open_config(&ini, path))
FILE *file = fopen(path, "r");
if (!open_config(&ini, &file))
return (enum ConfigError)-1;

find_sections(&ini);
Expand Down
Loading

0 comments on commit 738d9b4

Please sign in to comment.