Need Help. Can no l...
 
Notifications
Clear all

Need Help. Can no longer compile any program with the audio.loop() statement enclosed.

19 Posts
5 Users
0 Reactions
565 Views
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

I get this error every time "Compilation error: text section exceeds available space in board" It doesn't matter what I try to write. I've copied and pasted Tutorial Sketches that are pretty short and simple but I get the same problem. I've used several different ESP32 boards but to no avail. The NodeMCU-32S board was my original workhorse, I wrote a sketch that allowed me to play MP3 files or Internet Radio stations by push button selection. It worked fine and was my favorite but it will no longer compile unless I remove the audio.loop() statement. Then it compiles but doesn't work. Any Ideas????



   
Quote
(@davee)
Member
Joined: 5 years ago
Posts: 2042
 

Hi @crash,

   Not looked at this before, and have only followed through to compiling ... not actually connected an ESP32 board.

I 'selected' NodeMCU-32S in Arduino IDE and compiled code from https://github.com/schreibfaul1/ESP32-audioI2S, which included an audio.loop call.

When it got near to loading it to a board, like your experience, it concluded that it only had about 1,300,000 bytes of space to load about 1,700,000 bytes of code ... so not going to play! 

However, I think this is because it is using a default partition table  ... a quick Google suggested it should have 4Mbyte flash, albeit, some is normally reserved for bootloader, etc. So you need to use a different partition table.

Free hint from Gemini suggested using Tools->Partition Scheme in Arduino IDE ... but I couldn't find it.

Second free Gemini hint, when I said there was no such Tool in the list, suggested using a 'generic ESP32' ... so I went to ESP32 Dev Module, which offers a list of alternates.

So I'll pass it back to you to do some digging, etc. Note to be careful about this course of action ... if you choose the 'wrong' one, you can wipe the bootloader code from the ESP32, which should be recoverable, but if you are unlucky, it could effectively brick the board. So don't take my suggestion as any more than a hint as where to start looking and treat AI engines with even more caution ... they show lots of confidence, but frequently provide the wrong or inappropriate answer! You may need to create or find a partition table specific to the NodeMCU-32S board ... I don't know if it is significantly different to the Dev board I found listed. 

Good luck and best wishes, Dave



   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

Hello Dave --- Thanks very much for trying to help. This whole thing has become very exasperating. What I really find hard to understand is that up until a week or so ago I would occasionally take the ESP32 chip out of its storage place, plug it into a breadboard wired with an Oled, two Amp boards, and an Adafruit SD breakout board, plug this assembly into a USB port and as soon as i pushed the reset button on the ESP32 the Oled would light up and if I selected Internet Radio it would allow me to select a station and immediately start playing music. It even listed the title of the song and who was singing it. I wanted to install a few copies of the sketch on other ESP boards to have and that's where the trouble started. I tried downloading the working sketch onto several different ESP boards and as you stated, just before it finished compiling it would crash with the to much data error and stop trying. I took the sketch apart line by line to try deterining what the problem was and found that as soon as i removed the audio.loop() line the sketch would compile and load but it wouldn't work. Being curious I copied a Tutorial sketch from the Workshop and tried compiling it on my ESP32. No good with the same results. Any sketch with that line in it will no longer compile. Well I will continue investigating and maybe get lucky. Thanks again and I'll keep you posted. ---- Crash

 



   
ReplyQuote
(@davee)
Member
Joined: 5 years ago
Posts: 2042
 

Hi @crash,

   I suspect a recent library update has meant that a lot more code has been dumped into your programme, and it is now too large for the default space allocation. I've been using microcomputers since they were delivered with 8k bytes of RAM, and ever since programmes have increased in size to match the available space, so updates continually needing more space seems to be a 'fact of life'!

  I also think that it probably only needs a small change ... not to the programme, but to the 'instructions' sent to the code uploader. It was stupidly late when I looked at it last night, but the 'options' included under Tools in Arduino IDE for your board, did not include Partition Table management.

Essentially, compiling and linking a programme results in several demands for memory ... eg some will be for programme code, that in this code needs to be in flash or equivalent memory, other for data, that needs RAM. In practice there will be several different categories, with 'standardised' names, which makes it look a little obscure, but it is pretty simple. All of this applies to every system I have ever looked at.

