Help: Proposed Method to Burn eeprom With uC Instead of Computer

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by bayviewboom » Sun 2020-08-30 13:28

Plz jump down to viewtopic.php?p=13496#p13496

The EQ app says to run
uniprom1053.bat
from computer, to burn eeprom.
"2.2.3 VS10XX and SPI Boot Memory, No Modifiable Parameters
To program the SPI Memory you either need a separate programmer, or you can use VS1053b/VS1063a to program it. In the latter case you need to be able to redirect UART TX/RX control to a PC."

10.1.4 Standalone Tutorial: Writing Image File to SPI Memory
Open the Command Prompt. Using cd, go to the software folder in this package. Then,
depending on whether you are using VS1053 or VS1063, run either uniprom1053.bat, or
uniprom1063.bat, respectively. As a parameter, you need to give the COM port number
of your RS232 port or USB UART converter (see example below).

http://www.vlsi.fi/fileadmin/software/V ... alizer.pdf
How can i use a uC to burn the eeprom, instead of a computer?
Last edited by bayviewboom on Fri 2020-09-04 1:56, edited 1 time in total.

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: How to Burn eeprom With uC Instead of Computer?

Post by bayviewboom » Sun 2020-08-30 15:24

An arduino can write to eeprom. How can the arduino must pull the image to burn from the VS1053b?

How to do that? How can the arduino pull the image from the VS1053b?

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: How to Burn eeprom With uC Instead of Computer?

Post by bayviewboom » Tue 2020-09-01 17:59

I think I found my answer:

Equalizer doc says:
10 Programming and Running the Standalone Version

1. Read content of X addresses from 0x1800 through 0x18ff (128 16-bit values), using pseudo-code for ReadFilters() presented in Chapter 8.1.3.

Code: Select all

8.1.3 Function ReadFilters() SPI Implementation
// This pseudo-code shows how to read VS10xx's filter
// values through the SPI bus.
// Parameter d must be a pointer to a 128-size vector like below:
// u_int16 data[128];
#define SCI_WRAMADDR 7
#define SCI_WRAM 6
void ReadFilters(u_int16 *d) {
    int i;
    WriteSci(SCI_WRAMADDR, 0x1800);
    for (i=0; i<128; i++) {
        d[i] = ReadSci(SCI_WRAM);
        }
    }
2. Open vs1053b_vs1063a_equ_sa.img with a hex editor or a C program. Here, a computer is normally used to edit the OTS img file, which is pre-loaded with a flat EQ. Without a computer, we need to store the img file on arduino or eeprom itself, and then edit it as instructed. The img file is 18k (8k compressed).

3. At byte offset 0x10, you will see a two-byte pattern 0x12 0x34 that is repeated 128 times, filling 256 bytes.

4. Copy the data you got earlier to this part of the file. 16-bit numbers are encoded in the big-endian fashion, so number 0xface should be converted to bytes 0xfa 0xce (NOT 0xce 0xfa!).

10.1.3 Standalone Tutorial: Updating Filters to the Image File
You can either drop the resulting vector to the image file with a hex editor to byte offset
0x10, or you can copy the values using the following C code:

Code: Select all

FILE *fp = fopen("vs1053b_vs1063a_equ_sa.img", "r+b");
fseek(fp, 0x10, SEEK_SET);
for (i=0; i<128; i++) {
    fputc((filterVector[i]>>8)&0xFF);
    fputc((filterVector[i] )&0xFF);
    }
fclose(fp);
5. Now you can copy the boot image to the SPI EEPROM / FLASH. If you do this using a VS1053/VS1063 flasher program, remember to pull GPIO0 down before boot with a 10k resistor. This will prevent VS1053/VS1063 from trying to boot from SPI.

See reply below for details on VS1053 flasher program.

6. After programming, pull GPIO0 of VS1053/VS1063 high (e.g. 100k resistor), and reset the IC. Now it will boot from SPI and automatically run the equalizer application with the parameters you set.

Thx

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: How to Burn eeprom With uC Instead of Computer?

Post by bayviewboom » Tue 2020-09-01 18:23

From the doc:
Below is a successful run of programming the image on a VS1063, using port COM4.
Note that only the first command is issued by the user; the others come from the .bat
file. The name of the flasher script is uniprom1053.bat.

Code: Select all

