Wednesday, March 3, 2021

Install CH552 support for platformio (and CH5xx variants) with ch5xduino support

https://community.platformio.org/t/platformio-8051-model-medium-linker-err/18099

''
mkdir ~/.platformio/boards
cd ~/.platformio/boards
cat > ch55xduino.json << 'EOF'
{
  "build": {    
    "f_cpu": "24000000",
    "size_iram": 256,
    "size_xram": 1024,
    "size_code": 14336,
    "size_heap": 128,
    "mcu": "ch552t",
    "cpu": "mcs51"
  },
  "frameworks": [],
  "upload": {
    "maximum_ram_size": 1280,
    "maximum_size": 14336,
    "protocol": "stcgal",
    "stcgal_protocol": "stc15",
    "protocols": [
      "stcgal"
    ]
  },
  "name": "Generic CH552",
  "url": "http://www.wch.cn/product/CH552.html",
  "vendor": "WCH"
}
EOF

platformio boards|grep ch5xduino
cd
mkdir myproj552
cd myproj552
platformio init --board ch55xduino

cat > platformio.ini <<'EOF'
[env:ch552]
platform = intel_mcs51
board = ch552
build_flags =
  --model-medium
  --LC:/Users/caoyf/.platformio/packages/toolchain-sdcc/lib/medium
  -IC:
  -IC:/Users/caoyf/Documents/PlatformIO/Projects/ch552_gpio/src/Driver/inc
  -Isrc/PLAT/inc

extra_scripts = link_medium.py
'EOF'

cat > link_medium.py
Import("env")
env.Append(LINKFLAGS=["--model-medium"])

''