However, I am less familiar with the specific Arduino tools, and I have never used the particular board you have, so I suggest that you check out the specifics, such as exactly which addresses have flash memory, and which addresses are allocated to what. From what I have seen, some of the 'default' allocations probably make no sense for your requirement ... e.g. reserving space for a 'spare' copy of the programme code, whilst an update is downloaded OTA "Over The Air". 

Hence, being lazy, I posed a question to Gemini ... the free AI agent in Google Chrome browser. 

"how to change the partition table code memory space allocation when uploading code on to NodeMCU-32S in Arduino IDE. NB No option is provided in Tools menu of IDE."

Gemini's full answer had basically two options, the first as a simple workaround, which is probably all you need, and the second, a 'more professional and permanent change'. 

    • In the IDE change the selected board to Tools > Board > esp32 > ESP32 Dev Module ... which is my usual choice, by chance
    •  
    • Gemini claims "NodeMCU-32S is based on the standard ESP32-WROOM module, the "Dev Module" settings are fully compatible" ... which is plausible, but I recommend you 'fact check' it, independently before acting 
    •  
    • Gemini claims 'Tools > Partition Scheme menu should now appear, allowing you to select from standard presets like "Huge APP" or "No OTA".' ... I saw the Partition option and a list of Partition options last night, but made no attempt to try them out, as I didn't have a 'real' board attached. ... I'll leave that to you!
    •  
    • It will probably work, but there is a possibility that the operation will overwrite some preinstalled code that is used for the upload programme, possibly making the upload process more complicated. I think that can be fixed, but might need more research, etc., and I haven't done it. So I just wish you luck, and disclaim any responsibility if it bricks (temporarily or permanently) your board.
    •  
  1. Create a Custom Partition File (Per-Project) or for a different file for any number of projects using the NodeMCU-32S board specifically... it listed instructions to create a relatively simple text file in each case, and offered to create some samples to consider, assuming your board has 4MB of flash, which it claims is common. A simple 'yes' resulted in the samples, which I have only glanced at, but looked plausible.

I won't fill up the forum space with 2-3 pages verbatim ... you can easily replicate it by starting with the question I posed above, and maybe have some follow ups to check on details. I note, but again haven't followed up, it included references that you can also read, that it was using as a basis for its answer.

I think there is a good chance of you finding a simple solution if you look for it.

Best wishes, Dave

It 



   
ReplyQuote
(@crazyman)
Member
Joined: 2 years ago
Posts: 8
 

@crash 

Have you tried to set the Audio.loop in a task?

 

In Setup

 // setup player
  xTaskCreatePinnedToCore(
      Task1code,   /* Task function. */
      "Task1",     /* name of task. */
      5000,       /* Stack size of task */
      NULL,        /* parameter of the task */
      2 | portPRIVILEGE_BIT,           /* priority of the task */
      NULL,      /* Task handle to keep track of created task */
      1);          /* pin task to core */

 

Then add this function to your code. Remove audio.loop from everywhere else.

voidTask1code( void*pvParameters ){
for(;;){
audio.loop();
vTaskDelay(1);
  }
}
 
 
Not sure if this will help or not or if you tried it already.


   
ReplyQuote
noweare
(@noweare)
Member
Joined: 6 years ago
Posts: 209
 

You may have a couple of things going on. I use the esp32 but with the esp-idf so I am not up with where arduino ide keeps things and how they control the libraries used.

One problem that might be happening is that the internet radio project might have been written using version 2 of the espressif-arduino library.  The lastest is version 3, I think. But it is a major update and does have breaking changes. The I2S part of the Version 3 library was totally rewritten.

You may want to check which library/framework your using and make sure it matches what the project was written in.  I don't know if arduino ide environment can store two different versions of the same library (or whatever people are calling it these days ie framework, sdk, library)

If you are using the wrong library and go back to version 2 the flash should be large enough.

FYI : If you are using defaults then as mentioned above your max flash size is 1.3Meg and you would have to change that partition to something that allocates flash. You may actually be able to view the different partition.csv files  in one of the library folders. 

Let us know how you make out. This is a pretty common problem when an upgrade happens.



   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

