Flshtool - program to work with SPI flashes from SD card

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
Senior User
Posts: 144
Joined: Mon 2016-05-30 11:54

Flshtool - program to work with SPI flashes from SD card

Post by Hannu » Mon 2020-11-16 15:12

Dear VS1010 users,

Here is tool for manipulating SPI flashes.
Read, write, Erase, debug and unbrick are the main targets. It should run from SD card.

It has dependency to paramspl http://www.vsdsp-forum.com/phpbb/viewto ... 98&p=13041

The attached README.txt has full documentation and some hints for unbricking VS1010 which SPI has flash gone wild.
Also remember to use the patch http://www.vsdsp-forum.com/phpbb/viewto ... =15&t=2620 for VS1010D which fixes SPI write.

This program is on the larger side of VS1010 programs and even feature list is long as seen on usage help.

Code: Select all

VS1010>flshtool -h
flshtool [-i]|[-I][-p]|[-c]|[-f]|[-w]|[-W]|[-d sector]|[-b|-B filename]|[-r filename]|[-s|-S|-u filename]|[-h]
-i	Print information of device structures
-I	Probe and print SPI flash information
-p	Print boot area
-c	Erase boot area
-f	Initialize SPI flash
-w	Full flash erase (wipe)
-W	Filesystem erase
-d	Print sector
-b	Write image filename starting from boot area
-B	Write image filename starting from filesystem area
-r	Remove file filename
-s	Save image of boot area to filename
-S	Save image of full disk to filename
-u	Save image of filesystem to filename
-h	Print this help
As always, if you have problems with this program, feel free to ask help.
flshtool binary
(10.56 KiB) Downloaded 30 times
Sources for flshtool
(34.89 KiB) Downloaded 27 times
Documentation of flshtool
(4.57 KiB) Downloaded 32 times

Senior User
Posts: 144
Joined: Mon 2016-05-30 11:54

Re: Flshtool - program to work with SPI flashes from SD card

Post by Hannu » Thu 2020-11-19 13:20

Making a factory programming with flshtool is one of its targets. For it a SD card is needed and proper config.txt in there.

This post is on the longer side as I try to cover many scenarios.

The contens of the SD-card are flshtool.dlx and paramspl.dlx in sys directory. Also production test programs should be there.

The procedure of making master image from golden sample is
  1. Plug in the SD card
  2. Connect uart cable
  3. Reset VS1010
  4. Get control of VS1010
  5. Copy flash as image to your programming SD card
  6. Write correct config.txt
  7. Flash the rest of the devices
Steps 1, 2 and 3 are self explaining.
Step 4 depends on your software.
If there is left some way to exit to shell use it.
If your software runs only on specific runlevel, reboot to another runlevel (Automatic start is done with config.txt)
If you have no other choice get to the command prompt, do the steps like you were unbricking the device (short MISO pull-up resistor, short XCS0 to ground, flshtool -f)

In the case of exiting from SPI flash program to command prompt, it is much likely that the S device is pointing to SPI flash. Use attached copydev tool to change D: (sd card) to point S: device with command "D:sys/copydev.dlx D S"

A sample usage of copydev tool is below. I had D: as S: drive so I copied for demonstration D: to T:

Code: Select all

D: SD/SD Card
F: SPI Flash c214
S: SD/SD Card

VS1010>d:sys/copydev.dlx D T
Copied D to T

D: SD/SD Card
F: SPI Flash c214
S: SD/SD Card
T: SD/SD Card
Step 5
Make filesystem image with "flshtool -u D:fs.img"

Step 6
Next is to write correct config.txt, which would automatically flash your device. The given sample would be perfectly good for VS1010minidemoboard. It would test audio and USB connector.

Below is simple config.txt which makes small test by playing hello.mp3 from ROM. Use your production test programs in here
next it flashes the SPI flash file system area
Last it prints done and reboots VS1010 as flash USB disk

Code: Select all

play r:hello.mp3
flshtool -B D:fs.img
echo done
reboot 4
Step 7
Insert SD card to the new devices, reset, hear "Hello" and see how the filesystem appears to USB.

Remember to have boot.dlx patch for your flash in SD card and also in system SPI flash.

In the rare case you need to have some boot program, use "flshtool -S D:full.img" to generate full SPI flash image which would consist boot program area and filesystem. Then use "flhstool -b full.img" for flashing.

If image has to be updated, insert the SD card to computer (don't use VS1010 as SD card reader) and rename the config.txt and image to something else. Then update the image with instructions on this post.

I attached also production programming SD card contents. The config.txt shown here is provided as template_config.txt Add your tests and rename the template_config.txt to config.txt
Template SD card filesystem for factory programming from SD card
(7.09 KiB) Downloaded 31 times
Tool to copy device A to B (Set device B to point to same device as device A)
(30.66 KiB) Downloaded 29 times

User avatar
VLSI Staff
Posts: 2798
Joined: Tue 2010-06-22 13:43

Re: Flshtool - program to work with SPI flashes from SD card

Post by Panu » Thu 2020-11-19 13:35

Thanks, Hannu!

Another way to select which device is the system disk, from where programs are run, is to use the setsys program.

- to set the system disk to be the SD card, give command setsys D
- to set the system disk to be the SPI flash, give command setsys F

Select system disk, VS1010 VSOS Executable
(770 Bytes) Downloaded 27 times
Source code, VSIDE Solution
(6.51 KiB) Downloaded 28 times
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply