GithubHelp home page GithubHelp logo

marcinbor85 / can-prog Goto Github PK

View Code? Open in Web Editor NEW
77.0 7.0 21.0 61 KB

Command-line tool to flashing devices by CAN-BUS

License: MIT License

Python 100.00%
stm32 bootloade can bus canbus protocol socketcan

can-prog's Introduction

canprog

Command-line tool to flashing devices by CAN-BUS.

Main features

  • Support STM32 CAN-BUS ROM bootloader
  • Easily expand with other CAN-BUS protocols
  • Support iHEX and binary format files
  • Object oriented architecture
  • Command-line interface
  • Socket-CAN driver for CAN-BUS low level operations

Todo

  • Other microcontroller protocols
  • Other CAN-BUS interfaces
  • Autocalculating sectors for erasing (for STM32)
  • Memory write protect/unprotect (form STM32)
  • TDD tests

Requirements

  • Compatible PC CAN-BUS adapter
  • Linux + Python3
  • Enabled SocketCAN driver
  • Board with STM32 with CAN interface

Driver instalation

modprobe can
modprobe can-raw
modprobe slcan
slcand -o -c -f -s4 /dev/ttyUSB0 slcan0
ip link set up slcan0

App instalation

sudo pip install canprog

Usage:

General usage + configuration

usage: canprog [-h] [--verbose] [--version] [-n NAME] [-i {socketcan}]
               [-f {hex,bin}]
               {stm32} ...

Command-line tool to flashing devices by CAN-BUS.

others:
  -h, --help      show this help message and exit
  --verbose       enable verbose output
  --version       show program's version number and exit

configuration:
  -n NAME         interface name (default: slcan0)
  -i {socketcan}  interface type (default: socketcan)
  -f {hex,bin}    file format (default: hex)

protocols:
  {stm32}
    stm32         STM32 ROM bootloader

STM32 bootloader options

usage: canprog stm32 [-h] {write,read,erase,go,lock,unlock} ...

others:
  -h, --help            show this help message and exit

commands:
  {write,read,erase,go,lock,unlock}
    write               write file to target memory
    read                read target memory to file
    erase               erase target memory
    go                  start program application
    lock                enable readout protection
    unlock              disable readout protection
    speed               change the can baud rate the boot rom uses

Usage examples:

canprog stm32 write image.hex
canprog -f bin stm32 write image.bin -a 0x08000000
canprog stm32 read dump.hex -s 0x200
canprog stm32 lock
canprog stm32 erase -P 0 1 2 3

Example output:

[13:41:25.931] main INFO: Connecting target
[13:41:25.935] stm32 INFO: Bootloader initialized
[13:41:25.944] stm32 INFO: Bootloader version: 2.0
[13:41:25.947] stm32 INFO: Read protection: 0x0000
[13:41:25.950] stm32 INFO: Chip ID: 0x0413 - STM32F40xxx/41xxx
[13:41:25.950] main INFO: Connected
[13:41:25.958] main INFO: Writing memory at 0x08000000:6548
[13:41:25.958] stm32 INFO: Progress: 0%
[13:41:26.201] stm32 INFO: Progress: 11%
[13:41:26.429] stm32 INFO: Progress: 23%
[13:41:26.657] stm32 INFO: Progress: 35%
[13:41:26.895] stm32 INFO: Progress: 46%
[13:41:27.136] stm32 INFO: Progress: 58%
[13:41:27.371] stm32 INFO: Progress: 70%
[13:41:27.617] stm32 INFO: Progress: 82%
[13:41:27.908] stm32 INFO: Progress: 93%
[13:41:28.065] stm32 INFO: Progress: 100%
[13:41:28.065] main INFO: Successful
[13:41:28.065] main INFO: Writing memory at 0x08004000:16
[13:41:28.065] stm32 INFO: Progress: 0%
[13:41:28.074] stm32 INFO: Progress: 100%
[13:41:28.074] main INFO: Successful
[13:41:28.074] main INFO: Disconnecting target
[13:41:28.074] main INFO: Disconnected

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.