Dave thank you once again for the info. I will warn you to be careful with the Partition change. I gave step one a try and changed my board to an ESP32 Dev module. The Partition scheme did appear under Tools and I changed the Flash from 4m to 8. I thought we had fixed it as it DID compile. However the upload speed changed to some astronomical number even though I had it set for 9600 . That wasn't bad enough but it would not let me change the speed under Tools. The sketch still did not work but the gibberish pouring out of the monitor did not allow me to discover the problem. Finally I changed it back to the default size but it didn't help. I can no longer use the ESP32 Dev Module because the speed is to high and I can't understand make it stop scrolling out gibberish. So we proved that The size is the problem but Option 1 isn't the fix. In all my frustration trying to get it back to normal I froze the IDE and the board would not close. I had to restart the laptop to get the IDE back. I can't thank you enough for your help. I was happy to see the sketch compile and load but there is something else in the mix. I believe it is a problem that occurred. My NodeMCU board still works properly but it won't compile yet. I'll be plugging away still even though my wife is upset about the amount of hair I'm pulling out 🙂 Will keep you updated. ------- Crash.



   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

@crazyman

Hello and thank you for your information. Unfortunately, I could not make this code work. The compiler spit out error after error regarding the syntax. Perhaps I was doing something wrong but no matter where I placed it in the sketch the compiler never got beyond the first line. I will keep it and maybe write something simple to plug it into. Your help is very much appreciated. It seems odd to me that I suddenly need so much more Flash memory to make even the simple sketch compile with that one line included. I wonder if there are others who could copy and paste Bills small MP3 or Internet Tutorial Sketch and have it work for them? Seems like something else has to change in order to allow tinkerers such as myself to write small audio sketches and have them work 🙂 Oh well .... I'll keep trying and thanks again ..... Crash



   
ReplyQuote
(@davee)
Member
Joined: 5 years ago
Posts: 2042
 

Hi @crash

  Sorry I have been busy, so I haven't looked further into your issue, but I noticed one thing you said.

I changed the Flash from 4m to 8

By which I assume you meant that you changed the amount of Flash from 4 Megabytes to 8 Megabytes.

This unfortunately would confuse things, albeit I don't know the precise effect.

The amount of flash, would be an indication to the loader, of how much flash memory is installed on your specific board. This depends on which type and how many, memory chips are physically fitted. For the NodeMCU board, all of the indications I could find, said that it was likely to be 4 Megabytes, assuming it was the item regularly on sale, albeit perhaps some boards had been fitted with less, say 1 or 2 Megabytes. e.g. perhaps as a 'special', for a specific large volume customer.

However, unless you had some reason to believe that your board was a 'special version', you should not have changed that value for the code loader, because it would confuse it, probably causing it to try to upload to an address that has no memory.

The change you needed to do was NOT to change the 4 Megabyte value, (assuming your board actually has 4 Megabytes, which seems likely), but instead change how much of that 4 Megabyte is available for the programme upload. From what I saw during my brief web search, the default allocation is about 1.3 Megabytes, whilst you need roughly 1.7 Megabytes. As I indicated, this is physically possible, because you have 4 Megabytes, and the bootloader that is installed to make the Arduino upload easy only needs a tiny fraction of a Megabyte.

It is possible that your action has overwritten the bootloader, which could make things a little more tricky. I have the impression that it is possible to rewrite it. I know the basis of what is needed, but I haven't done it myself, so without some more digging, I can't give you precise instructions. If I get some time, I may look into it, but no promises.

---

I also didn't understand why (or even how) you would set the upload speed to 9600. This would be exceedingly slow, and would probably confuse the uploader. I am sure there is a 'magic' setting somewhere, but I have always left it to its default, and it seemed fine.

Note that although the code uploader may use the same USB interface, etc. for everything, it can use a different speed to that used to communicate with the Arduino IDE's "Terminal", typically set by a line like Serial.begin (9600); in the user's code.

It is probable that the download programme would set it to a much higher value than 9600, and if your upload failed to install correctly, your programme's Serial.begin (9600); code would never be executed, leaving the uploader's default active.

It might be worth you revisiting the Partition you found, with the board you tried before, and try again, using a more appropriate option. At least, have a look to see if you can spot an option.

