This repository has been archived by the owner on Apr 16, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 257
Emulator support #268
Merged
Merged
Emulator support #268
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ce651e2
Makefile.include: Use LDLIBS & LIBDEPS
saleemrashid f447837
emulator: Initial commit
saleemrashid 157f70f
emulator: Add EMULATOR=1 to emulator/Makefile
saleemrashid 89a21a9
emulator: Show DEBUG_LINK indicator
saleemrashid 4e1044f
script: Add Scripts To Rule Them All
saleemrashid 5efe6ff
Travis CI: Run tests on emulator
saleemrashid 1e364e3
Travis CI: Fix InsecurePlatformWarning
saleemrashid e4ca9f0
script: Do not start emulator if running
saleemrashid 07a5c2c
README: Use Markdown syntax for links
saleemrashid 4db3b05
README: Add development instructions
saleemrashid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ build/ | |
*.bin | ||
*.elf | ||
*.hex | ||
*.img | ||
*.list | ||
*.srec | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
EMULATOR := 1 | ||
|
||
OBJS += setup.o | ||
|
||
OBJS += buttons.o | ||
OBJS += flash.o | ||
OBJS += oled.o | ||
OBJS += rng.o | ||
OBJS += timer.o | ||
OBJS += udp.o | ||
|
||
OBJS += strl.o | ||
|
||
libemulator.a: $(OBJS) | ||
$(AR) rcs $@ $(OBJS) | ||
|
||
include ../Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This file is part of the TREZOR project, https://trezor.io/ | ||
* | ||
* Copyright (C) 2017 Saleem Rashid <[email protected]> | ||
* | ||
* This library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#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; | ||
} | ||
if (scancodes[SDL_SCANCODE_RIGHT]) { | ||
state |= BTN_PIN_YES; | ||
} | ||
#endif | ||
|
||
return ~state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This file is part of the TREZOR project, https://trezor.io/ | ||
* | ||
* Copyright (C) 2017 Saleem Rashid <[email protected]> | ||
* | ||
* This library is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef __EMULATOR_H__ | ||
#define __EMULATOR_H__ | ||
|
||
#if EMULATOR | ||
|
||
#include "strl.h" | ||
|
||
#include <stddef.h> | ||
|
||
extern void *emulator_flash_base; | ||
|
||
void emulatorPoll(void); | ||
void emulatorRandom(void *buffer, size_t size); | ||
|
||
void emulatorSocketInit(void); | ||
size_t emulatorSocketRead(void *buffer, size_t size); | ||
size_t emulatorSocketWrite(const void *buffer, size_t size); | ||
|
||
#endif | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python-trezor contains
--disable-hidapi
option insetup.py
, maybe we can try using pip install with--install-option
- I remember I was trying to use the same trick for trezor-core, but I failed, thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prusnak I tried that at least 5 different ways and gave up. 😆
pip
will not pass provided options to./setup.py egg_info
which is what it uses to gather dependencies.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, glad to know I am the only one who failed on this. Thanks :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prusnak There is an issue here but I don't imagine it will be fixed pypa/pip#4383