Weird behavior of ledcAttach on FireBeetle ESP32

When I run this code (only enough code to show the problem) as is sensorVal does not print. Instead I get this in monitor, over and over, with no delay;

ets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1448
load:0x40078000,len:14844
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c

If I remove all of the lines with ledcAttach from the code I do see sensorVal with a delay and do not see the above. I don't get it, what is that stuff and where does it come from? And why doesn't my Serial.println work?

Or does it mean that ledcAttach failed and this is the error?

//IMPORTANT USE ESP32 Board Version 2.0.17

int sensorVal=100;    //Set initial LDR value
int threshold= 2000;  //Set light sensitivity value for LDR and conditional statements
#define ldrPin A4    //Set LDR pin connection

void setup()
{
  
  ledcAttach(0, 500, 8);  // Set PWM pin connection number and  attributes
  ledcAttach(1, 500, 8);
  ledcAttach(2, 500, 8);
  ledcAttach(3, 500, 8);
  ledcAttach(4, 500, 8);
  ledcAttach(5, 500, 8);
  ledcAttach(6, 500, 8);
  ledcAttach(7, 500, 8);
  ledcAttach(8, 500, 8);
  ledcAttach(9, 500, 8);
  ledcAttach(10, 500, 8);
  ledcAttach(11, 500, 8);

  Serial.begin(115200);   //Turn on Serial monitor for observing light measurements
  }

void loop()
{
  sensorVal=analogRead(ldrPin);  //Read LDR input value on scale of 0 - 4096
  Serial.println("*********************sensorVal");     //Print on Serial Monitor the LDR Value
  Serial.println(sensorVal);     //Print on Serial Monitor the LDR Value
delay(3000);
}

Some pins of the ESP32 are no good to use as GPIO, since they are shared with other board resources. I suggest you try to identify wich pins on your board can actually be used as PWM outputs.

As a start, I´m not sure you´ll have 12 available pins to use PWM with.

Assuming pin 9 is your "led builtin", why don´t you try to replicate the error with this version:

//IMPORTANT USE ESP32 Board Version 2.0.17

int sensorVal=100;    //Set initial LDR value
int threshold= 2000;  //Set light sensitivity value for LDR and conditional statements
#define ldrPin A4    //Set LDR pin connection

void setup()
{
   ledcAttach(9, 500, 8);
  Serial.begin(115200);   //Turn on Serial monitor for observing light measurements
  }

void loop()
{
  sensorVal=analogRead(ldrPin);  //Read LDR input value on scale of 0 - 4096
  Serial.println("*********************sensorVal");     //Print on Serial Monitor the LDR Value
  Serial.println(sensorVal);     //Print on Serial Monitor the LDR Value
delay(3000);
}

Thanks, you got me to look at something. I actually got the code from someone else and they were using deprecated ledcSetup so I had to make changes. I missed that you don't call it pin 9, it is pin D9.