G:\software>uniprom1063.bat 4
G:\software>copy vs1053b_vs1063a_equ_sa.img eeprom.img
1 file(s) copied.
G:\software>vs3emu -chip vs1002b -e 0x50 -s 9600 -x 12288 -ts 38400 -l vs1063-un
iprom2.coff -c run.cmd -p 4
VSEMU 2.2 Nov 12 2010 16:48:42(c)1995-2010 VLSI Solution Oy
Using serial port 4, COM speed 9600
Waiting for a connection to the board...
Caused interrupt
Interrupted at 0x400d
Chip version "1063"
Stack pointer 0x1920, bpTable 0x4a2f
User program entry address 0x50
Speed changed to 38400
vs1063-uniprom2.coff: includes optional header, 24 sections, 930 symbols
Section 1: code page:0 start:80 size:7 relocs:2 fixed
Section 2: puthex page:0 start:87 size:50 relocs:2
Section 3: puthex8 page:0 start:137 size:36 relocs:2
Section 4: SpiPrivDelay page:0 start:173 size:17 relocs:1
Section 5: SpiSendClocks page:0 start:190 size:24 relocs:1
Section 6: SpiPrivSendReceive page:0 start:214 size:51 relocs:4
Section 7: SpiPrivInit page:0 start:265 size:14 relocs:0
Section 8: SpiPrivRead page:0 start:279 size:52 relocs:11
Section 9: SpiPrivStatus page:0 start:331 size:33 relocs:4
Section 10: SpiPrivWrite page:0 start:364 size:127 relocs:31
Section 11: SpiStatus page:0 start:491 size:33 relocs:4
Section 12: SpiEraseBlock page:0 start:524 size:102 relocs:22
Section 13: SpiBlockWrite page:0 start:626 size:70 relocs:13
Section 14: SpiVerify page:0 start:696 size:68 relocs:15
Section 15: SpiReadBlock page:0 start:764 size:59 relocs:13
Section 16: BlockProgram page:0 start:823 size:62 relocs:10
Section 17: ReadSignature page:0 start:885 size:120 relocs:38
Section 18: PrintFirst16 page:0 start:1005 size:87 relocs:20
Section 19: main page:0 start:1092 size:287 relocs:121
Section 20: init_x page:1 start:7168 size:21 relocs:0
Rev. 1.50 2016-02-26 Page 26(35)
HH
VS1053B / VS1063A EQUALIZER VSMPG
Section 21: const_x page:1 start:7189 size:792 relocs:0
Section 22: bss_x page:1 start:7981 size:274 relocs:0
Section 23: VS_stdiolib page:0 start:1379 size:74 relocs:18
Section 24: VS_stdiolib$0 page:0 start:1453 size:110 relocs:32
VS1053/VS1063 16/24 BIT SPI EEPROMMER / FLASHER V1.2 (UNIPROM2)
(can prom up to 64K bytes)
Detecting connected SPI Flash or EEPROM type...
Read electronic signature (RDES (0xAB) method): 29 29
Read manufacturer and product id (RDID (0x90) method): 00 00
First 16 bytes of the chip are now:
50264801010817fc0000000000000000 P&H.............
Sending a Flash Erase Block 0 (64KB) Command (0xD8)...
Erase took time, probably this is a Flash chip: Using 24-bit address.
First 16 bytes of the chip are now:
ffffffffffffffffffffffffffffffff ................
Opened file eeprom.img.
Programming blocks of data... "." means OK, "X" means error.
. 0x01 KB.. 0x02 KB.. 0x03 KB.. 0x04 KB.. 0x05 KB.. 0x06 KB.. 0x07 KB.. 0x08 KB.
. 0x09 KB.. 0x0a KB.. 0x0b KB.. 0x0c KB.. 0x0d KB... 0x0e KB..
Verifying...
.. 0x01 KB.. 0x02 KB.. 0x03 KB.. 0x04 KB.. 0x05 KB.. 0x06 KB.. 0x07 KB.. 0x08 KB
.. 0x09 KB.. 0x0a KB.. 0x0b KB.. 0x0c KB.. 0x0d KB.. 0x0e KB..
Verify OK.
Finished!
First 16 bytes of the chip are now:
50264801010817fc0000000000000000 P&H.............
Resetting chip.
A2 : 0x10 A1 : 0x1010 A0 : 0x1010
B2 : 0x10 B1 : 0x1010 B0 : 0x1010
C2 : 0x10 C1 : 0x1010 C0 : 0x1010
D2 : 0x10 D1 : 0x1010 D0 : 0x1010
LR0 : 0x1010 LR1 : 0x1010 MR0 : 0x1010 MR1 : 0x1010
LC : 0x1010 LS : 0x1010 LE : 0x1010
I0 : 0x1010 I1 : 0x1010 I2 : 0x1010 I3 : 0x1010
I4 : 0x1010 I5 : 0x1010 I6 : 0x1010 I7 : 0x1010
P : 0x0010101010 =~ 269488144
A : 0x0010101010 =~ 269488144
B : 0x0010101010 =~ 269488144
C : 0x0010101010 =~ 269488144
D : 0x0010101010 =~ 269488144
PC : 0x00000000
Next Exec: 0x0000 LDC 0x0,A0
_audio_buffer + 0x000000
G:\software>
Our desire is to execute the same bat file (or the same commands) from an arduino.

