Coder Social home page Coder Social logo

esp8266_mp3_decoder's Introduction

I2S MP3 webradio streaming example

This is an example of how to use the I2S module inside the ESP8266 to output sound. In this case, it is used to output decoded MP3 data (actually, more accurately: MPEG2 layer III data): the code described here basically is a webradio streamer which can connect to an Icecast server, take the MP3 data the server sends out, decode it and output it over the I2S bus to a DAC. The MP3 decoder has been tested for bitrates up to 320KBit/s and sample rates of up to 48KHz.

Configuration options, building

All high-level options can be configured in mp3/user/playerconfig.h. Edit that file to set up your access point and a webradio stream or other source of MP3 data served over HTTP.

To build the code, try running make.sh in the mp3/ directory. Alternatively, the way to use 'make' to build this code is: make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE=1024

The resulting binaries will be in the bin/ folder. Please disregard the message that pops up at the end of the make process: the addresses it mentions are wrong. The correct addresses to load the resulting files are:

bin/eagle.flash.bin     - 0x00000
bin/eagle.irom0text.bin - 0xA0000

Needed hardware

If you want to have nice, high-quality buffered audio output, you will need to connect two ICs to your ESP: a 128KByte SPI RAM and an I2S codec. Both ICs are optional, but you will get stuttering and low-quality sound if you leave them off.

The SPI RAM is a Microchip 23LC1024 part and is used to buffer the incoming MP3 data. This guards against latency isuues that are present in all but the most quiet networks and closest connections. It is connected to the same bus as the SPI flash:

ESP pin   - 23LC1024 pin
------------------------
GPIO0     - /CS (1)
SD_D0     - SO/SI1 (2)
SD_D3     - SIO2 (3) *
gnd       - gnd (4)
SD_D1     - SI/SIO0 (5)
SD_CLK    - SCK (6)
SD_D2     - /HOLD/SIO3 (7) *
3.3V      - VCC (8)

*=optional, may also be connected to Vcc on 23LC1024 side.

One way to make these connections is to take the SSOIC version of the 23LC1024, bend up pin 1 (/CS) and piggyback it on the SPI flash chip that already is on the ESP module. Solder all the pins to the same pins on the SPI flash chip except for the bent /CS pin; use a wire to connect that to GPIO0.

As Github user milkpirate correctly remarked, GPIO0 is also used to enter programming mode on the ESP8266 and will interfere with correct flashing if kept low. The correct way of flashing the module is to make GPIO0 low, reset the ESP8266 to enter programming mode, then make GPIO0 high again. Tools like esptool.py generally follow this method to automatically enter programming mode; if you manually enter programming mode you may have to adjust your methodology.

For the I2S codec, pick whatever chip or board works for you; this code was written using a ES9023 chip, but other I2S boards and chips will probably work as well. The connections to make here are:

ESP pin   - I2S signal
----------------------
GPIO2/TX1   - LRCK
GPIO3/RX0   - DATA
GPIO15      - BCLK

Also, don't forget to hook up any supply voltages and grounds needed.

Running without the SPI RAM part

To not use the SPI RAM chip, please edit mp3/user/playerconfig.h and define FAKE_SPI_BUFF. This will use a much smaller buffer in the main memory of the ESP8266. Because the buffer is much smaller, the code will be very sensitive to network latency; also, clock synchronization with live streaming stations will not work. Expect the sound to cut out a fair amount of times unless you have a quiet network and connect to a server very close to you.

Running without the I2S DAC

To not use an I2S DAC chip, please edit mp3/user/playerconfig.h and define PWM_HACK. This uses some code to abuse the I2S module as a 5-bit PWM generator. You can now connect an amplifier to the I2S data pin (GPIO3/RX0) of the ESP module. Connecting a speaker directly may also work but is not advised: the GPIOs of the ESP are not meant to drive inductive loads directly.

Sound quality

In the default configuration, this code will output 16-bit mono audio. Stereo audio is possible but hasn't been implemented yet: a stereo synth is available but has not been modified for ESP8266 use yet. In PWM mode, the output is a dithered 5-bit PWM output. Furthermore, the ESP can decode a pretty wide range of bitrates: 96KBit to 320KBit MP3s have been tested and seem to work fine. Sound quality in general is not bad, but the scaling and clock adaption algorithms can use some improvement if the decoder needs to output real high-quality sound: Patches are welcome.

About the FreeRTOS SDK used

The MP3 example is a very memory-sensitive piece of code: the MP3 decoder uses almost all the RAM and the needed buffers for input and output buffering take up the rest: when using no external SPI RAM, only a few bytes of memory are left. The SDK libs that come with this example are libraries that have been optimized for memory usage and are known to work.

Technical details on this implementation

The biggest part of this code consists of a modified version of libmad, a fixed-point mp3 decoder. The specific version we use here has already been modified by NXP to use less memory (source: www.nxp.com/documents/application_note/AN10583.pdf) and has been massaged by Espressif to store as much constants in flash as possible in order to decrease RAM use even more. The MP3 decoder is fed from a FIFO realized in the external 23LC1024 SPI RAM. This RAM is filled from a network socket in a separate thread.

