Skip to content

Commit

Permalink
Merge pull request #1 from spm81/main
Browse files Browse the repository at this point in the history
Resolve conflicts
  • Loading branch information
LolloDev5123 authored Jan 7, 2024
2 parents ba33362 + bb4f7ee commit 24a8b97
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 47 deletions.
51 changes: 42 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,36 @@ ifeq ($(OS),Windows_NT)
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
RM = del /Q
FixPath = $(subst /,\,$1)
WHERE = where
K5PROG = utils/k5prog/k5prog.exe -F -YYYYY -p /dev/com9 -b
else
TOP := $(shell pwd)
RM = rm -f
FixPath = $1
FixPath = $1
WHERE = which
K5PROG = utils/k5prog/k5prog -F -YYYYY -p /dev/ttyUSB3 -b
endif


ifneq (, $(shell $(WHERE) python))
MY_PYTHON := python
else ifneq (, $(shell $(WHERE) python3))
MY_PYTHON := python3
endif

ifdef MY_PYTHON
HAS_CRCMOD := $(shell $(MY_PYTHON) -c "import crcmod" 2>&1)
endif

ifndef MY_PYTHON
$(info )
$(info !!!!!!!! PYTHON NOT FOUND, *.PACKED.BIN WON'T BE BUILT)
$(info )
else ifneq (,$(HAS_CRCMOD))
$(info )
$(info !!!!!!!! CRCMOD NOT INSTALLED, *.PACKED.BIN WON'T BE BUILT)
$(info !!!!!!!! run: pip install crcmod)
$(info )
endif

AS = arm-none-eabi-gcc
Expand Down Expand Up @@ -315,15 +341,18 @@ INC += -I $(TOP)
INC += -I $(TOP)/external/CMSIS_5/CMSIS/Core/Include/
INC += -I $(TOP)/external/CMSIS_5/Device/ARM/ARMCM0/Include

#show size
LDFLAGS += -Wl,--print-memory-usage

LIBS =

DEPS = $(OBJS:.o=.d)

all: $(TARGET)
$(OBJCOPY) -O binary $< $<.bin
-python fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
-python3 fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin
$(SIZE) $<
@echo Create $(notdir $<.bin)
@$(OBJCOPY) -O binary $< $<.bin
@echo Create $(notdir $<.packed.bin)
@-$(MY_PYTHON) utils/fw-pack.py $<.bin MATOZ $(GIT_HASH) $<.packed.bin

debug:
/opt/openocd/bin/openocd -c "bindto 0.0.0.0" -f interface/jlink.cfg -f dp32g030.cfg
Expand All @@ -334,21 +363,25 @@ flash:
version.o: .FORCE

$(TARGET): $(OBJS)
$(LD) $(LDFLAGS) $^ -o $@ $(LIBS)
@echo LD $@
@$(LD) $(LDFLAGS) $^ -o $@ $(LIBS)

bsp/dp32g030/%.h: hardware/dp32g030/%.def

%.o: %.c | $(BSP_HEADERS)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
@echo CC $<
@$(CC) $(CFLAGS) $(INC) -c $< -o $@

%.o: %.S
$(AS) $(ASFLAGS) $< -o $@
@echo AS $<
@$(AS) $(ASFLAGS) $< -o $@

.FORCE:

-include $(DEPS)

clean:
# rm -f $(TARGET).bin $(TARGET) $(OBJS) $(DEPS)
$(RM) $(call FixPath, $(TARGET) $(OBJS) $(DEPS))

prog: all
$(K5PROG) firmware.bin
6 changes: 0 additions & 6 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,6 @@ void APP_CheckKeys(void) {
if (gPttDebounceCounter > 0) {
gPttIsPressed = true;
APP_ProcessKey(KEY_PTT, true, false);
#ifdef ENABLE_CW
if (gRxVfo->ModulationType == MOD_CW) {
gEnableSpeaker = false;
BK4819_TransmitTone(gEeprom.DTMF_SIDE_TONE, 641);
}
#endif
}
} else {
gPttDebounceCounter = 0;
Expand Down
13 changes: 0 additions & 13 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@
#include "../driver/systick.h"
#include "../driver/uart.h"

#ifdef ENABLE_CW
#include "../app/scanner.h"
#include "../audio.h"
#include "../driver/bk4819.h"
#include "../frequencies.h"
#include "../misc.h"
#include "../radio.h"
#include "../settings.h"
#include "../ui/inputbox.h"
#include "../ui/ui.h"
#include "../app/generic.h"
#endif

#ifdef ENABLE_MDC
static const uint16_t FSK_RogerTable[7] = {
0xF1A2, 0x7446, 0x61A4, 0x6544, 0x4E8A, 0xE044, 0xEA84,
Expand Down
38 changes: 24 additions & 14 deletions functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,34 @@ void FUNCTION_Select(FUNCTION_Type_t Function) {
RADIO_SetTxParameters();
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true);

#ifdef ENABLE_CW
if (gRxVfo->ModulationType == MOD_CW) {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
BK4819_TransmitTone(true, 641);
SYSTEM_DelayMs(2);
} else
#endif
{
#ifdef ENABLE_DTMF_CALLING
DTMF_Reply();
DTMF_Reply();
#endif
#if defined(ENABLE_TX1750)
if (gAlarmState != ALARM_STATE_OFF) {
if (gAlarmState == ALARM_STATE_TX1750) {
BK4819_TransmitTone(true, 1750);
if (gAlarmState != ALARM_STATE_OFF) {
if (gAlarmState == ALARM_STATE_TX1750) {
BK4819_TransmitTone(true, 1750);
}
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
break;
}
#endif
if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) {
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U);
} else {
BK4819_DisableScramble();
}
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
break;
}
#endif
if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) {
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U);
} else {
BK4819_DisableScramble();
}
break;
}
Expand Down
9 changes: 4 additions & 5 deletions fw-pack.py → utils/fw-pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ def obfuscate(fw):
return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))])

plain = open(sys.argv[1], 'rb').read()
if len(sys.argv[2]) > 10:
print('Version suffix is too big!')
sys.exit(1)

version = b'*MCFW-' + bytes(sys.argv[2], 'ascii')
version = b'*' + bytes(sys.argv[2], 'ascii') + b' ' + bytes(sys.argv[3], 'ascii')
version = version[0:16]

if len(version) < 16:
version += b'\x00' * (16 - len(version))

Expand All @@ -36,5 +35,5 @@ def obfuscate(fw):
digest = crc.digest()
digest = bytes([digest[1], digest[0]])

open(sys.argv[3], 'wb').write(packed + digest)
open(sys.argv[4], 'wb').write(packed + digest)

Binary file added utils/k5prog/cygwin1.dll
Binary file not shown.
Binary file added utils/k5prog/k5prog
Binary file not shown.
Binary file added utils/k5prog/k5prog.exe
Binary file not shown.

0 comments on commit 24a8b97

Please sign in to comment.