#!/usr/bin/python # # stm32_mem.py: STM32 memory access using USB DFU class # Copyright (C) 2009 Black Sphere Technologies # Written by Gareth McMullin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from time import sleep import struct from sys import stdout, argv import usb import dfu CMD_GETCOMMANDS = 0x00 CMD_SETADDRESSPOINTER = 0x21 CMD_ERASE = 0x41 def stm32_erase(dev, addr): erase_cmd = struct.pack("