Skip to content

Commit f61d201

Browse files
authored
Merge pull request #578 from recalci/minichlink_ch32l103
Add minichlink support for L103
2 parents d976d30 + 867b76b commit f61d201

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

ch32fun/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
|USBPD |N/A |N/A |N/A |N/A |N/A |1.4 | × | × |1.2 |
3434
|WWWDG || × || × | × || × | × ||
3535
|**chxxxhw.h** || × ||||| × | × ||
36-
|**minichlink**|| × | ||| √ ( √ )| × | × ||
36+
|**minichlink**|| × | + ||| √ ( √ )| | × ||
3737

3838
* n.m: Last commit message of the header file in ch32xxx/EVT/EXAM/SRC/Peripheral/inc
3939
* √: Merged in , version unspecified

minichlink/minichlink.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,18 @@ int DefaultDetermineChipType( void * dev )
10891089
switch( chip_type )
10901090
{
10911091
case 0x103:
1092-
fprintf( stderr, "Autodetected a ch32v10x\n" );
1093-
iss->target_chip_type = CHIP_CH32V10x;
1092+
// V103 Special chip ID location: 0x1ffff884
1093+
// CH32V103C8T6-0x25004102
1094+
// CH32V103R8T6-0x2500410F
1095+
// L103 Special chip ID location: 0x1ffff704
1096+
// CH32L103C8T6-0x103107x0
1097+
// CH32L103F8P6-0x103A07x0
1098+
// CH32L103G8R6-0x103B07x0
1099+
// CH32L103K8U6-0x103207x0
1100+
// CH32L103F8U6-0x103D07x0
1101+
// can be find in DBGMCU_GetCHIPID in \EVT\EXAM\SRC\Peripheral\src\chxxx_dbgmcu.c
1102+
fprintf( stderr, "Autodetected a ch32l10x\n" );
1103+
iss->target_chip_type = CHIP_CH32L10x;
10941104
break;
10951105
case 0x035: case 0x033:
10961106
fprintf( stderr, "Autodetected a ch32x03x\n" );
@@ -1365,7 +1375,8 @@ static int DefaultWriteWord( void * dev, uint32_t address_to_write, uint32_t dat
13651375
// c.ebreak
13661376
MCF.WriteReg32( dev, DMPROGBUF3,
13671377
(iss->target_chip_type == CHIP_CH32V003 || (iss->target_chip_type >= CHIP_CH32V002 && iss->target_chip_type <= CHIP_CH32V006)
1368-
|| iss->target_chip_type == CHIP_CH32X03x || iss->target_chip_type == CHIP_CH641 || iss->target_chip_type == CHIP_CH643) ?
1378+
|| iss->target_chip_type == CHIP_CH32X03x || iss->target_chip_type == CHIP_CH32L10x
1379+
|| iss->target_chip_type == CHIP_CH641 || iss->target_chip_type == CHIP_CH643) ?
13691380
0x4200c254 : 0x42000001 );
13701381

13711382
MCF.WriteReg32( dev, DMPROGBUF4,
@@ -2157,7 +2168,7 @@ void PostSetupConfigureInterface( void * dev )
21572168
iss->sector_size = 256;
21582169
break;
21592170
case CHIP_CH32X03x:
2160-
case CHIP_CH32V10x:
2171+
case CHIP_CH32L10x:
21612172
case CHIP_CH643:
21622173
iss->sector_size = 256; // ??? The X035 datasheet clearly says this is 128 bytes, but fast page erases do 256?
21632174
break;
@@ -2519,7 +2530,8 @@ int DefaultUnbrick( void * dev )
25192530

25202531
const uint8_t * option_data =
25212532
(iss->target_chip_type == CHIP_CH32V003 || (iss->target_chip_type >= CHIP_CH32V002 && iss->target_chip_type <= CHIP_CH32V006)
2522-
|| iss->target_chip_type == CHIP_CH32X03x || iss->target_chip_type == CHIP_CH641 || iss->target_chip_type == CHIP_CH643) ?
2533+
|| iss->target_chip_type == CHIP_CH32X03x || iss->target_chip_type == CHIP_CH32L10x
2534+
|| iss->target_chip_type == CHIP_CH641 || iss->target_chip_type == CHIP_CH643) ?
25232535
option_data_003_x03x : option_data_20x_30x;
25242536

25252537
DefaultWriteBinaryBlob(dev, 0x1ffff800, 16, option_data );

minichlink/pgm-wch-linke.c

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static int checkChip(enum RiscVChip chip) {
9393
case CHIP_CH32V005:
9494
case CHIP_CH641:
9595
case CHIP_CH643:
96+
case CHIP_CH32L10x:
9697
return 0; // Use direct mode
9798
case CHIP_CH32V10x:
9899
case CHIP_CH32V20x:

0 commit comments

Comments
 (0)