frank-zago / isp55e0

An ISP flashing tool for the WCH CH55x, CH579, CH32F103 under linux
GNU General Public License v3.0
52 stars 18 forks source link

CH32X035F7P6 incorrect code flash size #18

Open nikitos1550 opened 1 month ago

nikitos1550 commented 1 month ago

The chip has 62K as other in x035 series. 62K is mentioned in pdf files and x035 page desciption (WCH website), same time chips list page says it is 48K, that seem to be typo.

        {
                .name = "CH32X035F7P6",  
                .family = 0x23,
                .type = 0x57,   
                .code_flash_size = 49152, // ----> 62K !
                .mcu_id_len = 8,
                .clear_cfg_rom_read = true,
                .need_remove_wp = true,
                .need_last_write = true,
        },
nikitos1550 commented 1 month ago

There is new code:

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0
# Copyright 2024 Frank Zago

# Generate chips.h from upstream wcfg files

import configparser

Where wcfg files can be obtained?

frank-zago commented 1 month ago

The wcfg files are part of the official WCHISPTool from wch. https://www.wch-ic.com/downloads/WCHISPTool_Setup_exe.html

frank-zago commented 1 month ago

I can make a patch for that, but since you have that chip, could you check whether you can actually flash a 62KB file?

frank-zago commented 1 month ago

The CH32L103F7P6 is also listed as having 48KB, while the others in that family have 64KB, so this might be correct and the docs are wrong.

nikitos1550 commented 1 month ago

I already checked, but with random 62K data. Here is closed PR https://github.com/frank-zago/isp55e0/pull/17 with log from my console.

nikitos1550 commented 1 month ago

Well, I can think that typo in doc also possible. Let postpone this issue for a while, I have plans to code some test for ch32x035, I will also make some test that will check actual flash size.

nikitos1550 commented 1 month ago

I just come to ch32x035 EVT and first applications.

/* Flash Program Valid Address */
#define ValidAddrStart             (FLASH_BASE)
#define ValidAddrEnd               (FLASH_BASE + 0xF800)

EVT has same settings for all chips (all family). 0xF800 is 62K.

Also there is only one link script for all chips.

FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 62K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K

Later I can proof it with some application, but seems WCH util has some mistake or error.

nikitos1550 commented 4 weeks ago

I asked vendor about this, the answer was that there actually two versions, 48k and 62k! 48k is old one. We can read specific register to understand what version we are using. I will try check are there any ability to check that register via bootloader.