added-build-artefacts

pull/16/head
Piotr Lewandowski 2023-07-04 22:32:40 +02:00
rodzic cf918e907b
commit 43150e7800
12 zmienionych plików z 485 dodań i 1 usunięć

Wyświetl plik

@ -38,6 +38,30 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target rssi_printer_encoded rssi_sbar_encoded pong_encoded most_useless_mod_encoded
- name: Upload rssi_printer_encoded as artifact
uses: actions/upload-artifact@v2
with:
name: rssi_printer_encoded
path: ${{github.workspace}}/build/src/rssi_printer/rssi_printer_encoded.bin
- name: Upload rssi_sbar_encoded as artifact
uses: actions/upload-artifact@v2
with:
name: rssi_sbar_encoded
path: ${{github.workspace}}/build/src/rssi_sbar/rssi_sbar_encoded.bin
- name: Upload pong_encoded as artifact
uses: actions/upload-artifact@v2
with:
name: pong_encoded
path: ${{github.workspace}}/build/src/pong/pong_encoded.bin
- name: Upload most_useless_mod_encoded as artifact
uses: actions/upload-artifact@v2
with:
name: most_useless_mod_encoded
path: ${{github.workspace}}/build/src/most_useless_mod/most_useless_mod_encoded.bin
- name: Get the date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

Wyświetl plik

@ -184,6 +184,38 @@ public:
}
}
unsigned char PrintFixedDigtsNumer(int s32Number, unsigned char u8Digts)
{
char U8NumBuff[32];
memset(U8NumBuff, 0, sizeof(U8NumBuff));
auto pString = U8NumBuff;
if(s32Number < 0)
{
*pString++ = '-';
u8Digts--;
}
unsigned char u8DigtsCnt = u8Digts;
while(u8DigtsCnt--)
{
char c8Char;
if(u8DigtsCnt == 0)
{
c8Char = '0' + (s32Number % 10);
}
else
{
c8Char = '0' + ((s32Number / ((u8DigtsCnt)*10)) % 10);
}
*pString++ = c8Char;
}
Print(U8NumBuff);
return u8Digts * pCurrentFont->GetSizeX('0');
}
private:
const BitmapType &Bitmap;
mutable const IFont *pCurrentFont;

Wyświetl plik

@ -2,4 +2,5 @@ add_subdirectory(orginal_fw)
add_subdirectory(rssi_printer)
add_subdirectory(rssi_sbar)
add_subdirectory(most_useless_mod)
add_subdirectory(pong)
add_subdirectory(pong)
add_subdirectory(spectrum)

Wyświetl plik