Best wishes, Dave



   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

  @davee

I just wrote a long answer to your long answer and I don't know where my fingers were but just as I was going to close.... It disappeared. Seriously!!!!  I downgraded Board Manager 3 back to Board Manager 2 Version 2.0.17 (I Think). As was offered as a possibility in a DroneBot post. The downgrade went well but I think it left some libraries out at sea because nothing worked there either. I retreated back to Board Manager 3. I believe I have the IDE so screwed up now that it doesn't know what to do. Here's a sort of funny example of why I am going crazy. I have a sketch that operates the OLED function. When you run it it displays an Adafruit Logo on the screen complete with words and the Star. It worked fine. I was enthusiastic about the screen working so I closed that Sketch and brought up my original Radio/MP3 Sketch to see if it would also work. Well the OLED worked (sort of) it lit up and lo and behold it showed the Adafruit Logo from the last sketch. There is no data in the second sketch requesting it to do so....... I deleted the original code from the initial sketch but it ran it anyway Hahahaha. It's like it's stuck in there somewhere and can't get out. So now just to let you know I put everything back as I found it in my partition exercise but it is not happy. Don't make yourself any crazier than I am wondering about this. I certainly appreciate the help but I think I will do one more thing and then give up if it doesn't work  I'm contemplating Uninstalling and Reinstalling the Arduino IDE program hoping that I'll get a fresh copy of the program. Just desperate option. I have a neat video of my sketch showing how the OLED and push buttons work before it got overrun 🙂 If i can get it here I'll post it so you can see. I was pretty proud of it. Thanks again and be well. -----Crash 



   
ReplyQuote
TFMcCarthy
(@tfmccarthy)
Member
Joined: 2 years ago
Posts: 496
 

@crash 

Have you tried ESPConnect to help identify the board properties?

This tool has been mentioned in the forum in the past and this seems like a good candidate for it.


The one who has the most fun, wins!


   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

@davee  and all the other wonderful helpers,

                                               I'm about back in Business!!!!!  At least I once again have audio from the Internet Radio Stations. The problem was indeed the ESP32 boards. I purchased two new ESP32 WROVER-E boards and I took Dave's advice. I installed the board and tried to compile the Sketch with just a Max Amp and a speaker. It failed Then I remembered a suggestion from Dave that I go into Tools and looked at the drop down menu that presented itself. The PSRAM option was enabled but that didn't fix the compile trouble. What fixed it was changing the Partitioning Scheme option from the Default 4MB to the "Minimal SPIFFS (1.9MB APP with OTA/128kb SPIFFS)" This allowed the Sketch to compile. and the enabled PSRAM corrected the boards inability to allocated enough memory for the AudioBuffer. As soon as it compiled the music started playing. I will now go back to my original breadboard project to see if I can get the OLED and SD Card reader working with Push button selection. If all is good I will be able to Change Radio Stations or play various MP3 or WAV files at the push of a button and see the changes on the OLED. Wish me luck and I'll be back to let you know how it came out. Keep your towels handy just in case I need something to dry the tears 🙂 ...... Crash



   
ReplyQuote
(@davee)
Member
Joined: 5 years ago
Posts: 2042
 

Hi @crash,

   Good to hear you are making progress.

  I suspect you can 'revive' the old boards, assuming you have the patience, etc., assuming they do not want to play the same games as your new boards.

As I said, I haven't needed to. So I can only offer suggestions of where to start looking for a fix.

My first Google took me to the Random Nerd Tutorials, who usually seem to be reliable. So maybe start there.

see https://randomnerdtutorials.com/esp32-erase-flash-memory/

for what looks like a simple first try.

Remember, if successful, this will set to the default partition still needs the new tricks you just found for the larger programme downloads. Of course, their procedure may not be suitable for your particular case, but you have only a little patience to lose by trying.

Let us know how you get on. I recall reading a more complex procedure, but need to do a bit more searching for that, and hopefully the simple approach will be enough.

Good luck!



   
ReplyQuote
(@crash)
Member
Joined: 3 years ago
Posts: 13
Topic starter  

