cederom commented on code in PR #3033: URL: https://github.com/apache/nuttx-apps/pull/3033#discussion_r2010226471
########## benchmarks/mtd/CMakeLists.txt: ########## @@ -0,0 +1,33 @@ +# ############################################################################## +# apps/testing/fs/mtd_test/CMakeLists.txt Review Comment: apps/benchmarks/mtd/CMakeLists.txt ########## benchmarks/mtd/mtd.c: ########## @@ -0,0 +1,207 @@ +/**************************************************************************** + * apps/benchmarks/mtd/mtd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/stat.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include <nuttx/mtd/mtd.h> +#include <nuttx/fs/smart.h> +#include <nuttx/fs/ioctl.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, FAR char *argv[]) +{ + struct inode *inode; + struct timespec start; + struct timespec end; + struct mtd_geometry_s geo; + struct partition_info_s info; + int ret; + int x; + double elapsed_time; + double transfer_rate; + size_t total_bytes_written = 0; + size_t total_bytes_read = 0; + char *buffer; + + /* Argument given? */ + + if (argc < 2) + { + fprintf(stderr, "usage: mtd_test flash_block_device\n"); Review Comment: usage: mtd <flash_block_device> ? :-) ########## benchmarks/mtd/Makefile: ########## @@ -0,0 +1,34 @@ +############################################################################ +# apps/benchmarks/mtd/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +# MTD transfer rate test Review Comment: test -> benchmark ? ########## benchmarks/mtd/Kconfig: ########## @@ -0,0 +1,18 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config BENCHMARK_MTD + tristate "MTD transfer rate test" Review Comment: test -> benchmark? :-) ########## benchmarks/mtd/mtd.c: ########## @@ -0,0 +1,207 @@ +/**************************************************************************** + * apps/benchmarks/mtd/mtd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/stat.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include <nuttx/mtd/mtd.h> +#include <nuttx/fs/smart.h> +#include <nuttx/fs/ioctl.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, FAR char *argv[]) +{ + struct inode *inode; + struct timespec start; + struct timespec end; + struct mtd_geometry_s geo; + struct partition_info_s info; + int ret; + int x; + double elapsed_time; + double transfer_rate; + size_t total_bytes_written = 0; + size_t total_bytes_read = 0; + char *buffer; + + /* Argument given? */ + + if (argc < 2) + { + fprintf(stderr, "usage: mtd_test flash_block_device\n"); + return -1; + } + + /* Find the inode of the block driver identified by 'source' */ + + ret = open_blockdriver(argv[1], 0, &inode); + if (ret < 0) + { + fprintf(stderr, "Failed to open %s\n", argv[1]); + return ret; + } + + /* Get the low-level format from the device. */ + + ret = inode->u.i_bops->ioctl(inode, BIOC_PARTINFO, (unsigned long) &info); + if (ret != OK) + { + fprintf(stderr, "Device is not a block device\n"); + goto errout_with_driver; + } + + /* Get the MTD geometry */ + + ret = inode->u.i_bops->ioctl(inode, MTDIOC_GEOMETRY, (unsigned long) &geo); + if (ret != OK) + { + fprintf(stderr, "Device is not a MTD device\n"); + goto errout_with_driver; + } + + /* Report the device structure */ + + printf("FLASH Test on device with:\n"); Review Comment: FLASH device parameters: ? ########## benchmarks/mtd/Kconfig: ########## @@ -0,0 +1,18 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config BENCHMARK_MTD + tristate "MTD transfer rate test" + default n + depends on BUILD_FLAT && MTD + ---help--- + This testing application performs an erase/write operation to + evaluate write transfer rate and then reads the written content + back to evaluate the read transfer rate. Finally, it compares + the read data with the previously written data to ensure the + MTD device is working as expected. + + NOTE: This test uses internal OS interfaces and so it is not Review Comment: test -> application ? ########## benchmarks/mtd/Kconfig: ########## @@ -0,0 +1,18 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config BENCHMARK_MTD + tristate "MTD transfer rate test" + default n + depends on BUILD_FLAT && MTD + ---help--- + This testing application performs an erase/write operation to Review Comment: testing -> benchmark? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org