Show version over UART and boot.

This commit is contained in:
Dual Tachyon 2023-09-02 23:01:39 +01:00
parent 80fbe5cd05
commit 6d575836d5
5 changed files with 37 additions and 1 deletions

View File

@ -66,6 +66,7 @@ OBJS += ui/scanner.o
OBJS += ui/status.o
OBJS += ui/ui.o
OBJS += ui/welcome.o
OBJS += version.o
OBJS += main.o
@ -81,9 +82,12 @@ LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
GIT_HASH := $(shell git rev-parse --short HEAD)
ASFLAGS = -mcpu=cortex-m0
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
ifeq ($(DEBUG),1)
@ -111,6 +115,8 @@ debug:
flash:
/opt/openocd/bin/openocd -c "bindto 0.0.0.0" -f interface/jlink.cfg -f dp32g030.cfg -c "write_image firmware.bin 0; shutdown;"
version.o: .FORCE
$(TARGET): $(OBJS)
$(LD) $(LDFLAGS) $^ -o $@ $(LIBS)
@ -122,6 +128,8 @@ bsp/dp32g030/%.h: hardware/dp32g030/%.def
%.o: %.S
$(AS) $(ASFLAGS) $< -o $@
.FORCE:
-include $(DEPS)
clean:

View File

@ -30,6 +30,7 @@
#include "misc.h"
#include "settings.h"
#include "sram-overlay.h"
#include "version.h"
#define DMA_INDEX(x, y) (((x) + (y)) % sizeof(UART_DMA_Buffer))
@ -178,7 +179,7 @@ static void SendVersion(void)
Reply.Header.ID = 0x0515;
Reply.Header.Size = sizeof(Reply.Data);
strcpy(Reply.Data.Version, "Open Edition FW");
strcpy(Reply.Data.Version, Version);
Reply.Data.bHasCustomAesKey = bHasCustomAesKey;
Reply.Data.bIsInLockScreen = bIsInLockScreen;
Reply.Data.Challenge[0] = gChallenge[0];

View File

@ -22,6 +22,7 @@
#include "settings.h"
#include "ui/helper.h"
#include "ui/welcome.h"
#include "version.h"
void UI_DisplayWelcome(void)
{
@ -45,6 +46,7 @@ void UI_DisplayWelcome(void)
}
UI_PrintString(WelcomeString0, 0, 127, 1, 10, true);
UI_PrintString(WelcomeString1, 0, 127, 3, 10, true);
UI_PrintString(Version, 0, 127, 5, 10, true);
ST7565_BlitStatusLine();
ST7565_BlitFullScreen();
}

2
version.c Normal file
View File

@ -0,0 +1,2 @@
const char Version[] = "OEFW-" GIT_HASH;

23
version.h Normal file
View File

@ -0,0 +1,23 @@
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VERSION_H
#define VERSION_H
extern const char Version[];
#endif