Page 1 of 1

Partial reads and writes to memory

Posted: Thu Mar 05, 2020 5:12 pm
by KS5D
I was browsing through the CPS code, and it appears that one can read and write to targeted areas of memory separately. That a complete read/modify/write of everything is not required. Is this true? I have started a Javascript tool that can read the configuration of a GD-77 using node-hid.

Reason I ask, is that I have a simple project in mind that will upload -only- channels, zones, lists, contacts, leaving the rest of the configuration intact. Does this sounds feasible? Really, when people talk about trading codeplugs, this is what they want. What if channels & contacts & zones were in an easy-to-read and easy-to-edit JSON file?

Thanks,
Bob

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 5:19 pm
by KC7RBW
The interface isn't HID, so I don't know if node-hid will do the trick.

One thing that could make this idea hard to get right is that sometimes you have to erase a larger region before you can write. If the regions you want aren't aligned just right you may have to read a larger region and write it back with only your changed data changed. A developer more familiar with the actual storage architecture on the device will have to say.

It would be super cool if this could all be done in-browser using WebUSB.

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 5:40 pm
by KS5D
What gave me the idea is this file: https://github.com/rogerclarkmelbourne/ ... ugComms.cs
where HID is definitely used to read and write to the GD-77. So I started my little JS project, and yes I am starting to get results from it.

Yes, and I was looking into WebUSB too. I mean, what if some site had all of the DMR repeaters for each region, with a button that said "Download onto radio"? No installation necessary, ever.

Possibly some wrapper code around node-hid and webusb api's, to hide the differences, and use the proper one for the given environment.

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 8:22 pm
by VK3KYY
You can read and write any address in the EEPROM or Flash.

But because of the way Flash memory works, you have to do a read modify write on 4K blocks

You can’t just write a few bytes to the Flash because the firmware is not designed to handle that sort of access.

Hence the calibration data sits in its own 4K block even though it’s only a few hundred bytes long, and the rest of the block is not used.

Also beware, if you erase the calibration data you almost brick the radio, unless you have the test equipment to recalibrate it and put the radio specific data beach into its calibration table

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 8:25 pm
by VK3KYY
Btw. Also, you should be careful when testing your code, as the flash has a limited number of erase cycles.
I can’t remember the exact number, you need to check the data sheet. It’s something like 50000.

But you could easily make loads of requests which cause page erases very quickly and rapidly use up the lifespan of the flash.

The EEPROM also has limited write cycles, but it’s a higher number.

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 9:55 pm
by KC7RBW
VK3KYY wrote:
Thu Mar 05, 2020 8:25 pm
Btw. Also, you should be careful when testing your code, as the flash has a limited number of erase cycles.
I can’t remember the exact number, you need to check the data sheet. It’s something like 50000.

But you could easily make loads of requests which cause page erases very quickly and rapidly use up the lifespan of the flash.

The EEPROM also has limited write cycles, but it’s a higher number.
Is the codeplug all in flash or all in EEPROM, or part in both? Does writing back VFO settings, for example, wear down the flash rapidly?

In the early days of OpenGD77 you had to confirm that you wanted to write something back to the codeplug but now it's automatic mostly.

Re: Partial reads and writes to memory

Posted: Thu Mar 05, 2020 10:02 pm
by VK3KYY
VFO is kept as part of the nonVolatile settings.

These are only written back to EEPROM when you turn the radio off

The official firmware is a complete mess, it seems to write to the Flash at random times during the normal operation of the radio, even when nothing has changed.

When the CPS uploads a new codeplug, it also sends a special command to the firmware so that the new VFO, is updated from the new data in the codeplug.

Re: Partial reads and writes to memory

Posted: Fri Aug 07, 2020 11:57 am
by DL3DCM
It may be a newbie question, but I could not find the answer so far:

How can I read the flash parts using CPS? I am using the recent version of CPS (1-Aug-20).
I can read the firmware, but all Flash-part buttons are greyed out. Switching the radio to firmware programming just creates a communication error.

Thanks in advance, Michael ..

Re: Partial reads and writes to memory

Posted: Fri Aug 07, 2020 10:31 pm
by VK3KYY
DL3DCM wrote:
Fri Aug 07, 2020 11:57 am
It may be a newbie question, but I could not find the answer so far:

How can I read the flash parts using CPS? I am using the recent version of CPS (1-Aug-20).
I can read the firmware, but all Flash-part buttons are greyed out. Switching the radio to firmware programming just creates a communication error.

Thanks in advance, Michael ..
This was a technical post in relation to the data transfer protocol between the CPS and the radio.
The CPS always writes the whole codeplug to the radio.

Re: Partial reads and writes to memory

Posted: Sun Aug 09, 2020 11:18 am
by DL3DCM
Just found the answer to my question in an external userguide:

The Flash parts can be backed up using the CPS menu item:
Extras --> OpenGD77 Support