Trying to install adafruit ssd1305 OLED library and compile failed

Thanks for your time! I did a clean all, closed vscode (all windows), deleted the build folder. Restarted vscode, build and then upload. It turned out that this particular board has only 4MB FLASH. I checked with esptool flash_id command. So I changed flash to 4MB. The program works, but with an issue. I have a serial port device connected to Serial1. This device responds with correct info if I compiled and uploaded from arduino IDE but in platformio, the first few characters are messed up:
Here from Arduino IDE’s serial monitor.

08:54:05.080 -> rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
08:54:05.080 -> configsip: 0, SPIWP:0xee
08:54:05.080 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
08:54:05.080 -> mode:DIO, clock div:1
08:54:05.080 -> load:0x3fff0030,len:1324
08:54:05.080 -> ho 0 tail 12 room 4
08:54:05.080 -> load:0x40078000,len:13508
08:54:05.080 -> load:0x40080400,len:3604
08:54:05.080 -> entry 0x400805f0
08:54:06.040 -> ESP32 SDI-12
08:54:09.031 -> SSD1305 OLED test
08:54:25.374 -> ⸮⸮b⸮ՑɁ  SDITRD152
08:54:30.480 -> z0014
08:54:30.480 -> z
08:54:37.320 -> ⸮	r⸮⸮⸮⸮⸮j⸮r⸮⸮⸮⸮⸮j⸮r⸮⸮⸮⸮⸮j⸮r⸮⸮⸮⸮⸮j

I pressed reset on the board and my serial monitor is at 115200, 9600 for Serial1. You can see, down to “SSD1305 OLED test” line were all printed by esp32 and all correct. Then after that I sent some commands to the serial device and its responses were messed up. I can probe the Serial1 pins with my logic analyzer to see if there are any difference between arduino IDE and platformio.

I noticed that despite the ini change, this still says I have 320KB of RAM. Shouldn’t I have 520KB like typical ESP32 processors do?

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.4% (used 17824 bytes from 327680 bytes)
Flash: [==        ]  21.2% (used 278301 bytes from 1310720 bytes)

This still appears:
image