@ -0,0 +1,79 @@
set(NAME spectrum)
set(MCU_TARGET_FILES_DIR ../mcu_target_common)
add_executable(${NAME}
main.cpp
hardware/hardware.cpp
dp32g030.s
)
target_link_libraries(${NAME}
orginal_fw
uv_k5_system
lcd
)
target_include_directories(${NAME} PUBLIC
./
Drivers/CMSIS/Device/ST/STM32G0xx/Include
Drivers/CMSIS/DSP/Include
Drivers/CMSIS/Include
)
target_compile_definitions(${NAME} PRIVATE
${STM32_DEFINES}
$<$<CONFIG:Debug>:DEBUG_ENABLED>
)
target_compile_options(${NAME} PRIVATE
${COMPILER_OPTIONS}
-flto
)
target_link_options(${NAME} PRIVATE
#-print-multi-lib
-T ${CMAKE_CURRENT_SOURCE_DIR}/memory.ld
-flto
-mcpu=cortex-m0
-mthumb
-mfpu=auto
-mfloat-abi=soft
-specs=nosys.specs
-specs=nano.specs
-lc
-lm
-lnosys
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections
-Wl,--print-memory-usage
-Wstack-usage=128
-Wno-register
)
add_custom_command(TARGET ${NAME}
POST_BUILD
COMMAND arm-none-eabi-size ${NAME}
)
#convert to hex
add_custom_command(TARGET ${NAME}
POST_BUILD
COMMAND arm-none-eabi-objcopy -O ihex ${NAME} ${NAME}.hex
COMMAND arm-none-eabi-objcopy -O binary ${NAME} ${NAME}.bin
)
get_target_property(BOOTLOADER_BIN_PATH orginal_fw BOOTLOADER_BIN_PATH)
add_custom_command(TARGET ${NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "generating full binary with bootloader to ${NAME}_with_bootloader.bin"
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/fw_merger.py ${BOOTLOADER_BIN_PATH} ${NAME}.bin ${NAME}_with_bootloader.bin
)
add_custom_target(${NAME}_flash
COMMAND openocd -f interface/cmsis-dap.cfg -f ${PROJECT_SOURCE_DIR}/openocd_scripts/dp32g030.cfg -c "write_image ${PROJECT_SOURCE_DIR}/build/src/rssi_printer/rssi_printer.bin 0x1000" -c "halt" -c "shutdown"
DEPENDS ${NAME}
)
add_custom_target(${NAME}_encoded
COMMAND python ${PROJECT_SOURCE_DIR}/tools/fw_tools/python-utils/fw_pack.py ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.bin ${CMAKE_CURRENT_SOURCE_DIR}/../orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_encoded.bin
DEPENDS ${NAME}
)

Wyświetl plik

@ -0,0 +1,18 @@
.syntax unified
.cpu cortex-m0
.fpu softvfp
.thumb
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
ldr r0, =_estack
mov sp, r0 /* set stack pointer */
bl main
LoopForever:
b LoopForever
.size Reset_Handler, .-Reset_Handler

Wyświetl plik

@ -0,0 +1,17 @@
#include "registers.hpp"
class CExec final
{
public:
CExec(){};
void InterruptCallback()
{
CheckButtons();
}
private:
void CheckButtons() const
{
}
};

Wyświetl plik

@ -0,0 +1,16 @@
import sys
def merge_files(in1, in2, out):
f1 = open(in1, 'rb')
f2 = open(in2, 'rb')
fo = open(out, 'wb')
fo.write(f1.read())
fo.write(f2.read())
fo.close()
f1.close()
f2.close()
if __name__ == '__main__':
args = sys.argv
merge_files(args[1], args[2], args[3])

Wyświetl plik

@ -0,0 +1,50 @@
#include "hardware.hpp"
#include "registers.hpp"
using namespace Hardware;
void TPower::EnableDbg()
{
GPIOB->DIR &= ~(GPIO_PIN_11|GPIO_PIN_14);
// PB11 alternate fx to SWDIO
GPIO->PORTB_SEL1 &= ~(0b1111 << 12);
GPIO->PORTB_SEL1 |= (0b1 << 12);
// PB14 alternate fx to SWDIO
GPIO->PORTB_SEL1 &= ~(0b1111 << 24);
GPIO->PORTB_SEL1 |= (0b1 << 24);
}
void TSystem::Delay(unsigned int u32Ticks)
{
for(volatile unsigned int i = 0; i < u32Ticks; i++)
{
__asm volatile ("dsb sy" : : : "memory");
}
}
void TFlashLight::On()
{
GPIOC->DATA |= 1 << 3;
}
void TFlashLight::Off()
{
GPIOC->DATA &= ~(1 << 3);
}
void TFlashLight::Toggle()
{
GPIOC->DATA ^= 1 << 3;
}
void TFlashLight::BlinkSync(unsigned char u8BlinksCnt)
{
for(unsigned char i = 0; i < u8BlinksCnt*2; i++)
{
Toggle();
System.Delay(200000);
}
Off();
}

Wyświetl plik

@ -0,0 +1,29 @@
namespace Hardware
{
struct TPower
{
void EnableDbg();
};
struct TSystem
{
static void Delay(unsigned int u32Ticks);
};
struct TFlashLight
{
TFlashLight(TSystem& Sys) :System(Sys){};
void On();
void Off();
void Toggle();
void BlinkSync(unsigned char u8BlinksCnt);
TSystem& System;
};
struct THardware
{
TPower Power;
TSystem System;
TFlashLight FlashLight = {System};
};
}

Wyświetl plik

@ -0,0 +1,35 @@
#include "system.hpp"
#include "hardware/hardware.hpp"
#include "registers.hpp"
#include "uv_k5_display.hpp"
#include "spectrum.hpp"
#include <string.h>
Hardware::THardware Hw;
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
const System::TOrgData& FwData = System::OrgData_01_26;
CSpectrum<System::OrgFunc_01_26, System::OrgData_01_26> Spectrum;
int main()
{
System::JumpToOrginalFw();
return 0;
}
void MultiIrq_Handler(unsigned int u32IrqSource)
{
static bool bFirstInit = false;
if(!bFirstInit)
{
System::CopyDataSection();
__libc_init_array();
bFirstInit = true;
}
static unsigned int u32StupidCounter = 1;
if(u32StupidCounter++ > 200)
{
Spectrum.Handle();
}
}

Wyświetl plik

@ -0,0 +1,88 @@
ENTRY(Reset_Handler)
MEMORY
{
RAM (rwx) : ORIGIN = 0x2000138C, LENGTH = 256
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 60K
}
_estack = 0x20001388;
SECTIONS
{
. = 0x0;
.isr_vectors :
{
. = ALIGN(4);
KEEP(*(.isr_vectors))
. = ALIGN(4);
} >FLASH
.org_fw_rest :
{
. = ALIGN(4);
KEEP(*(.org_fw_rest))
} > FLASH
.org_vectors :
{
. = ALIGN(4);
__org_vectors_start = .;
KEEP(*(.org_vectors))
} > FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text*)
*(.rodata)
*(.rodata*)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
} >FLASH
.preinit_array :
{
__preinit_array_start = .;
KEEP (*(.preinit_array*))
__preinit_array_end = .;
} >FLASH
.init_array :
{
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
__init_array_end = .;
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
_flash_data_start = .;
} >FLASH
_sidata = LOADADDR(.data);
.data : AT (_flash_data_start)
{
. = ALIGN(4);
_sdata = .;
*(.data)
*(.data*)
*(.ramsection)
_edata = .;
} >RAM
.bss :
{
. = ALIGN(4);
_sbss = .;
*(.bss)
_ebss = .;
} >RAM
}

