B350 gaming plus gets stuck on red VGA light when booting

randomley157902e0

New member
Joined
Aug 15, 2023
Messages
3
I have this motherboard for a while now and I had some issues with it. The last time I had to change the boot configuration because it wouldn't boot further than BIOS. Yesterday I powered my PC, BIOS/Mobo screen appeard for 2 seconds as always and then nothing happend. I restarted, nothing at all, no video signal, no power on the usb ports. The EZ debug LED stops at the VGA indicator. Since then I tried a lot of methods but nothing worked for me. I am also pretty sure that the problem is not my GPU because when I had a similar problem I exchanged my GPU to make sure it is not the cause. I think it might have to do with the boot configuration but I'm not sure since it doesn't even get to the boot LED.

Specs:
Ryzen 7 2700x
Rtx 3070ti fe
B350 gmaing plus
32gb Corsair Vengeance pro 3600mhz
700w pure power 11 CM
Samsung 980 1tb
SanDisk SSD 120gb
WD Blue HDD 1tb
 
Codes are ment as debug light? Usually the CPU light turns on first for a second, then nothing and then the VGA light stays on. After clearing CMOS:
CPU light turns on first for a second, then nothing, then the CPU light turns on again for a second or two and then the VGA light stays on.
 
Codes are ment as debug light?

debug code if your board has such function

Usually the CPU light turns on first for a second, then nothing and then the VGA light stays on. After clearing CMOS:
CPU light turns on first for a second, then nothing, then the CPU light turns on again for a second or two and then the VGA light stays on.

If you press reset button and waits does it pass it?
 
Codes are ment as debug light? Usually the CPU light turns on first for a second, then nothing and then the VGA light stays on. After clearing CMOS:
CPU light turns on first for a second, then nothing, then the CPU light turns on again for a second or two and then the VGA light stays on.
did you solve the problem ?
 
Codes are ment as debug light? Usually the CPU light turns on first for a second, then nothing and then the VGA light stays on. After clearing CMOS:
CPU light turns on first for a second, then nothing, then the CPU light turns on again for a second or two and then the VGA light stays on.
i have exactly the same issue with my b350m mortar arctic. some months ago, i update my windows to 11 and poped up a msi updater. i ran trough the update process, at the end my pc restarted and got this ez-debug light stuck at vga led. later i bought a new rtx 3060 instead of original gtx 1050ti and a new psu for it, cause i read online the cause of the issue is a new bios update which makes video cards before 2019 incompatible with the board. but the issue is persist.

i tried everything i found in forums, such as boot with and without graphics card, with one and two stick of ram, try booting only with cpu, clear cmos, short jbat jumpers.

specs:
ryzen 5 1600x
rtx 3060 ventus 2x 12g oc
2x8gb hikvision ddr4 2666mhz
b350m mortar arctic
gigabyte gp-p750gm 750w gold
Samsung 980 512gb
SanDisk SSD 512gb
 
I have exactly the same problem with my B450i Gaming Plus AC motherboard. I upgraded to Windows 11 back in november, had to flash my BIOS to the latest version to get it all to work. It seemed to work all fine, until my PC stopped working sometime around january. The VGA boot light on the motherboard is led, indicating it can't find a GPU (according to the manual). I put in a new videocard (Asus Radeon RX 550 EVO Phoenix 4G which did not require any aux-power) but this didn't make any difference. I tried to reset the CMOS and even replaced the CMOS battery, all to no avail. I don't think there's a problem with the power unit as all components seem to get power (fans turning, DVDRom can be opened/closed, all motherboard/case leds are working). Quite frankly am at my wits end here.

At this point I'm having serious doubts about the motherboard. What's striking is that around the time I upgraded to Win11 I had major stability isues which I could eventually lead back to a faulty RAM module, which I had subsequently removed. I can't help thinking that the latest BIOS upgrade (7A40vAH3(Beta version) which I needed for the TPM support required by Win11) has something to do with this all, but then again: It has worked fine for about 2 months....

I was running my PC with basic settings, nothing overclocked.

My setup:
MSI B450i Gaming Plus AC
AMD Ryzen 5 2600
G.Skill Aegis 1x8GB DDR4
MSI Geforce GTX1060 AERO ITX 6G OC
Crucial MX500 SSD 500GB
Corsair RM550x
 
