最近在 Ubuntu 上搭 51 单片机的开发环境。安装了网上推荐的烧写器 stcgal 。但是烧写总会卡在这里:
51 ➤ stcgal -P stc89 ./18b20/18b20.ihx Waiting for MCU, please cycle power:
不指定 protocol version 的话,又会这样:
51 ➤ stcgal ./18b20/18b20.ihx Waiting for MCU, please cycle power: done Protocol detected: stc89 Protocol error: packet checksum mismatch Disconnected!
去官方仓库看了一堆 issue ,发现了原因:
STC89C52 有不同的 BSL version,我手头的 BSL version 是 7.2C 。在我写下这篇文章的时候,stcgal 还不支持这个版本(曾经试着支持过,后来可能是因为有问题又取消了,详见这几个 commit 和 issue #50)。
好在有一个 fork 出去的版本已经支持了,仓库在这里。
直接 clone 下来,然后就可以正常使用。注意使用参数 -P stc89a:
51 ➤ python3 ./stcgal/stcgal.py -P stc89a ./18b20/18b20.ihx Waiting for MCU, please cycle power: done Target model: Name: STC89C52 Magic: F051 Code flash: 8.0 KB EEPROM flash: 6.0 KB Target frequency: 11.030 MHz Target BSL version: 7.2.5C Target options: cpu_6t_enabled=False bsl_pindetect_enabled=False eeprom_erase_enabled=False clock_gain=high ale_enabled=True xram_enabled=True watchdog_por_enabled=False Loading flash: 1610 bytes (Intel HEX) Switching to 19200 baud: checking 19200 testing done Erasing All blocks: MCU ID: f051c5f06f012 done Writing flash: 2176 Bytes [00:01, 1266.72 Bytes/s] Setting options: done Disconnected!



