-
Notifications
You must be signed in to change notification settings - Fork 135
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
Wrong dump: nvram_(0x10000-0x107FF).bin #110
Comments
As suggested by @Lar-Sen in #110 Co-Authored-By: LarSeN <[email protected]>
That is very interesting info, for sure it would be great to investigate further. |
Just to correct myself: 0x516 only allows updating the 104 first bytes (ECDSA signature?) of sector 1. Anyway it's easy enough to mod bootloader's code. As I lost my original NVRAM bytes on this device, I cannot investigate further about the signature algorithm they implemented. I'm about to receive a fresh new UV-K5, I'll dump all the regions asap. Another interesting fact: The wrong NVRAM dump we talk about seems to be a The code apparently allows to read EDIT: Dit it. So surprise, this is a read-only region. Even with "god bit" on. Everything beyond 0x0FFFF loops back to bootloader's address, as expected. |
"The forgotten piece of code" is just the normal boot ROM of the MCU. At power on, the ROM is mapped from 0 all the way to 0x1FFFFFFF. After doing the trim work, it switches in the FLASH into address 0..0xFFFF, which is why you see this "forgotten code" at 0x10000+. 0x16 is nothing more than "NV_SEL = 1 && CMD = READ_APB". The flash can be read in 2 ways: via AHB (= direct memory map) and via APB (= via register programming). You can see the details of the CFG register here: https://github.com/DualTachyon/uv-k5-firmware/blob/main/hardware/dp32g030/flash.def#L19 |
As a beginner, I made an assumption about these unknown bytes which needed some necessary knowledge I wasn't aware of :) Thank you for your explanation about boot code. I thought that what we call 'bootloader' was enough to properly initialize full MCU and its interfaces... I haven't managed to reverse engineer (and understand!) all of its code, and for sure I lack some basics about ARM microcontroller architecture. Did you find FLASH_CFG valid states in official DP32G030 chinese technical document? |
Maybe you should delete this file. In fact, true NVRAM region is hidden everytime. It is no way located at the mentioned address, thus the dump being garbage.
To dump NVRAM region correctly, you must first issue
write_memory 0x4006F000 32 0x3
in OpenOCD to select it.Then you can dump 0x800 bytes from 0x0000 address:
dump_image my_nvram.bin 0x0 0x800
Its contents are interesting, as they host a fingerprint for Quansheng's "anti-counterfeiting" routines to recognize the device as genuine, plus CpuID (sector 0 = OTP only) and some factory data at the very end of the dump.
This fake dump was misleading me in finding the reason why my transceiver went nuts after playing with UART 0x516 command :)
So, 0x516 is definitely used as an updater for NVRAM's sectors 1 to 3. Maybe we could make use of that.
The text was updated successfully, but these errors were encountered: