Skip to content

Commit

Permalink
Merge pull request spm81#9 from qshosfw/main
Browse files Browse the repository at this point in the history
LIVESEEK
  • Loading branch information
spm81 authored Jan 9, 2024
2 parents 384bb0c + b21826f commit e9a1955
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 95 deletions.
44 changes: 30 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#=================================================================#
# Matoz @spm81 | Joaquim @joaquimorg | Andrej @Tunas1337 & QSH-OSFW Team
#=================================================================#
# FIRMWARE BUILD OPTIONS # 1: Enable # 0: Disable #
#=================================================================#

TARGET = firmware

# ---- STOCK QUANSHENG FERATURES ----
#======== STOCK QUANSHENG FERATURES ========#
ENABLE_AIRCOPY := 0
# 3856 bytes
ENABLE_FMRADIO := 0
Expand All @@ -23,10 +21,10 @@ ENABLE_TX1750 := 0
ENABLE_ROGERBEEP := 1
ENABLE_MDC := 0

# ---- MODIFICATIONS ----
#============== MODIFICATIONS =============#
# AM Modulation Fix - 544 bytes
ENABLE_AM_FIX := 1
# Apply to Spectrum - 40 bytes
# Apply fix to Spectrum - 40 bytes
ENABLE_AM_FIX_ON_SPECTRUM := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1
# Restore FM in 1 second after RX - 0 bytes
Expand All @@ -46,7 +44,7 @@ ENABLE_FASTER_CHANNEL_SCAN := 1
# CW Modulation
ENABLE_CW := 1

# ---- EXTRA: MESSENGER ---- Special Thanks to Joaquimorg (www.joaquim.org)
#============ EXTRA: MESSENGER ============#
ENABLE_MESSENGER := 0
ENABLE_MESSENGER_DELIVERY_NOTIFICATION := 1
# 124 bytes
Expand All @@ -72,6 +70,24 @@ ENABLE_LIVESEEK_MHZ_KEYPAD := 1
ENABLE_OVERLAY := 0
ENABLE_SWD := 0



















