Author Topic: CH32V003 Flash like Eprom  (Read 711 times)

0 Members and 1 Guest are viewing this topic.

Offline AtlanTopic starter

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: sk
CH32V003 Flash like Eprom
« on: March 19, 2024, 08:41:06 am »
HI. is there any way to ensure that the data in the flash is not overwritten during programming.

I use cast flash as eprom. Everything works, but every time I program the data is deleted. Is there going to be some kind of protection to prevent it from being deleted? or if I put them on the bootloader address, won't they be deleted there? is such a use possible? I assume that uP does not contain a bootloader? well thank you
« Last Edit: March 19, 2024, 08:50:35 am by Atlan »
FNIRSI 1013D Always provide a picture or video with the problem where the parameters of the oscilloscope are visible, and a picture of the diagnostic screen with the values.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4039
  • Country: nz
Re: CH32V003 Flash like Eprom
« Reply #1 on: March 19, 2024, 10:04:52 am »
Strange, I recall another thread where someone was complaining that the remainder of the flash was NOT erased when a new program was written, allowing malicious users to extract the code from commercial products by uploading a very short new program that dumps the contents of the rest of the flash. (And, given two devices, you can load that program at different addresses on each one, thus extracting everything)
 

Offline AtlanTopic starter

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: sk
Re: CH32V003 Flash like Eprom
« Reply #2 on: March 19, 2024, 11:10:20 am »
The standard procedure for programming is erasing the chip before programming.  I prefer this option because it happened to me on other uP that the program did not work correctly.  An external programming program allows selection without erasing, but.  I don't want to use that.  Programming directly from the IDE erases the flash before programming.
FNIRSI 1013D Always provide a picture or video with the problem where the parameters of the oscilloscope are visible, and a picture of the diagnostic screen with the values.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7391
  • Country: nl
  • Current job: ATEX product design
Re: CH32V003 Flash like Eprom
« Reply #3 on: March 19, 2024, 11:37:07 am »
When you write a byte with 1 on top of a 0 in a Flash block or sector, you have to erase the entire sector. The empty one will be all 1s. You can then write all the 0s . The solution is to never write 1s, or use buffering in RAM and update after erase.
 

Offline AtlanTopic starter

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: sk
Re: CH32V003 Flash like Eprom
« Reply #4 on: March 19, 2024, 12:07:54 pm »
The problem is that when programming uP, the entire flash is erased, including my data (eprom like flash)
FNIRSI 1013D Always provide a picture or video with the problem where the parameters of the oscilloscope are visible, and a picture of the diagnostic screen with the values.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14481
  • Country: fr
Re: CH32V003 Flash like Eprom
« Reply #5 on: March 19, 2024, 09:09:33 pm »
I suggest considering using a third-party flashing tool, such as this: https://github.com/ch32-rs/wlink
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1478
  • Country: gb
Re: CH32V003 Flash like Eprom
« Reply #6 on: March 20, 2024, 04:58:24 am »
You can configure in the option bytes (WRPR0 - WRPR3) write protection of the flash memory on a sector basis (1k per sector). However, I doubt that will help you, because I don't think it applies for a whole-chip erasure performed by programming tools. I think the write-protection is only to guard against accidental in-app erasure at run-time.
 

Offline AtlanTopic starter

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: sk
Re: CH32V003 Flash like Eprom
« Reply #7 on: March 20, 2024, 07:34:12 am »
Yes, you're right, if I do that, the burning program says that the memory is write-protected.

I unchecked the option to delete everything during programming. And I'll be careful. When the program is finished, the entire flash will be erased and flashed to uP

I am attaching a zip. Extract FlashEprom.c and h from it.
« Last Edit: March 20, 2024, 07:54:59 am by Atlan »
FNIRSI 1013D Always provide a picture or video with the problem where the parameters of the oscilloscope are visible, and a picture of the diagnostic screen with the values.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf