Partial reads and writes to memory

OpenGD77CPS
Post Reply
KS5D
Posts: 5
Joined: Thu Mar 05, 2020 4:59 pm

Partial reads and writes to memory

Post by KS5D » Thu Mar 05, 2020 5:12 pm

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

KC7RBW
Posts: 159
Joined: Wed Nov 20, 2019 1:23 am

Re: Partial reads and writes to memory

Post by KC7RBW » Thu Mar 05, 2020 5:19 pm

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.

KS5D
Posts: 5
Joined: Thu Mar 05, 2020 4:59 pm

Re: Partial reads and writes to memory

Post by KS5D » Thu Mar 05, 2020 5:40 pm

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.

VK3KYY
Posts: 7490
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Partial reads and writes to memory

Post by VK3KYY » Thu Mar 05, 2020 8:22 pm

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

VK3KYY
Posts: 7490
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Partial reads and writes to memory

Post by VK3KYY » 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.

KC7RBW
Posts: 159
Joined: Wed Nov 20, 2019 1:23 am

Re: Partial reads and writes to memory

Post by KC7RBW » Thu Mar 05, 2020 9:55 pm

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.

VK3KYY
Posts: 7490
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Partial reads and writes to memory

Post by VK3KYY » Thu Mar 05, 2020 10:02 pm

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.

DL3DCM
Posts: 3
Joined: Sun Jul 19, 2020 7:32 pm

Re: Partial reads and writes to memory

Post by DL3DCM » 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 ..

VK3KYY
Posts: 7490
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia

Re: Partial reads and writes to memory

Post by VK3KYY » Fri Aug 07, 2020 10:31 pm

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.

DL3DCM
Posts: 3
Joined: Sun Jul 19, 2020 7:32 pm

Re: Partial reads and writes to memory

Post by DL3DCM » Sun Aug 09, 2020 11:18 am

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

Post Reply