On the output side, the MP3 samples are fed into the I2S subsystem using DMA. The I2S DMA basically consists of a circular buffer consisting of a number of smaller buffers. As soon as the DMA is done emptying one of the smaller buffers into the I2S subsystem, it will fire an interrupt. This interrupt will put the buffer address in a queue.

When the MP3 decoder has a bunch of samples ready, it will pop a buffer off this queue and put the samples in it until it is full, then take the next buffer etc. The MP3 decoder generally is faster than the I2S output, so at a certain moment there will be no free buffers left. The queue system of FreeRTOS will suspend the mp3 decoding task when that happens, allowing the ESP8266 to attend to other tasks.

While the ESP8266 is able to run at 160MHz, we're leaving it at its default speed of 80MHz here: it seems that at that speed the ESP8266 is perfectly capable of decoding even 320KBit MP3 data.

esp8266_mp3_decoder's People

Contributors

jensh avatar spritetm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp8266_mp3_decoder's Issues

ESP-12E gets extremely hot

Hey,

like in #19 discussed my setup works - kind of. While running the system the output is pretty distorded and the ESP gets extremely hot (burned my finger touching it). I was also wondering if it has some thermal protection? Could the software do some wired stuff? If not I have an idea why this could happen: Please have a look at the pictures below.

img_20160611_001239
img_20160611_001253

I always thought these SMD inductiors are shielded but since the inductor of the buck converter is seemingly right below the ESP, I think it could induce some current that results in this heating. Is that possible?

Setup Help

Hi,
I am new to this project but I am very interested in being able to play MP3s off of my ESP8266. I am actually using the Huzzah from Adafruit: https://www.adafruit.com/product/2821

I have few questions:

  1. I am new to github so it might be I don't know how to navigate it well, but is there a step by step guide somewhere of how to get this project up and running? If not, I would love to help document the procedure if someone can hand hold me.
  2. Would this setup be allowed to play Mp3 files on demand from a web server? I see that there are mentions of being able to play from an Icecast server. I just want a setup that can play different MP3s from my ESP8266 on demand from start to finish (e.g., not midstream) Would this project work for me and would I have to have an Icecast server involved?
  3. Is there a fritzing diagram or something that shows how to wire up the ESP8266 to implement this project?

Reboot Loop! MEM CHECK FAIL

Dears,

Compiled with no SPI RAM and I2C Decoder..
When it runs, stay in reboot loop with this log:

MEM CHECK FAIL!!!
�������n�n�n�
쌜��b
b�nn���
b���rrn��l�l`���n���n�n�n�
쌜���

                                                    b
                                                     b�nn��
                                                           b���rrn��

                                                                    l`��r��n����n�n�n�
                                                                                      쌜��
                                                                                          b
                                                                                           b�nn��

                                                                                                 b|��rrn�
                                                                                                         lb��n����rrn�n�n�
