dword1511 / stm32-vserprog

flashrom serprog programmer based on STM32 MCU & USB CDC protocol. Uses libopencm3 and deprecates the old serprog-stm32vcp project.
GNU General Public License v3.0
310 stars 91 forks source link

stm32-vserprog:

flashrom serprog programmer based on STM32 MCU & USB CDC protocol.

This project deprecates previous serprog-stm32vcp project, which uses STMicro's proprietary firmware library. Most functions are the same.


Features

  1. Clone and compile.

    Simply type (change the board name accordingly, for details see the header of the Makefile or just type make):

    git clone --recurse-submodules https://github.com/dword1511/stm32-vserprog.git
    make BOARD=stm32-vserprog-v2
  2. Program.

    Connect the USB-to-UART bridge to your computer first. Then connect TXD and RXD lines to your STM32 board with wires. On V2 or V3 boards mentioned above, connect BOOT0 (labeled BT0 on boards) to the 3.3V output of the USB-to-UART bridge. For other boards, find the BOOT0 jumper or ISP switch, put it into high or enabled. On some boards, you will also need to ensure BOOT1 is pulled low. Then, connect your STM32 board to your computer via USB to power it up. Finally, type:

    make BOARD=stm32-vserprog-v2 flash-uart
  3. Done!

    Throw the USB-to-UART bridge away and enjoy. Do not forget to pull BOOT0 low before resetting or replugging the board.


Usage

The following assumes Linux platform, and that the programmer appears as /dev/ttyACM0.

  1. To read a flash chip:

    • Connect a 25 type SPI Flash to the board's DIP-8 slot or according to the schematics.
    • Connect your board to your PC via USB.
    • Type:
    flashrom -p serprog:dev=/dev/ttyACM0:4000000 -r file-to-save.bin
    • Sometimes flashrom will ask you to choose a chip, add something like:
    -c SST25VF040B

    This is because sometimes different devices with distinct timing requirements can only be distinguished by the device code, however currently flashrom will not read it as it is not returned by the RDID command.

  2. To erase a flash chip:

    • Erase is automatically done during writing. However, if you simply want an empty chip, you will need to erase manually.
    • Type:
    flashrom -p serprog:dev=/dev/ttyACM0:4000000 -E
    • For certain chips like MX25L6445E, the first pass could fail with some old flashrom version, but if you try a second pass, everything will be alright. Seems that the first block needs more delay to be erased.
    • Flash contents are verified to be empty automatically.
    • The whole process can take a few minutes.
  3. To write a flash chip:

    • Type:
    flashrom -p serprog:dev=/dev/ttyACM0:4000000 -w file-to-load.bin
    • Flash chips are checked and blocks that are not empty are automatically erased.
    • Images are verified after writing automatically.
    • The whole process can take a few minutes.

Problems?

  1. If you encountered something like "Error: Cannot open serial port: Device or resource busy", please try to stop or remove ModemManager.
  2. Check your wirings and flashrom version. Do not forget to power the flash chip itself if operating on a breadboard or prototype board.
  3. If you are sure it is caused by bugs in the programmer's firmware, please open a new ticket and provide details, e.g. the board you are using and flashrom's output. I appreciate your feedback.