core+legacy: drop NOUI and HEADLESS, SDL_VIDEODRIVER works fine

pull/156/head
Pavol Rusnak 5 years ago
parent b69a9e768b
commit f7d41cbbd7
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -9,7 +9,8 @@ ENV TOOLCHAIN_FLAVOR=$TOOLCHAIN_FLAVOR
RUN apt-get update && apt-get install -y \
build-essential wget git libsodium-dev graphviz \
valgrind check libssl-dev libusb-1.0-0-dev libudev-dev zlib1g-dev
valgrind check libssl-dev libusb-1.0-0-dev libudev-dev zlib1g-dev \
libsdl2-dev libsdl2-image-dev
# install clang-format 6 from backports
RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list

@ -1,5 +1,9 @@
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
variables:
SDL_VIDEODRIVER: "dummy"
XDG_RUNTIME_DIR: "/var/tmp"
build core firmware:
stage: build
script:
@ -21,24 +25,24 @@ build core unix:
stage: build
script:
- cd core
- pipenv run make build_unix_noui
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
untracked: true
expire_in: 1 day
- pipenv run make build_unix
build core unix frozen:
stage: build
script:
- cd core
- pipenv run make build_unix_noui_frozen
- pipenv run make build_unix_frozen
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
untracked: true
expire_in: 1 day
test core unix unit:
stage: test
variables:
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
dependencies:
- build core unix
- build core unix frozen
script:
- cd core
- pipenv run make test
@ -48,7 +52,7 @@ test core unix device:
variables:
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
dependencies:
- build core unix
- build core unix frozen
script:
- cd core
- pipenv run make test_emu
@ -58,7 +62,7 @@ test core unix monero:
variables:
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
dependencies:
- build core unix
- build core unix frozen
script:
- cd core
- pipenv run make test_emu_monero

@ -1,5 +1,9 @@
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
variables:
SDL_VIDEODRIVER: "dummy"
XDG_RUNTIME_DIR: "/var/tmp"
build legacy firmware:
stage: build
script:
@ -31,9 +35,8 @@ build legacy firmware bitcoinonly:
build legacy emu:
stage: build
variables:
HEADLESS: "1"
EMULATOR: "1"
DEBUG_LINK: "1"
EMULATOR: "1"
script:
- cd legacy
- pipenv run script/cibuild
@ -53,4 +56,4 @@ test legacy emu:
EMULATOR: "1"
script:
- cd legacy
- pipenv run script/test
- pipenv run script/test

@ -108,12 +108,6 @@ build_unix: res ## build unix port
build_unix_frozen: res build_cross ## build unix port with frozen modules
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_FROZEN=1
build_unix_noui: res ## build unix port without UI support
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1
build_unix_noui_frozen: res build_cross ## build unix port without UI support with frozen modules
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 TREZOR_EMULATOR_FROZEN=1
build_unix_raspi: res ## build unix port for Raspberry Pi
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1

