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.
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
-r, --reset <cmd> [args] ; command to perform reset or power cycle
-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
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
This will erase the flash.
./stc8prog -p /dev/ttyUSB0 -e
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
By default PlatformIO places packages at /home/[username]/.platformio/packages
tool-stc8prog
under itCreate 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
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:
[your env name]
in PROJECT TASKS
Advanced
Verbose Upload
, this will output the full log of all commandssudo apt install build-essential
xcode-select --install
git clone https://github.com/IOsetting/stc8prog.git
cd stc8prog
make
sudo make install
Package dev-embedded/stc8prog-9999 located in unoficial rasdark overlay. Resulting binary will be from last commit from https://github.com/IOsetting/stc8prog.git