BSP_DEFINITIONS := $(wildcard hardware/*/*.def)
BSP_HEADERS := $(patsubst hardware/%,bsp/%,$(BSP_DEFINITIONS))
BSP_HEADERS := $(patsubst %.def,%.h,$(BSP_HEADERS))
Expand Down Expand Up @@ -141,6 +157,7 @@ endif
ifeq ($(ENABLE_SPECTRUM_NUNU), 1)
OBJS += app/spectrumnunu.o
endif

ifeq ($(ENABLE_UART),1)
OBJS += app/uart.o
endif
Expand Down Expand Up @@ -168,6 +185,9 @@ endif
ifeq ($(ENABLE_MESSENGER),1)
OBJS += ui/messenger.o
endif
ifeq ($(ENABLE_LIVESEEK_MHZ_KEYPAD),1)
OBJS += app/ceccommon.o
endif
OBJS += ui/helper.o
OBJS += ui/inputbox.o
OBJS += ui/lock.o
Expand All @@ -182,14 +202,6 @@ OBJS += ui/welcome.o
OBJS += apps/scanlist.o
OBJS += version.o
OBJS += main.o
ifeq ($(ENABLE_LIVESEEK_MHZ_KEYPAD),1)
#################### ADDED BY KD8CEC ###################
# IF YOU USE THIS FUNCTION, COPY BELOW TO OTHER FIRMWARE#
#########################################################
OBJS += ceccommon.o
endif

################### END OF ADDED BY KD8CEC ##############

ifeq ($(OS),Windows_NT)
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
Expand Down Expand Up @@ -356,6 +368,10 @@ endif
ifeq ($(ENABLE_BATTERY_CHARGING),1)
CFLAGS += -DENABLE_BATTERY_CHARGING
endif
ifeq ($(ENABLE_LIVESEEK_MHZ_KEYPAD),1)
CFLAGS += -DENABLE_LIVESEEK_MHZ_KEYPAD
endif




Expand Down
134 changes: 97 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# MCFW - [@Matoz](https://github.com/spm81) Costum Firmware
# Open Source Firmware for Quansheng UV-K* Radios
An attempt to port unify as many of the many other fork's features as possible

* Please visit my friend [@joaquimorg](https://github.com/joaquimorg/uv-k5-firmware-custom) OEFW Firmware homepage and help him too
[![Compile with Docker CI](https://github.com/qshosfw/matoz/actions/workflows/cwd.yml/badge.svg)](https://github.com/qshosfw/matoz/actions/workflows/cwd.yml)
![GitHub License](https://img.shields.io/github/license/qshosfw/matoz)
![GitHub issues](https://img.shields.io/github/issues/qshosfw/matoz)


# Open reimplementation of the Quan Sheng UV K5 v2.1.27 firmware

This repository is a preservation project of the UV K5 v2.1.27 firmware.
It is dedicated to understanding how the radio works and help developers making their own customisations/fixes/etc.
It is by no means fully understood or has all variables/functions properly named, as this is best effort only.
As a result, this repository will not include any customisations or improvements over the original firmware.

You can find an alternate branch called "fixes" that contains fixes for real bugs present in the original firmware.
This branch will also accumulate fixes/improvements from newer releases by QS (for example v2.01.31).
> [!WARNING]
> Use this firmware at your own risk (entirely). There is absolutely no guarantee that it will work in any way shape or form on your radio(s), it may even brick your radio(s), in which case, you'd need to buy another radio.
Anyway, have fun.

For improved/better firmware and new features, you can find the following repositories by other collaborators:

Expand All @@ -20,19 +17,101 @@ For improved/better firmware and new features, you can find the following reposi
* https://github.com/Tunas1337/uv-k5-firmware (Check the branches)
* https://github.com/rebezhir/openquack for Russian users

## Credits

Many thanks to various people on Telegram for putting up with me during this effort and helping:

* [OneOfEleven](https://github.com/OneOfEleven)
* [DualTachyon](https://github.com/DualTachyon)
* [Joaquim](https://github.com/joaquimorg)
* [Mikhail](https://github.com/fagci)
* [Andrej](https://github.com/Tunas1337)
* [Manuel](https://github.com/manujedi)
* [Adam Mnemonic](https://github.com/amnemonic)
* [egzumer](https://github.com/egzumer)
* [Matoz](https://github.com/spm81)
* [ludwich66](https://github.com/ludwich66)
* [Chris](https://github.com/RE3CON)
* [sq5bpf](https://github.com/sq5bpf)
* [Juan Antonio Aldea](https://github.com/JuantAldea)
* [LolloDev5123](https://github.com/LolloDev5123)

## Radio performance

Please note that the Quansheng UV-Kx radios are not professional quality transceivers, their
performance is strictly limited. The RX front end has no track-tuned band pass filtering
at all, and so are wide band/wide open to any and all signals over a large frequency range.

Using the radio in high intensity RF environments will most likely make reception anything but
easy (AM mode will suffer far more than FM ever will), the receiver simply doesn't have a
great dynamic range, which results in distorted AM audio with stronger RX'ed signals.
There is nothing more anyone can do in firmware/software to improve that, once the RX gain
adjustment I do (AM fix) reaches the hardwares limit, your AM RX audio will be all but
non-existent (just like Quansheng's firmware).
On the other hand, FM RX audio will/should be fine.

But, they are nice toys for the price, fun to play with.

## Building

### Github Codespace build method

This is the least demanding option as you don't have to install enything on your computer. All you need is Github account.

1. Go to https://github.com/egzumer/uv-k5-firmware-custom
1. Click green `Code` button
1. Change tab from `Local` to `Codespace`
1. Click green `Create codespace on main` button

<img src="media/codespace1.png" width=700 />

5. Open `Makefile`
1. Edit build options, save `Makefile` changes
1. Run `./compile-with-docker.sh` in terminal window
1. Open folder `compiled-firmware`
1. Right click `firmware.packed.bin`
1. Click `Download`, now you should have a firmware on your computer that you can proceed to flash on your radio. You can use [online flasher](https://egzumer.github.io/uvtools)

<img src="media/codespace2.png" width=700 />

### Docker build method

If you have docker installed you can use [compile-with-docker.bat](./compile-with-docker.bat) (Windows) or [compile-with-docker.sh](./compile-with-docker.sh) (Linux/Mac), the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challenge can be (or not) installing docker itself.

### Windows environment build method

1. Open windows command line and run:
```
winget install -e -h git.git Python.Python.3.8 GnuWin32.Make
winget install -e -h Arm.GnuArmEmbeddedToolchain -v "10 2021.10"
```
2. Close command line, open a new one and run:
```
pip install --user --upgrade pip
pip install crcmod
mkdir c:\projects & cd /D c:/projects
git clone https://github.com/egzumer/uv-k5-firmware-custom.git
```
3. From now on you can build the firmware by going to `c:\projects\uv-k5-firmware-custom` and running `win_make.bat` or by running a command line:
```
cd /D c:\projects\uv-k5-firmware-custom
win_make.bat
```
4. To reset the repository and pull new changes run (!!! it will delete all your changes !!!):
```
cd /D c:\projects\uv-k5-firmware-custom
git reset --hard & git clean -fd & git pull
```
I've left some notes in the win_make.bat file to maybe help with stuff.
# Compiler
arm-none-eabi GCC version 10.3.1 is recommended, which is the current version on Ubuntu 22.04.03 LTS.
Other versions may generate a flash file that is too big.
You can get an appropriate version from: https://developer.arm.com/downloads/-/gnu-rm
# Building

To build the firmware, you need to fetch the submodules and then run make:
```
git submodule update --init --recursive --depth=1
make
```
# Flashing with the official updater
Expand All @@ -48,25 +127,6 @@ make
* If you want to use OpenOCD instead, you can use run "make flash" off this repo.
* The DP32G030 has flash masking to move the bootloader out of the way. Do not try to flash your own way outside of the above methods or risk losing your bootloader.
# Support

* If you like my work, you can support me through https://ko-fi.com/DualTachyon

# Credits

Many thanks to various people on Telegram for putting up with me during this effort and helping:

* [Mikhail](https://github.com/fagci/)
* [Andrej](https://github.com/Tunas1337)
* [Manuel](https://github.com/manujedi)
* @wagner
* @Lohtse Shar
* [@Matoz](https://github.com/spm81)
* @Davide
* @Ismo OH2FTG
* [OneOfEleven](https://github.com/OneOfEleven)
* and others I forget

# License
Copyright 2023 Dual Tachyon
Expand Down
16 changes: 11 additions & 5 deletions ceccommon.c → app/ceccommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/


#include "ceccommon.h"
#include "ui/helper.h"
#include "ui/ui.h"

typedef struct
{
uint8_t LOW_VALUE;
Expand All @@ -29,7 +33,7 @@ TADC_RANGE CW_KEY_ADC[3];

//================================= For Reduce Use Memory ====================
//gMR_ChannelAttributes[207]; -> function
//resize to 7 byte and Move to ceccommon.c
//resize to 7 byte and Move to app/ceccommon.c
uint16_t CEC_GetRssi()
{
int _wait_count = 0;
Expand All @@ -41,7 +45,7 @@ uint16_t CEC_GetRssi()

void DisplayIntLog(char* displayMessage, int _logInt1, int _logInt2)
{
uint8_t tmpBuff[32];
char tmpBuff[32];

memset(gStatusLine, 0, sizeof(gStatusLine));
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
Expand All @@ -66,7 +70,7 @@ uint32_t CommBuffLastUseTime = 0; //10milisec using millis10() function
uint8_t CommValue1 = 0; //temp varaible
uint8_t CommValue2 = 0;
uint8_t CommValue3 = 0;
uint8_t strBuff[32]; //For sprintf
char strBuff[32]; //For sprintf
//-----------------------------------------------------------------------------------------
//=================== End of Common Variables =============================================

Expand Down Expand Up @@ -107,12 +111,14 @@ void DrawFrequencySmall(uint32_t _frequency, int _startX, int _Length, int _line
// 58096 48 3284 61428 eff4 firmware
// 58036 48 3284 61368 efb8 firmware
//sprintf(strBuff, "%1u.%03u", (_frequency / 100000) % 10, (_frequency / 100) % 1000);

sprintf(strBuff, "%3u.%03u", _frequency / 100000, (_frequency / 100) % 1000);
//UI_PrintStringSmallLeft(strBuff, _startX, _startX + _Length, _lineNumber);
memset(gFrameBuffer[_lineNumber], 0, 128);
UI_PrintStringSmallNormal(strBuff, _startX, 0, _lineNumber);
UI_PrintStringSmall(strBuff, _startX, 0, _lineNumber);
}


void DrawCommBuffToSpectrum(void)
{
//Low Value
Expand Down Expand Up @@ -191,7 +197,7 @@ void CEC_TimeSlice500ms(void)
CommBuffUsingType = COMBUFF_USE_SEEK_NONE;
if (gScreenToDisplay == DISPLAY_MAIN)
{
gMonitor = false;
//gMonitor = false;

if (addRssiCount > 3)
{
Expand Down
22 changes: 11 additions & 11 deletions ceccommon.h → app/ceccommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@

#ifndef CEC_COMMON_H
#define CEC_COMMON_H

#include <stdbool.h>
#include <math.h>
#include <stdio.h>
#include "driver\bk4819.h"
#include "driver\keyboard.h"
#include "driver/bk4819.h"
#include "driver/keyboard.h"
#include "audio.h"
#include "string.h"
#include <stdint.h>
#include <string.h>
#include "external/printf/printf.h"
//#include "gpsinfo.h"
#include "driver\eeprom.h"
#include "driver/eeprom.h"
#include "misc.h"
#include "radio.h"
#include "driver\system.h"
#include "driver\st7565.h"
#include "driver/system.h"
#include "driver/st7565.h"
#include "settings.h"
#include "driver\systick.h"
#include "ui\helper.h"
#include "ui\ui.h"
#include "ui\main.h"
#include "driver/systick.h"
#include "ui/helper.h"
#include "ui/ui.h"
#include "ui/main.h"
#include "font.h"
#include "functions.h"
#include "app\app.h"
#include "app.h"


#define _MAX_READ_CH_ATTRIBUTES 7
#define COMBUFF_USE_SEEK_RSSI 01
Expand Down
Loading

0 comments on commit e9a1955

Please sign in to comment.