@tfmccarthy @davee Thank you for the tip. I believe it will help once I figure out what to do. I am still not too sure it's a memory problem as I have gotten the code to compile and load but I still do not get the final result that I want. in my last post the Push button Station changer works, the OLED works to display the Station name because I tell it to, the audio plays the station content, and the SD card plays my song selection of MP3 or WAV files. The only thing that I cannot recapture is the fact that in the past before the new Board Manager the OLED would display the Station Name as instructed then drop the display and use the optional data to display the song title and singer. It no longer does that and nothing I have tried to date will make it 🙂   I thought that maybe the Sketch was to big so I whittled it down to just one station with no Amps and no displays but it still will not work even to the monitor. Oh well still plugging away.  Here is my copy of the new tiny sketch down from over 300 lines. 

#include"Arduino.h"
#include"WiFi.h"
#include"Audio.h"

#define I2S_DOUT25
#define I2S_BCLK26
#define I2S_LRC27

Audio audio;

String ssid = "ssid";
String password = "Password";

void setup(){
  // put your setup code here, to run once:
Serial.begin(115200);

WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());

while(WiFi.status()!= WL_CONNECTED){
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address  ");
Serial.println(WiFi.localIP());
Serial.println(".");

audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);

audio.setVolume(15);

audio.connecttohost("http://icecast.a.ware.com:8000/mmoldies.mp3");
}

void loop()

{

audio.loop();
  
}

void audio_showstreamtitle(constchar*info){
Serial.print("streamtitle "); Serial.println(info);
}
void audio_showstreaminfo(constchar*info){
Serial.print("streaminfo "); Serial.println(info);
}
 
 


   
ReplyQuote
(@davee)
Member
Joined: 5 years ago
Posts: 2042
 

Hi @crash,

   As mentioned before, I don't have the same hardware, etc., plus limited time, so all I can offer is an untested/unresearched suggestion for you to try to follow up.

As a side issue, unfortunately, your programme listing is not in the best format for this forum, so you might like to try to figure out the 'proper' method, which should result in a more readable result, before posting a future listing, but as it's fairly short, I think I can manage this time. Instructions are near the top of the righthand column of almost any forum page.

My thought related to the functions "void audio_showstreamtitle" and "void audio_showstreaminfo". Presumably these are related to the issue you are trying to fix. It wasn't immediately clear how these will actually be called.

I appreciated there may be some 'invisible' call, possibly buried in the depths of the class "Audio", so I Googled "audio_showstreamtitle" and it came up with a number of suggestions, the first being a GitHub repository

https://github.com/schreibfaul1/ESP32-audioI2S/wiki/home/3e30aa4e696a599061eba2e58db12c9256f0bd4b

which includes listing of possible functions that may be called, including:

audio_showstreamtitle if the radio station transmits information about the artist, music track ... in its metadata, this event is called

void audio_showstreamtitle(const char *info)

which appears to be similar in intent to your code.

This led me to wonder how the compiler/linker handled code whose presence was optional. I am sure more experienced programmers will recognise the situation and its solution, but I had previously only ensured the function was implemented, even if it was only a 'do nothing  except return, function', whose full replacement would be manually implemented in a future build.

I then looked at the include code in this repo, starting with file Audio.h

( https://github.com/schreibfaul1/ESP32-audioI2S/blob/master/src/Audio.h)

and found a line ... 

"extern __attribute__((weak)) void audio_process_raw_samples(int32_t* outBuff, int16_t validSamples); 

I confess to not being familiar with 'weak', but it suggested some likely magic.

And as a quick way forward, asked (free) Gemini in Chrome, the query:

given a library includes a declaration like "extern __attribute__((weak)) void audio_process_raw_samples(int32_t* outBuff, int16_t validSamples); ", explain how this "weak" works, and how to ensure it functions correctly.

To which I got an explanatory reply. It asked if this was a problem now, which I affirmed, so it provided a very plausible list of things, including those that can cause the linker to fail to match, such as C++ name mangling causing the function you provide to be different from the library declaration.

I am reluctant to fill this forum with the pages of AI transcript, but suggest you try following the same path. Hopefully one of the suggestions will fix your problem.

Good luck and best wishes, Dave.

 



   
ReplyQuote
Page 1 / 2