쌜��ll�
       bb�nn��
              b���rrn��쎎l��n����rrn�n�n�
                                         쌜�����
                                                b
                                                 b�nn��
                                                       b|��rrn��l�l`����n|�r�����r�p`����n⌒`��brb��WH�*ɑ݅ɕ�initialized. Waiting for network.

mode :
Fatal exception (28):
epc1=0x402a0425
epc2=0x00000000
epc3=0x00000000
epcvaddr=0x00000000
depc=0x00000000
rtn_add=0x3fff4a10

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 32096, room 16
tail 0
chksum 0x80
load 0x3ffe8000, len 1656, room 8
tail 0
chksum 0x46
load 0x3ffe8680, len 6484, room 8
load 0x3ffe8680, len 6484, room 8
tail 12
chksum 0xc8
csum 0xc8
system param error
b5 0a 00 00 e5 05 00 00 e5 05 00 00 a7 0b 00 00 77 0d 00 00 d5 07 00 00 d5 07 00 00 e5 04 00 00
e5 04 00 00 85 0c 00 00 85 0c 00 00 c5 08 00 00 c5 08 00 00 47 0e 00 00 27 0e 00 00 35 0e 00 00
35 0e 00 00 65 0d 00 00 d5 06 00 00 e5 03 00 00 95 0b 00 00 b5 09 00 00 a5 0a 00 00 e5 02 00 00
15 0e 00 00 e5 01 00 00 55 0d 00 00 d5 05 00 00 75 0c 00 00 c5 07 00 00 45 0d 00 00 85 0b 00 00
b5 08 00 00 d5 04 00 00 95 0a 00 00 a5 09 00 00 65 0c 00 00 c5 06 00 00 35 0d 00 00 d5 03 00 00
25 0d 00 00 d5 02 00 00 15 0d 00 00 75 0b 00 00 b5 07 00 00 d5 01 00 00 55 0c 00 00 c5 05 00 00
85 0a 00 00 a5 08 00 00 95 09 00 00 45 0c 00 00 c5 04 00 00 65 0b 00 00 65 0b 00 00 b5 06 00 00
b5 06 00 00 d7 00 00 00 07 0c 00 00 35 0c 00 00 35 0c 00 00 c5 03 00 00 75 0a 00 00 a5 07 00 00
25 0c 00 00 c5 02 00 00 55 0b 00 00 b5 05 00 00 15 0c 00 00 85 09 00 00 95 08 00 00 c5 01 00 00
45 0b 00 00 c7 00 00 00 07 0b 00 00 35 0b 00 00 35 0b 00 00 b7 00 00 00 07 0a 00 00 15 0a 00 00
15 0a 00 00 b3 04 00 00 b3 04 00 00 65 0a 00 00 a5 06 00 00 75 09 00 00 75 09 00 00 95 07 00 00
95 07 00 00 a7 00 00 00 07 09 00 00 95 00 00 00 95 00 00 00 b3 03 00 00 83 08 00 00 25 0b 00 00
55 0a 00 00 b3 02 00 00 b3 02 00 00 a5 05 00 00 15 0b 00 00 b5 01 00 00 65 09 00 00 93 06 00 00
a3 04 00 00 45 0a 00 00 75 08 00 00 83 07 00 00 83 07 00 00 33 0a 00 00 a3 03 00 00 53 09 00 00
93 05 00 00 23 0a 00 00 a3 02 00 00 a3 01 00 00 63 08 00 00 83 06 00 00 73 07 00 00 43 09 00 00
93 04 00 00 33 09 00 00 93 03 00 00 53 08 00 00 83 05 00 00 23 09 00 00 63 07 00 00 73 06 00 00
93 02 00 00 13 09 00 00 93 01 00 00 43 08 00 00 83 04 00 00 53 07 00 00 73 05 00 00 33 08 00 00
83 03 00 00 63 06 00 00 23 08 00 00 83 02 00 00 13 08 00 00 43 07 00 00 73 04 00 00 83 01 00 00
83 01 00 00 05 08 00 00 85 00 00 00 53 06 00 00 63 05 00 00 13 07 00 00 13 07 00 00 05 07 00 00
75 00 00 00 33 07 00 00 23 07 00 00 03 06 00 00 63 00 00 00 03 05 00 00 53 00 00 00 08 01 00 00
08 02 00 00 08 03 00 00 04 04 00 00 19 01 00 00 09 01 00 00 17 00 00 00 17 00 00 00 03 00 00 00
03 00 00 00 03 00 00 00 03 00 00 00 03 00 00 00 03 00 00 00 03 00 00 00 03 00 00 00 46 04 00 00
c6 04 00 00 44 05 00 00 f9 0f 00 00 84 05 00 00 c2 05 00 00 e8 05 00 00 f9 02 00 00 e2 06 00 00
19 0f 00 00 f9 01 00 00 08 07 00 00 08 08 00 00 08 09 00 00 08 0a 00 00 08 0b 00 00 08 0c 00 00
06 0d 00 00 86 0d 00 00 06 0e 00 00 86 0e 00 00 06 0f 00 00 86 0f 00 00 06 10 00 00 84 10 00 00
c4 10 00 00 02 11 00 00 24 11 00 00 64 11 00 00 a2 11 00 00 59 01 00 00 c2 11 00 00 e2 11 00 00
02 12 00 00 22 12 00 00 19 04 00 00 49 01 00 00 42 12 00 00 29 03 00 00 39 02 00 00 17 03 00 00
17 03 00 00 37 01 00 00 37 01 00 00 09 03 00 00
f9 01 00 00 f9 00 00 00 82 16 00 00 a2 16 00 00 c2 16 00 00 e9 02 00 00 e2 16 00 00 19 0e 00 00
e9 01 00 00 02 17 00 00 22 17 00 00 42 17 00 00 62 17 00 00 82 17 00 00 a2 17 00 00 c9 06 00 00
39 0d 00 00 c2 17 00 00 29 0d 00 00 d9 02 00 00 19 0d 00 00 b9 07 00 00 e2 17 00 00 02 18 00 00
c9 03 00 00 22 18 00 00 49 0b 00 00 d7 01 00 00 d7 01 00 00 09 0d 00 00 d9 00 00 00 89 0a 00 00
a9 08 00 00 49 0c 00 00 c9 04 00 00 69 0b 00 00 b9 06 00 00 37 0c 00 00 37 0c 00 00 27 0c 00 00
27 0c 00 00 c7 02 00 00 c7 02 00 00 57 0b 00 00 57 0b 00 00 b9 05 00 00 89 09 00 00 17 0c 00 00
17 0c 00 00 c7 01 00 00 c7 01 00 00 99 08 00 00 09 0c 00 00 c7 00 00 00 c7 00 00 00 b9 04 00 00
69 0a 00 00 a9 06 00 00 79 09 00 00 37 0b 00 00 37 0b 00 00 b7 03 00 00 b7 03 00 00 89 08 00 00
59 0a 00 00 27 0b 00 00 27 0b 00 00 a9 05 00 00 69 09 00 00 a7 04 00 00 a7 04 00 00 79 08 00 00
89 07 00 00 97 04 00 00 97 04 00 00 79 07 00 00 79 06 00 00 b5 02 00 00 b5 02 00 00 b5 02 00 00
b5 02 00 00 15 0b 00 00 15 0b 00 00 b5 01 00 00 b5 01 00 00 07 0b 00 00 b7 00 00 00 97 06 00 00
47 0a 00 00 37 0a 00 00 a7 03 00 00 57 09 00 00 97 05 00 00 25 0a 00 00 25 0a 00 00 a5 02 00 00
a5 02 00 00 15 0a 00 00 15 0a 00 00 a5 01 00 00 a5 01 00 00 07 0a 00 00 67 08 00 00 a5 00 00 00
a5 00 00 00 87 06 00 00 47 09 00 00 95 03 00 00 95 03 00 00 37 09 00 00 57 08 00 00 87 05 00 00
67 07 00 00 25 09 00 00 25 09 00 00 95 02 00 00 95 02 00 00 57 07 00 00 77 05 00 00 35 08 00 00
35 08 00 00 85 03 00 00 85 03 00 00 67 06 00 00 47 07 00 00 77 04 00 00 57 06 00 00 67 05 00 00
77 03 00 00 13 09 00 00 93 01 00 00 05 09 00 00 95 00 00 00 45 08 00 00 85 04 00 00 75 02 00 00
75 02 00 00 47 06 00 00 67 04 00 00 23 08 00 00 23 08 00 00 23 08 00 00 23 08 00 00 83 02 00 00
13 08 00 00 35 07 00 00 25 07 00 00 13 07 00 00 13 07 00 00 73 01 00 00 73 01 00 00 55 05 00 00
05 07 00 00 75 00 00 00 35 06 00 00 65 03 00 00 45 05 00 00 55 04 00 00 25 06 00 00 65 02 00 00
35 05 00 00 03 08 00 00 83 00 00 00 13 06 00 00 63 01 00 00 03 06 00 00 63 00 00 00 55 03 00 00
45 04 00 00 23 05 00 00 23 05 00 00 53 02 00 00 03 05 00 00 33 04 00 00 43 03 00 00 53 00 00 00
23 04 00 00 43 02 00 00 33 03 00 00 46 18 00 00 f9 0f 00 00 e9 0f 00 00 d9 0f 00 00 e9 0e 00 00
c9 0f 00 00 d9 0e 00 00 b9 0f 00 00 f9 0b 00 00 c9 0e 00 00 d9 0c 00 00 c2 18 00 00 e7 0c 00 00
e7 0c 00 00 d7 0d 00 00 d7 0d 00 00 f9 0a 00 00 c9 0d 00 00 b7 0e 00 00 b7 0e 00 00 e7 0b 00 00
e7 0b 00 00 97 0f 00 00 97 0f 00 00 f7 09 00 00 f7 09 00 00 e7 0a 00 00 e7 0a 00 00 b7 0d 00 00
b7 0d 00 00 d7 0b 00 00 d7 0b 00 00 87 0f 00 00 87 0f 00 00 f7 08 00 00 f7 08 00 00 c7 0c 00 00
c7 0c 00 0

Its an NODE MCU ESP-12E With 4Mbyte ROM

mv: cannot stat ‘eagle.app.flash.bin’: No such file or directory

Hi, the uses of ESP8266 NONOS SDK V2.1.0 20170505 and build,
can you help ?
build error

failed and last part of output log as following,

ta-sections -ffast-math -fmerge-all-constants -fomit-frame-pointer -funroll-loops -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lmain -lfreertos -llwip -ludhcp user/.output/eagle/debug/lib/libuser.a mad/.output/eagle/debug/lib/libmad.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out

!!!
Usage: gen_appbin.py eagle.app.out boot_mode flash_mode flash_clk_div flash_size
mv: cannot stat ‘eagle.app.flash.bin’: No such file or directory
make: *** [.output/eagle/debug/bin/eagle.app.v6.bin] Error 1
esp8266@esp8266-VirtualBox:~/Share/ESP8266_MP3_DECODER/mp3$

sigma delta modulator Bit 0 always 0

The Bitshift is done at the wrong position. Below a fixed version.

Fixed code:
static inline int sampToI2sDeltaSigma(short s) {
int x;
int val=0;
int w;
static int i1v=0, i2v=0;
static int outReg=0;
for (x=0; x<32; x++) {
val<<=1; //next bit ADDED!
w=s;
if (outReg>0) w-=32767; else w+=32767; //Difference 1
w+=i1v; i1v=w; //Integrator 1
if (outReg>0) w-=32767; else w+=32767; //Difference 2
w+=i2v; i2v=w; //Integrator 2
outReg=w; //register
if (w>0) val|=1; //comparator
//val<<=1; //next bit ISSUE: This results in Bit 0 ALWAYS being zero. Bitshift needs to be done upfront
}
return val;
}

It's been restarting all the time

hi:
I'm very interested in ESP8266 recently,especially your MP3,but i Compile it according to your description(README ), and the burn has been rebooted ever since

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 32552, room 16
tail 8
chksum 0x7d
load 0x3ffe8000, len 1656, room 0
tail 8
chksum 0x99
load 0x3ffe8680, len 6524, room 0
tail 12
chksum 0x8d
csum 0x8d
Fatal exception (29):
epc1=0x402a1864
epc2=0x40100070
epc3=0x00000000
epcvaddr=0x00000000
depc=0x4010124a
rtn_add=0x00000041

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 32552, room 16
tail 8
chksum 0x7d
load 0x3ffe8000, len 1656, room 0
tail 8
chksum 0x99
load 0x3ffe8680, len 6524, room 0
tail 12
chksum 0x8d
csum 0x8d
Fatal exception (29):
epc1=0x402a1864
epc2=0x40100070
epc3=0x00000000
epcvaddr=0x00000000
depc=0x4010124a
rtn_add=0x00000041

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 32552, room 16
tail 8
chksum 0x7d
load 0x3ffe8000, len 1656, room 0
tail 8
chksum 0x99
load 0x3ffe8680, len 6524, room 0
tail 12
chksum 0x8d
csum 0x8d
Fatal exception (29):
epc1=0x402a1864
epc2=0x40100070
epc3=0x00000000
epcvaddr=0x00000000
depc=0x4010124a
rtn_add=0x00000041

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 32552, room 16
tail 8
chksum 0x7d
load 0x3ffe8000, len 1656, room 0
tail 8
chksum 0x99
load 0x3ffe8680, len 6524, room 0
tail 12
chksum 0x8d
csum 0x8d
Fatal exception (29):
epc1=0x402a1864
epc2=0x40100070
epc3=0x00000000
epcvaddr=0x00000000
depc=0x4010124a
rtn_add=0x00000041

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 32552, room 16
tail 8
chksum 0x7d
load 0x3ffe8000, len 1656, room 0
tail 8
chksum 0x99
load 0x3ffe8680, len 6524, room 0
tail 12
chksum 0x8d
csum 0x8d
Fatal exception (29):
epc1=0x402a1864
epc2=0x40100070
epc3=0x00000000
epcvaddr=0x00000000
depc=0x4010124a
rtn_add=0x00000041
....
...
...

can you help me?

make wifi bridge between phone and mobile

sorry to open ticket for my question, actually I've plan to make wifi bridge (ESP8266) between my landline phone and my smart mobile , so I could dial or receive my phone by mobile , I'm not sure about the which hardware should be selected and really appreciated to have your probably advise for that

Connection closed. lwip_read failes with -1

After reopening the first write to the socket blocks endless
write(sock, "GET ", 4);

The log file is attached
log.txt

I changed the following parts in the configuration:

diff --git a/mp3/user/playerconfig.h b/mp3/user/playerconfig.h
index 24339af..1974c8b 100644
--- a/mp3/user/playerconfig.h
+++ b/mp3/user/playerconfig.h
@@ -4,13 +4,13 @@
 /*
 Define the access point name and its password here.
 */
-#define AP_NAME "testjmd"
-#define AP_PASS "pannenkoek"
+#define AP_NAME "Baumschule"
+#define AP_PASS "blabla"
 
 /* Define stream URL here. For example, the URL to the MP3 stream of a certain Dutch radio station
 is http://icecast.omroep.nl/3fm-sb-mp3 . This translates of a server name of "icecast.omroep.nl"
 and a path of "/3fm-sb-mp3". The port usually is 80 (the standard HTTP port) */
-#if 0
+#if 1
 #define PLAY_SERVER "icecast.omroep.nl"
 #define PLAY_PATH "/3fm-sb-mp3"
 #define PLAY_PORT 80
@@ -26,12 +26,18 @@ Here's a DI.fm stream
 
 /* You can use something like this to connect to a local mpd server which has a configured 
 mp3 output: */
-#if 1
+#if 0
 #define PLAY_SERVER "192.168.33.128"
 #define PLAY_PATH "/"
 #define PLAY_PORT 8000
 #endif
 
+#if 0
+#define PLAY_SERVER "192.168.178.23"
+#define PLAY_PATH "/pc.mp3"
+#define PLAY_PORT 8888
+#endif
+
 /* You can also play a non-streaming mp3 file that's hosted somewhere. WARNING: If you do this,
 make sure to comment out the ADD_DEL_SAMPLES define below, or you'll get too fast a playback 
 rate! */
@@ -102,7 +108,7 @@ this if you don't have a 23LC1024 chip connected to the ESP but still want to tr
 the MP3 decoder. Be warned, if your network isn't 100% quiet and latency-free and/or
 the server isn't very close to your ESP, this _will_ lead to stutters in the played 
 MP3 stream! */
-//#define FAKE_SPI_BUFF
+#define FAKE_SPI_BUFF
 
 
-#endif
\ No newline at end of file
+#endif

using esp01 without spi ram, but with i2s codec

I see it says:

ESP pin - I2S signal

GPIO2/TX1 - LRCK
GPIO3/RX0 - DATA
GPIO15 - BCLK

Can I reassign GPIO15 by doing find and replace on GPIO_ID_PIN(15) and BIT(15) in the code, and reassign, or do I only need to worry about GPIO_ID_PIN(15). A am trying to adapt this tutorial to the ESP8266-01. Is it possible to do this?

The range of I2S_CLKM_DIV_NUM and I2S_BCK_DIV_NUM

in file i2s_freertos.c function i2sSetRate writes the range of I2S_CLKM_DIV_NUM and I2S_BCK_DIV_NUM:

I2S_CLKM_DIV_NUM - 5-127
I2S_BCK_DIV_NUM - 2-127

However, when I look into the document and found that the bit size of them is both 6, which means the correct range is:

I2S_CLKM_DIV_NUM - 5-63
I2S_BCK_DIV_NUM - 2-63

right?

compile issue

I have following on my path:
/home/me/dev/v2.2.x/ESP8266_NONOS_SDK/tools or ESP8266_RTOS_SDK/tools latest from GitHub
/home/me/dev/1.22.0-100-ge567ec7-5.2.0/xtensa-lx106-elf/bin

and with make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE=1024
getting:

xtensa-lx106-elf-gcc -Os -g -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals  -DICACHE_FLASH   -I include -I ../include -I ../../include -I ../../extra_include -I ../../include/lwip -I ../../include/lwip/ipv4 -I ../../include/lwip/ipv6 -I ../../include/espressif  -o .output/eagle/debug/obj/user_main.o -c user_main.c
user_main.c: In function 'recalcAddDelSamp':
user_main.c:122:6: error: implicit declaration of function 'spiRamFifoLen' [-Werror=implicit-function-declaration]
  if (spiRamFifoLen()<10*1024) {
      ^
user_main.c: At top level:
user_main.c:187:8: error: type defaults to 'int' in declaration of 'oldRate' [-Werror=implicit-int]
 static oldRate=0;
        ^
user_main.c: In function 'user_init':
user_main.c:404:2: error: implicit declaration of function 'UART_SetBaudrate' [-Werror=implicit-function-declaration]
  UART_SetBaudrate(0, 115200);
  ^

EDIT: with ESP8266_RTOS_SDK_V1.4.0 + xtensa-lx106-elf-gcc (crosstool-NG crosstool-ng-1.22.0-88-gde0bdc1) 4.8.5
I got xtensa-lx106-elf/bin/ld: cannot find -lhal:
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcall s -mtext-section-literals -DICACHE_FLASH -I include -I ../include -I ../../include -I ../../extra_include -I ../../include/lw ip -I ../../include/lwip/ipv4 -I ../../include/lwip/ipv6 -I ../../include/espressif user_main.c DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcall s -mtext-section-literals -DICACHE_FLASH -I include -I ../include -I ../../include -I ../../extra_include -I ../../include/lw ip -I ../../include/lwip/ipv4 -I ../../include/lwip/ipv6 -I ../../include/espressif spiram_fifo.c xtensa-lx106-elf-gcc -Os -g -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-se ction-literals -DICACHE_FLASH -I include -I ../include -I ../../include -I ../../extra_include -I ../../include/lwip -I .. /../include/lwip/ipv4 -I ../../include/lwip/ipv6 -I ../../include/espressif -o .output/eagle/debug/obj/spiram_fifo.o -c spir am_fifo.c xtensa-lx106-elf-gcc -Os -g -Os -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-se ction-literals -DICACHE_FLASH -I include -I ../include -I ../../include -I ../../extra_include -I ../../include/lwip -I .. /../include/lwip/ipv4 -I ../../include/lwip/ipv6 -I ../../include/espressif -o .output/eagle/debug/obj/user_main.o -c user_m ain.c xtensa-lx106-elf-ar ru .output/eagle/debug/lib/libuser.a .output/eagle/debug/obj/spiram_fifo.o .output/eagle/debug/obj/user_m ain.o xtensa-lx106-elf-ar: creating .output/eagle/debug/lib/libuser.a .. /1.22.0-88-gde0bdc1-4.8.5/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx10 6-elf/4.8.5/../../../../xtensa-lx106-elf/bin/ld: cannot find -lhal collect2: error: ld returned 1 exit status ../Makefile:321: recipe for target '.output/eagle/debug/image/eagle.app.v6.out' failed make[1]: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1 make[1]: Leaving directory '/home/zsolt/dev/projects/c/esp/esp8266/projects/ESP8266_MP3_DECODER/mp3' Makefile:266: recipe for target '.subdirs' failed make: *** [.subdirs] Error 2

Which SDK+Toolchain should be used?

Waiting for network... loops

Repeats waiting for network then I think it dies and loops

LED flashes on each loop.

Never seems to connect to any wpa2 access point I give it, any way to debug further?

Using an Adafruit Huzzah.

What does the 23LC1024 while programming?

Hey,

as suggested I piggyback the 23LC1024 onto the flash chip of my ESP-12E as suggested in the README.md. I also connected the /CE pin of the 23LC1024 to GPIO0.

So to program the ESP (i.e. enter the bootloader) the GPIO0 pin has to be low but since it is also connected to the /CE of the 23LC1024 (which is active low as well) the RAM chip is enabled while programming and might/does interfer with the ESP talking to the flash chip.

I also tired removing the pulldown of the GPIO0 after entering the bootloader but the programming still fails!

Please tell me if I have a twisted way of thinking...

esp8266 newbie - where's the DMA precisely?

I'm used to seeing DMA code that runs something like the following - can you point out where the equivalent code is in this project please? Don't worry about stating the obvious; much better that I say 'I know that' to myself instead of 'but how do they get from X to Z, where's Y?'.

  1. Set up a timer that will drive the DMA process
  2. Set some memory up with the data to be thrown out
  3. 'Attach' the memory to the output in some manner e.g. set registers to say 'PWM receives from DMA channel X'
  4. Associate the timer with the DMA channel
  5. Hit the 'go' button.
  6. Either poll for status or wait for an interuppt that pops when the DMA has exhausted the data, assuming that it's not set to loop
  7. Now stop the DMa if required and unroll the associations etc above.

FYI, what I'm hoping to do is to use this code as a basis to DMA stream data serially out of a GPIO port to a 433MHz transmitter to create a nice stable signal to send to a 433MHz receiver. Doing this using a Non-OS CPU based routine doesn't work because the timings are way too variable :-(.

Thanks,
Papadeltasierra.

ES9023 MCLK

First of all, thank you for this code, this is my first real MCU project and this gave me a major sense of achievement (I got it to work using the PWM output and the Olimex board).
It reminded me of the first detector radio that I built as a child.

I'm currently waiting for the ES9023 to arrive, and it seems I need an MCLK signal that is a multiple of the current sampling rate (e.g. 11,2896Mhz for 44,1KHz, there is a table on the ES9023 datasheet).

I guess I need some crystal/PLL to generate this myself?
I couldn't find detailed information about this anywhere that a beginner like myself would understand. If you could say a few words or point me to a url, that would be most welcome.

List of needed dependencies?

I can't seem to compile the code because of all the errors i'm getting for missing dependencies (i think). I would be nice to have one apt-get command to install everything.

For example i now have a xt-xcc error. Any tips on that?

Schematics

This project looks great, could you share a schematic for it?
Can I build one without any PCB, but just ESP8266, the SOIC DAC and SOIC RAM (and probably breakout board for SOIC)?
Thanks in advance if you can share a photo, or anything that would help the prototyping.

Connecting the SRAM

I have an ESP8266 that uses one of those shielded silver AI-Thinker modules, where the flash chip isn't visible. Since no module currently sold seems to breakout the SPI pins used for the flash bus, only the HSPI ones, I'm clueless on how to connect the sram.

Can I just use the HSPI pins instead? If so, where and how do I change the pin definitions? I din't quite understand how spiram.c works.

How to flash this code

I've seen this project and I wanna use it but I havent used this ESP8266 before so I dont know how to flash program to this IC.
Could you please tell me how to do that? And, Could I use this code in Module ESP8266 v7, v12?
Thanks for your help

Hardware PWM vs I2S

Great project, thanks for sharing!
The code lays out 2 alternative methods of generating the audio if the I2S IC is not available, but would it be possible to simplify this further using the built in PWM feature of the ESP8266 instead? Is the hardware PWM not fast enough to generate audio, unlike the PWM found on the arduino?

PWM binary

Would be nice have a PWM binary in the package for lazy guys like me :-)

xTaskCreate sets usStackDepth to e.g. 2100 for 2100 bytes (not 2100 words)

Hi,
I've been reading the freeRTOS "practical guide" and it states that the parameter usStackDepth in xTaskCreate specifies the stack depth in words - but your comment in user_main, in the function tskreader, states that the value 2100 is used to request 2100 bytes. I understand that the ESP8266 is a 32bit architecture, so is this a typo (for 8400 bytes), or does the specific behaviour of the version of freeRTOS you use here differ from that documented in the practical guide? (or, third option - have I just completely misunderstood what's going on in some other way?!)

Thanks
Dan

Sample rate not ok?

The function i2sSetRate in i2s_freertos.c did not work properly. When measuring the i2s wordselect frequency with then one, the function actually calculated (variable bestfreq), there was quite a deviation.
The accoustic effect was a change of sound-pitch.

The divider "calculation" in the below fix is not the most elegant one, but at least I think I identified the real formula for the word select formula (see code, line that begins with tstfreq=). The Base frequency is also 160 MHz (Independent on CPU speed setting).

Cannot commit the fix myself. So here the solution, which works for me.
Have also a second order sigma delta converter with over sampling ration of 64 working, delivering better sound quality (effectively 13.3 bit resolution, compared to 10 bits). E.g. speach does not sound that metallic anymore as before. Of course the noise on the IO pin itself will decrease the ENOB with respect to the ideal one.

So... here the sample rate fix code:

#define ABS(x) (((x)>0)?(x):(-(x)))

//Set the I2S sample rate, in HZ
void i2sSetRate(int rate) {
    //Find closest divider 
    int bestbck=0, bestfreq=0;
    int tstfreq;
    int i;
    int div;

    div = 2; // 2 is the minimal supported divider (divider 1 ends up in divider 2 setting)
    if (rate < 40000) // 39682 is the minimal sampling frequency supported with divider 2
        div = 3; // this one supports minimal 19841Hz

    //The base divider can be off by as much as <1 Compensate by trying to make the amount of bytes in the
    //i2s cycle more than 16. Do this by trying the amounts from 16 to 32 and keeping the one that fits best.
    for (i=1; i<64; i++) {
        tstfreq=(160000000l / (i*div*32) );
        printf("Best (%d,%d) cur (%d,%d) div %d\n", bestbck, bestfreq, i, tstfreq, ABS(rate-tstfreq));
        if (ABS(rate-tstfreq)<ABS(rate-bestfreq)) {
            bestbck=i;
            bestfreq=tstfreq;
        }
    }

    printf("ReqRate %d Div %d Bck %d Frq %d\n", rate, div, bestbck, bestfreq);
    CLEAR_PERI_REG_MASK(I2SCONF, I2S_TRANS_SLAVE_MOD|
                        (I2S_BITS_MOD<<I2S_BITS_MOD_S)|
                        (I2S_BCK_DIV_NUM <<I2S_BCK_DIV_NUM_S)|
                        (I2S_CLKM_DIV_NUM<<I2S_CLKM_DIV_NUM_S));
    SET_PERI_REG_MASK(I2SCONF, I2S_RIGHT_FIRST|I2S_MSB_RIGHT|I2S_RECE_SLAVE_MOD|
                        I2S_RECE_MSB_SHIFT|I2S_TRANS_MSB_SHIFT|
                        (((bestbck)&I2S_BCK_DIV_NUM )<<I2S_BCK_DIV_NUM_S)|
                        (((div)&I2S_CLKM_DIV_NUM)<<I2S_CLKM_DIV_NUM_S));
}

FreeRTOS

Do I have to upload the FreeRTOS firmware first and then upload the ESP8266_MP3_DECODER code?

What do these constants mean?

Hi!

I can't work out what
TRANS_MSB_SHIFT,
RECE_MSB_SHIFT and
MSB_RIGHT do.
They all seem a single bit value (true or false).
I guess MSB_RIGHT is either most significant bit/byte right, but I'm not sure which one of the two, and applied to what, each 16/24 bit channel value?
And I haven't even got a guess for TRANS_MSB_SHIFT and RECE_MSB_SHIFT :)

Help? :)

I'm also not sure what BITS_MOD does, but that's less interesting I think :)

SDK Versions and "section '.text' will not fit in region 'iram1_0_seg'"

Hi,

What an awesome project! Keep it up 😄

I currently facing some issues when I try to compile the project. The compiler returns the following error:

xtensa-lx106-elf-gcc -L../lib -nostdlib -T../ld/eagle.app.v6.ld -Wl,--no-check-sections -Wl,--Map=mapfile -u call_user_start -Wl,-static -Wl,--start-group -fdata-sections -ffast-math -fmerge-all-constants -fomit-frame-pointer -funroll-loops -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lmain -lfreertos -llwip -ludhcp user/.output/eagle/debug/lib/libuser.a mad/.output/eagle/debug/lib/libmad.a driver/.output/eagle/debug/lib/libdriver.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out /home/sircas/Source/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .output/eagle/debug/image/eagle.app.v6.out section '.text' will not fit in region 'iram1_0_seg' collect2: error: ld returned 1 exit status make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1

I'm using the pfalcon/esp-open-sdk toolchain with Ubuntu 14.04 LTS.

The error indicate that there is a problem with fitting the code into the ESP module during the linking. So I checked the size parameter of the SPI flash RAM and it was correctly set at 1024. In an attempt to resolve the issue I've change this value to 4096.

make COMPILE=gcc BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE=4096

... But it didn't resolve the issue.

Then I started to wonder if the size of the SDK have increased considerable. Resulting in the binary blobs being to large that even 4M isn't enough.
I then changed the SDK to earlier versions.
Namely the following versions:
esp_iot_sdk_v1.0.1_b1 (based on the release date of the SDK and the initial commit of the MP3 project this could be the one used when developing the project)
esp_iot_sdk_v0.9.6_b1

Unfortunately the result was the same using the above SDK versions.

  • Which versions of the SDK is known to work with this project?
  • Does anyone have any suggestions for what I should try next?

Any help is much appreciated 👍

xtensa-lx106-elf error

Hi Spritetm,

It is a super project, I want to try to make it. I built up toolchain, according to:
https://github.com/esp8266/esp8266-wiki/wiki/Toolchain#install-the-xtensa-crosstool-ng-as-local-user
but if I make it ("make", or "sh make.sh") in folder mp3, I get errors:
/bin/sh: 2: xtensa-lx106-elf-gcc: not found
make: *** [.subdirs] Error 2

If I tried an example project (blinky), I got an error:
Error calling xtensa-lx106-elf-readelf, do you have Xtensa toolchain in PATH?

Please help me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.