atanisoft / ESP32CommandStation

An ESP32 based DCC Command Station with integrated OpenLCB (LCC) --- NOTE: this project is not under active development.
https://atanisoft.github.io/ESP32CommandStation/
GNU General Public License v3.0
90 stars 34 forks source link

Enabling Railcom without increasing Preamble Bits > 11 throws an error during menuconfig re-entry #43

Closed TrainzLuvr closed 4 years ago

TrainzLuvr commented 4 years ago

I'm setup using WSL2 (Debian) with ESP-IDF environment, in Win10. Right now I'm just playing with it...

When I do idf.py menuconfig most of the time I can get into the menu and change settings.

The first time I loaded the menuconfig, I enabled the Railcom and set the RAILCOM-EN pin to 12, as per the ESP32CS schematics.

I did not change OPS PREAMBLE BITS, so they stayed at 11 (didn't know about that/missed the config).

I tried to build and I got an error about Preamble Bits needing to be at least 16.

I thought sure, I'll go back to menuconfig and fix it. Turns out, menuconfig won't load because it checks for the Preamble Bits and Railcom Enabled, and triggers an error. So, it's a Catch-22, a circular error.

I edited the sdkconfig manually and changed CONFIG_OPS_DCC_PREAMBLE_BITS=16 then went back to try and build.

This time build failed with on RAILCOM-EN pin

Make Error at CMakeLists.txt:259 (message):
  OPS RailCom enable pin should not use GPIO 0-3, 5, 12, 15.  These are reserved pins.

Obviously something's not right, because the schematic says it's pin 12, so either the reserved pins need to be updated, or the schematic needs to.

TrainzLuvr commented 4 years ago

Just to add one more thing, menuconfig still does not load because of that OPS Railcom pin assignment error.

atanisoft commented 4 years ago

Thanks for the detailed report, was this done using the VSCode graphical config utility or via idf.py menuconfig?

Just to add one more thing, menuconfig still does not load because of that OPS Railcom pin assignment error.

If this was with VSCode it is very likely https://github.com/espressif/vscode-esp-idf-extension/issues/147 which should be available in version v0.4.0 of the plugin.

In any case, I see the enable pin and brake pin are missing default values and a pin number range so the VSCode plugin would likely still have an issue and/or default to pin zero which is not ideal.

I did not change OPS PREAMBLE BITS, so they stayed at 11 (didn't know about that/missed the config).

Enabling RailCom should have reset the default value for OPS PREAMBLE BITS to 16. In this case it looks like there should be a validation check done in code to check for RailCom enabled and OPS PREAMBLE BITS to be correct and dynamically adjust during the build.

This time build failed with on RAILCOM-EN pin

Make Error at CMakeLists.txt:259 (message):
  OPS RailCom enable pin should not use GPIO 0-3, 5, 12, 15.  These are reserved pins.

Obviously something's not right, because the schematic says it's pin 12, so either the reserved pins need to be updated, or the schematic needs to.

The build check needs to be adjusted here likely. GPIO 5, 12 and 15 do have some restrictions on use but in this usage GPIO 12 having a pull-down (typically) is not a problem. I'll adjust the checks accordingly.