Build and upload successful but firmware not working as expected

Hi guys,
bit of a stange one, I wish I could be a bit more precise about what I’m asking but I’m a bit too new to PIO and esp-idf to know what might be going wrong. I’m using a custom PCB with an esp32s2, esp-idf, platformio, and vscode. I’ve been working on a project for a few months successfully using this same toolchain, but after some prodding around with the IDF folders (mainly introducing new folders into the components, trying to get a separate projects dependencies to work) I guess I broke something in the framework. I returned to this project and the first build threw up a yellow warning about a missing rtc_pm.c file that the target needed. I restarted VSCode and now it builds successfully. It even uploads successfully, which I know because 2 previously functioning boards are now bricked - the code only manages to set its LDO enable pin high before… I don’t quite know… “not working” is the best way to describe it.

The code is super simple and something I’ve done successfully unchanged in previous versions. The esp sets a pin high to enable an LDO and keep itself on, then another pin goes low to turn on an LED, then it sits in a while(1) loop doing nothing. The LED stays high for maybe 5ms before turning off forever, but the enable pin remains high, weirdly. Blinking the LED in the while loop does nothing, using printf to USB serial comms also no longer works and the device doesn’t appear as a serial COM port on reset as it did previously (it does appear as a COM port while in boot mode, so code can be uploaded to it). These exact lines of code have been proven to work on this hardware - I’m confident it’s not a hardware fault since after this happened on one board, I carefully checked an identical board which I verified was working and running its existing firmware, and equally carefully bricked that one too by uploading this new firmware.

I’m sort of 90% convinced I’ve done something to mess up the IDF since this is the same project and files from before I messed with these folders. I can upload the same pin setup code using arduino and it works absolutely fine.

I’m not getting any compiler errors so I’m not sure what the issue might even be, and to my knowledge I haven’t removed any folders from the IDF, only updated or added components. Right off the bat I’m noticing that platformio has it’s own copy of the esp framework stored in the C:/Users/username/.platformio/ folder, and that it seems to be using a particular version (3.5) for whatever reason. Maybe this is a clue, and I updated something I shouldn’t have? Or maybe something in menuconfig?

Any help or guidance as to how I could even start tackling this would be appreciated.