Author Topic: HC32L110 complete erase  (Read 2864 times)

0 Members and 1 Guest are viewing this topic.

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
HC32L110 complete erase
« on: August 28, 2023, 05:34:30 pm »
Anyone can tell me if this MCU can be completely erased in case the debug interface and/or the reset pin have been disabled?
I can't find any such information in the (translated) datasheet but some (https://github.com/pyocd/pyOCD/issues/1364#issuecomment-1098492831) say it should be possible.
Thanks
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #1 on: August 30, 2023, 02:47:05 am »
Translated from Datasheet Rev2.5 Page13
Quote
Programming mode

Support two programming protocols: ISP protocol and SWD protocol.
ISP protocol programming interfaces: P35, P36 or P27, P31.
SWD protocol programming interfaces: P27, P31.
When the chip receives the ISP programming instruction within a few milliseconds after the reset, the chip works in ISP programming mode and can be programmed. Use programmer device to program FLASH.
If the chip does not receive the ISP programming instruction within a few milliseconds after the reset is completed, the chip works in user mode and executes program code in FLASH.

Note:
It is suggested to reserve P35 and P36 as ISP programming interfaces;
For using P27 and P31 as ISP programming interfaces, please refer to PCN: PCN20200304-1 _ HC32L110HC32F003HC32F005 to improve the burning speed.

Datasheet and HDSC ISP tool can be downloaded from their product page
https://www.hdsc.com.cn/Category82
For HC32L110 https://www.hdsc.com.cn/Category82-1389
ISP programming uses UART port so USB2TTL dongle is required.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6539
  • Country: es
