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

uv5r.py: fix Baofeng UV-6 support - fixes #11199 #1073

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions chirp/drivers/uv5r.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,15 @@ def _ident_radio(radio):
def _do_download(radio):
data = _ident_radio(radio)

if radio.MODEL == "BJ-UV55":
if not radio._aux_block:
_read_block(radio, 0x0000, 0x40, True)
elif radio.MODEL == "BJ-UV55":
radio_version = _get_radio_firmware_version(radio)
else:
radio_version, has_dropped_byte = \
_get_radio_firmware_version(radio)
LOG.info("Radio Version is %s" % repr(radio_version))
LOG.info("Radio has dropped byte issue: %s" % repr(has_dropped_byte))
LOG.info("Radio Version is %s" % repr(radio_version))
LOG.info("Radio has dropped byte issue: %s" % repr(has_dropped_byte))

# Main block
LOG.debug("downloading main block...")
Expand Down Expand Up @@ -619,8 +621,16 @@ def _do_upload(radio):
if image_upper_band != radio_upper_band:
raise errors.RadioError("Image not supported by radio")

image_version = _firmware_version_from_image(radio)
if radio.MODEL == "BJ-UV55":
if radio._aux_block:
image_version = _firmware_version_from_image(radio)
if not radio._aux_block:
_ranges_main_default = [
(0x0008, 0x0CF8), # skip 0x0CF8 - 0x0D08
(0x0D08, 0x0DF8), # skip 0x0DF8 - 0x0E08
(0x0E08, 0x1808),
]
_ranges_aux_default = []
elif radio.MODEL == "BJ-UV55":
radio_version = _get_radio_firmware_version(radio)

# default ranges
Expand Down Expand Up @@ -710,8 +720,8 @@ def _do_upload(radio):
(0x1FC0, 0x1FD0), # new band limits
]

LOG.info("Image Version is %s" % repr(image_version))
LOG.info("Radio Version is %s" % repr(radio_version))
LOG.info("Image Version is %s" % repr(image_version))
LOG.info("Radio Version is %s" % repr(radio_version))

if radio._all_range_flag:
# user enabled 'Range Override Parameter', upload everything
Expand All @@ -735,11 +745,12 @@ def _do_upload(radio):
LOG.info("Old image, not writing aux block")
return # Old image, no aux block

# Auxiliary block at radio address 0x1EC0, our offset 0x1808
for start_addr, end_addr in ranges_aux:
for i in range(start_addr, end_addr, 0x10):
addr = 0x1808 + (i - 0x1EC0)
_send_block(radio, i, mmap[addr:addr + 0x10])
if radio._aux_block:
# Auxiliary block at radio address 0x1EC0, our offset 0x1808
for start_addr, end_addr in ranges_aux:
for i in range(start_addr, end_addr, 0x10):
addr = 0x1808 + (i - 0x1EC0)
_send_block(radio, i, mmap[addr:addr + 0x10])

if radio._all_range_flag:
radio._all_range_flag = False
Expand Down
Loading