Wyświetl plik

@ -0,0 +1,95 @@
#pragma once
#include "system.hpp"
#include "uv_k5_display.hpp"
#define REVERSE_UINT16(x) ((((x)&0xFF00) >> 8) | (((x)&0x00FF) << 8))
template <const System::TOrgFunctions &Fw, const System::TOrgData &FwData>
class CSpectrum
{
public:
static constexpr auto StepSize = 0xFFFF / TUV_K5Display::SizeX;
static constexpr auto StepSizeFreq = 10'000;
static constexpr unsigned char EnableKey = 13;
static constexpr auto DrawingSize = TUV_K5Display::SizeX * 2;
CSpectrum()
: DisplayBuff(FwData.pDisplayBuffer),
FontSmallNr(FwData.pSmallDigs),
Display(DisplayBuff),
bDisplayCleared(true),
p8DrawingStart((unsigned char *)DisplayBuff.GetCoursorData(
DisplayBuff.GetCoursorPosition(2, 0)))
{
Display.SetFont(&FontSmallNr);
};
void Handle()
{
// char C8RssiString[] = "g000";
// auto u8Rssi = Fw.PollKeyboard();
// C8RssiString[1] = '0' + u8Rssi / 100;
// C8RssiString[2] = '0' + (u8Rssi / 10) % 10;
// C8RssiString[3] = '0' + u8Rssi % 10;
// Display.SetCoursor(3, 0);
// Display.SetFont(&FontSmallNr);
// Display.Print(C8RssiString);
// Fw.FlushFramebufferToScreen();
// while(1);
// if(!FreeToDraw())
// {
// if(!bDisplayCleared)
// {
// bDisplayCleared = true;
// ClearDrawings();
// Fw.FlushFramebufferToScreen();
// }
// return;
// }
bDisplayCleared = false;
Display.SetCoursor(3, 0);
Display.PrintFixedDigtsNumer(123456, 10);
Display.DrawCircle(64, 25, 8, false);
Fw.FlushFramebufferToScreen();
}
private:
void SetFrequency(unsigned int u32Freq)
{
u32Freq /= 10;
Fw.BK4819Write(0x39, REVERSE_UINT16((u32Freq >> 16) & 0xFFFF));
Fw.BK4819Write(0x38, REVERSE_UINT16(u32Freq & 0xFFFF));
}
unsigned int GetFrequency()
{
unsigned short u16f1 = Fw.BK4819Write(0x39);
unsigned short u16f2 = Fw.BK4819Write(0x38);
return (u16f1 << 16) | u16f2;
}
bool FreeToDraw()
{
auto const PressedKey = Fw.PollKeyboard();
auto *pMenuCheckData = (unsigned char *)DisplayBuff.GetCoursorData(
DisplayBuff.GetCoursorPosition(2, 6 * 8 + 1));
return PressedKey == EnableKey && *pMenuCheckData != 0xFF;
}
void ClearDrawings()
{
memset(p8DrawingStart, 0, DrawingSize);
}
TUV_K5Display DisplayBuff;
const TUV_K5SmallNumbers FontSmallNr;
CDisplay<const TUV_K5Display> Display;
bool bDisplayCleared;
unsigned char *const p8DrawingStart;
};