i have exactly the same issue with my b350m mortar arctic. some months ago, i update my windows to 11 and poped up a msi updater. i ran trough the update process, at the end my pc restarted and got this ez-debug light stuck at vga led. later i bought a new rtx 3060 instead of original gtx 1050ti and a new psu for it, cause i read online the cause of the issue is a new bios update which makes video cards before 2019 incompatible with the board. but the issue is persist.

i tried everything i found in forums, such as boot with and without graphics card, with one and two stick of ram, try booting only with cpu, clear cmos, short jbat jumpers.

specs:
ryzen 5 1600x
rtx 3060 ventus 2x 12g oc
2x8gb hikvision ddr4 2666mhz
b350m mortar arctic
gigabyte gp-p750gm 750w gold
Samsung 980 512gb
SanDisk SSD 512gb
I had the same issue during a Windows 10 update a few days ago. It would get stuck on the VGA debug light on boot no matter which GPU I tried in any of the PCIE slots.

SPECS
- R5-2600X
- MSI B350m Mortar Artic
- 16gb DDR4 ram
- Various GPUs (R5 340, RX 580, GTX 1650, GTX 1660 Super, RTX 2060)

Suspecting a BIOS issue caused by the update, my issue was FIXED by pulling out my R5-5600g with integrated GPU from another system, dropping into the mainboard and it booted into the BIOS screen where I was able to re-flash it with the latest BIOS - 7A37vAM6(Beta version) found here (https://www.msi.com/Motherboard/B350M-MORTAR-ARCTIC/support#bios). Tested and confirmed working with all the discrete GPUs I had, replaced the R5 2600X back into the mainboard and tested again with the GPUs again. All working, no red VGA debug light after the BIOS flash.

Long story short, if you are able to get your hands on an AM4 CPU with integrated graphics (R3-2200G, R5-2400G, R3-3200G, R5-3400G, R5-5600G) that is supported by your mainboard, you may be able to boot into the BIOS screen to re-flash the BIOS and fix your problem.
 
I have experienced exactly the same issue with two identical systems, both based on the MSI B350 Gaming Plus motherboard and Ryzen 5 1600 CPU.

First incident

The problem occurred after upgrading Windows 11 from 23H2 to 26H2. The motherboard was running BIOS version 7A34vMJC.
The system worked normally for some time, but after eventually entering sleep mode, it failed to POST. The VGA EZ Debug LED remained permanently lit.
Nothing I tried helped: repeated CMOS resets, removing the battery, and testing several discrete GPUs. (every possible trick tried with no luck including various reset/power cut sequences in order to reset the board, GPU on 2nd PCIe slot etc...)
I finally installed a Ryzen 3 2200G APU, which allowed me to access the BIOS. I then flashed the latest BIOS version 7A34vMJE and replaced the CPU with a Ryzen 7 5700X. The system has been working normally ever since.

Second incident

The same problem occurred on my second, identical system. This time, I updated the motherboard from the old BIOS version 7A34vMD to the latest BIOS version 7A34vMJE. The system was running Windows 11 25H2.
Everything worked normally until the system entered sleep mode. After that, it again failed to POST, with the VGA EZ Debug LED permanently lit.
The same recovery procedure worked: I installed the Ryzen 3 2200G APU, accessed the BIOS, and reflashed the BIOS. After reinstalling the original Ryzen 5 1600 CPU and discrete GPU, the system worked normally again.

My observations

  • Both motherboards developed exactly the same failure.
  • In both cases, the failure occurred after entering sleep mode.
  • The problem persisted despite CMOS resets, battery removal and testing different discrete GPUs.
  • Both motherboards recovered after booting with an APU and reflashing the BIOS.
  • The original Ryzen 5 1600 CPUs and discrete GPUs worked normally again after recovery.
This strongly suggests a BIOS/AGESA or ACPI-related problem involving sleep-state transitions and subsequent PCIe/GPU initialization.

I understand that the B350 chipset is old, but two identical motherboards exhibiting the same failure, with the same recovery procedure, is extremely concerning. This behaviour is not acceptable, especially when it effectively renders a working motherboard unusable without access to an APU.

I would appreciate MSI investigating this as a potential BIOS/firmware issue rather than treating it as an isolated hardware failure.
 
Last edited:
Update to my previous post:

The system with the Ryzen 7 5700X is still working normally, but the system with the original Ryzen 5 1600 has encountered exactly the same issue again. Now running the system with R3 2200G.

I tried to downgrade to the previous BIOS version, but to my surprise, MSI does not allow downgrading to an older BIOS version.

BE AWARE OF THIS BEFORE UPDATING YOUR BIOS!
 

Attachments

  • BIOSmessage.png
    BIOSmessage.png
    76.7 KB · Views: 37
MSI B350 TOMAHAWK - Bricked BIOS Recovery Using Arduino UNO + W25Q128FW

Hello everyone,

I wanted to share a BIOS recovery procedure that successfully recovered an MSI B350 TOMAHAWK motherboard after a failed/problematic BIOS update.

After the BIOS update, the motherboard could no longer boot normally and was getting stuck around the VGA/POST stage. Since normal BIOS recovery methods were no longer available, I recovered the onboard SPI flash directly using an Arduino UNO.

The important part of this procedure is that I did not erase the flash immediately. I first created two complete independent backups and verified that both backups had exactly the same SHA256 hash.

Motherboard:
MSI B350 TOMAHAWK

SPI Flash:
Winbond W25Q128FW / 25Q128FWSQ
128 Mbit / 16 MiB
1.8 V device

Verified JEDEC ID:

EF 60 18

BIOS version used for recovery:

MSI 7A34v1M
E7A34AMS.1M0
Release date: 2019-01-30
Size: 16,777,216 bytes

Important Warning

This procedure directly erases and programs the motherboard SPI flash.

Do not perform CHIP ERASE until you have at least two complete 16 MiB dumps and both dumps produce exactly the same SHA256 value.

The W25Q128FW is a 1.8 V flash device. Do not connect the Arduino UNO 5 V logic outputs directly to the flash CS, MOSI or CLK signals.

Hardware Connection

The motherboard JSP11 service header was used.

Arduino UNO to JSP11:

D10 -> 1.8 kOhm series resistor -> node -> 1 kOhm to GND -> JSP11 Pin 5 / SPI_CS#

D11 -> 1.8 kOhm series resistor -> node -> 1 kOhm to GND -> JSP11 Pin 4 / SPI_DATAOUT / MOSI

D13 -> 1.8 kOhm series resistor -> node -> 1 kOhm to GND -> JSP11 Pin 6 / SPI_CLK

D7 <- direct input from JSP11 Pin 3 / SPI_DATAIN / MISO

Arduino GND -> motherboard GND

JSP11 Pin 1/2 -> CPU_1P8 / external laboratory PSU set to 1.80 V

JSP11 Pin 11 / SPI_WP#_R -> 10 kOhm pull-up to 1.8 V

JSP11 Pin 12 / SPI_HOLD#_R -> 10 kOhm pull-up to 1.8 V

ATX and CPU power cables were disconnected while externally powering the 1.8 V rail.

Arduino GND, laboratory PSU GND and motherboard GND were connected together.

The motherboard consumed approximately:

Read operation: 0.02 A

Erase/program operation: 0.03 A

1794462945669.png


Step 1 - Verify SPI Communication

Before reading or writing anything, I verified communication using the JEDEC ID command.

The flash repeatedly returned:

Manufacturer: 0xEF
Memory Type: 0x60
Capacity: 0x18

JEDEC:

EF 60 18

This confirmed that the Arduino was communicating correctly with the Winbond flash.

Step 2 - Create Two Independent Full Dumps

I read the complete 16 MiB flash twice.

bios_dump_1.bin
Size: 16,777,216 bytes

bios_dump_2.bin
Size: 16,777,216 bytes

Both files produced exactly the same SHA256:

5adbf6f7226a3b8124f219c0ffc560b7f97cef7e781f9b2427d3d0515ec5c652

This was my safety baseline.

If the two hashes do not match, do not continue with erase/programming.

1794462990371.png


Step 3 - Prepare the Official MSI BIOS

I used the official MSI B350 TOMAHAWK BIOS package:

Version:
7A34v1M

BIOS image:
E7A34AMS.1M0

Image size:
16,777,216 bytes

SHA256 of E7A34AMS.1M0:

3e14c954757398cf2ec4ffe75f0d374d1fb68fd0a74264e6a1466dcf65b10909

The official image and my existing flash dump were significantly different, so I did not simply copy a few bytes.

I created a board-specific restore image while preserving persistent DMI/SMBIOS NVRAM data from the original dump.

Important:

Do not use my personalized restore image on another motherboard.

DMI/SMBIOS/NVRAM data may contain board-specific information.

Each motherboard should use its own dumps and its own restore image.

The final restore image used on my board was:

E7A34AMS_1M0_DMI_PRESERVED.bin

Size:
16,777,216 bytes

SHA256:

db31227075b7980fbeb0a8adc385fd7f056dc5d359c950d236cce4e278bbfffc

This SHA256 is specific to my recovery image and must not be reused for another motherboard.

Step 4 - Safety Checks Before Erase

The PC-side programming script checks:

Image size

Image SHA256

JEDEC ID

The script does not automatically erase the flash when started.

It requires the user to manually type:

ERASE

Only after all checks pass.

Step 5 - Erase

The Arduino performs a Winbond Chip Erase operation.

Expected result:

ERASE_START

ERASE_OK

Step 6 - Blank Check

After erase, the complete 16 MiB flash is read and checked for 0xFF.

Expected result:

BLANK_START

BLANK_OK

If BLANK_OK is not received, programming should not continue.

1794463053356.png


Step 7 - Programming

The BIOS is programmed in 256-byte pages.

Every programmed page is immediately read back and verified before the next page is accepted.

Expected final progress:

16777216 / 16777216

In my case the complete programming + page verify process took approximately 749 seconds.

Step 8 - Full 16 MiB Read-Back Verification

After programming completed, the entire flash was read again from address 0x000000 to the end.

The SHA256 of the data physically read back from the flash was:

db31227075b7980fbeb0a8adc385fd7f056dc5d359c950d236cce4e278bbfffc

Expected restore image SHA256:

db31227075b7980fbeb0a8adc385fd7f056dc5d359c950d236cce4e278bbfffc

Result:

VERIFY : BASARILI - BYTE-FOR-BYTE IMAGE DOGRU

In English:

VERIFY SUCCESSFUL - BYTE-FOR-BYTE IMAGE MATCH

This was important to me because I did not want to trust only a "program completed" message. The complete contents physically stored in the SPI flash were independently read back and hashed.

1794463100714.png


Result

After removing the Arduino, external 1.8 V supply and temporary programming connections, the motherboard was able to enter the BIOS setup again.

So the motherboard itself was successfully recovered.

Windows Boot Note

After recovering or downgrading the BIOS, the previous boot configuration may be reset.

If the BIOS detects the SSD/HDD but Windows does not boot, do not immediately assume that the disk or Windows installation is damaged.

Check:

Is the SSD/HDD detected in BIOS?

Is "Windows Boot Manager" available?

Is Boot Mode set correctly for UEFI/GPT?

Is CSM/Legacy configured correctly?

Is SATA Mode the same as before, for example AHCI or RAID?

A CMOS reset or BIOS downgrade can change these settings.

Recovery Checklist

  1. Confirm the motherboard model.
  2. Physically identify the SPI flash.
  3. Confirm the flash voltage.
  4. Do not apply Arduino 5 V logic directly to a 1.8 V flash input.
  5. Verify the JEDEC ID.
  6. Read the complete flash twice.
  7. Confirm both dumps are exactly 16,777,216 bytes.
  8. Confirm both dumps have identical SHA256 hashes.
  9. Keep both original dumps permanently.
  10. Verify the official target BIOS image size and hash.
  11. Preserve board-specific DMI/SMBIOS/NVRAM information where necessary.
  12. Keep WP# and HOLD# HIGH during programming.
  13. Perform CHIP ERASE.
  14. Perform a complete BLANK CHECK.
  15. Program using 256-byte pages.
  16. Verify every programmed page.
  17. Read the complete 16 MiB flash again.
  18. Compare the final read-back SHA256 against the image that was programmed.
  19. Do not disconnect the programmer or power the motherboard normally until the final hash matches.
Arduino Firmware

The Arduino UNO firmware used for this recovery supports:

J = JEDEC ID

E = Chip Erase

B = Blank Check

P = Page Program + immediate page verification

D = Full Flash Read-Back

I will include the Arduino firmware below.

Code:
// REV16
// MSI B350 Tomahawk - Winbond W25Q128FW/FWSQ
// External recovery programmer using Arduino UNO
// Commands: J=JEDEC, E=erase, B=blank check, P=page program+verify, D=full readback dump
 
#include <Arduino.h>
 
#define CS_BIT   PB2   // D10
#define MOSI_BIT PB3   // D11
#define CLK_BIT  PB5   // D13
 
const uint8_t  PIN_MISO   = 7;       // AIN1 comparator input
const uint32_t FLASH_SIZE = 16777216UL;
const uint16_t PAGE_SIZE  = 256;
 
inline void csLow()   { PORTB &= ~_BV(CS_BIT); }
inline void csHigh()  { PORTB |=  _BV(CS_BIT); }
inline void clkLow()  { PORTB &= ~_BV(CLK_BIT); }
inline void clkHigh() { PORTB |=  _BV(CLK_BIT); }
inline void mosiLow() { PORTB &= ~_BV(MOSI_BIT); }
inline void mosiHigh(){ PORTB |=  _BV(MOSI_BIT); }
 
inline bool readMISO() {
  // ACBG=1: comparator + input is internal bandgap (~1.1 V), - input is D7/AIN1.
  // MISO > ~1.1 V => ACO=0.
  return (ACSR & _BV(ACO)) == 0;
}
 
inline void spiWriteByte(uint8_t data) {
  for (uint8_t mask = 0x80; mask; mask >>= 1) {
    if (data & mask) mosiHigh(); else mosiLow();
    clkHigh();
    asm volatile("nop\n\tnop\n\tnop\n\t");
    clkLow();
  }
}
 
inline uint8_t spiReadByte() {
  uint8_t value = 0;
  for (uint8_t mask = 0x80; mask; mask >>= 1) {
    clkHigh();
    asm volatile("nop\n\tnop\n\tnop\n\tnop\n\t");
    if (readMISO()) value |= mask;
    clkLow();
  }
  return value;
}
 
void writeEnable() {
  csLow();
  spiWriteByte(0x06);
  csHigh();
}
 
uint8_t readStatus1() {
  csLow();
  spiWriteByte(0x05);
  uint8_t sr = spiReadByte();
  csHigh();
  return sr;
}
 
bool waitReady(uint32_t timeoutMs) {
  uint32_t start = millis();
  while (readStatus1() & 0x01) {
    if ((millis() - start) > timeoutMs) return false;
    delay(1);
  }
  return true;
}
 
bool checkWEL() {
  return (readStatus1() & 0x02) != 0;
}
 
void startRead(uint32_t address) {
  csLow();
  spiWriteByte(0x03);
  spiWriteByte((address >> 16) & 0xFF);
  spiWriteByte((address >> 8) & 0xFF);
  spiWriteByte(address & 0xFF);
}
 
void stopRead() { csHigh(); }
 
void printJedec() {
  csLow();
  spiWriteByte(0x9F);
  uint8_t a = spiReadByte();
  uint8_t b = spiReadByte();
  uint8_t c = spiReadByte();
  csHigh();
  Serial.print("JEDEC=");
  if (a < 0x10) Serial.print('0'); Serial.print(a, HEX); Serial.print(' ');
  if (b < 0x10) Serial.print('0'); Serial.print(b, HEX); Serial.print(' ');
  if (c < 0x10) Serial.print('0'); Serial.println(c, HEX);
}
 
bool chipErase() {
  writeEnable();
  if (!checkWEL()) {
    Serial.println("ERR_WEL");
    return false;
  }
  Serial.println("ERASE_START");
  Serial.flush();
  csLow();
  spiWriteByte(0xC7);
  csHigh();
  if (!waitReady(300000UL)) {
    Serial.println("ERR_ERASE_TIMEOUT");
    return false;
  }
  Serial.println("ERASE_OK");
  return true;
}
 
bool blankCheck() {
  Serial.println("BLANK_START");
  Serial.flush();
  startRead(0);
  for (uint32_t address = 0; address < FLASH_SIZE; address++) {
    uint8_t v = spiReadByte();
    if (v != 0xFF) {
      stopRead();
      Serial.print("BLANK_FAIL 0x");
      Serial.println(address, HEX);
      return false;
    }
  }
  stopRead();
  Serial.println("BLANK_OK");
  return true;
}
 
bool programPage(uint32_t address, const uint8_t *data, uint16_t len) {
  if (len == 0 || len > PAGE_SIZE) return false;
  if ((address & 0xFF) + len > PAGE_SIZE) return false;
 
  writeEnable();
  if (!checkWEL()) return false;
 
  csLow();
  spiWriteByte(0x02);
  spiWriteByte((address >> 16) & 0xFF);
  spiWriteByte((address >> 8) & 0xFF);
  spiWriteByte(address & 0xFF);
  for (uint16_t i = 0; i < len; i++) spiWriteByte(data[i]);
  csHigh();
 
  if (!waitReady(2000UL)) return false;
 
  // Immediate page read-back verify before accepting next page.
  startRead(address);
  for (uint16_t i = 0; i < len; i++) {
    if (spiReadByte() != data[i]) {
      stopRead();
      return false;
    }
  }
  stopRead();
  return true;
}
 
void dumpFlash() {
  Serial.println("DUMP_BEGIN");
  Serial.flush();
  startRead(0);
  for (uint32_t address = 0; address < FLASH_SIZE; address++) {
    Serial.write(spiReadByte());
  }
  stopRead();
  Serial.flush();
}
 
bool readExactSerial(uint8_t *dst, uint16_t count, uint32_t timeoutMs) {
  uint16_t got = 0;
  uint32_t last = millis();
  while (got < count) {
    if (Serial.available()) {
      dst[got++] = (uint8_t)Serial.read();
      last = millis();
    } else if ((millis() - last) > timeoutMs) {
      return false;
    }
  }
  return true;
}
 
void setup() {
  DDRB |= _BV(CS_BIT) | _BV(MOSI_BIT) | _BV(CLK_BIT);
  csHigh();
  mosiLow();
  clkLow();
 
  pinMode(PIN_MISO, INPUT);
  ACSR = _BV(ACBG);
 
  Serial.begin(1000000);
  delay(1500);
 
  Serial.println();
  Serial.println("REV16");
  Serial.println("W25Q128FW RECOVERY PROGRAMMER");
  Serial.println("WAITING");
  printJedec();
}
 
void loop() {
  if (!Serial.available()) return;
  char cmd = (char)Serial.read();
 
  if (cmd == 'J') {
    printJedec();
  }
  else if (cmd == 'E') {
    chipErase();
  }
  else if (cmd == 'B') {
    blankCheck();
  }
  else if (cmd == 'D') {
    dumpFlash();
  }
  else if (cmd == 'P') {
    uint8_t hdr[5];
    if (!readExactSerial(hdr, 5, 3000)) {
      Serial.println("ERR_HEADER_TIMEOUT");
      return;
    }
 
    uint32_t address = ((uint32_t)hdr[0] << 16) |
                       ((uint32_t)hdr[1] << 8) |
                       ((uint32_t)hdr[2]);
    uint16_t len = ((uint16_t)hdr[3] << 8) | hdr[4];
 
    if (len == 0 || len > PAGE_SIZE || ((address & 0xFF) + len > PAGE_SIZE)) {
      Serial.println("ERR_PARAM");
      return;
    }
 
    uint8_t buffer[PAGE_SIZE];
    if (!readExactSerial(buffer, len, 5000)) {
      Serial.println("ERR_DATA_TIMEOUT");
      return;
    }
 
    if (programPage(address, buffer, len)) {
      Serial.println("OK");
    } else {
      Serial.print("ERR_VERIFY 0x");
      Serial.println(address, HEX);
    }
  }
}

PC-Side Python Tool

The Python program performs:

Image size validation

Image SHA256 validation

JEDEC verification

Explicit ERASE confirmation

Chip erase

Blank check

256-byte page programming

Per-page verification

Complete 16 MiB read-back

Final SHA256 verification

Important:

The EXPECTED_SHA256 value inside the Python program belongs to the restore image being programmed.

Do not copy my SHA256 value blindly.

Calculate the SHA256 of your own restore image and replace EXPECTED_SHA256 accordingly.

Code:
# REV17
# MSI B350 Tomahawk / W25Q128FW recovery writer
# Sequence: identify -> hash guard -> explicit ERASE confirmation -> chip erase -> blank check
# -> 256-byte page program (Arduino verifies every page) -> full 16 MiB read-back SHA256 verify.
 
import hashlib
import os
import serial
import sys
import time
 
PORT = "COM8"
BAUD = 1_000_000
FLASH_SIZE = 16_777_216
EXPECTED_SHA256 = "db31227075b7980fbeb0a8adc385fd7f056dc5d359c950d236cce4e278bbfffc"
EXPECTED_JEDEC = "JEDEC=EF 60 18"
PAGE_SIZE = 256
 
if len(sys.argv) < 2:
    print('Kullanim: py REV17_bios_write_verify.py "E7A34AMS_1M0_DMI_PRESERVED.bin"')
    sys.exit(1)
 
image_path = sys.argv[1]
readback_path = os.path.splitext(image_path)[0] + "_READBACK.bin"
 
if not os.path.isfile(image_path):
    print("HATA: Dosya bulunamadi:", image_path)
    sys.exit(1)
 
size = os.path.getsize(image_path)
if size != FLASH_SIZE:
    print("HATA: Boyut yanlis:", size, "beklenen:", FLASH_SIZE)
    sys.exit(1)
 
h = hashlib.sha256()
with open(image_path, "rb") as f:
    for chunk in iter(lambda: f.read(1024 * 1024), b""):
        h.update(chunk)
image_sha = h.hexdigest()
 
print()
print("REV17 MSI BIOS WRITE + VERIFY")
print("Port   :", PORT)
print("Image  :", image_path)
print("Boyut  :", size)
print("SHA256 :", image_sha)
print()
 
if image_sha.lower() != EXPECTED_SHA256:
    print("HATA: Restore image SHA256 beklenen degerle ayni degil.")
    print("Beklenen:", EXPECTED_SHA256)
    sys.exit(1)
 
ser = serial.Serial(PORT, BAUD, timeout=5, write_timeout=5)
 
def readline_text(timeout=10):
    old = ser.timeout
    ser.timeout = timeout
    raw = ser.readline()
    ser.timeout = old
    return raw.decode("ascii", errors="ignore").strip()
 
print("Arduino bekleniyor...")
ready = False
jedec_ok = False
for _ in range(40):
    line = readline_text(1)
    if not line:
        continue
    print(line)
    if line == EXPECTED_JEDEC:
        jedec_ok = True
    if line == "WAITING":
        ready = True
    if ready and jedec_ok:
        break
 
# Explicit JEDEC request once Arduino is up.
ser.reset_input_buffer()
ser.write(b"J")
ser.flush()
line = readline_text(3)
print(line)
if line != EXPECTED_JEDEC:
    print("HATA: JEDEC kimligi beklenen degil. ERASE YAPILMADI.")
    ser.close()
    sys.exit(1)
 
print()
print("Restore image ve flash kimligi dogrulandi.")
confirm = input('FLASH SILINECEK. Devam etmek icin tam olarak ERASE yaz: ').strip()
if confirm != "ERASE":
    print("Iptal edildi. Flash degistirilmedi.")
    ser.close()
    sys.exit(0)
 
# ERASE
print("\nChip erase basliyor...")
ser.reset_input_buffer()
ser.write(b"E")
ser.flush()
erase_ok = False
start = time.time()
while time.time() - start < 330:
    line = readline_text(5)
    if not line:
        continue
    print(line)
    if line == "ERASE_OK":
        erase_ok = True
        break
    if line.startswith("ERR_"):
        break
if not erase_ok:
    print("HATA: Chip erase tamamlanmadi. Yazma baslatilmadi.")
    ser.close()
    sys.exit(1)
 
# BLANK CHECK
print("\nBlank check basliyor...")
ser.reset_input_buffer()
ser.write(b"B")
ser.flush()
blank_ok = False
start = time.time()
while time.time() - start < 300:
    line = readline_text(5)
    if not line:
        continue
    print(line)
    if line == "BLANK_OK":
        blank_ok = True
        break
    if line.startswith("BLANK_FAIL"):
        break
if not blank_ok:
    print("HATA: Blank check gecmedi. Programlama baslatilmadi.")
    ser.close()
    sys.exit(1)
 
# PROGRAM
print("\nProgramlama basliyor...")
start = time.time()
with open(image_path, "rb") as f:
    for page in range(FLASH_SIZE // PAGE_SIZE):
        address = page * PAGE_SIZE
        data = f.read(PAGE_SIZE)
        if len(data) != PAGE_SIZE:
            print("HATA: Image beklenmedik sekilde bitti.")
            ser.close()
            sys.exit(1)
 
        packet = (
            b"P" +
            address.to_bytes(3, "big") +
            PAGE_SIZE.to_bytes(2, "big") +
            data
        )
 
        ser.write(packet)
        ser.flush()
        reply = readline_text(5)
        if reply != "OK":
            print(f"\nHATA: 0x{address:06X} sayfasinda program/verify hatasi: {reply!r}")
            ser.close()
            sys.exit(1)
 
        if (page + 1) % 4096 == 0 or page == 0:
            done = (page + 1) * PAGE_SIZE
            percent = done * 100.0 / FLASH_SIZE
            elapsed = time.time() - start
            speed = done / max(elapsed, 0.001) / 1024
            print(f"{done:>9} / {FLASH_SIZE} ({percent:5.1f}%) {speed:7.1f} KB/s")
 
program_time = time.time() - start
print("Programlama + page verify tamamlandi. Sure:", round(program_time, 1), "s")
 
# FULL READ-BACK
print("\nTam 16 MiB read-back SHA256 verify basliyor...")
ser.reset_input_buffer()
ser.write(b"D")
ser.flush()
 
while True:
    line = readline_text(10)
    if not line:
        print("HATA: DUMP_BEGIN gelmedi.")
        ser.close()
        sys.exit(1)
    if line == "DUMP_BEGIN":
        break
    print(line)
 
remaining = FLASH_SIZE
read_sha = hashlib.sha256()
received = 0
start = time.time()
next_report = 1024 * 1024
 
with open(readback_path, "wb") as out:
    while remaining:
        want = min(16384, remaining)
        chunk = bytearray()
        retries = 0
        while len(chunk) < want:
            data = ser.read(want - len(chunk))
            if data:
                chunk.extend(data)
                retries = 0
            else:
                retries += 1
                if retries >= 15:
                    print("HATA: Read-back veri akisi kesildi. Alinan:", received + len(chunk))
                    ser.close()
                    sys.exit(1)
        out.write(chunk)
        read_sha.update(chunk)
        received += len(chunk)
        remaining -= len(chunk)
 
        if received >= next_report or received == FLASH_SIZE:
            percent = received * 100.0 / FLASH_SIZE
            elapsed = time.time() - start
            speed = received / max(elapsed, 0.001) / 1024
            print(f"{received:>9} / {FLASH_SIZE} ({percent:5.1f}%) {speed:7.1f} KB/s")
            next_report += 1024 * 1024
 
ser.close()
read_sha_hex = read_sha.hexdigest()
 
print("\n--------------------------------")
print("READ-BACK TAMAMLANDI")
print("Readback:", readback_path)
print("SHA256  :", read_sha_hex)
print("Beklenen:", image_sha)
 
if read_sha_hex.lower() == image_sha.lower():
    print("VERIFY   : BASARILI - BYTE-FOR-BYTE IMAGE DOGRU")
    print("--------------------------------")
    sys.exit(0)
else:
    print("VERIFY   : HATA - HASH ESLESMIYOR")
    print("Anakarti calistirmayin; mevcut programlayici baglantisini koruyun.")
    print("--------------------------------")
    sys.exit(2)

Files I Recommend Keeping Permanently

bios_dump_1.bin

bios_dump_2.bin

Original MSI stock BIOS

Board-specific restore image

Final read-back image

Arduino programmer source code

Python write/verify tool

Final Notes

This was an in-circuit recovery performed on an MSI B350 TOMAHAWK using the onboard JSP11 service header and a Winbond W25Q128FW-class 1.8 V SPI flash.

The most important rule in the entire process was:

Never erase the original flash until you have two independent full dumps with identical SHA256 hashes.

And after programming:

Never assume that successful programming means the flash is correct. Read the complete flash back and compare its SHA256 against the image you intended to write.

I hope this helps someone recover a motherboard that would otherwise be considered dead.
 
Last edited:
Back
Top