mirror of
https://github.com/OpenRTX/OpenRTX
synced 2026-08-08 12:29:06 -04:00
Automatic sa8x8-fw flashing and patching
Now the 1.4.1 release of sa8x8-fw is downloaded at every build of the ttwr21 target, it is converted from s37 to bin to c header file and is included in the OpenRTX firmware image. OpenRTX, at runtime detects the band of the radio and patches the firmware with the appropriate identification string. TG-553
This commit is contained in:
parent
35c9fe766c
commit
67a45cb26d
3 changed files with 35 additions and 25 deletions
|
|
@ -6,15 +6,15 @@
|
|||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
# Download sa8x8-fw from the web and package it as a header file
|
||||
set(SAX8FW "sa8x8-fw-sa868s-uhf")
|
||||
set(SA8X8FW "sa8x8-fw-sa868s-uhf")
|
||||
file(DOWNLOAD
|
||||
https://github.com/OpenRTX/sa8x8-fw/releases/download/v1.4.1/sa8x8-fw-sa868s-uhf.s37
|
||||
${CMAKE_CURRENT_LIST_DIR}/${SAX8FW}.s37
|
||||
${CMAKE_CURRENT_LIST_DIR}/${SA8X8FW}.s37
|
||||
EXPECTED_HASH SHA512=0e046c745683cf204112feef97ab9cab8718d12b63fa2990a15ae054be28c26b18ae7a3f3518d0c81727426478e08580ce9a67e8f244d31f4401d7430a2e70e4
|
||||
SHOW_PROGRESS
|
||||
)
|
||||
execute_process(COMMAND objcopy -I srec -O binary --gap-fill 0xff --pad-to 0x4000 ${CMAKE_CURRENT_LIST_DIR}/${SAX8FW}.s37 ${CMAKE_CURRENT_LIST_DIR}/${SAX8FW}.bin)
|
||||
execute_process(COMMAND awk -b -f ${OPENRTX_ROOT}/scripts/bin2c.awk ${CMAKE_CURRENT_LIST_DIR}/${SAX8FW}.bin)
|
||||
execute_process(COMMAND objcopy -I srec -O binary --gap-fill 0xff --pad-to 0x4000 ${CMAKE_CURRENT_LIST_DIR}/${SA8X8FW}.s37 ${CMAKE_CURRENT_LIST_DIR}/${SA8X8FW}.bin)
|
||||
execute_process(COMMAND awk -b -f ${OPENRTX_ROOT}/scripts/bin2c.awk ${CMAKE_CURRENT_LIST_DIR}/${SA8X8FW}.bin)
|
||||
|
||||
target_sources(app
|
||||
PRIVATE
|
||||
|
|
@ -46,6 +46,7 @@ target_include_directories(app
|
|||
|
||||
${OPENRTX_ROOT}/subprojects/XPowersLib/src
|
||||
${OPENRTX_ROOT}/subprojects/XPowersLib/src/REG
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(app PRIVATE PLATFORM_TTWR CONFIG_SCREEN_BRIGHTNESS CONFIG_UI_NO_KEYBOARD)
|
||||
|
|
|
|||
|
|
@ -144,6 +144,24 @@ void platform_init()
|
|||
// Initialize PMU
|
||||
pmu_init();
|
||||
|
||||
// Detect radio model and set hwInfo accordingly
|
||||
enum ttwr21_band band = detect_band();
|
||||
switch(band) {
|
||||
case VHF:
|
||||
hwInfo.vhf_band = 1;
|
||||
hwInfo.vhf_minFreq = 134;
|
||||
hwInfo.vhf_maxFreq = 174;
|
||||
break;
|
||||
case UHF:
|
||||
hwInfo.uhf_band = 1;
|
||||
hwInfo.uhf_minFreq = 400;
|
||||
hwInfo.uhf_maxFreq = 480;
|
||||
break;
|
||||
case MHZ350:
|
||||
printk("Error: 350MHz band not supported!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (gpio_pin_get_dt(&button_mode)) {
|
||||
led_color.r = 0x50;
|
||||
led_color.g = 0x50;
|
||||
|
|
@ -152,8 +170,12 @@ void platform_init()
|
|||
|
||||
pmu_setBasebandProgramPower(true);
|
||||
|
||||
// If band is VHF we need to patch the firmware
|
||||
if (band == VHF)
|
||||
sa8x8_fw_sa868s_uhf[sa8x8_fw_sa868s_uhf_patch_offset] = 'V';
|
||||
|
||||
// Flash a supported baseband firmware
|
||||
if (rl78_flash(sa8x8_fw, sa8x8_fw_len)) {
|
||||
if (rl78_flash(sa8x8_fw_sa868s_uhf, sa8x8_fw_sa868s_uhf_len)) {
|
||||
led_color.r = 0x50;
|
||||
led_color.g = 0x00;
|
||||
led_color.b = 0x00;
|
||||
|
|
@ -177,24 +199,6 @@ void platform_init()
|
|||
pmu_setBasebandProgramPower(false);
|
||||
}
|
||||
|
||||
// Detect radio model and set hwInfo accordingly
|
||||
enum ttwr21_band band = detect_band();
|
||||
switch(band) {
|
||||
case VHF:
|
||||
hwInfo.vhf_band = 1;
|
||||
hwInfo.vhf_minFreq = 134;
|
||||
hwInfo.vhf_maxFreq = 174;
|
||||
break;
|
||||
case UHF:
|
||||
hwInfo.uhf_band = 1;
|
||||
hwInfo.uhf_minFreq = 400;
|
||||
hwInfo.uhf_maxFreq = 480;
|
||||
break;
|
||||
case MHZ350:
|
||||
printk("Error: 350MHz band not supported!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
// Enable power to baseband
|
||||
pmu_setBasebandPower(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ BEGIN {
|
|||
bytes_x_line = 12
|
||||
outfile = infile
|
||||
gsub(getext(infile), ".h", outfile)
|
||||
arr_name = basename(infile)
|
||||
gsub("-", "_", arr_name)
|
||||
|
||||
# Print header
|
||||
printf("unsigned char %s[] = {\n", basename(infile)) > outfile
|
||||
printf("unsigned char %s[] = {\n", arr_name) > outfile
|
||||
for(i=0; i<len; i+=bytes_x_line) {
|
||||
printf(" ") > outfile
|
||||
# printf("0x%08x ", i)
|
||||
|
|
@ -47,7 +49,10 @@ BEGIN {
|
|||
print "" > outfile
|
||||
}
|
||||
printf("};\n\n") > outfile
|
||||
printf("unsigned int %s_len = %d;\n", basename(infile), len) > outfile
|
||||
printf("unsigned int %s_len = %d;\n", arr_name, len) > outfile
|
||||
# Find offset of character to patch (UHF -> VHF)
|
||||
patch_offset = index($0, "SA868S-UHF") + 6
|
||||
printf("unsigned int %s_patch_offset = %d;\n", arr_name, patch_offset) > outfile
|
||||
}
|
||||
# Extract basename of file
|
||||
function basename(filename, a) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue