Giter VIP home page Giter VIP logo

stm32loader's Introduction

STM32Loader
===========

Python script which will talk to the STM32 bootloader to upload and download firmware.

Original Version by: Ivan A-R <[email protected]>


Usage: ./stm32loader.py [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin]
    -h          This help
    -q          Quiet
    -V          Verbose
    -e          Erase
    -w          Write
    -v          Verify
    -r          Read
    -l length   Length of read
    -p port     Serial port (default: /dev/tty.usbserial-ftCYPMYJ)
    -b baud     Baud speed (default: 115200)
    -a addr     Target address

    ./stm32loader.py -e -w -v example/main.bin


Example:
stm32loader.py -e -w -v somefile.bin

This will pre-erase flash, write somefile.bin to the flash on the device, and then perform a verification after writing is finished.

stm32loader's People

Contributors

jsnyder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32loader's Issues

unable to load firmware to stm32f103C

I have setup stm32 board properly with boot0 set to 1 and boot1 set to 0 and connecting RX and TX to arduino uno board removing mcu from it.
I get this error ..

 python ./stm32loader.py -p /dev/cu.usbmodem1421 -w ~/Downloads/generic_boot20_pc13.bin
Can't init. Ensure that BOOT0 is enabled and reset device
Traceback (most recent call last):
  File "./stm32loader.py", line 436, in <module>
    bootversion = cmd.cmdGet()
  File "./stm32loader.py", line 118, in cmdGet
    if self.cmdGeneric(0x00):
  File "./stm32loader.py", line 115, in cmdGeneric
    return self._wait_for_ask(hex(cmd))
  File "./stm32loader.py", line 91, in _wait_for_ask
    raise CmdException("Unknown response. "+info+": "+hex(ask))
__main__.CmdException: Unknown response. 0x0: 0xf8

whats the problem I can't upload the firmware. :(

Clarify maintainership status

Hi,

It seems this repository receives no maintenance anymore.

I'm glad to assist ; I have a modernized fork at https://github.com/florisla/stm32loader .
I'd be open for all options - merge back to here, put this repository under an organization, ...

Please weigh in on how you'd like stm32loader to evolve.

The current situation is confusing for users, since there's no indication that merge requests are not being considered. See e.g. #16 (comment)

Open Source license?

It seems this script has spawned a large amount of children. Lots of projects refer to it as their startingpoint.

However, this project does not clarify under which license it may be used?

Is this project open source? If so, under which license may it be used?

Invalid syntax

Hi ,

I am using stm32loader 0.5.0 to flash fw to STMF4 series board. Using , python 3.7 series.
I am trying to run in command line first, but it throws me sytax error(Invalid end of statement) , I have attached screen shot. what could be the problem. Can you help me how do I run through program or command line properly ?

STM32loader

Addition of run / go feature

Hi,

FYI.

I'm using this for a port of Arduino to STM32F1xx hardware.

However I noticed that your script didnt have a run/go feature in its command line, but I also noticed that you had written code to do this, but just didn't have a way to call it

So I've done some very minor changes to add a -g option, which Go/Run's the after upload from the address of the upload

See https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/tools/win/stm32loader.py

