Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No full dump #39

Open
Nikotine1 opened this issue May 30, 2024 · 9 comments
Open

No full dump #39

Nikotine1 opened this issue May 30, 2024 · 9 comments

Comments

@Nikotine1
Copy link

Nikotine1 commented May 30, 2024

I have an HX890E. I have installed this using pip install, as instructed.
I noticed that the config dump doesn't dump the full memory, only half of it.
The files are 32 kb, while those available here (https://pc5e.nl/info/standard-horizon-hx890e-marine-handheld) are 64 kb.

In config.py, I see indeed that bytes_to_go is 0x8000, while this should be 0x10000.
Or are you intentionally only reading half of it?

Edit: changed HX890 to HX890E

@cr
Copy link
Owner

cr commented May 31, 2024

Thanks for the info! Reading just half of the memory is not intentional – at least not as far as I remember. Have you tried running it with 0x10000?

I only ever had an HX890 for a couple of weeks during development and now I'm wondering whether this is the same for the HX870. Any way, I'd need time to investigate and get back into the code, but am a long way from my HX870 at the moment.

@Nikotine1
Copy link
Author

Nikotine1 commented May 31, 2024

Reading just half of the memory is not intentional

Great, now that I know this, I can start experimenting with the code.
Dumping looks easy to adjust. For flashing, there seems to be a bit more going on (magic_end, certain data written to some memory locations...).

What happens if you flash wrong data, does it brick the device?

I'm wondering whether this is the same for the HX870.

I don't believe so. Looking at Johan Nessen's memory table, it ends at 0x7fff, so my HX890E seems to have double the memory.

I'm not a github expert, but I'll try to share what I discover.
I'm also making a pattern file for ImHex (a free and very capable alternative to 010 Editor), which I can also share.

@cr
Copy link
Owner

cr commented May 31, 2024

Let me commit a few quick changes that should make the dump behave properly for the HX890.

Writing data essentially just writes back what's been dumped without interpreting the data, so it theoretically is a safe operation and should not brick the device, but of course there's a significant risk if the code is faulty. You'd need to proceed at your own risk when adapting the code. However, if you keep a clean backup of a know-working config memory dump around, there should always be a way to restore it.

config_write() just looks a bit more complicated because it checks the model-specific magic values at the beginning and the end in an attempt to prevent flashing incompatible config data and skips the magic bytes when writing.

@cr
Copy link
Owner

cr commented May 31, 2024

Please have a look at my current dev branch at https://github.com/cr/hx870/tree/dev .

I can't test the code with a real device right now, but it should produce a 64k config dump on an HX890 now. Dumping is not a dangerous operation, but I'd refrain from flashing the images back for now.

Please, if you don't mind playing along, feel free to create a dump with the dev version of hxtool and provide me the file. I'd be happy to have a look.

@Nikotine1
Copy link
Author

That worked!

Took me while to figure out though, because before I had just created a venv and done the pip install on the main branch.
Now I had to git clone and switch to dev branch.
I then assumed I could just run config.py, but no, I still had to do pip install . still.

Just done a memory dump and now it is 64k with the magic number at the end.

@cr
Copy link
Owner

cr commented Jun 1, 2024

I use pipenv shell to create an environment in the directory, and then pip install -e '.[dev]' to install the dev target as defined in setup.py, with the main advantage being that changes in the python module code are directly effective without reinstalling the module over and over.

@Nikotine1
Copy link
Author

Oh that's a neat trick! I did not know about editable installs!

@Nikotine1
Copy link
Author

Please, if you don't mind playing along, feel free to create a dump with the dev version of hxtool and provide me the file. I'd be happy to have a look.

Here's the dump.
Maybe you can use it to adapt the flash code?

dump240601.dat.zip

I have removed my MMSI and ATIS codes.
You'll see some test data for waypoints and routes.

@Nikotine1
Copy link
Author

Oh I noticed you already adapted the write code as well.
I will review and see if I dare flash my new device 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants