Show Posts
Pages: 1 ... 55 56 [57] 58 59 ... 111
841  Products / Arduino Due / Happiness is SdFat with DMA SPI on: November 27, 2012, 10:53:57 am
I decided to implement DMA SPI for SdFat on Due.  I couldn't be more pleased with the results!

Here are bench.ino results for very large, 32 KB, reads and writes with this class 4 Sandisk 8 GB card:

Type is FAT32

File size 40MB
Buffer size 32768 bytes
Starting write test.  Please wait up to a minute
Write 3835.82 KB/sec
Maximum latency: 45560 usec, Minimum Latency: 7815 usec, Avg Latency: 8538 usec

Starting read test.  Please wait up to a minute
Read 4324.64 KB/sec
Maximum latency: 12697 usec, Minimum Latency: 7495 usec, Avg Latency: 7576 usec

The Arduino standard SD.h library is based on a very old version of SdFat that I tried to keep small enough to run on 168 AVR processors.

After some patching to make the standard SD.h library work with 32 KB reads I get this result on Due with the above SD card:

Type is FAT32

File size 40MB
Buffer size 32768 bytes
Starting write test.  Please wait up to a minute
Write 229.87 KB/sec
Maximum latency: 805951 usec, Minimum Latency: 130704 usec, Avg Latency: 142545 usec

Starting read test.  Please wait up to a minute
Read 434.30 KB/sec
Maximum latency: 77666 usec, Minimum Latency: 72686 usec, Avg Latency: 75448 usec

Happiness is a factor of 16 in write speed and a factor of nearly 10 in read speed over the standard SD library.

I am running SPI at 42 MHz.  I built an SD shield with very short wire connecting the SD socket directly to the ISP connector.
842  Using Arduino / Storage / Re: Power consumption to write to SD card? on: November 25, 2012, 10:03:48 am
You won't get the answer with a DMM.  The max current occurs while flash is being programmed.  This is a brief interval and occurs at random times determined by the SD card's flash controller.  A DMM is too slow to measure this.

80 ma is common for consumer uSD cards.

Plan on 100 ma.  Some cards hit 150 ma peak for 10 us so good bypass caps are needed.

Some older SDHC cards require 200 ma for write.
843  Using Arduino / Storage / Re: How to work SD Library's "CardInfo" Program? on: November 24, 2012, 10:03:54 pm
A 168 is too small.
844  Development / Other Software Development / Re: RTOS candidates for Cortex M3/M4 duino boards. on: November 24, 2012, 09:55:01 pm
FreeRTOS can be used in commercial products  You must pay for the version called OpenRTOS.

There is also a free version of ChibiOS that can be used in commercial products  ChibiOS also has a non-free version.

I have looked at Contiki and at first glance it didn't look easy to port it as an Arduino library.  I haven't ruled it out and will study it more.
845  Using Arduino / Storage / Re: Second time i read dir arduino halts on: November 24, 2012, 09:21:53 pm
There are several problems.  The most serious is
String files [1][3];
may used with bad indicies here:
It looks like j could be one and i could be three.

Another problem is that the File wrapper for SdFat uses malloc so this assignment causes a memory leak unless you close entry. 
    entry =  root.openNextFile();
I didn't write the SD.h wrapper so you you nee to post this problem on the Arduino issues site.

There are other problems like you using the SD object and Sd2Card and SdVolume.  SD already has an instance of Sd2Card and SdVolume.

I stopped looking after I found these problems.
846  Products / Arduino Due / Re: Disappointing SPI performance with SdFat on: November 24, 2012, 03:30:07 pm

I understand the problem is with the library.  I want to use the standard SPI library since it's a pain to maintain my own SPI layer for every chip that runs SdFat.  Also, my SPI functions may not play well with the standard SPI library.

I would like to see optimized functions in the SPI library for sending and receiving blocks of data.


I don't have a Maple version of SdFat with the new caching improvements for large memory chips.  Others have ported old versions of SdFat to Maple but these are slow.
847  Products / Arduino Due / Disappointing SPI performance with SdFat on: November 24, 2012, 12:47:44 pm
My Arduino Due finally arrived and I started testing SdFat.

The results are disappointing since the standard SPI library is slow.  I used an SPI clock of 42 MHz.

When I run the SdFat bench example with large 4096 byte reads and writes, the results are just a little slower than the same test on an AVR Mega with an 8 MHz clock.  The Mega is fast since I wrote optimized SPI functions for AVR.  The maximum read/write rates are about 600 KB/sec for a high quality industrial SD.

I checked with a scope on the Due's SCK and the result is that a byte is transferred in about 200 ns then there is a gap of about 1250 ns until the next byte.

The Due SPI library needs optimized block read/write functions.

On Teensy 3.0 I get over three times the performance of Due.  This is with an 24 MHz SPI clock on Teensy 3.0.

The maximum read/write rate is over 2 MB/sec on Teensy 3.0.  Due should be faster with a 42 MHz clock.

848  Development / Other Software Development / Re: RTOS candidates for Cortex M3/M4 duino boards. on: November 23, 2012, 12:29:04 pm
The classroom version of using state machines is great.  In practice not so much.

The idea is that you design with something like UML state diagrams.  Once you totally understand the problem, you implement the solution possibly with the help of some tools.  You then live happily ever after.

The problem is that you never understand the real world while you are drawing state charts.  Systems evolve and the real world is messy.