@ -134,8 +134,6 @@ SOURCE_MOD += [
'embed/extmod/modtrezorui/modtrezorui.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']
if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0):
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
@ -341,8 +339,7 @@ env.Replace(
] + CPPDEFINES_MOD,
ASPPFLAGS='$CFLAGS $CCFLAGS', )
if not ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image || :')
env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image')
env.Replace(
PYTHON='python',

@ -9,7 +9,7 @@ RUN apt-get update
RUN apt-get install libusb-1.0-0
RUN pip3 install scons trezor
RUN make build_unix_noui
RUN make build_unix
ENTRYPOINT ["emulator/run.sh"]
EXPOSE 21324/udp 21325

@ -2,6 +2,7 @@
cd "$(dirname "$0")"
cd ..
export SDL_VIDEODRIVER=dummy
export TREZOR_UDP_IP=0.0.0.0
source emu.sh

@ -17,10 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#ifndef TREZOR_EMULATOR_NOUI
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <stdlib.h>
#define EMULATOR_BORDER 16
@ -90,12 +89,8 @@ void PIXELDATA(uint16_t c) {
PIXELWINDOW.pos.y++;
}
}
#else
#define PIXELDATA(X) (void)(X)
#endif
void display_init(void) {
#ifndef TREZOR_EMULATOR_NOUI
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("%s\n", SDL_GetError());
ensure(secfalse, "SDL_Init error");
@ -166,12 +161,10 @@ void display_init(void) {
#else
DISPLAY_ORIENTATION = 0;
#endif
#endif
}
static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
uint16_t y1) {
#ifndef TREZOR_EMULATOR_NOUI
if (!RENDERER) {
display_init();
}
@ -181,11 +174,9 @@ static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
PIXELWINDOW.end.y = y1;
PIXELWINDOW.pos.x = x0;
PIXELWINDOW.pos.y = y0;
#endif
}
void display_refresh(void) {
#ifndef TREZOR_EMULATOR_NOUI
if (!RENDERER) {
display_init();
}
@ -208,7 +199,6 @@ void display_refresh(void) {
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
}
SDL_RenderPresent(RENDERER);
#endif
}
static void display_set_orientation(int degrees) { display_refresh(); }
@ -216,7 +206,6 @@ static void display_set_orientation(int degrees) { display_refresh(); }
static void display_set_backlight(int val) { display_refresh(); }
const char *display_save(const char *prefix) {
#ifndef TREZOR_EMULATOR_NOUI
if (!RENDERER) {
display_init();
}
@ -243,6 +232,4 @@ const char *display_save(const char *prefix) {
IMG_SavePNG(crop, filename);
prev = crop;
return filename;
#endif
return NULL;
}

@ -17,10 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#ifndef TREZOR_EMULATOR_NOUI
#include <SDL2/SDL.h>
#endif
#include <stdint.h>
#include "touch.h"
@ -31,7 +29,6 @@ extern void __shutdown(void);
extern const char *display_save(const char *prefix);
uint32_t touch_read(void) {
#ifndef TREZOR_EMULATOR_NOUI
SDL_Event event;
SDL_PumpEvents();
if (SDL_PollEvent(&event) > 0) {
@ -113,6 +110,5 @@ uint32_t touch_read(void) {
break;
}
}
#endif
return 0;
}

@ -91,14 +91,8 @@ LDFLAGS += -L$(TOP_DIR)emulator
LDLIBS += -ltrezor -lemulator
LIBDEPS += $(TOP_DIR)/libtrezor.a $(TOP_DIR)emulator/libemulator.a
ifeq ($(HEADLESS),1)
CFLAGS += -DHEADLESS=1
else
CFLAGS += -DHEADLESS=0
CFLAGS += $(shell pkg-config --cflags sdl2)
LDLIBS += $(shell pkg-config --libs sdl2)
endif
ifdef RANDOM_DEV_FILE
CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\"

@ -19,14 +19,11 @@
#include "buttons.h"
#if !HEADLESS
#include <SDL.h>
#endif
uint16_t buttonRead(void) {
uint16_t state = 0;
#if !HEADLESS
const uint8_t *scancodes = SDL_GetKeyboardState(NULL);
if (scancodes[SDL_SCANCODE_LEFT]) {
state |= BTN_PIN_NO;
@ -34,7 +31,6 @@ uint16_t buttonRead(void) {
if (scancodes[SDL_SCANCODE_RIGHT]) {
state |= BTN_PIN_YES;
}
#endif
return ~state;
}

@ -19,14 +19,6 @@
#include "oled.h"
#if HEADLESS
void oledInit(void) {}
void oledRefresh(void) {}
void emulatorPoll(void) {}
#else
#include <SDL.h>
static SDL_Renderer *renderer = NULL;
@ -146,5 +138,3 @@ void emulatorPoll(void) {
}
}
}
#endif

Loading…
Cancel
Save