Storage
Ejecting SD Card or USB Storage Device
If the camera is powered on, before removing a storage device, you should first eject (unmount) the storage device before removing it. Press the web UI icon to display the eject storage modal.
Downloading captured videos and metadata files
There are many ways to download your videos.
- Web UI download button
- A web browser to access the list of all captured videos and metadata files by browsing to the URL - http://10.11.12.13/static/mnt/sdcard/DCIM
- WebDAV and your computer's file browser -- Explorer on Windows and Finder on macOS
- FTP. The camera runs an FTP server. Videos are typically stored in the /mnt/sdcard/DCIM directory.
Deleting all files
After inserting the SD card or USB thumb drive into your laptop computer, you can use the file browser (called File Explorer in Windows and Finder on the Mac) to select and delete all files. Be sure to unmount the storage device after deleting the file and waiting 20 seconds after you think it is safe to remove the storage device before actually removing the storage device from your laptop.
Formatting SD Card or USB Storage Device
If you plan to reformat the card, the file system needs to be the FAT32 (also called VFAT) file system. I have read you should avoid re-formatting SD cards because the layout used by the SD card manufacturer for the VFAT file system in done in a way that optimizes the FAT (File Allocation Table) to a region of storage that is much faster than the rest of the storage area on the SD card. I have no idea if this is still true, but it is now part of my lore.
I recommend re-formatting the SD card only when you are getting errors read or writing the SD card. You will also need to reformat if your storage card is larger than 32 Gbytes.
Windows Formatting
You need to use a different tool to format a storage device larger than 32GB. John, an edgertronic camera user, had good luck with Rufus for Windows). I have never used Rufus. Another edgertronic camera user, Adeola, recommends guiformat. I haven't used guiformat either.
On Windows (for storage devices up to 32 GB):
- Insert the SD card or USB storage device
- In Explorer, right mouse click on the SD card or USB storage device shown in the left pane of the Explorer window
- Select Format from the drop down list of choices
- Make sure the File system is set to FAT32
- Press the start button
- In Explorer, right mouse click on the SD card or USB storage device shown in the left pane of the Explorer window
- Select Eject from the drop down list of choices
Wait 20 seconds after you think it is safe to remove the storage device before actually removing it.
Mac OSX Formatting
On an OSX system (for storage devices up to 32 GB),
- Run Spotlight to launch Disk Utility
- In Spotlight,
- Select the external storage device (likely named NO NAME)
- At the top center of the window, click on Erase
- Make sure the Format box has MS-DOS (FAT) select
- Press the Erase button
- Wait for the formatting to complete
- At the top center of the window, click on Unmount
Wait 20 seconds after you think it is safe to remove the storage device before actually removing it.
Which SD card should I buy
There are several factors to consider, with reliability being most important for use cases where an experiment can not be easily repeated. If you are taking many videos, such as every pitch in a baseball game, then capacity might be your key consideration. If you are impatient, then make sure your SD card is fast enough that it will not increase the video save time.
Reliability
All flash memory devices, including SD cards, have a limited number of times they can be erased and rewritten (Write Endurance Cycles), and in general. flash technologies with greater write endurance are more expensive and have lower capacity. To extend the useful life of an SD card, the processor built into each card supports wear leveling so that when small regions of the card fail, the overall card performs reliability.
Typical consumer grade Triple Level Cell (TLC) SD cards are the lowest cost and have a write endurance of around 300 cycles. A heavy use case like baseball training could wear out a TLC SD card in 1-2 years.
Industrial SD cards that have Single Level Cell (SLC) or Pseudo Single Level Cell (pSLC) technology have the highest write endurance (>10K cycles) but are very expensive and hard to find in 32GB capacity.
Swissbit and Delkin make MLC industrial cards that feature 3K write endurance and are the best choice for edgertronic users that expect to fill up and erase the SD card a few hundred times per year.
Capacity
The edgertronic camera was designed and tested to use SDHC cards. SDHC cards have a maximum capacity of 32 GBytes.
My experience is the camera works fine with larger capacity SDXC cards, but you must format the card (as described above). If you try SD card larger than 32 Gbytes and run into problems after you reformat the card, please let us know.
SDXC card
The TI DM368 processor inside the edgertronic camera was designed to support SDHC (up to 32G) cards. The SDXC standard wasn't released until after the DM368 was released. Therefore, we say the edgertronic camera was designed and tested to use SDHC cards (and not SDXC cards).
The only electrical difference I can find between SDHC and SDXC is maximum bus speed, which shouldn't affect compliance if we run at the DM368 support speeds.
The big difference is SDXC cards come preformatted with exFAX, which the edgertronic camera does not support. You need to reformat SDXC cards to use FAT32 files system (as described above).
You will not hurt the camera using SDXC. We have not done extensive testing, so there is a chance you will lose captured videos. My guess it using reformatted SDXC cards will work just fine.
Can I use a 256G SD card
The official company-line, don't complain to us, answer is: no, only SD cards up to 32G are supported. But will a 256G SD card work, you ask. So I bought a 256G Samsung Evo Plus card to try it out.
Observations:
- I bought the card online from Amazon selecting the Samsung store so I knew the card was not counterfeit.
- The camera properly reported the new 256G SD card was exFAT formatted.
- Most storage file system formatting tools will force you to use exFAT for large storage devices. This is true for the SD Card Assoication's formatter. I was able to use the MacOS Disk Utility to format to MS-DOS (FAT) format.
- When I inserted the FAT32 (VFAT) formatted 256G SD card, the camera properly reported lots of available space. Dang that is hard to read. Who thought white text with a light blue background was a good idea?!?
- My first thought was simple to trigger the camera a bunch of times until the SD card was full. But that would cause too many files in a single VFAT subdirectory which is a known limitation. Instead I used hcamapi.py to write a simple sd_card_test.py program to use a new directory when the current one had 100 files in it.
Results:
- My first attempt was not encouraging. I was monitoring the automated test run by keeping a browser tab open to the camera. During the test, I opened another browser tab and downloaded a video. The video was not playable. Later, while the test was still running, I clicked on the play last saved video button and almost immediately, the webUI reported Insert Memory Card. In checking the log file, there was a kernel error message FAT: Filesystem error (dev mmcblk3p1), invalid access to FAT (entry 0x0fff0fff) followed the camera code logging that the metadata file could not be saved. I inserted the 256G SD card into a Linux computer to see if I could recover the FAT file system. The fsck.vfat tool reported the filesystem was unrecoverable.
- On the second attempt I used the the camera's file system formatting tool to mkfs.vfat to put a VFAT file system on the 256G SD card. The exact command I ran was mkfs.vfat -n EDGER256 /dev/mmcblk1p1. I also changed the duration from 3.0 sec to 0.3 seconds so there would me more, 32 in my case, capture buffers. I had a browser open to the camera's webUI so I could monitor progress. I didn't interact with the camera during the test beyond the webUI monitoring and sd_card_test.py triggering and monitoring.
Speed
Have you ever noticed how every SD card has some sort of performance label and almost no USB thumb drives label their speed? The NAND storage chips used is essentially the same for both SD cards and USB thumb drives, with the slow NAND storage chips being used in thumb drives. Put simply, use SD cards, not USB thumb drives.
There is a dizzying array of speed labels approved by the SD Card Association. You should use 10 Mbit/sec or faster SD cards. Using slower cards will work fine, but increase the time to save a captured video. The following symbols indicate 10 Mbit/sec cards.
Counterfeit SD cards
Always buy SD cards from a reputable vendor. Never buy a cheap SD card online as it will cause you nothing but trouble. If I buy an SD card online via Amazon, I always make sure the company selling the card is the manufacturer of the card.
Camera does not use my new storage device
If you purchased an SD card or USB thumb drive that is larger than 32GB, it is likely the storage device was formatted with the exFAT file system (Microsoft exFAT specification). This is a Microsoft proprietary and patented file system. You will need to reformat your storage device using FAT32 file system as described above.
Software release v2.5.3rc23 and newer: If an exFAT formatted storage device is installed, the webUI status message will display exFAT Storage Unsupported.
Storage devices larger than 32 Gbytes use exFAT and must be formatted before they are usable in an edgertronic camera.
External hard disk
During camera endurance testing, a 320GB Western Digital My Passport USB hard disk is used for video storage. To get the USB disk to work consistently, a high quality powered USB hub is used so the disk can be powered on before the camera is powered on. I had to reformat the hard disk to use FAT32 file system.
Storage device support
The camera continues to save to the active storage device if there is room even when another storage device is added. If both SD card storage and USB are available at power on, the camera will initially use the USB storage device until it is full then switch to storing on the SD card. Specifically:
Power On Condition | User Action | Camera Behavior |
---|---|---|
SD card installed No USB storage |
Saves videos to SD card only. | |
SD card installed No USB storage |
USB storage inserted | Saves videos to SD card then switches to saving to USB storage when SD card is full. |
SD card installed USB storage inserted |
Saves videos to USB storage then switches to saving to to SD card when USB storage is full. | |
No SD card USB storage inserted |
Saves videos to USB storage only. | |
No SD card USB storage inserted |
SD card inserted | Saves videos to USB storage then switches to saving to SD card when USB storage is full. |
A storage device is considered full if there is less than 50 Mbytes (52,428,800 bytes) free space available.
Changing storage device without power cycling
1. To change from saving to SD card to usb (with only SD card inserted), go to settings and choose to dismount the SD card. You will receive an alert that you have no storage device, close the alert and then insert the usb, you will now be saving to the usb. Once you have done this you may reinsert the big sd card and the camera will continue saving to the usb.
2. To change from saving to usb to SD card(with only usb inserted), go to settings and choose to dismount the usb. You will receive an alert that you have no storage device, close the alert and then insert the big sd card, you will now be saving to the SD card. Once you have done this you may reinsert the usb and the camera will continue saving to the big sd card.
3. To change to your desired storage device when both devices (SD card and usb) are inserted, go to settings and choose to unmount the device you do not want to save to(device 2), this will allow you to save to the remaining storage device(device 1). Once you have done this you may reinsert the unmounted storage device (device 2) and the camera will continue saving to the device that was never unmounted (device 1).
Multiple USB storage devices
Unless you need a very large storage, it is recommended you only use one USB storage device at a time. The camera does not handle USB storage plug and unplug events correctly when more than one USB storage device is installed.
Storage implementation technical details
Most of the edgertronic camera functionality is straight forward, with the glaring exception being the logic to handle removable storage devices. Most people only use an SD card to save videos, so if that is your use case, you can skip this section.
At first glance, removable storage seems simple:
- User installs storage device (possibly before powering on).
- Camera uses storage as needed.
- User indicates they want to remove a storage device (technically meaning the Linux operating system unmounts the storage device). Having the user indicate they want to remove the storage device is needed because removable storage uses VFAT, a horrible, slow, easily-corruptible file system. Someday the tech industry will get smart and use a real file system on removable storage devices. The Microsoft proprietary exFAT is worse, as it is not journaled like a real file system and you need to pay royalties.
- User physically removes the storage device.
Those steps would be truly simple if step 3 wasn't in the list.
The complexity is partially due to how the camera uses removable storage:
- To hold software update images.
- To communicate the camera's IP address.
- To hold a variety of configuration files to allow the complex camera settings to be customized.
- To hold captured videos and related metadata information.
- Switching automatically to a different storage device if the active storage device is full or removed.
- Allowing the user to save a previously captured (but unsaved) video if the active storage device didn't have sufficient space.
To support all these features, the software:
- Mounts all removable storage during boot, but not all at the same time. The microSD card contains 3 partitions, with the SD card and USB storage devices typically containing 1 partition.
- The first microsSD card partition (VFAT format) is used by the U-Boot bootloader to get the details on how to check for button presses and magic files on an installed SD card (VFAT format) in order to know how to boot Linux.
- Then Linux is booted, which mounts the second partition on the microSD card based on the Linux command line parameters set by U-Boot, as that is the EXT4 formatted root file system for Linux.
- The Unix System V Init style start up logic causes the 3rd partition on the microSD card to be mounted and also mounts the 1st partition on the SD card (VFAT format) to check for an update file.
- Once the camera application is running, the USB subsystem is activated, detecting if an accessory is installed or a USB storage device is installed, then mounts the 1st partition (VFAT format) on any installed USB storage devices.
- Uses mdev to monitor change in available storage devices. When a change is detected:
- All new storage devices are mounted.
- The active storage device is left untouched if possible, but if the active storage device has been removed, or is full, then a new active storage device is identified with USB having priority over the SD card.
- Allows the user to unmount the storage device prior to the device being removed.
- If a storage device is not mountable, the Master Boot Record is read to check the [partition ID] to see if the device is exFAT formatted. If so, a special error is reported in the response by the CAMAPI get_camstatus() method.
CAMAPI mount and unmount commands
The active storage device can be controlled using the CAMAPI mount() and unmount() commands. If a storage device (SD card, USB storage, or CIFS network storage) is unmounted it will not be used again until it is either mounted or the camera is power cycled. When powered on, the camera saves first to the SD card (if possible), then USB storage (if possible), then work storage (if possible). You have to unmount the SD card and/or USB storage if you want the camera to only save to network storage after the camera is powered on.
Network storage
The camera software supports the notion that network storage can be used.
Network storage states
- Unconfigured
- Configured
- Mounted
- Error
Network storage CAMAPI status flags
- CAMAPI_FLAG_NET_CONFIGURED - bit 7
- CAMAPI_FLAG_NET_UNMOUNTABLE - bit 8
- CAMAPI_FLAG_NET_FULL - bit 9
CIFS
The only network storage currently supported is Common Internet File System (CIFS). User level CIFS configuration and usage provides one way to utilize CIFS based storage. You want to invoke the CAMAPI external storage methods directly, as described below.
The camera supports NFS (used regularly by the product development team), but not for enabled for video storage. If you would like NFS enabled for video storage, let us know.
Detailed SD card and DM368 processor technical information
Life is short; don't waste your time by reading the information below.
Recently (Spring 2022) we received a bunch of questions about using SD cards with more storage capacity. Since I hadn't looked into the implementation details in years, I did a deep dive into what is in the SD card standard and what is supported by the TI DM368 processor used in the edgertronic camera. These are notes to myself for when the questions get asked again.
SD Card Association specifications
According to SPRUFH5B DM368 Multimedia Card (MMC)/Secure Digital (SD) Card Controller User's Guide (section 1.5), The DM368 is compliant with Secure Digital (SD) Physical Layer Specification V1.1. From a version of SD-Memory Card Specifications / Part 1. Physical Layer Specification; Version 1. 01 dated April 2001. I found online (that also says it is the simplified version, so I don't know if the versioning numbering is consistent), the card physical interface is for what is now called SDSC for Secure Digital Standard Capacity (but was called SD back then).
The latest Physical Layer Simplified Specification is Version 8.00 dated September 23, 2020 and is an enjoyable read coming it at 284 pages. Another helpful SD Card Association specification is the SD Host Controller Simplified Specification Version 4.20 dated July 25, 2018. On PDF page 160, it describes handling three different types of SD cards - (1) SDSC ver 1.01 or 1.10 SDSC, (2) ver 2.00 or 3.00 SDSC, and SDHC. The different handling appears to be in the software commands used to interact with the SD card. To figure out what the edgertronic camera is doing, we need to look at the Linux SD card driver source code.
From the above information gleaned from the SD Card Association specifications, the physical interface is half-duplex 4-bit data 3.3v pin signaling with a maximum clock rate of 25 Mhz.
DM368 processor specifications
The SD card capabilities of the TI DM368 processor are described in the SPRUFH5B DM368 Multimedia Card (MMC)/Secure Digital (SD) Card Controller User's Guide dated April 2010. In section 1.2, Features, it states max clock rate of 50 MHz for SD cards (spec. ver. 2.0 ). From section 2.1 Clock Control, the memory clock is generated by dividing the function clock in the MMC/SD controller and is determined by the equation:
memory clock frequency = function clock frequency/(2 x (CLKRT + 1))
By dumping the pseudo-file /proc/davinci_clocks, we see
... mmcsd1 users= 1 psc 170000000 Hz ... mmcsd0 users= 1 psc 97142857 Hz
So the function clock frequency is 97Mhz for SD card slot 0 (microSD) and 170Mhz for SD card slot 1 (big SD card).
The 32-bit MMCCLK register is at offset 0x04 in the control register bank and has a definition of bit 7..0 being the CLKRT. The SD card slot 0 base address is 0x01D11000 and for SD card slot 1, 0x01D00000
381-v2_5_2rc32 / # devmem 0x01D11004 32 # SD card slot 0 0x00000100 381-v2_5_2rc32 / # devmem 0x01D00004 32 # SD card slot 1 0x00000101
For SD card slot 0:
memory clock frequency = function clock frequency/(2 x (CLKRT + 1)) = 97Mhz / (2 x (0 + 1)) = 48.5 Mhz
For SD card slot 1:
memory clock frequency = function clock frequency/(2 x (CLKRT + 1)) = 170Mhz / (2 x (1 + 1)) = 42.5 Mhz
Linux DM368 SD card driver
Performance measurements
I ran a couple of quick performance tests to get an idea of how fast of SD card we should recommend. Here are my results (average of 3 large captured videos):
frames | 8222 |
save time (sec) | 580 |
file size (Gbytes) | 1.12 |
avg Mbytes/sec write | 1.9 |
avg Mbits/sec write | 15.5 |
avg frames/sec save | 14.2 |
horizontal (pixels) | 1920 |
vertical (pixels) | 1088 |
I was using an SD card with a 10 Mbit/sec write speed and yet I measured 10.5 Mbytes/sec average write performance. This makes me not believe the data.