Re: HC32L110 complete erase
« Reply #2 on: August 30, 2023, 03:25:13 am »
I guess you found that mcu somewhere in a device and you're trying to repurpose it?
Because for what it costs you can get a much better STM32G030F6P6 for same price or lower.
« Last Edit: August 30, 2023, 03:29:08 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #3 on: August 30, 2023, 12:43:09 pm »
I guess you found that mcu somewhere in a device and you're trying to repurpose it?
Because for what it costs you can get a much better STM32G030F6P6 for same price or lower.
Exactly. The device (https://www.ebyte.com/en/product-view-news.html?id=129) has an interesting radio module on it, the AX5243. That's the source of my interest
 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #4 on: August 30, 2023, 12:46:58 pm »
Translated from Datasheet Rev2.5 Page13
Quote
Programming mode

Support two programming protocols: ISP protocol and SWD protocol.
ISP protocol programming interfaces: P35, P36 or P27, P31.
SWD protocol programming interfaces: P27, P31.
When the chip receives the ISP programming instruction within a few milliseconds after the reset, the chip works in ISP programming mode and can be programmed. Use programmer device to program FLASH.
If the chip does not receive the ISP programming instruction within a few milliseconds after the reset is completed, the chip works in user mode and executes program code in FLASH.

Note:
It is suggested to reserve P35 and P36 as ISP programming interfaces;
For using P27 and P31 as ISP programming interfaces, please refer to PCN: PCN20200304-1 _ HC32L110HC32F003HC32F005 to improve the burning speed.

Datasheet and HDSC ISP tool can be downloaded from their product page
https://www.hdsc.com.cn/Category82
For HC32L110 https://www.hdsc.com.cn/Category82-1389
ISP programming uses UART port so USB2TTL dongle is required.

I'm not proficient in chinese so I can't read the datasheet from the link you specified. Instead I found an (automatically translated) english version. I noticed it talks of an ISP methos but I guess it must be supported by the current firmware. Or is it a built-in feature of the MCU? What software should I use to upload a different firmware using ISP?
« Last Edit: August 30, 2023, 01:12:03 pm by buttim »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6539
  • Country: es
Re: HC32L110 complete erase
« Reply #5 on: August 30, 2023, 01:42:03 pm »
Probably it's the same as most, setting pin BOOT0=1 and powering it up.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #6 on: August 30, 2023, 03:29:32 pm »
Probably it's the same as most, setting pin BOOT0=1 and powering it up.

Can't find any reference to such a thing in the datasheet
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 851
  • Country: es
Re: HC32L110 complete erase
« Reply #7 on: August 30, 2023, 05:47:47 pm »
From that translated fragment it looks more like some BootROM activated at each reset unconditionally (not requiring any pin pulled), waiting for some specific byte from the ISP tool within a short time window, then jumping to flash.
 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #8 on: August 30, 2023, 07:09:49 pm »
From that translated fragment it looks more like some BootROM activated at each reset unconditionally (not requiring any pin pulled), waiting for some specific byte from the ISP tool within a short time window, then jumping to flash.

True. What worries me is that the reset pin can be multiplexed to a GPIO.
What would happen in that case? I'm asking because I actually found an ISP programming tool but I'm not having any success with it...
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #9 on: August 31, 2023, 03:00:59 am »
True. What worries me is that the reset pin can be multiplexed to a GPIO.
What would happen in that case? I'm asking because I actually found an ISP programming tool but I'm not having any success with it...
You don't actually need the RESET pin. Power it off -> on will do it. ISP tool and HcUnlock tool can be downloaded from the link I posted. (I attached the screenshot of the download page)
It's not recommended to re-program the module, unless you have the source code, otherwise you will easily brick it. HC32L110 is M0/M0+ based but the SDK is quite different from those of standard SPL/HAL/LL.

Exactly. The device (https://www.ebyte.com/en/product-view-news.html?id=129) has an interesting radio module on it, the AX5243. That's the source of my interest
E-Byte uses HC32 chips quite a lot in their products. They mainly use STM8L before, but about 2 or 3 years ago, they switched to HC32. I got to know HC32 series only because I bought their test-kit of nRF24L01 module.
 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #10 on: August 31, 2023, 10:40:10 am »
True. What worries me is that the reset pin can be multiplexed to a GPIO.
What would happen in that case? I'm asking because I actually found an ISP programming tool but I'm not having any success with it...
You don't actually need the RESET pin. Power it off -> on will do it. ISP tool and HcUnlock tool can be downloaded from the link I posted. (I attached the screenshot of the download page)
It's not recommended to re-program the module, unless you have the source code, otherwise you will easily brick it. HC32L110 is M0/M0+ based but the SDK is quite different from those of standard SPL/HAL/LL.

Exactly. The device (https://www.ebyte.com/en/product-view-news.html?id=129) has an interesting radio module on it, the AX5243. That's the source of my interest
E-Byte uses HC32 chips quite a lot in their products. They mainly use STM8L before, but about 2 or 3 years ago, they switched to HC32. I got to know HC32 series only because I bought their test-kit of nRF24L01 module.

Thanks a lot. I downloaded the unblock tool but when I launch it, it presents me a window like this, no idea what I should do
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #11 on: August 31, 2023, 11:56:51 am »
There is a PDF in the zip file, these are the content of this PDF translated by machine
Quote
HC32F003/HC32F005/HC32L110 unlocking instructions
1. Some users locked the SWD port of MCU due to improper operation when using MCU, resulting in MCU. Can't be used again. Now, an unlocking tool is provided to erase the program in MCU and save this kind of MCU.

2. The hardware needed for this operation is: USB to TTL serial port module; The required software is HcUnlock.

3. Operating steps
Step1, plug the USB to serial module into the USB interface of the computer.
Step2. Adjust the serial number of the serial port to COM4 according to the following figure. If the serial port has "delayed timing" option, then adjust its value to 1.
Step3: Connect the corresponding pins of the serial module with the corresponding pins of the MCU to be unlocked.
MCU.VCC <--- > serial module. VCC
MCU.GND <--- > serial module. GND
Mcu.txd (p31/p35) <-> serial module. RXD
Mcu. rxd (p27/p36) <-> serial module. TXD
MCU.RST(P00) <----> serial module. RTS/DTR

Step4, double-click to execute hcunlock _ 003 _ 005 _ 110.exe.

4. Remarks
At present, the serial port modules that have been tested and can be unlocked correctly are FT232 and CH340

It seems this unlock tool works only on fixed port COM4. The port number can be changed in Windows Device Manager (there are screenshots in the PDF).

For the RESET part, if the RESET pin is not available, you can connect TX, RX and GND only, then run this tool and quickly connect the VCC. HC32L110 is 5V compatible but I would suggest to try 3.3V first.

 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #12 on: August 31, 2023, 12:38:15 pm »
Quote
It seems this unlock tool works only on fixed port COM4. The port number can be changed in Windows Device Manager (there are screenshots in the PDF).

For the RESET part, if the RESET pin is not available, you can connect TX, RX and GND only, then run this tool and quickly connect the VCC. HC32L110 is 5V compatible but I would suggest to try 3.3V first.



I renamed the port to COM4 and rebooted. Absolutely nothing happens when I launch the unlocker. The LEDs on the FT232 module never turn on so apparantly it is not trying to access the serial. I tried to access the port with a different program (Putty) at the same time and it works, so the com port is actually not in use it seems
« Last Edit: August 31, 2023, 01:02:15 pm by buttim »
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #13 on: September 01, 2023, 12:49:38 am »
I'll see if I can do a test in the weekend.
 
The following users thanked this post: buttim

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #14 on: September 02, 2023, 04:08:30 pm »
I renamed the port to COM4 and rebooted. Absolutely nothing happens when I launch the unlocker. The LEDs on the FT232 module never turn on so apparantly it is not trying to access the serial. I tried to access the port with a different program (Putty) at the same time and it works, so the com port is actually not in use it seems
Confirmed: the unlock tool doesn't work.
I use a CH340 dongle and change the port to COM4, run the tool, nothing happens. It seems it didn't recognize the port, just kept reminding me to change the port to COM4.
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #15 on: September 02, 2023, 05:04:16 pm »
The good news is the ISP tool works.

The HC32L110 board I am using


Wiring:
* RTS  -> P00
* RX   -> P31
* TX   -> P27
* GND  -> GND
* 3.3V -> VCC

1. Switch the language to English.

2. Target MCU: HC32L110x4xx
3. Com Baud: 115200 (691200 always fails on my CH340)
4. Hex File: you need provide some dummy hex file, it's required but you can choose to erase without uploading
5. COM Setting: the port used by USB2TTL
6. Check Erase + Blank Check, leave Program,Verify,Encrypt unchecked. If you just want to test the communication without erase, uncheck them all.
7. Click Execute



Then it will reset the chip, do the erase and blank check. The output log tells the result of each step, 成功 means success.




The tests without connecting RTS to P00

1. Using reset button

If I click Execute and press RESET at the same time, at a 20% success rate it successfully connected to the board and did the erase.

2. Disconnect/Connect VCC manually

I tried to reconnect VCC and click Execute button at the same time, I tried many times with no luck. In theory there is a possibility but the time window may be too short.
« Last Edit: September 09, 2023, 02:29:59 pm by IOsetting »
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 68
  • Country: cn
Re: HC32L110 complete erase
« Reply #16 on: September 02, 2023, 05:29:02 pm »
This can be achieved by circuit. I once made an auto-download circuit for STC8x 8-bit chips

Using this dongle I can erase HC32L110 without connecting RESET pin

 

Offline buttimTopic starter

  • Contributor
  • Posts: 24
  • Country: it
Re: HC32L110 complete erase
« Reply #17 on: September 02, 2023, 10:35:46 pm »
The good news is the ISP tool works.

The HC32L110 board I am using


Wiring:
* RTS  -> P00
* RX   -> P31
* TX   -> P27
* GND  -> GND
* 3.3V -> VCC

1. Switch the language to English.

2. Target MCU: HC32L110x4xx
3. Com Baud: 115200 (691200 always fails on my CH340)
4. Hex File: you need provide some dummy hex file, it's required but you can choose to erase without uploading
5. COM Setting: the port used by USB2TTL
6. Check Erase + Blank Check, leave Program,Verify,Encrypt unchecked. If you just want to test the communication without erase, uncheck them all.
7. Click Execute



Then it will reset the chip, connect to it and do the erase and blank check. The output log is in Chinese, it tells the result of each step, 成功 means success.



The test of programming it without connecting RTS to P00:

1. Use reset button

click Execute and press RESET at the same time, a 20% success rate it successfully connected to the chip and did the erase.

2. Disconnect/Connect VCC manually

I tried to reconnect VCC and click Execute button at the same time, but unfortunately I tried many times without any success. In theory there is a possibility but the time window is too short.

Many many thanks for the very detailed explanation. Tomorrow I will read all that again and see if I can solve my problem.
Just remember to reboot after you change name to a COM port otherwise the change will not have any effect.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf