mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
core+legacy: drop NOUI and HEADLESS, SDL_VIDEODRIVER works fine
This commit is contained in:
parent
b69a9e768b
commit
f7d41cbbd7
@ -9,7 +9,8 @@ ENV TOOLCHAIN_FLAVOR=$TOOLCHAIN_FLAVOR
|
|||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
build-essential wget git libsodium-dev graphviz \
|
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
|
# install clang-format 6 from backports
|
||||||
RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list
|
RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list
|
||||||
|
22
ci/core.yml
22
ci/core.yml
@ -1,5 +1,9 @@
|
|||||||
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
|
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
|
||||||
|
|
||||||
|
variables:
|
||||||
|
SDL_VIDEODRIVER: "dummy"
|
||||||
|
XDG_RUNTIME_DIR: "/var/tmp"
|
||||||
|
|
||||||
build core firmware:
|
build core firmware:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
@ -21,24 +25,24 @@ build core unix:
|
|||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- cd core
|
- cd core
|
||||||
- pipenv run make build_unix_noui
|
- pipenv run make build_unix
|
||||||
artifacts:
|
|
||||||
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
|
|
||||||
untracked: true
|
|
||||||
expire_in: 1 day
|
|
||||||
|
|
||||||
build core unix frozen:
|
build core unix frozen:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- cd core
|
- 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:
|
test core unix unit:
|
||||||
stage: test
|
stage: test
|
||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
||||||
dependencies:
|
dependencies:
|
||||||
- build core unix
|
- build core unix frozen
|
||||||
script:
|
script:
|
||||||
- cd core
|
- cd core
|
||||||
- pipenv run make test
|
- pipenv run make test
|
||||||
@ -48,7 +52,7 @@ test core unix device:
|
|||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
||||||
dependencies:
|
dependencies:
|
||||||
- build core unix
|
- build core unix frozen
|
||||||
script:
|
script:
|
||||||
- cd core
|
- cd core
|
||||||
- pipenv run make test_emu
|
- pipenv run make test_emu
|
||||||
@ -58,7 +62,7 @@ test core unix monero:
|
|||||||
variables:
|
variables:
|
||||||
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
GIT_SUBMODULE_STRATEGY: none # no need to fetch submodules
|
||||||
dependencies:
|
dependencies:
|
||||||
- build core unix
|
- build core unix frozen
|
||||||
script:
|
script:
|
||||||
- cd core
|
- cd core
|
||||||
- pipenv run make test_emu_monero
|
- pipenv run make test_emu_monero
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
|
image: registry.corp.sldev.cz/trezor/trezor-firmware/environment
|
||||||
|
|
||||||
|
variables:
|
||||||
|
SDL_VIDEODRIVER: "dummy"
|
||||||
|
XDG_RUNTIME_DIR: "/var/tmp"
|
||||||
|
|
||||||
build legacy firmware:
|
build legacy firmware:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
@ -31,9 +35,8 @@ build legacy firmware bitcoinonly:
|
|||||||
build legacy emu:
|
build legacy emu:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
HEADLESS: "1"
|
|
||||||
EMULATOR: "1"
|
|
||||||
DEBUG_LINK: "1"
|
DEBUG_LINK: "1"
|
||||||
|
EMULATOR: "1"
|
||||||
script:
|
script:
|
||||||
- cd legacy
|
- cd legacy
|
||||||
- pipenv run script/cibuild
|
- pipenv run script/cibuild
|
||||||
@ -53,4 +56,4 @@ test legacy emu:
|
|||||||
EMULATOR: "1"
|
EMULATOR: "1"
|
||||||
script:
|
script:
|
||||||
- cd legacy
|
- 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
|
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
|
$(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
|
build_unix_raspi: res ## build unix port for Raspberry Pi
|
||||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1
|
$(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/modtrezorui.c',
|
||||||
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.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):
|
if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0):
|
||||||
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
|
||||||
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
|
if ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0):
|
||||||
@ -341,8 +339,7 @@ env.Replace(
|
|||||||
] + CPPDEFINES_MOD,
|
] + CPPDEFINES_MOD,
|
||||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
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(
|
env.Replace(
|
||||||
PYTHON='python',
|
PYTHON='python',
|
||||||
|
@ -9,7 +9,7 @@ RUN apt-get update
|
|||||||
RUN apt-get install libusb-1.0-0
|
RUN apt-get install libusb-1.0-0
|
||||||
|
|
||||||
RUN pip3 install scons trezor
|
RUN pip3 install scons trezor
|
||||||
RUN make build_unix_noui
|
RUN make build_unix
|
||||||
|
|
||||||
ENTRYPOINT ["emulator/run.sh"]
|
ENTRYPOINT ["emulator/run.sh"]
|
||||||
EXPOSE 21324/udp 21325
|
EXPOSE 21324/udp 21325
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
export SDL_VIDEODRIVER=dummy
|
||||||
export TREZOR_UDP_IP=0.0.0.0
|
export TREZOR_UDP_IP=0.0.0.0
|
||||||
|
|
||||||
source emu.sh
|
source emu.sh
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define EMULATOR_BORDER 16
|
#define EMULATOR_BORDER 16
|
||||||
|
|
||||||
@ -90,12 +89,8 @@ void PIXELDATA(uint16_t c) {
|
|||||||
PIXELWINDOW.pos.y++;
|
PIXELWINDOW.pos.y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define PIXELDATA(X) (void)(X)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void display_init(void) {
|
void display_init(void) {
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
printf("%s\n", SDL_GetError());
|
printf("%s\n", SDL_GetError());
|
||||||
ensure(secfalse, "SDL_Init error");
|
ensure(secfalse, "SDL_Init error");
|
||||||
@ -166,12 +161,10 @@ void display_init(void) {
|
|||||||
#else
|
#else
|
||||||
DISPLAY_ORIENTATION = 0;
|
DISPLAY_ORIENTATION = 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
|
static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
|
||||||
uint16_t y1) {
|
uint16_t y1) {
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
if (!RENDERER) {
|
if (!RENDERER) {
|
||||||
display_init();
|
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.end.y = y1;
|
||||||
PIXELWINDOW.pos.x = x0;
|
PIXELWINDOW.pos.x = x0;
|
||||||
PIXELWINDOW.pos.y = y0;
|
PIXELWINDOW.pos.y = y0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_refresh(void) {
|
void display_refresh(void) {
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
if (!RENDERER) {
|
if (!RENDERER) {
|
||||||
display_init();
|
display_init();
|
||||||
}
|
}
|
||||||
@ -208,7 +199,6 @@ void display_refresh(void) {
|
|||||||
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
|
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
|
||||||
}
|
}
|
||||||
SDL_RenderPresent(RENDERER);
|
SDL_RenderPresent(RENDERER);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_set_orientation(int degrees) { display_refresh(); }
|
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(); }
|
static void display_set_backlight(int val) { display_refresh(); }
|
||||||
|
|
||||||
const char *display_save(const char *prefix) {
|
const char *display_save(const char *prefix) {
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
if (!RENDERER) {
|
if (!RENDERER) {
|
||||||
display_init();
|
display_init();
|
||||||
}
|
}
|
||||||
@ -243,6 +232,4 @@ const char *display_save(const char *prefix) {
|
|||||||
IMG_SavePNG(crop, filename);
|
IMG_SavePNG(crop, filename);
|
||||||
prev = crop;
|
prev = crop;
|
||||||
return filename;
|
return filename;
|
||||||
#endif
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#endif
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
@ -31,7 +29,6 @@ extern void __shutdown(void);
|
|||||||
extern const char *display_save(const char *prefix);
|
extern const char *display_save(const char *prefix);
|
||||||
|
|
||||||
uint32_t touch_read(void) {
|
uint32_t touch_read(void) {
|
||||||
#ifndef TREZOR_EMULATOR_NOUI
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
if (SDL_PollEvent(&event) > 0) {
|
if (SDL_PollEvent(&event) > 0) {
|
||||||
@ -113,6 +110,5 @@ uint32_t touch_read(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,8 @@ LDFLAGS += -L$(TOP_DIR)emulator
|
|||||||
LDLIBS += -ltrezor -lemulator
|
LDLIBS += -ltrezor -lemulator
|
||||||
LIBDEPS += $(TOP_DIR)/libtrezor.a $(TOP_DIR)emulator/libemulator.a
|
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)
|
CFLAGS += $(shell pkg-config --cflags sdl2)
|
||||||
LDLIBS += $(shell pkg-config --libs sdl2)
|
LDLIBS += $(shell pkg-config --libs sdl2)
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef RANDOM_DEV_FILE
|
ifdef RANDOM_DEV_FILE
|
||||||
CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\"
|
CFLAGS += -DRANDOM_DEV_FILE=\"$(RANDOM_DEV_FILE)\"
|
||||||
|
@ -19,14 +19,11 @@
|
|||||||
|
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
|
|
||||||
#if !HEADLESS
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t buttonRead(void) {
|
uint16_t buttonRead(void) {
|
||||||
uint16_t state = 0;
|
uint16_t state = 0;
|
||||||
|
|
||||||
#if !HEADLESS
|
|
||||||
const uint8_t *scancodes = SDL_GetKeyboardState(NULL);
|
const uint8_t *scancodes = SDL_GetKeyboardState(NULL);
|
||||||
if (scancodes[SDL_SCANCODE_LEFT]) {
|
if (scancodes[SDL_SCANCODE_LEFT]) {
|
||||||
state |= BTN_PIN_NO;
|
state |= BTN_PIN_NO;
|
||||||
@ -34,7 +31,6 @@ uint16_t buttonRead(void) {
|
|||||||
if (scancodes[SDL_SCANCODE_RIGHT]) {
|
if (scancodes[SDL_SCANCODE_RIGHT]) {
|
||||||
state |= BTN_PIN_YES;
|
state |= BTN_PIN_YES;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return ~state;
|
return ~state;
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,6 @@
|
|||||||
|
|
||||||
#include "oled.h"
|
#include "oled.h"
|
||||||
|
|
||||||
#if HEADLESS
|
|
||||||
|
|
||||||
void oledInit(void) {}
|
|
||||||
void oledRefresh(void) {}
|
|
||||||
void emulatorPoll(void) {}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
static SDL_Renderer *renderer = NULL;
|
static SDL_Renderer *renderer = NULL;
|
||||||
@ -146,5 +138,3 @@ void emulatorPoll(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user