The end result is that the code to implement state machines is not readable so you need or should go back to the design documents to make changes.

This just doesn't work well in the development of large embedded systems.

This article, that is selling a tool for state machines, hits on a lot of the problems but this type of tool doesn't solve them in the real world.

At one point I was a principal in a start-up company that promoted a state machine approach to embedded systems.  After leaving the company I went back to building large embedded systems for big science projects.  I found once again that tools like QP are not nearly as important as fundamental knowledge of the problem to be solved.  Having a PhD in physics trumps use of any tool when you are dealing with a Large Hadron Collider.
849  Development / Other Software Development / RTOS candidates for Cortex M3/M4 duino boards. on: November 20, 2012, 12:53:29 pm
I have ported ChibiOS/RT and FreeRTOS to Teensy 3.0 as libraries.  This allows mixing Teensy software with RTOS functions.

I am now working on ports for Due. It looks like Due will also be able to support these RTOSs as Arduino libraries.

I am also looking at other possible RTOS candidates.  Here are my criteria for candidates.
Active development

Supports Cortex M3/M4

Open Source

Free version available

OS Website has forum with activity

Here is my current list of candidates.  Some of these would not be easy to port to Due.


CooCox CoOS





First, are there other good candidates that satisfy the above criteria?

Second, what features would other RTOSs have that are not covered by ChibiOS/RT and FreeRTOS?

Clearly QP is different since it is state-machine based.  In the past I was a fan of state-machines in embedded systems but I am less enthusiastic now.

It's interesting that after making the above list, I found this list  It has many of the same systems.
850  Products / Arduino Due / Re: RTOS hooks on: November 20, 2012, 11:16:31 am


I understand this may not be supported in the future or may change.

Soon after I get my Due, I will post a version of ChibiOS/RT and FreeRTOS for Due with a number of examples.

I also have a version of SdFat ready for testing.  I have optimized it for chips with large memory.

I wish there were fast native SPI functions for reading and writing blocks of memory on Due.  On Teensy 3.0 with 24 MHz native SPI I get file read and write rates over 2 MB/sec for large reads and writes.  Due should be even faster but I plan to use the official SPI library
851  Products / Arduino Due / Re: RTOS hooks on: November 19, 2012, 06:54:09 pm

That sounds great.  Teensy 3.0 has these three weak handlers, SVC_Handler, PendSV_Handler, and SysTick_Handler.

The only question is how to handle SysTick.  In Teensy 3.0 I replace the handler with one that that duplicates the Teensy 3.0 functionality and the RTOS needs.

I want the standard Arduino functionality to continue to work and have the option for a few high priority tasks and ISRs to use the RTOS functionality.

This way an ISR can cause a high priority task to execute in about 3 microseconds while loop() does low priority stuff like a normal Arduino sketch.
852  Products / Arduino Due / RTOS hooks on: November 18, 2012, 07:17:02 pm
It would be nice to have hooks in Due so popular RTOSs could be ported to Due as libraries.

The main requirement is to have access to the SVC_Handler, PendSV_Handler, and SysTick_Handler vectors.

A call to a weak dummy function at the end of these handles would be sufficient.  Currently SVC_Handler and PendSV_Handler are just for() loops that stop execution.

I understand that full preemptive RTOSs are not appropriate for most Arduino users but a few advanced users want the functionally of a full RTOS.

There are a lot of first class open source RTOSs that would run well on Due.

Paul Stoffregen provided these hooks for Teensy 3.0 and I ported ChibiOS/RT and FreeRTOS to Teensy 3.0 using these hooks.  I may port additional systems since I enjoy seeing how RTOSs are implemented and how they perform. 

I would like to provide these libraries to Due users in a way that would not require modification of the Arduino core.
853  Products / Arduino Due / Re: Mutex for task scheduler. on: November 17, 2012, 06:37:40 pm
Why not do a well designed kernel instead of growing it by software sprawl.  We have yield(), wait(), maybe Time-Triggered Cooperative (TTC) scheduling, a mutex, a way to wake a thread from an isr. Finally you will have the functionality of a true OS.

I started my career developing an OS for early multiprocessor supercomputers, CDC 6600 and others, in the late 1960s.  I have watched this haphazard growth of the OS happen at each level of computer, mainframe, minicomputer, PC, single board computer, single chip processors, ....

Now Arduino is doing the same drill.

854  Development / Other Software Development / Re: ChibiOS/RT and FreeRTOS for Teensy 3.0 on: November 17, 2012, 09:41:01 am
I have been posting additional information about use of these RTOSs here
855  Development / Other Software Development / ChibiOS/RT and FreeRTOS for Teensy 3.0 on: November 16, 2012, 11:29:09 am
I have posted a first beta of two Real Time Operating System kernels for Teensy 3.0 as

These systems are packaged as Arduino libraries so they can be used with other Arduino software. Since these are preemptive kernels, careful design is required to avoid problems with normally single-threaded Arduino software.

These RTOSs must be used with the beta8 version of the Teensy 3.0 software.

ChibiOS/RT is version 2.4.2

FreeRTOS is version 7.3.0

Warning: If this is your first use of a RTOS, you will likely experience the pain of my bugs and problems that are inherent to preemptive RTOSs. Please read the warnings in the included html documentation.

Four examples are included with each system. These example are described in the html included with the libraries.
Pages: 1 ... 55 56 [57] 58 59 ... 111