Skip to content

Commit

Permalink
k230 canmv release v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed Nov 23, 2023
1 parent dc2656a commit 9aa8938
Show file tree
Hide file tree
Showing 193 changed files with 39,697 additions and 1,497 deletions.
185 changes: 159 additions & 26 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ variables:
HW_MODEL: canmv
HW_VER: v0.1
TFTP_BASE: /data1/tftp_server
NFS_BASE: /data/nfs_server
NFS_SERVER: 10.10.1.94
GITLAB_REPO: [email protected]:maix_sw/k230_canmv.git
GITHUB_REPO: [email protected]:kendryte/k230_canmv.git
GITEE_REPO: [email protected]:kendryte/k230_canmv.git
Expand Down Expand Up @@ -224,6 +226,26 @@ tag_sync:
- echo "---save sdk build output---"
- sudo cp -rf --sparse=always ${SRC_DIR}/ ${DST_DIR}/${SUB_DIR}/
- echo "${DST_DIR}/${SUB_DIR}/"
- |
echo "check linux and rtsmart should be enable at the same time to cp mpp/cdk demo"
config_rtsmart=$(cat ./configs/${CONF} | grep 'CONFIG_SUPPORT_RTSMART=y' || true)
config_linux=$(cat ./configs/${CONF} | grep 'CONFIG_SUPPORT_LINUX=y' || true)
if [[ -n "$config_rtsmart" ]] && [[ -n "$config_linux" ]];
then
sudo mkdir -p ${DST_DIR}/${SUB_DIR}/sdk_testcase/ || exit 1
echo "---save sdk testcase output---"
mkdir -p sdk_testcase/app_demo/
cp -rf --sparse=always ./src/big/mpp/userapps/sample/elf/* ./sdk_testcase/app_demo/
cp -rf --sparse=always ./src/common/cdk/user/out/big/* ./sdk_testcase/app_demo/
tree ./sdk_testcase/
echo "---compress sdk_testcase dir---"
tar -zcf k230_testcase_${SUB_BASE}.tar.gz ./sdk_testcase/ || exit 1
echo "---save zip file---"
sudo cp -rf --sparse=always k230_testcase_${SUB_BASE}.tar.gz ${DST_DIR}/${SUB_DIR}/sdk_testcase/
else
echo "current config only support linux or only support rtsmart ,skip cp mpp/cdk demo"
fi
- echo "${DST_DIR}/${SUB_DIR}/"
- ls "${DST_DIR}/${SUB_DIR}/"
- echo "add latest link for current build"
- test -h ${DST_DIR}/latest && sudo rm ${DST_DIR}/latest
Expand Down Expand Up @@ -291,7 +313,7 @@ tag_sync:
- test -f ./bin/ailab && rm -rf ./bin/ailab
- wget -qc https://ai.b-bug.org/k510/downloads/github/ailab -O ./bin/ailab
- chmod +x ./bin/ailab
- available=$(./bin/ailab show --dest available --domain ai --hw_type ${HW_TYPE} --hw_model ${HW_MODEL} --hw_ver ${HW_VER} --format args)
- available=$(./bin/ailab show --dest available --domain ${TEST_ENV} --hw_type ${HW_TYPE} --hw_model ${HW_MODEL} --hw_ver ${HW_VER} --format args)
- echo ${available}
- >
if [[ $available =~ "k230" ]]; then
Expand Down Expand Up @@ -417,6 +439,112 @@ tag_sync:
echo "---finished load image in loop $i"
- echo "---load image pass"
- echo "----------load image to test device done----------"
copy_test_resource:
- echo "----------Step 5. copy test resource----------"
- echo "get build step result"
- echo $sdk_path
- echo $image_path
- echo $utest_path
- echo $ai_poc_path
- echo $fancy_poc_path
- echo $SUB_BASE
- pwd
- |
echo "---get utest floder without build or with build---"
if [[ -z $utest_path ]]; then
echo "k230 utest NOT build in current job, use latest utest daily build"
echo "get latest K230 utest"
utest_ver=$(ls -alht /data1/k230/dev-release/utest/latest | awk -F '/' '{print $11}')
utest_dir=$(ls -alht /data1/k230/dev-release/utest/latest | awk -F '-> ' '{print $2}')
ls -alht $utest_dir || exit 1
utest_path="$utest_dir/k230_utest_${utest_ver}.tar.gz"
echo "---use latest utest path: $utest_path"
echo "---use latest utest ver: $utest_ver"
else
echo "k230 utest already build and exist in current job"
utest_ver=$SUB_BASE
echo "---use current utest path: $utest_path"
echo "---use current utest ver: $utest_ver"
fi
- echo "---get nfs case floder---"
- |
echo ${NFS_BASE}
echo "set NFS_DST_DIR with different type based on docs/images/src"
NFS_DST_DIR="${NFS_BASE}/${HW_TYPE}/${HW_MODEL}_${HW_VER}"
echo ${NFS_DST_DIR}
echo "---create NFS dir---"
echo "generate sub dir for MR/Pre-releae/relese job"
echo "check job from MR or tag or schedule or web"
sdk_testcase_copy="NO"
if [[ ${CI_MERGE_REQUEST_IID} ]]; then
echo "current job is MR, skip and use CI_MERGE_REQUEST_IID"
echo "set MR flag for sdk_testcase copy"
sdk_testcase_copy="YES"
elif [[ ${CI_COMMIT_TAG} ]]; then
echo "current job is release job, use CI_COMMIT_TAG"
CI_MERGE_REQUEST_IID=${CI_COMMIT_TAG}
elif [[ $CI_PIPELINE_SOURCE == "schedule" ]]; then
echo "current job is daily build schedule job, use CI_PIPELINE_SOURCE"
CI_MERGE_REQUEST_IID=$CI_PIPELINE_SOURCE
else
echo "current job is not match, use CI_PIPELINE_SOURCE"
CI_MERGE_REQUEST_IID=$CI_PIPELINE_SOURCE
fi
echo "current MR ID ${CI_MERGE_REQUEST_IID}"
SUB_DIR="${CI_MERGE_REQUEST_IID}_${CI_PIPELINE_ID}";
NFS_CASE_FOLDER="${NFS_DST_DIR}/${SUB_DIR}/${TEST_ENV}"
echo "NFS_CASE_FOLDER: $NFS_CASE_FOLDER"
echo "update current NFS_CASE_FOLDER permission before write"
sudo mkdir -p ${NFS_CASE_FOLDER} || exit 1
sudo chmod -R 777 ${NFS_CASE_FOLDER} || exit 1
- echo "---copy test resource to nfs dir in nfs_server"
- mkdir -p $NFS_CASE_FOLDER/output || exit 1
- sudo chmod -R 777 $NFS_CASE_FOLDER/output || exit 1
#- test -h $NFS_CASE_FOLDER/resource && rm -rf $NFS_CASE_FOLDER/resource
#- ln -s $NFS_BASE/$HW_TYPE/resource $NFS_CASE_FOLDER/resource || exit 1
- time cp -rf --sparse=always $NFS_BASE/$HW_TYPE/resource $NFS_CASE_FOLDER/resource
- echo "unzip utest file to nfs dir in nfs_server"
- cd $NFS_CASE_FOLDER/ || exit 1;
- ls $utest_path || exit 1
- time tar -zxf $utest_path || exit 1
- ls -alht || exit 1
- |
if [[ -d "testcase" ]]; then
echo "testcase dir exist, skip rename and continue"
elif [[ -d "utest" ]]; then
echo "testcase not exist and utest exist, rename utest dir to testcase"
mv -f utest testcase || exit 1
else
echo "utest and testcase dir not exit, return error and exit"
exit 1
fi
- echo "confirm testcase dir again"
- ls -alht testcase || exit 1
- |
echo "copy sdk testcase for MR smoke test"
if [[ "$sdk_testcase_copy" == "YES" ]]; then
echo "current job is MR, copy sdk_testcase from image path"
echo $image_path || exit 1
echo "get testcase full path"
ls $image_path/$DEFAULT_CONF/sdk_testcase/ |grep k230_testcase
sdk_testcase_name=$(ls $image_path/$DEFAULT_CONF/sdk_testcase/ |grep k230_testcase)
echo $sdk_testcase_name || exit 1
time tar -zxf $image_path/$DEFAULT_CONF/sdk_testcase/$sdk_testcase_name || exit 1
else
echo "current job is not MR, skip copy sdk testcase"
fi
- echo "show test resource in nfs_server"
- tree $NFS_CASE_FOLDER
- cd -
- pwd
- echo "finished copy test resource in nfs_server"
- echo "----------Step 6. generate test device yml file for test job----------"
- ./bin/ailab convert --dest=script --format yaml --file_name=${TEST_ENV}.yml --nfs_server_ip $NFS_SERVER --nfs_case_folder $NFS_CASE_FOLDER ${available}
- test -f ${TEST_ENV}.yml || exit 1
- echo "cp ${TEST_ENV}.yml to nfs_case_folder for NUC remote PC audio job"
- cp -rf --sparse=always ${TEST_ENV}.yml $NFS_CASE_FOLDER/ || exit 1
- test -f $NFS_CASE_FOLDER/${TEST_ENV}.yml || exit 1

smoke_test:
- echo "----------Run Smoke Test start----------"
- test -d bin || mkdir ./bin
Expand All @@ -425,8 +553,11 @@ tag_sync:
- chmod +x ./bin/airobot
- test -f ./k230.robot && rm -rf ./k230.robot
- wget -qc https://ai.b-bug.org/k510/downloads/github/k230.robot -O ./k230.robot
- ./bin/ailab convert --dest=script --format yaml --file_name=k230.yml ${available}
- test -f k230.yml || exit 1
- ./bin/ailab convert --dest=script --format yaml --file_name=${TEST_ENV}.yml --nfs_server_ip $NFS_SERVER --nfs_case_folder $NFS_CASE_FOLDER ${available}
- test -f ${TEST_ENV}.yml || exit 1
- echo "cp ${TEST_ENV}.yml to nfs_case_folder for NUC remote PC audio job"
- cp -rf --sparse=always ${TEST_ENV}.yml $NFS_CASE_FOLDER/ || exit 1
- test -f $NFS_CASE_FOLDER/${TEST_ENV}.yml || exit 1
- echo ""----------Run smoke test start"----------"
- |
echo "---start to run smoke test in for loop"
Expand Down Expand Up @@ -600,26 +731,28 @@ build_image:
reports:
dotenv: build.env

# test setup for all jobs
# load_image_smoke_test:
# stage: load_test
# rules:
# # MR job
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# # release job
# - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^v\d+\.\d+.*$/
# # pre-release job
# - if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG =~ /^v\d+\.\d+.*$/
# # manual job
# - if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG !~ /^v\d+\.\d+.*$/
# # daily build
# - if: $CI_PIPELINE_SOURCE == "schedule"
# timeout: 30m
# script:
# - *show_vars
# - *check_build_result
# - !reference [.test, test_setup]
# - !reference [.test, load_image]
# #- !reference [.test, smoke_test]
# after_script:
# - !reference [.test, test_teardown]
#test setup for all jobs
load_image_smoke_test:
stage: load_test
variables:
TEST_ENV: ai
rules:
# MR job
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
# release job
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^v\d+\.\d+.*$/
# pre-release job
- if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG =~ /^v\d+\.\d+.*$/
# manual job
- if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG !~ /^v\d+\.\d+.*$/
# daily build
- if: $CI_PIPELINE_SOURCE == "schedule"
timeout: 30m
script:
- *show_vars
- *check_build_result
- !reference [.test, test_setup]
- !reference [.test, load_image]
#- !reference [.test, smoke_test]
after_script:
- !reference [.test, test_teardown]
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ micropython: k230_sdk_build
.PHONY: build-image
build-image: micropython
@cp -r tests $(K230_CANMV_BUILD_DIR)/images/app
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_detection_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/nncase_runtime/face_detection
@mkdir -p $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_recognition.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_detection_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n_seg_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/LPD_640.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/ocr_det_int16.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/hand_det.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_landmark.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_pose.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_parse.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/LPD_640.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/licence_reco.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/handkp_det.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/ocr_rec_int16.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/hand_reco.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/person_detect_yolov5n.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n-pose.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/kws.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_alignment.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_alignment_post.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@make -C k230_sdk build-image

.PHONY: micropython-clean
Expand All @@ -121,4 +143,4 @@ k230_sdk-clean:
@rm -f $(K230_CANMV_BUILD_DIR)/.k230_sdk_all

.PHONY: clean
clean: micropython-clean k230_sdk-clean
clean: micropython-clean k230_sdk-clean
2 changes: 1 addition & 1 deletion k230_sdk
Submodule k230_sdk updated 1591 files
5 changes: 2 additions & 3 deletions k230_sdk_overlay/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ prepare_toolchain: extract_toolchain
.PHONY: prepare_sourcecode check_toolchain
prepare_sourcecode:prepare_toolchain
@echo "prepare source code"
@cd $(UNITTEST_SRC_PATH);cp -rf testcases ../rt-smart/userapps;cd -
#ai
@echo "download nncase sdk"
@rm -rf src/big/utils/; rm -rf src/big/ai;
@wget -q --show-progress $(DOWNLOAD_URL)/downloads/kmodel/kmodel_v2.3.0.tgz -O - | tar -xzC src/big/
@wget -q --show-progress $(DOWNLOAD_URL)/downloads/nncase/nncase_k230_v2.3.0.tgz -O - | tar -xzC src/big/
@wget -q --show-progress $(DOWNLOAD_URL)/downloads/kmodel/kmodel_v2.4.0.1.tgz -O - | tar -xzC src/big/
@wget -q --show-progress $(DOWNLOAD_URL)/downloads/nncase/nncase_k230_v2.4.0.tgz -O - | tar -xzC src/big/

#big utils
@echo "download big utils"
Expand Down
5 changes: 3 additions & 2 deletions k230_sdk_overlay/board/common/env/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ kernel_addr=0xc100000
loadaddr=0xc000000
mmc_boot_dev_num=0
netmask=255.255.255.0
ramdisk_addr=0xa100000
ramdisk_addr=0x8200000
serverip=10.10.1.94
upsdimg=usb start; dhcp; tftp 0x9000000 10.10.1.94:wjx/sysimage-sdcard.img.gz;gzwrite mmc 1 0x$fileaddr 0x$filesize;
upsduboot=usb start; dhcp; tftp 0xc100000 10.10.1.94:wjx/u-boot.img && mmc dev 1; mmc write 0x$fileaddr 0x1000 0xc00;
upspiimg=usb start; dhcp; tftp 0x9000000 10.10.1.94:wjx/sysimage-spinor32m.img;sf probe 0:0;sf erase 0 0x2000000;sf write 0x$fileaddr 0 0x$filesize; sf remove;
upspiuboot=usb start; dhcp; tftp 0xc100000 10.10.1.94:wjx/u-boot.img && sf probe 0:0;sf erase 0x80000 0x180000; sf update 0x$fileaddr 0x80000 0x$filesize; sf remove;
usb_load=usb start; dhcp; tftp $ramdisk_addr jiangxiangbing/rtt_system.bin; k230_boot mem $ramdisk_addr 0x$filesize; tftp $kernel_addr jiangxiangbing/fw_payload.img;tftp $ramdisk_addr jiangxiangbing/rootfs-final.cpio.gz;tftp $dtb_addr jiangxiangbing/k230.dtb
vendor=canaan
bootargs=loglevel=8 rw console=ttyS0,115200 crashkernel=256M-:128M earlycon=sbi;
bootargs=loglevel=8 rw console=ttyS0,115200 earlycon=sbi;

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image app.vfat {
}
}
# empty =true
size = 64M
size = 1024M
}

image sysimage-sdcard.img {
Expand Down
Binary file added k230_sdk_overlay/src/big/mpp/kernel/lib/libvo.a
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct usbd_interface intf2;
void cdc_acm_msc_init(void)
{
rt_sem_init(&cdc_read_sem, "cdc/read", 0, RT_IPC_FLAG_FIFO);
rt_sem_init(&cdc_write_sem, "cdc/write", 1, RT_IPC_FLAG_FIFO);
rt_sem_init(&cdc_write_sem, "cdc/write", 0, RT_IPC_FLAG_FIFO);
usbd_desc_register(cdc_msc_descriptor);
usbd_add_interface(usbd_cdc_acm_init_intf(&intf0));
usbd_add_interface(usbd_cdc_acm_init_intf(&intf1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static void dcd_int_handler_wrap(int irq, void *param)
struct rt_device g_cdc_rt_device;
volatile int g_cdc_mask = 0;
struct rt_semaphore cdc_read_sem, cdc_write_sem;
struct rt_mutex cdc_write_mutex;
extern volatile char ep_tx_busy_flag;
volatile size_t actual_bytes = 0;
static bool last_rts = false;
Expand Down Expand Up @@ -95,30 +96,11 @@ static int cdc_write(struct dfs_fd *fd, const void *buf, size_t count) {
if (count == 0) {
return 0;
}
static void* hold_buffer = NULL;
// FIXME
rt_err_t error = rt_sem_take(&cdc_write_sem, 100);
if (error == RT_ETIMEOUT) {
return 0;
} else if (error != RT_EOK) {
return -1;
}
if (hold_buffer != NULL) {
rt_free(hold_buffer);
}
hold_buffer = rt_malloc(count);
rt_memcpy(hold_buffer, buf, count);
#if 0
rt_kprintf("write:");
for (size_t i = 0; i < count; i++) {
rt_kprintf("\\x%02X", ((unsigned char*)buf)[i]);
}
rt_kprintf("\n");
#endif
usbd_ep_start_write(CDC_IN_EP, hold_buffer, count);
rt_mutex_take(&cdc_write_mutex, RT_WAITING_FOREVER);
usbd_ep_start_write(CDC_IN_EP, buf, count);
rt_err_t error = rt_sem_take(&cdc_write_sem, RT_WAITING_FOREVER);
rt_mutex_release(&cdc_write_mutex);
// FIXME: async
// usleep(10000);
// rt_sem_take(&cdc_write_sem, RT_WAITING_FOREVER);
return count;
}

Expand Down Expand Up @@ -150,6 +132,8 @@ void usb_dc_low_level_init(void)
rt_hw_interrupt_install(173, dcd_int_handler_wrap, NULL, "usb");
rt_hw_interrupt_umask(173);

rt_mutex_init(&cdc_write_mutex, "cdc/write", RT_IPC_FLAG_FIFO);

// CDC uart
rt_err_t err = rt_device_register(device, DEV_NAME, RT_DEVICE_OFLAG_RDWR);
if (err != RT_EOK) {
Expand Down Expand Up @@ -233,6 +217,7 @@ void usb_dc_low_level_deinit(void)
rt_hw_interrupt_mask(173);
rt_sem_detach(&cdc_read_sem);
rt_sem_detach(&cdc_write_sem);
rt_mutex_detach(&cdc_write_mutex);
}

void usb_hc_low_level_init(void)
Expand Down
Loading

0 comments on commit 9aa8938

Please sign in to comment.