Community-PIO-CH32V / platform-ch32v

PlatformIO platform for CH32V RISC-V chips (CH32V003, CH32V103, CH32V20x, CH32V30x, CH32X035) and CH56x, CH57x, CH58x, CH59x
Apache License 2.0
203 stars 34 forks source link

CH592F: isp flash/upload failed #67

Closed KenjutsuGH closed 4 weeks ago

KenjutsuGH commented 1 month ago

When I try to upload to my WeAct CH592F board using the isp protocol, I get the error:

Configuring upload protocol...
AVAILABLE: isp, minichlink, wch-link, wlink
CURRENT: upload_protocol = isp
Uploading .pio/build/genericCH592F/firmware.elf
Error: Device type of 0x22 not found
*** [upload] Error 1

When I go to the project directory and manually invoke wchisp (0.2.3), it works:

wchisp  flash .pio/build/genericCH592F/firmware.elf                    
08:53:06 [INFO] Chip: CH592[0x9222] (Code Flash: 448KiB, Data EEPROM: 32KiB)
08:53:06 [INFO] Chip UID: 42-38-4F-10-53-5C-E4-A4
08:53:06 [INFO] BTVER(bootloader ver): 02.30
08:53:06 [INFO] Current config registers: ffffffffffffffff4d0fff4f0002030042384f10535ce4a4
RESERVED: 0xFFFFFFFF
WPROTECT: 0xFFFFFFFF
  [0:0]   NO_KEY_SERIAL_DOWNLOAD 0x1 (0b1)
    `- Enable
  [1:1]   DOWNLOAD_CFG 0x1 (0b1)
    `- PB22(Default set)
USER_CFG: 0x4FFF0F4D
  [2:0]   RESERVED 0x5 (0b101)
    `- Default
  [3:3]   CFG_RESET_EN 0x1 (0b1)
    `- Enable
  [4:4]   CFG_DEBUG_EN 0x0 (0b0)
    `- Disable
  [5:5]   RESERVED 0x0 (0b0)
    `- Default
  [6:6]   CFG_BOOT_EN 0x1 (0b1)
    `- Enable
  [7:7]   CFG_ROM_READ 0x0 (0b0)
    `- Disable the programmer to read out, and keep the program secret
  [27:8]  RESERVED 0xFFF0F (0b11111111111100001111)
    `- Error
  [31:28] VALID_SIG 0x4 (0b100)
    `- Valid
08:53:06 [INFO] Read .pio/build/genericCH592F/firmware.elf as ELF format
08:53:06 [INFO] Found loadable segment, physical address: 0x00000000, virtual address: 0x00000000, flags: 0x5
08:53:06 [INFO] Section names: [".init"]
08:53:06 [INFO] Found loadable segment, physical address: 0x00000004, virtual address: 0x20000000, flags: 0x5
08:53:06 [INFO] Section names: [".highcode"]
08:53:06 [INFO] Found loadable segment, physical address: 0x00000874, virtual address: 0x00000874, flags: 0x5
08:53:06 [INFO] Section names: [".text"]
08:53:06 [INFO] Found loadable segment, physical address: 0x00000ea8, virtual address: 0x20000870, flags: 0x6
08:53:06 [INFO] Section names: [".data"]
08:53:06 [INFO] Firmware size: 4096
08:53:06 [INFO] Erasing...
08:53:06 [WARN] erase_code: set min number of erased sectors to 8
08:53:06 [INFO] Erased 8 code flash sectors
08:53:07 [INFO] Erase done
08:53:07 [INFO] Writing to code flash...
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 4096/409608:53:07 [INFO] Code flash 4096 bytes written
08:53:08 [INFO] Verifying...
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 4096/409608:53:08 [INFO] Verify OK
08:53:08 [INFO] Now reset device and skip any communication errors
08:53:08 [INFO] Device reset

My installed packages:

pio upgrade
You're up-to-date!
PlatformIO 6.1.15 is currently the newest version available.

My platformio.ini:

[env:genericCH592F]
platform = ch32v
board = genericCH592F
framework = noneos-sdk
upload_protocol = isp

I am using macOS Sonoma 14.5 (23F79) M1

maxgerhardt commented 4 weeks ago

When I go to the project directory and manually invoke wchisp (0.2.3), it works:

Can you copy your latest wchisp version into ~/.platformio/packages/tool-wchisp/ to overwrite the old version? Does PlatformIO upload then?

KenjutsuGH commented 4 weeks ago

Thank you @maxgerhardt, that solves the problem

maxgerhardt commented 3 weeks ago

Thanks for letting me to, I'll try to update the packages in a scripted way some time in the future.

s00500 commented 1 week ago

Just ran into the same, installed the 2.3 from cargo and copied it, now it works

maxgerhardt commented 6 hours ago

The updated tool-wchisp pacakges have been pio pkg publish'ed today, but are in manual review by the PlatformIO team before they're visible.