1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

build: don't use STM32_HAL_H directly to detect port, introduce TREZOR_STM32 and TREZOR_UNIX macros

This commit is contained in:
Pavol Rusnak 2017-04-17 17:57:42 +02:00
parent a7e17f07ee
commit 117edd233f
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
10 changed files with 31 additions and 22 deletions

View File

@ -118,6 +118,7 @@ CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)

View File

@ -130,6 +130,7 @@ CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)

View File

@ -356,6 +356,7 @@ CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY

View File

@ -1,10 +1,10 @@
#ifdef UNIX
#define NORCOW_UNIX 1
#define NORCOW_FILE "/var/tmp/trezor.config"
#endif
#ifdef STM32_HAL_H
#if defined TREZOR_STM32
#define NORCOW_STM32 1
#define NORCOW_START_SECTOR 2
#define NORCOW_START_ADDRESS 0x08008000
#elif defined TREZOR_UNIX
#define NORCOW_UNIX 1
#define NORCOW_FILE "/var/tmp/trezor.config"
#else
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
#endif

View File

@ -15,12 +15,12 @@
#if MICROPY_PY_TREZORMSG
#if defined STM32_HAL_H
#include "modtrezormsg-stmhal.h"
#elif defined UNIX
#if defined TREZOR_STM32
#include "modtrezormsg-stm32.h"
#elif defined TREZOR_UNIX
#include "modtrezormsg-unix.h"
#else
#error Unsupported port. Only STMHAL and UNIX ports are supported.
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
#endif
#define MAX_INTERFACES 8

View File

@ -20,10 +20,12 @@ static int DISPLAY_BACKLIGHT = 0;
static int DISPLAY_ORIENTATION = 0;
static int DISPLAY_OFFSET[2] = {0, 0};
#if defined STM32_HAL_H
#include "display-stmhal.h"
#else
#if defined TREZOR_STM32
#include "display-stm32.h"
#elif defined TREZOR_UNIX
#include "display-unix.h"
#else
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
#endif
// common display functions

View File

@ -8,16 +8,18 @@
#include <stdio.h>
#include <string.h>
#if defined STM32_HAL_H
#include "common.h"
#elif defined UNIX
#include <stdlib.h>
#endif
#include "py/runtime.h"
#if MICROPY_PY_TREZORUTILS
#if defined TREZOR_STM32
#include "common.h"
#elif defined TREZOR_UNIX
#include <stdlib.h>
#else
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
#endif
/// def trezor.utils.memcpy(dst: bytearray, dst_ofs: int,
/// src: bytearray, src_ofs: int,
// n: int) -> int:
@ -69,12 +71,12 @@ STATIC mp_obj_t mod_TrezorUtils_halt(size_t n_args, const mp_obj_t *args) {
printf("HALT!\n");
}
// TODO: is this the best we can do?
#if defined STM32_HAL_H
#if defined TREZOR_STM32
__fatal_error("HALT");
#elif defined UNIX
#elif defined TREZOR_UNIX
exit(1);
#else
#error Unsupported port. Only STMHAL and UNIX ports are supported.
#error Unsupported TREZOR port. Only STM32 and UNIX ports are supported.
#endif
return mp_const_none;
}

View File

@ -121,6 +121,8 @@ CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized
CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
CFLAGS += -DTREZOR_UNIX
# Debugging/Optimization
ifdef DEBUG
CFLAGS += -g