在淘寶買了一台新的單片機 HC6800-ES (STC12C2052) 但附送的都是 Win 平台的東西, 所以要找方法在 Linux 下燒錄

  1. Install sdcc either from website or by “apt” (Debian/Ubuntu) or “dnf” (Fedora)

  2. Install python-serial package

  3. Install STCFlash (Python tool for flashing to STC12C2052) from repository

  4. Write a simple blink.c for testing

    #include <8052.h> __sbit __at 0x80 LED; // or // #define LED P0_0 void main() { unsigned int i=0; while (1) { for (i=0; i<10000; i++) LED = 0; for (i=0; i<10000; i++) LED = 1; } }

  5. Compile to BIN file

    sdcc blink.c

  6. Convert the format to HEX

    objcopy -Iihex -Obinary blink.hex blink.bin

  7. Flash to the device after plugging in USB and reset

    python stcflash.py blink.hex