It successfully compiles and uploads from both arduino and pio (yes, the main.cpp in pio has #include <Arduino.h> in it), but in the pio case nothing happens after the upload.
I tried uninstalling an old global pio core from my system, alongside the stm32 framework with no luck.
I also find that, when uploading from arduino, the LD4 led on the nucleo programmer is green, while it is red when uploading from PIO. Going to keep trying!
However due to recent linker script changes the maximum_ram_size value is used in the build system to calculate the start stack pointer. By using a value of 256Kbyte, this will point at 0x2000000 + 256*1024, at which there is no RAM, the board will instantly crash on startup.
Add
board_upload.maximum_ram_size = 196608
to the platformio.ini.
EDIT: Fix board_build to board_upload, facepalm.
This corrects the stackpointer back down to where there is RAM.
Then there’s a problem even before you get to the uploading part.
I overlooked this earlier, but you musn’t have that option in. The upload happens via USB (the STLink), not via a COM port.
If there is a failed.txt then the connections between the STLink and the MCU might have been disconnected. There are 2 jumpers for the SWD connections, one voltage selection jumper (E5V vs U5V) and one IDD jumper (supplies the entire current to the MCU). Make sure these are all set. When you re-plug the Nucleo into the PC, the LD1 LED must go green. See docs chapter 6.3.3 and 6.4.2.
I followed the thread you linked and using there value of ram worked.
board_upload.maximum_ram_size = 98304
I took out upload_port at one point because I saw another thread suggesting it, although I don’t think it was ever an issue. By any chance do you know why this random ram value made it work?