How to change default value in the firmware?

Hi,

I need a lot of WLED unit for my project, so I would like to change some default values.

Here’s a quick list :
*Led count from 30 to 60
*Led maximum current from 850 to 2500
*Time for macro 18, 00, etc.
*Default macro T=1, T=0 basic On/Off
*Get time from NTP Server to True by default

So I changed the code using VS Code :
*wled.h/188 : WLED_GLOBAL uint16_t ledCount _INIT(60); // overcurrent prevented by ABL
*wled.h/410 : WLED_GLOBAL byte timerHours[] _INIT_N(({ 18, 00, 7, 9, 0, 0, 0, 0 }));
*wled.h/412 : WLED_GLOBAL byte timerMacro[] _INIT_N(({ 1, 2, 1, 2, 0, 0, 0, 0 }));
*wled.h/270 : WLED_GLOBAL bool ntpEnabled _INIT(true);
*const.h/127: #define ABL_MILLIAMPS_DEFAULT 2500; //

And that’s it, i click compile and use the firmware.bin (travis_esp8266) for esp8266 Nodemcu V3. The problem is, when I do this WLED doesn’t work. I tried to do it step by step, but it doesn’t work. The interface and webserver is up, but there is no effect on light and only like 10 LEDS are white, and no preset value.

I use PyFlasher, and wipe all data at every flash.

edit : I also have another tab “DMX Output” added to the config, although I didn’t activate it in the code.

Thank you very much for this awesome project.

Regards

Hi!
Your changes should not cause the software to fail addressing the LEDs…
If you compile and flash without the modifications, does it work?

You could try the d1_mini environment, travis_esp8266 is really just for the continuous integration and has a lot of debug activated. The environment also enables the DMX support, which can interfere with the LEDs as it’s on the same port (GPIO2)

Hope it helps :slight_smile:

1 Like

Thank you very much for your answer, testing the d1_mini env right now.

Okay so, with de d1_mini env it seems to work for the LED . So DMX was probably intefering like you said !

But the value I entered before are not here. The only value that was changed was the NTP to true.
All the other change were not applied.

edit: I’m gonna try with a fresh MCU board

Well, my last board won’t work at all, the board is unresponsive so I can’t test on a fresh board.

I’m gonna try to erase a board, then upload the firmware

EDIT : I have erased everything on the board using ESPTOOL, but it doesn’t keep the value either, the only new default value applied is on the NTP. The rest stay the same as default.

By the way, is there a way to add pre configured macro ? Like “T=0”, “T=1” ? I didn’t found any way to do it in the code.

Thank you

I’m sorry that it is still not working correctly…
For presetting macros there is also no good way yet - I am working on filesystem support which will let you set everything by uploading a cfg.json file - but that is not done yet.

For now the easiest option if you want to flash multiple units is to flash one unit, set up the settings as you’d like, use esptool to read the entire 4MB of flash to a binary and then flash that to all other units.
For that, set the mdns address in WiFi settings to “x”, all units will then replace it with their wled-123456.local ID again.

1 Like

I’m gonna try that, thank you very much :slight_smile:

EDIT: Where are stored WLED data in the EEPROM ? I’m gonna try to erase it manually with a blank firmware

EDIT 2: Exporting the firmware with esptool works like a charm, but I really need to understand why the edited code doesn’t work

The code is in wled_eeprom.h :slight_smile:

The way it works is:

  • on boot, attempt to load EEPROM
  • look if EEPROM is valid WLED save (byte 233 has value 233)
  • if valid, load all values from EEPROM
  • if not valid, overwrite EEPROM with zeros and store the default values

Therefore, you can see that changes to the defaults will only take effect when WLED hasn’t been installed to a given unit or it has been erased.
The part I don’t get is why it doesn’t seem to apply your changes to new or erased units, which should work :thinking:

1 Like

Thank you for the explanation, digging the code!

I asked a friend to compile my edited code and send me the firmware. The result is the same, the only default value applied is the NTP turned to enabled.

To erase unit, I tried with esptool with erase_flash and even uploaded blank firmware to all location available in the flash.

EDIT : I use VSCode to dig a little in the code, and CCPChecker mentionned some errors. I don’t know if they are revelant but sharing them can only help so :

|cppcheck|HIGH|ERROR|CWE-0:There is an unknown macro here somewhere. Configuration is required. If CHSV is a macro then please configure it.|…FastLED\pixeltypes.h:53:12|
|cppcheck|HIGH|ERROR|CWE-398:Local variable ‘index’ shadows outer function|…time\DateStrings.cpp:92:12|
|cppcheck|LOW|STYLE|CWE-561:The function ‘dayShortStr’ is never used.|…time\DateStrings.cpp:90:0|
|cppcheck|LOW|STYLE|CWE-561:The function ‘dayStr’ is never used.|…time\DateStrings.cpp:84:0|
|cppcheck|LOW|STYLE|CWE-561:The function ‘monthShortStr’ is never used.|…time\DateStrings.cpp:76:0|
|cppcheck|LOW|STYLE|CWE-561:The function ‘monthStr’ is never used.|…time\DateStrings.cpp:70:0|

Depending on #DEFINE values, different parts of logic hit the compiler. You probably know this already. What ccpcheck may not know is what conditional define values will be set and what sections of logic will get omitted.
And, of course, there is the possibility the code is either stale from prior changes, or pending integration in future changes.

Yes of course, that was not the point of this topic, just to mention them as I saw them :slight_smile:

Okay so I solved it !

It seems that the value were always retrievied from the EEPROM. So I commented the lines concerning ledcount / maxamps variables and it’s working ! Also, there’s another definition of “ablMilliampsMax” in FX.h so I changed it too.

I’m gonna do some testing with leds, but it seems promising.

1 Like

If you build firmware and deploy to a new ESP8266 / ESP32, defaults changed using #DEFINE should be written to the EEPROM when settings are saved. If the device is not erased, settings will get overwritten by EEPROM settings. Those statements are another way to say what @Aircookie said earlier in this topic.

The problem was that the firmware always retrieved the defaults from EEPROM no matter what. I have erased my units in different ways and it was always still able to retrieve the data from it.

Thank you for your insight !

EDIT : If you have the same problem, just comment the lines retrieving data from the EEPROM in the file wled_eeprom and it will work ! Hope it help someone in the future :slight_smile:
Thank you very much @Aircoookie for the help, your work is awesome !