bootloader

This commit is contained in:
rusefillc 2023-12-26 15:31:31 -05:00
parent 8c201022b7
commit 1128eb2ac2
3 changed files with 49 additions and 46 deletions

View File

@ -7,12 +7,11 @@
ifeq ($(DEBUG_LEVEL_OPT),)
# this value would be used by default. For 'debug' configuration override with '-O0 -ggdb -g' or something along these lines
DEBUG_LEVEL_OPT = -O2
DEBUG_LEVEL_OPT = -Os -ggdb -g
DDEFS += -DEFI_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE
endif
# let everyone know that we are compiling bootloader
IS_RE_BOOTLOADER = yes
DDEFS += -DENABLE_AUTO_DETECT_HSE=TRUE -DSTM32_HSECLK=25000000
# disable some modules to shrink bootloader binary
DDEFS += -DEFI_BOOTLOADER
@ -22,8 +21,7 @@ DDEFS += -DHAL_USE_FLASH=FALSE
DDEFS += -DEFI_USE_UART_DMA=FALSE
# disable USB (The bootloader has currently UART support only)
DDEFS += -DEFI_USB_SERIAL=FALSE
DDEFS += -DEFI_USB_SERIAL=TRUE -DHAL_USE_USB_MSD=FALSE
# disable CAN
DDEFS += -DEFI_CAN_SUPPORT=FALSE
@ -34,6 +32,9 @@ ifeq ($(USE_OPT),)
USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -Wno-error=implicit-fallthrough -Wno-error=bool-operation -fomit-frame-pointer -falign-functions=16 -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Werror=type-limits -Wno-error=strict-aliasing -Wno-error=attributes
endif
# Configure the linker script to build the bootloader, not the firmware
USE_OPT += -Wl,--defsym=IS_BOOTLOADER=1
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT = -fgnu89-inline -std=gnu99 -Werror-implicit-function-declaration
@ -52,13 +53,6 @@ ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
ifeq ($(CCACHE_DIR),)
$(info No CCACHE_DIR)
else
$(info CCACHE_DIR is ${CCACHE_DIR})
CCPREFIX=ccache
endif
# Linker extra options here.
ifeq ($(USE_LDOPT),)
USE_LDOPT =
@ -119,7 +113,7 @@ endif
#
# Define project name here
PROJECT = bootloader
PROJECT = fome_bl
PROJECT_DIR = ..
# Configure precompiled header
@ -177,7 +171,14 @@ CSRC = $(ALLCSRC) \
$(HW_LAYER) \
$(HW_LAYER_PORT) \
$(HW_LAYER_DRIVERS_CORE) \
$(FATFSSRC) \
$(PROJECT_DIR)/hw_layer/openblt/shared_params.c \
$(PROJECT_DIR)/hw_layer/main_hardfault.c \
$(PROJECT_DIR)/ext/openblt/Target/Source/backdoor.c \
$(PROJECT_DIR)/ext/openblt/Target/Source/boot.c \
$(PROJECT_DIR)/ext/openblt/Target/Source/com.c \
$(PROJECT_DIR)/ext/openblt/Target/Source/xcp.c \
$(PROJECT_DIR)/bootloader/openblt_chibios/nvm.c \
$(PROJECT_DIR)/hw_layer/openblt/hooks.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# todo: reduce code duplication with primary Makefile!!!
@ -185,18 +186,12 @@ CSRC = $(ALLCSRC) \
CPPSRC = $(ALLCPPSRC) \
$(HW_LAYER_PORT_CPP) \
$(BOARDCPPSRC) \
$(HW_SENSORS_SRC) \
$(TUNERSTUDIO_SRC_CPP) \
$(CONSOLE_SRC_CPP) \
$(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
$(PROJECT_DIR)/console/binary/tunerstudio_io_serial.cpp \
$(PROJECT_DIR)/controllers/algo/engine_configuration.cpp \
$(PROJECT_DIR)/controllers/persistent_store.cpp \
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
$(PROJECT_DIR)/hw_layer/serial_over_usb/usbcfg.cpp \
$(PROJECT_DIR)/util/efilib.cpp \
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
$(RUSEFI_LIB_CPP) \
$(PROJECT_DIR)/bootloader/openblt_chibios/openblt_chibios.cpp \
$(PROJECT_DIR)/bootloader/openblt_chibios/openblt_flash.cpp \
$(PROJECT_DIR)/bootloader/openblt_chibios/openblt_usb.cpp \
src/rusefi_stubs.cpp \
src/main.cpp
@ -263,6 +258,9 @@ INCDIR = $(ALLINC) \
$(PROJECT_DIR)/init \
$(RUSEFI_LIB_INC) \
$(BOARDS_DIR) \
$(PROJECT_DIR)/hw_layer/openblt \
$(PROJECT_DIR)/ext/openblt/Target/Source \
$(PROJECT_DIR)/bootloader/openblt_chibios \
config
BUILDDIR=blbuild

View File

@ -1,20 +1,38 @@
#include "pch.h"
#include "usbconsole.h"
#include "hardware.h"
extern "C" {
#include "boot.h"
#include "shared_params.h"
}
int main(void) {
halInit();
chSysInit();
// set base pin configuration based on the board
setDefaultBasePins();
/* at the moment SD card is not needed by bootloader
// set SD card configuration also
setDefaultSdCardParameters();
*/
baseMCUInit();
// Init openblt shared params
SharedParamsInit();
// Init openblt itself
BootInit();
while (true) {
chThdSleepMilliseconds(1);
BootTask();
}
}
// very basic version, supports on chip pins only (really only used for USB)
void efiSetPadMode(const char* msg, brain_pin_e brainPin, iomode_t mode) {
ioportid_t port = getHwPort(msg, brainPin);
ioportmask_t pin = getHwPin(msg, brainPin);
/* paranoid */
if (port == GPIO_NULL) {
return;
}
palSetPadMode(port, pin, mode);
}

View File

@ -12,20 +12,7 @@
void chDbgPanic3(const char* /*msg*/, const char* /*file*/, int /*line*/) {
}
namespace priv
{
void efiPrintfInternal(const char* /*fmt*/, ...) {
}
}
void firmwareError(ObdCode /*code*/, const char* /*fmt*/, ...) {
}
Logging::Logging(char const* /*name*/, char* /*buffer*/, int /*bufferSize*/) {
}
LoggingWithStorage::LoggingWithStorage(const char *name) : Logging(name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)) {
}
void logHardFault(uint32_t type, uintptr_t faultAddress, struct port_extctx* ctx, uint32_t csfr) { }
void setPinConfigurationOverrides() { }
@ -38,4 +25,4 @@ void contextSwitchHook() {}
void threadInitHook(void*) {}
void onLockHook() {}
void onUnlockHook() {}
//#endif /* ENABLE_PERF_TRACE */
//#endif /* ENABLE_PERF_TRACE */