Other Parts Discussed in Thread: AM5728
Tool/software: Linux
Hello,
Is it possible to confirm the timing I am getting on Linux RT 03.03.00.04.
A thumb drive that looks like a USB 2 is connected to the IDK USB1 slot, which is a USB 3 connector.
Using clock_gettime(), which has nanosecond timing to find the length of time to write 1,000,000 ( 1 million) bytes to a file on the thumb drive. I have also been using the Linux 'time' command to confirm that my timing code was correct.
I am getting about 800 Mbits/second. I tried this on a desktop Ubuntu machine and getting 82 to 110 Mbits/second using the same thumb drive. And the read is still faster at up to 2700 Mbits/second. What I can find on the USB 2 specification says 480 Mbits/sec maximum. This appears to indicate a possible error in the clock information in the IDK AM5728 Linxu RT configuration.
I used the following code using the open, write, and close functions.
-----------------------------------------------------------
/*
file_write_test.c
An attempt to time the writing to a file on a USB flash drive
that is mounted as a file directory partition.
This creates a file.
*/
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
//################################################
// Globals
#define ARRLEN 1000000
//################################################
//
// FUNCTIONS
float timespecDiff(struct timespec *timeA_p, struct timespec *timeB_p)
{
return (float) ((float) timeA_p->tv_sec + (float) (timeA_p->tv_nsec / 1000000000.0)) - ((float) timeB_p->tv_sec + (float) (timeB_p->tv_nsec / 1000000000.0));
}
//################################################
//
// MAIN
int main() {
unsigned char txbytes[ARRLEN + 1];
int i;
struct timespec start, end; // Timing in seconds and nanoseconds
float elapsed;
// Puts some hex values in the array.
for (i = 0; i < ARRLEN; i++)
{
txbytes[i] = (i % 10) + 48;
//printf("\n\ttxbytes value: %c", txbytes[i]);
}
//printf("\n");
//fflush(stdout);
// Start timing
clock_gettime(CLOCK_MONOTONIC, &start);
int fd = open("/media/user01/UBUNTU 14_0/zfile001.txt", O_RDWR | O_CREAT);
// Start timing
write(fd, txbytes, ARRLEN);
// Get amount of time to write to the newly opened and created file.
close(fd);
clock_gettime(CLOCK_MONOTONIC, &end);
// Get read time difference
elapsed = timespecDiff(&end, &start);
fprintf(stderr, "\nElapsed time = %f seconds", elapsed);
fprintf(stderr, "\nThe write rate is: %f bits/sec.\n\n", (float) (ARRLEN*8)/elapsed);
return 0;
}