Custom board, not an ST development board.
MCU: STM32G031J6M6 SO8 package. UART RX/TX are Pins 1 and 8 respectively.
Pin 8 is also SWDCLK
Pin 7 is SWDIO and not used except for SWD
NRST is Pin 4 and has an internal pull-up.
From reading the option bytes via the STM32 CubeProgrammer. All the options are checked by default, including nBOOT_SEL, nBOOT1, nBOOT0 and NRST_Mode is 3. The BOOT_LOCK is unchecked (0) With this configuration it appears the MCU is booting straight into flash memory as intended.
I am able to flash the firmware and also run the program successfully.
But the successful running is only with the STLink utility connected to the board. If it's not connected, there's some random gibberish characters being displayed on the terminal along with my own input as i type into the keyboard.
e.g. if i type 'ACTION', i will see 'AACTION??$d', etc.
The input is clean when the STLink is connected.
If I disconnect the STLink and reconnect it, the program no longer seems to work (at least I am unable to track where it is in its execution state), I have to then do a power reset with the STLink connected and it's functional again. The firmware is a 'Release' build.
In the main loop, I just added a block of code to continually print 'hi\n' so it seems the UART init is OK even without the STLink connected, and it prints hi continuously except for those random gibberish characters turning up sometimes along with the hi. The gibberish seems more persistent when I'm typing, almost like an echo.
I have an FTDI (original not fake) TTL-232R serial convertor connected to the board and back to the PC via USB on the same USB bus as the STLink debugger. I am only using the GND, TX, and RX pins.