I guess that perhaps the -g option would be good if the address is optional, but my python skills are not up to doing that (well I'd have to do some research on how to do it etc)

But I think adding the -g option even if it just runs from the upload address is worth including

Thanks

Roger

When not provided with no argument, it should report an error and usage example

When not provided with no argument, it should report an error and usage example.

Right now, it throws an error saying it cannot find "/dev/tty.usbserial-ftCYPMYJ":

$ ./stm32loader.py 
Traceback (most recent call last):
  File "./stm32loader.py", line 427, in <module>
    cmd.open(conf['port'], conf['baud'])
  File "./stm32loader.py", line 71, in open
    timeout=5               # set a timeout value, None for waiting forever
  File "/usr/lib64/python2.7/site-packages/serial/serialutil.py", line 236, in __init__
    self.open()
  File "/usr/lib64/python2.7/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/tty.usbserial-ftCYPMYJ: [Errno 2] No such file or directory: '/dev/tty.usbserial-ftCYPMYJ'

Documentation updates

Hi Guys,

I think it is necessary to insert prerequisites like python version.

Regards,

Unable to load firmware to Blue Pill.

I'm following the instructions on https://medium.com/@paramaggarwal/converting-an-stm32f103-board-to-a-black-magic-probe-c013cf2cc38c to use stm32loader to flash the blackmagic firmware onto Blue Pill boards.

I have tried four separate boards, ordered on two different occasions.

The error I get is most often:

fadedbee@cyan:~/blackmagic/src$ python ../../stm32loader/stm32loader.py -p /dev/ttyUSB0 -e -w -v blackmagic_dfu.bin
Bootloader version 22
Chip id: 0x410 (STM32 Medium-density)
Write 256 bytes at 0x8000000
Write 256 bytes at 0x8000100
Write 256 bytes at 0x8000200
Write 256 bytes at 0x8000300
Write 256 bytes at 0x8000400
Write 256 bytes at 0x8000500
Write 256 bytes at 0x8000600
Write 256 bytes at 0x8000700
Write 256 bytes at 0x8000800
Write 256 bytes at 0x8000900
Write 256 bytes at 0x8000A00
Write 256 bytes at 0x8000B00
Write 256 bytes at 0x8000C00
Write 256 bytes at 0x8000D00
Write 256 bytes at 0x8000E00
Write 256 bytes at 0x8000F00
Write 256 bytes at 0x8001000
Write 256 bytes at 0x8001100
Write 256 bytes at 0x8001200
Write 256 bytes at 0x8001300
Write 256 bytes at 0x8001400
Write 256 bytes at 0x8001500
Write 256 bytes at 0x8001600
Write 256 bytes at 0x8001700
Write 256 bytes at 0x8001800
Write 256 bytes at 0x8001900
Write 256 bytes at 0x8001A00
Write 256 bytes at 0x8001B00
Write 256 bytes at 0x8001C00
Read 256 bytes at 0x8000000
Read 256 bytes at 0x8000100
Read 256 bytes at 0x8000200
Read 256 bytes at 0x8000300
Read 256 bytes at 0x8000400
Read 256 bytes at 0x8000500
Read 256 bytes at 0x8000600
Read 256 bytes at 0x8000700
Read 256 bytes at 0x8000800
Read 256 bytes at 0x8000900
Read 256 bytes at 0x8000A00
Read 256 bytes at 0x8000B00
Read 256 bytes at 0x8000C00
Read 256 bytes at 0x8000D00
Read 256 bytes at 0x8000E00
Read 256 bytes at 0x8000F00
Read 256 bytes at 0x8001000
Read 256 bytes at 0x8001100
Read 256 bytes at 0x8001200
Read 256 bytes at 0x8001300
Read 256 bytes at 0x8001400
Read 256 bytes at 0x8001500
Read 256 bytes at 0x8001600
Read 256 bytes at 0x8001700
Read 256 bytes at 0x8001800
Read 256 bytes at 0x8001900
Read 256 bytes at 0x8001A00
Read 256 bytes at 0x8001B00
Read 256 bytes at 0x8001C00
Verification FAILED
7348 vs 7348
0xe0: 0xbf vs 0xff
0x14c: 0xbf vs 0xff
0x156: 0x70 vs 0xb9
0x157: 0x47 vs 0x23
0x158: 0x10 vs 0x88
0x159: 0xb5 vs 0xda
0x15a: 0xf vs 0x7
0x15b: 0x4c vs 0x26
0x15c: 0x22 vs 0x11
0x15d: 0x68 vs 0xb4
0x15e: 0xa3 vs 0x51
0x15f: 0x88 vs 0x44
0x160: 0x2a vs 0x95
0x161: 0xb9 vs 0xdc
0x162: 0xbd vs 0x5e
0x163: 0xe8 vs 0x74
0x164: 0x10 vs 0x8
0x165: 0x40 vs 0xa0
0x166: 0x19 vs 0xc
0x167: 0x46 vs 0x23
0x168: 0xc vs 0x6
0x169: 0x48 vs 0x24
0x16b: 0xf0 vs 0x78
0x16c: 0xe2 vs 0xf1
0x16d: 0xbb vs 0x5d
0x16e: 0xa2 vs 0x51
0x16f: 0x68 vs 0x34
0x170: 0x12 vs 0x9
0x171: 0xf0 vs 0xf8
0x172: 0x1 vs 0x0
0x173: 0x2 vs 0x81
0x174: 0xb vs 0x5
0x175: 0xd0 vs 0x68
0x177: 0x22 vs 0x11
0x178: 0x2 vs 0x81
0x179: 0x21 vs 0x10
0x17a: 0x8 vs 0x84
0xb16: 0xff vs 0xbf
0xc80: 0xcb vs 0xcf
0xd7e: 0x13 vs 0x11
0xd90: 0xff vs 0xbf
0x122c: 0x1f vs 0x3f
0x122d: 0xfa vs 0x7d
0x122e: 0x8a vs 0xc5
0x122f: 0xf9 vs 0x7c
0x1230: 0x4a vs 0x25
0x1231: 0x46 vs 0x23
0x1233: 0xf0 vs 0xf8
0x1234: 0x45 vs 0x22
0x1235: 0xfc vs 0x7e
0x1236: 0x0 vs 0x80
0x1237: 0x9b vs 0x4d
0x1238: 0xa4 vs 0xd2
0x1239: 0xeb vs 0xf5
0x123a: 0x9 vs 0x4
0x123b: 0x4 vs 0x82
0x123c: 0xd3 vs 0xe9
0x1781: 0xbf vs 0xff

but sometimes:

fadedbee@cyan:~/blackmagic/src$ python ../../stm32loader/stm32loader.py -p /dev/ttyUSB0 -e -w -v blackmagic_dfu.bin
Bootloader version 22
Chip id: 0x410 (STM32 Medium-density)
Write 256 bytes at 0x8000000
Write 256 bytes at 0x8000100
Write 256 bytes at 0x8000200
Write 256 bytes at 0x8000300
Write 256 bytes at 0x8000400
Write 256 bytes at 0x8000500
Write 256 bytes at 0x8000600
Write 256 bytes at 0x8000700
Write 256 bytes at 0x8000800
Write 256 bytes at 0x8000900
Write 256 bytes at 0x8000A00
Write 256 bytes at 0x8000B00
Write 256 bytes at 0x8000C00
Write 256 bytes at 0x8000D00
Write 256 bytes at 0x8000E00
Write 256 bytes at 0x8000F00
Write 256 bytes at 0x8001000
Write 256 bytes at 0x8001100
Write 256 bytes at 0x8001200
Write 256 bytes at 0x8001300
Write 256 bytes at 0x8001400
Write 256 bytes at 0x8001500
Write 256 bytes at 0x8001600
Write 256 bytes at 0x8001700
Write 256 bytes at 0x8001800
Write 256 bytes at 0x8001900
Write 256 bytes at 0x8001A00
Write 256 bytes at 0x8001B00
Write 256 bytes at 0x8001C00
Traceback (most recent call last):
  File "../../stm32loader/stm32loader.py", line 455, in <module>
    cmd.writeMemory(conf['address'], data)
  File "../../stm32loader/stm32loader.py", line 337, in writeMemory
    self.cmdWriteMemory(addr, data[offs:offs+lng] + ([0xFF] * (256-lng)) )
  File "../../stm32loader/stm32loader.py", line 204, in cmdWriteMemory
    self._wait_for_ask("0x31 programming failed")
  File "../../stm32loader/stm32loader.py", line 80, in _wait_for_ask
    raise CmdException("Can't read port or timeout")
__main__.CmdException: Can't read port or timeout

Is there any further investigation I can do?

Question about syntax

Hi,

I have instructions to flash a firmware that were done with the old version of stm32loader by Ivan A-R.

./stm32loader.py -p $port -b 115200 -a 0x8000000 -E 126 -w firmware.bin

I would like to use your version as it works with python3.

But I'm uncertain about corresponding syntax.

Options for the old version were :
-h This help
-q Quiet
-V Verbose
-e Erase
-E nbPages Erase nbPages flash block
-w Write
-v Verify
-r Read
-l length Length of read
-p port Serial port (default: /dev/tty.usbserial-ftCYPMYJ)
-b baud Baud speed (default: 115200)
-a addr Target address

What would be the correct commande line with the new version, especially regarding -a and -E of the old syntax ?

Thanks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.