The uniprom1053.bat flasher program code :

Code: Select all

copy vs1053b_vs1063a_equ_sa.img eeprom.img 
vs3emu -chip vs1002b -e 0x50 -s 9600 -x 12288 -ts 38400 -l vs1053-uniprom2.coff -c run.cmd -p %1 
- The first line copies image template to a working file, eeprom.img.

- The second line executes vs3emu, and makes use of vs1053-uniprom2.Coff. Vs3emu.Exe must be generic eeprom burner program. What is vs1053-uniprom2.Coff? Where does it get the new filters?

I suspect vs3emu copies the filters directly from the VS1053b chip, and writes them to the working file eeprom.img. Correct?

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: How to Burn eeprom With uC Instead of Computer?

Post by bayviewboom » Fri 2020-09-04 1:53

Would be great if someone from VSLI could comment!

At the moment, i think the Flasher Program can only be run from computer.

Here's my current plan:

Use our microcontroller to read the filters from the VS1053b into the microcontroller memory using your code `Function ReadFilters()`.

Then, in the microcontroller, merge the filters into the equalizer template file (same as the computer-based process).
`vs1053b_vs1063a_equ_sa.img`

And then write the filters to the eeprom directly from the microcontroller (without using the VS1053b). The burn process would be a standard arduino-to-eeprom burning process.

Image

Image

https://www.instructables.com/id/Readin ... OM-Using-/

WOULD THIS WORK?

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

Re: Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by Hannu » Fri 2020-09-04 8:48

Basically your current plan is good.

VS1053 doesn't support I2C flashes so you want to use SPI flash. Most of them have 25xxx kind of part number.
Also check that the flash is 5V tolerant.

Pins for the SPI flash are defined in chapter 10.9 SPI boot of the datasheet.

There is probably some arduino code out there to programming spi flash. So yes it could be done.

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by bayviewboom » Fri 2020-09-04 9:41

Hannu, thx for reply! I understand we must use SPI.

I see the first thing it does is copy the filter template file `vs1053b_vs1063a_equ_sa.img` to `eeprom.img`.

Question: What is `eeprom.img`? Is that the COMPLETE flash image? Could we write JUST `eeprom.img` to the flash, and boot from it?

thx!

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

Re: Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by Panu » Fri 2020-09-04 10:58

eeprom.img is the complete image. It must have a known name (eeprom.img) because that file name is hardcoded in the prommer binary (it uses our very old "vs3emu" uart protocol to open a file in the PC and read from that file using the uart). That's why the script takes some file name and copies it to eeprom.img so that the prommer binary that runs inside the VS10xx IC can open that eeprom.img file and read from it.

Our prommer binaries are usually called eeprommers or flashers depending on if they write an eeprom (25LC640 et al) using 16 bit address or a SPI flash (25xx016 et al) using 24 bit address. Some prommer binaries such as UNIPROM detect which is connected (eeprom or flash) and can prom both. That name is purely decorative and just helps to detect which one is used, in case we get a screenshot or something from the customer. In all cases, the file name "eeprom.img" is used, because changing that would be REALLY confusing.

These prommer binaries do not READ flash/eeprom contents. There's no nonvolatile memory of any kind inside the VS10xx ICs, the prommers just write external eeprom/flash ic contents so that the VS10xx chip can boot from the external flash/eeprom IC.
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by bayviewboom » Fri 2020-09-04 11:19

Thx, Panu!

If i have some filters defined in the VS chip, then what merges those filters into the img file, before writing to flash?

thx

bayviewboom
Senior User
Posts: 55
Joined: Wed 2019-11-27 9:49

Re: Help: Proposed Method to Burn eeprom With uC Instead of Computer

Post by bayviewboom » Fri 2020-09-04 20:46

i think i understand.

First, you have to do "10.1.3 Standalone Tutorial: Updating Filters to the Image File".
That puts the custom filters into the image file. So now you have an intermediate file.

The sequence is:
- Template file: vs1053b_vs1063a_equ_sa.img Before editing.
- Intermediate file: vs1053b_vs1063a_equ_sa.img after Updating Filters to the Image File

The problem here is your filenames. You're using the SAME FILENAME for both the template file, and the intermediate file.

This is confusing and poor practice.

- The intermediate file should have a DIFFERENT filename, to distinguish it from the template file.
- Using the same filename risks overwriting the original template file, forcing the user to download the template file from your website every time they do this process.

Am i correct?

A workaround is for the user to rename the template file after downloading, and keep it in a backup directory.
When they edit it, save it with the filename expected by the prommer: vs1053b_vs1063a_equ_sa.img

thx

Post Reply