GithubHelp home page GithubHelp logo

humbleoh / stc8prog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iosetting/stc8prog

0.0 0.0 0.0 169 KB

Open Source STC8G/STC8H ISP flash tool

License: Apache License 2.0

C 98.90% Makefile 1.10%

stc8prog's Introduction

stc8prog - STC MCU ISP flash tool

stc8prog is a command line flash programming tool for STC 8051 series microcontrollers, Currently, only STC8H/STC8G/STC8A, STC15 (FWVER > 0x72) series are supported.

STC microcontrollers have an UART/USB based boot strap loader (BSL). It utilizes a packet-based protocol to flash the code memory and IAP memory over a serial link. This is referred to as in-system programming (ISP). This tool is built according to the ISP described in STC8H datasheet.

Tested MCU Types:

  • STC8A8K64S4A12
  • STC8A8K64D4
  • STC8G1K08A
  • STC8H1K08
  • STC8H3K32S2
  • STC8H3K64S4
  • STC8H8K64U
  • STC15W104
  • STC15F104W
  • STC15W408AS
  • STC15F2K60S2

How To Use

CLI Tool

Usage: stc8prog [options]...
  -h, --help            display this message
  -p, --port <device>   set device path
  -s, --speed <baud>    set download baudrate
  -r, --reset <msec>    make reset sequence by pulling low dtr
  -f, --flash <file>    flash chip with data from hex file
  -e, --erase           erase the entire chip
  -d, --debug           enable debug output
  -v, --version         display version information

Baudrate options: 
   4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000,
   921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000,
   4000000

Check

Communicate with MCU without changing anything. It will communicate in 2400 baud first, then switch to a higher baud for a second check

# 2400 baud -> 115200 baud
./stc8prog -p /dev/ttyUSB0

You can specify other baud with parameter -s

# 2400 baud -> 1152000 baud
./stc8prog -p /dev/ttyUSB0 -s 1152000

Erase Flash

This will erase the flash.

./stc8prog -p /dev/ttyUSB0 -e

Write Flash

Suggest to erase before writing flash

./stc8prog -p /dev/ttyUSB0 -e -f foo.hex

High baudrate will speed up the writing

./stc8prog -p /dev/ttyUSB0 -s 1152000 -e -f foo.hex

PlatformIO Integration

1. Add it to packages

By default PlatformIO places packages at /home/[username]/.platformio/packages

  1. create a folder named tool-stc8prog under it
  2. and place stc8prog executable under it.

2. Configurate platformio.ini

Create a new env in platformio.ini, it can be a clone of existing one, change the name and change upload_protocol option to custom, then configurate the rest accordingly, for example:

[env:stc8h3k32s2-stc8prog]
platform = intel_mcs51
board = stc8h3k32s2
upload_protocol = custom
upload_port = /dev/ttyUSB0
upload_flags =
    -p
    $UPLOAD_PORT
    -s
    1152000
    -e
upload_command = ${platformio.packages_dir}/tool-stc8prog/stc8prog $UPLOAD_FLAGS -f $SOURCE

If you want to reset the MCU by pulling DTR line low, add -r 5 to upload_flags config
If you want to make this env default, set it to default_envs

[platformio]
default_envs = stc8h3k32s2-stc8prog

For more options, please read platformio section_env_upload

3. First time upload

You can trigger upload with hotkey Ctrl+Alt+U.

If there are any erros and you want to see more detailed logs, run it in the verbose way:

  1. Click PlatformIO icon in the left navigation panel
  2. Expand [your env name] in PROJECT TASKS
  3. Expand Advanced
  4. Click Verbose Upload, this will output the full log of all commands

Build From Source

Install DEV-tools

sudo apt install build-essential

Checkout the project

git clone https://github.com/IOsetting/stc8prog.git

Compile the project

cd stc8prog
make

Optional: install to system path

sudo make install

Gentoo linux

Package dev-embedded/stc8prog-9999 located in unoficial rasdark overlay. Resulting binary will be from last commit from https://github.com/IOsetting/stc8prog.git

Build From Source in Windows under Cygwin

  1. Run Cygwin setup
  2. Install 'gcc-core' and 'make' packages
  3. Use command-line git to pull latest stc8prog source to desired folder
  4. Run Cygwin terminal
  5. Navigate to folder with stc8prog source (windows disks are mapped to /cygdrive; eg. to navigate to 'stc8prog' folder located on 'D' drive, use 'cd /cygdrive/d/stc8prog/')
  6. Run make to build binary
  • By default, Cygwin's gcc binary requires cygwin1.dll to work correctly, just copy it from Cygwin installation dir bin folder

stc8prog's People

Contributors

egan-ru avatar iosetting avatar xuhg-zjcn avatar

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.