1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-25 08:58:14 +00:00

unix: emulator debug build options

This commit is contained in:
Milan Rossa 2018-10-09 14:35:52 +02:00 committed by Pavol Rusnak
parent 84b53e5813
commit 32fe5d20af
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 32 additions and 7 deletions

View File

@ -246,11 +246,19 @@ env.Replace(
STRIP='strip', STRIP='strip',
OBJCOPY='objcopy', ) OBJCOPY='objcopy', )
if env.get('ENV').get('DEBUG_BUILD', 0):
import platform
platsys = platform.system()
env.Replace(
OPTIMIZE='-O0',
LINKFLAGS='-Wl,-no_pie' if platsys == "Darwin" else '-Wl,-no-pie'
)
env.Replace( env.Replace(
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), ) TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
env.Replace( env.Replace(
COPT=env.get('ENV').get('OPTIMIZE', '-Os'), COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
CCFLAGS='$COPT ' CCFLAGS='$COPT '
'-g3 ' '-g3 '
'-std=gnu99 -Wall -Werror -Wuninitialized ' '-std=gnu99 -Wall -Werror -Wuninitialized '

View File

@ -98,3 +98,15 @@ Use `make upload` to upload the firmware to a production device (with a bootload
For flashing firmware to blank device (without bootloader) use `make flash`, For flashing firmware to blank device (without bootloader) use `make flash`,
or `make flash STLINK_VER=v2-1` if using a ST-LINK/V2.1 interface. or `make flash STLINK_VER=v2-1` if using a ST-LINK/V2.1 interface.
You need to have OpenOCD installed. You need to have OpenOCD installed.
## Building for debugging and hacking in Emulator (Unix port)
Build the debuggable unix binary so you can attach the gdb or lldb.
This removes optimizations and reduces address space randomizaiton.
Beware that this will significantly bloat the final binary
and the firmware runtime memory limit HEAPSIZE may have to be increased.
```sh
DEBUG_BUILD=1 make build_unix
```

View File

@ -32,8 +32,8 @@ void touch_power_off(void);
uint32_t touch_read(void); uint32_t touch_read(void);
uint32_t touch_click(void); uint32_t touch_click(void);
uint32_t touch_is_detected(void); uint32_t touch_is_detected(void);
inline uint16_t touch_unpack_x(uint32_t evt) { return (evt >> 12) & 0xFFF; } static inline uint16_t touch_unpack_x(uint32_t evt) { return (evt >> 12) & 0xFFF; }
inline uint16_t touch_unpack_y(uint32_t evt) { return (evt >> 0) & 0xFFF; } static inline uint16_t touch_unpack_y(uint32_t evt) { return (evt >> 0) & 0xFFF; }
inline uint32_t touch_pack_xy(uint16_t x, uint16_t y) { return ((x & 0xFFF) << 12) | (y & 0xFFF); } static inline uint32_t touch_pack_xy(uint16_t x, uint16_t y) { return ((x & 0xFFF) << 12) | (y & 0xFFF); }
#endif #endif

11
emu.sh
View File

@ -4,9 +4,9 @@ source emu.config 2>/dev/null
EXE=build/unix/micropython EXE=build/unix/micropython
PYOPT="${PYOPT:-1}" PYOPT="${PYOPT:-1}"
MAIN="${MAIN:-main.py}" MAIN="${MAIN:-${PWD}/src/main.py}"
BROWSER="${BROWSER:-chromium}" BROWSER="${BROWSER:-chromium}"
HEAPSIZE="${HEAPSIZE:-800K}" HEAPSIZE="${HEAPSIZE:-50M}"
SOURCE_PY_DIR="${SOURCE_PY_DIR:-src}" SOURCE_PY_DIR="${SOURCE_PY_DIR:-src}"
ARGS="-O${PYOPT} -X heapsize=${HEAPSIZE}" ARGS="-O${PYOPT} -X heapsize=${HEAPSIZE}"
@ -16,7 +16,12 @@ cd `dirname $0`/$SOURCE_PY_DIR
case "$1" in case "$1" in
"-d") "-d")
shift shift
gdb --args ../$EXE $ARGS $* $MAIN OPERATING_SYSTEM=$(uname)
if [ $OPERATING_SYSTEM == "Darwin" ]; then
PATH=/usr/bin /usr/bin/lldb -f ../$EXE -- $ARGS $* $MAIN
else
gdb --args ../$EXE $ARGS $* $MAIN
fi
;; ;;
"-r") "-r")
shift shift