mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
embed: refactor cpu flags in sconscript files
This commit is contained in:
parent
2a06ff4986
commit
45e10a2e79
@ -86,17 +86,27 @@ env.Replace(
|
|||||||
OBJCOPY='arm-none-eabi-objcopy', )
|
OBJCOPY='arm-none-eabi-objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
if env.get('TREZOR_MODEL') == 'T':
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
|
CPU_MODEL = 'STM32F427xx'
|
||||||
|
else:
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||||
|
CPU_MODEL = 'STM32F405xx'
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-nostdlib '
|
'-nostdlib '
|
||||||
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
||||||
'-mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard '
|
|
||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CCFLAGS_MOD,
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/boardloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/boardloader/boardloader.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -111,11 +121,11 @@ env.Replace(
|
|||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
||||||
'STM32F427xx',
|
CPU_MODEL,
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASFLAGS='-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
|
ASFLAGS=CPU_ASFLAGS,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -107,17 +107,27 @@ env.Replace(
|
|||||||
OBJCOPY='arm-none-eabi-objcopy', )
|
OBJCOPY='arm-none-eabi-objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
if env.get('TREZOR_MODEL') == 'T':
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
|
CPU_MODEL = 'STM32F427xx'
|
||||||
|
else:
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||||
|
CPU_MODEL = 'STM32F405xx'
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-nostdlib '
|
'-nostdlib '
|
||||||
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
||||||
'-mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard '
|
|
||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CCFLAGS_MOD,
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/bootloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader/bootloader.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/bootloader/memory.ld -Wl,--gc-sections -Wl,-Map=build/bootloader/bootloader.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -133,12 +143,12 @@ env.Replace(
|
|||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
||||||
'STM32F427xx',
|
CPU_MODEL,
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
'PB_FIELD_16BIT',
|
'PB_FIELD_16BIT',
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASFLAGS='-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
|
ASFLAGS=CPU_ASFLAGS,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
|
@ -301,17 +301,27 @@ env.Replace(
|
|||||||
OBJCOPY='arm-none-eabi-objcopy', )
|
OBJCOPY='arm-none-eabi-objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
if env.get('TREZOR_MODEL') == 'T':
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
|
CPU_MODEL = 'STM32F427xx'
|
||||||
|
else:
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||||
|
CPU_MODEL = 'STM32F405xx'
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-nostdlib '
|
'-nostdlib '
|
||||||
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
||||||
'-mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard '
|
|
||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CCFLAGS_MOD,
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}.ld -Wl,--gc-sections -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}.ld -Wl,--gc-sections -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -327,11 +337,11 @@ env.Replace(
|
|||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
||||||
'STM32F427xx',
|
CPU_MODEL,
|
||||||
'USE_HAL_DRIVER',
|
'USE_HAL_DRIVER',
|
||||||
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASFLAGS='-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
|
ASFLAGS=CPU_ASFLAGS,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
|
@ -76,17 +76,18 @@ env.Replace(
|
|||||||
OBJCOPY='arm-none-eabi-objcopy', )
|
OBJCOPY='arm-none-eabi-objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-nostdlib '
|
'-nostdlib '
|
||||||
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
||||||
'-mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard '
|
|
||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CCFLAGS_MOD,
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/prodtest/memory.ld -Wl,--gc-sections -Wl,-Map=build/prodtest/prodtest.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/prodtest/memory.ld -Wl,--gc-sections -Wl,-Map=build/prodtest/prodtest.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -100,10 +101,11 @@ env.Replace(
|
|||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
||||||
'STM32F427xx',
|
CPU_MODEL,
|
||||||
('STM32_HAL_H', '"<stm32f4xx_hal.h>"'),
|
'USE_HAL_DRIVER',
|
||||||
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASFLAGS='-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
|
ASFLAGS=CPU_ASFLAGS,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
|
@ -76,17 +76,27 @@ env.Replace(
|
|||||||
OBJCOPY='arm-none-eabi-objcopy', )
|
OBJCOPY='arm-none-eabi-objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
if env.get('TREZOR_MODEL') == 'T':
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||||
|
CPU_MODEL = 'STM32F427xx'
|
||||||
|
else:
|
||||||
|
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||||
|
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||||
|
CPU_MODEL = 'STM32F405xx'
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-nostdlib '
|
'-nostdlib '
|
||||||
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
'-std=gnu99 -Wall -Werror -Wdouble-promotion -Wpointer-arith -fno-common '
|
||||||
'-mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard '
|
|
||||||
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
'-fsingle-precision-constant -fdata-sections -ffunction-sections '
|
||||||
'-ffreestanding '
|
'-ffreestanding '
|
||||||
'-fstack-protector-all '
|
'-fstack-protector-all '
|
||||||
+ CCFLAGS_MOD,
|
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||||
LINKFLAGS='-T embed/reflash/memory.ld -Wl,--gc-sections -Wl,-Map=build/reflash/reflash.map -Wl,--warn-common',
|
LINKFLAGS='-T embed/reflash/memory.ld -Wl,--gc-sections -Wl,-Map=build/reflash/reflash.map -Wl,--warn-common',
|
||||||
CPPPATH=[
|
CPPPATH=[
|
||||||
@ -100,10 +110,11 @@ env.Replace(
|
|||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD,
|
||||||
CPPDEFINES=[
|
CPPDEFINES=[
|
||||||
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
||||||
'STM32F427xx',
|
CPU_MODEL,
|
||||||
('STM32_HAL_H', '"<stm32f4xx_hal.h>"'),
|
'USE_HAL_DRIVER',
|
||||||
|
('STM32_HAL_H', '"<stm32f4xx.h>"'),
|
||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASFLAGS='-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16',
|
ASFLAGS=CPU_ASFLAGS,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
|
@ -247,7 +247,9 @@ env.Replace(
|
|||||||
OBJCOPY='objcopy', )
|
OBJCOPY='objcopy', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'),
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
#define FLASH_SECTOR_COUNT 24
|
#define FLASH_SECTOR_COUNT 24
|
||||||
|
|
||||||
// note: FLASH_SR_RDERR is STM32F42xxx and STM32F43xxx specific (STM32F427) (reference RM0090 section 3.7.5)
|
// note: FLASH_SR_RDERR is STM32F42xxx and STM32F43xxx specific (STM32F427) (reference RM0090 section 3.7.5)
|
||||||
#ifndef FLASH_SR_RDERR
|
#ifndef STM32F427xx
|
||||||
#define FLASH_SR_RDERR 0
|
#define FLASH_SR_RDERR 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user