Now it builds the image.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
023039deb2
commit
49f05e9e13
13 changed files with 38 additions and 64 deletions
|
|
@ -86,6 +86,8 @@ endif(USB_ITF_CCID)
|
|||
add_definitions(-DDEBUG_APDU=${DEBUG_APDU})
|
||||
if (NOT ESP_PLATFORM)
|
||||
add_definitions(-DMBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/config/mbedtls_config.h")
|
||||
else()
|
||||
add_definitions(-DCFG_TUSB_CONFIG_FILE="../../src/usb/tusb_config.h")
|
||||
endif()
|
||||
|
||||
message(STATUS "USB VID/PID: ${USB_VID}:${USB_PID}")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
|
||||
#
|
||||
IGNORE_UNKNOWN_FILES_FOR_MANAGED_COMPONENTS=1
|
||||
|
||||
CONFIG_TINYUSB=y
|
||||
CONFIG_TINYUSB_MSC_ENABLED=y
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
|
|
@ -11,6 +12,9 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
|||
CONFIG_WL_SECTOR_SIZE_512=y
|
||||
CONFIG_WL_SECTOR_MODE_PERF=y
|
||||
|
||||
CONFIG_TINYUSB_CDC_ENABLED=y
|
||||
CONFIG_TINYUSB_VENDOR_ENABLED=y
|
||||
CONFIG_TINYUSB_VENDOR_COUNT=2
|
||||
CONFIG_TINYUSB_HID_ENABLED=y
|
||||
CONFIG_TINYUSB_HID_COUNT=2
|
||||
# CONFIG_TINYUSB_DESC_USE_DEFAULT_PID is not set
|
||||
CONFIG_TINYUSB_DESC_CUSTOM_PID=0x4001
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
idf_component_register(
|
||||
SRCS ${INTERNAL_SOURCES}
|
||||
INCLUDE_DIRS . fs rng usb
|
||||
PRIV_REQUIRES bootloader_support esp_partition
|
||||
INCLUDE_DIRS . fs rng usb ../mbedtls/include
|
||||
REQUIRES bootloader_support esp_partition tinyusb
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ENABLE_EMULATION
|
||||
#if defined(ENABLE_EMULATION)
|
||||
#elif defined(ESP_PLATFORM)
|
||||
#include "esp_compat.h"
|
||||
#else
|
||||
#include <pico/unique_id.h>
|
||||
#endif
|
||||
#include "mbedtls/md.h"
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@
|
|||
#ifndef _CRYPTO_UTILS_H_
|
||||
#define _CRYPTO_UTILS_H_
|
||||
|
||||
#include "stdlib.h"
|
||||
#ifndef ENABLE_EMULATION
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/md.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@
|
|||
#ifndef _EAC_H_
|
||||
#define _EAC_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifndef ENABLE_EMULATION
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
#include "pico_keys.h"
|
||||
|
||||
typedef enum MSE_protocol {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@
|
|||
#include "mman.h"
|
||||
#else
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_compat.h"
|
||||
esp_partition_t part0;
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp_tinyusb: "^1.2"
|
||||
idf: "^5.0"
|
||||
espressif/tinyusb: "^0.15.0"
|
||||
|
|
|
|||
38
src/main.c
38
src/main.c
|
|
@ -25,28 +25,11 @@
|
|||
#endif
|
||||
#include "emulation.h"
|
||||
#elif defined(ESP_PLATFORM)
|
||||
#include "tusb.h"
|
||||
#else
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
|
||||
// For memcpy
|
||||
#include <string.h>
|
||||
|
||||
#ifndef ENABLE_EMULATION
|
||||
// Include descriptor struct definitions
|
||||
//#include "usb_common.h"
|
||||
// USB register definitions from pico-sdk
|
||||
#include "hardware/regs/usb.h"
|
||||
// USB hardware struct definitions from pico-sdk
|
||||
#include "hardware/structs/usb.h"
|
||||
// For interrupt enable and numbers
|
||||
#include "hardware/irq.h"
|
||||
// For resetting the USB controller
|
||||
#include "hardware/resets.h"
|
||||
|
||||
#include "pico/multicore.h"
|
||||
#endif
|
||||
|
||||
#include "random.h"
|
||||
#include "pico_keys.h"
|
||||
#include "apdu.h"
|
||||
|
|
@ -101,11 +84,14 @@ static inline void ws2812_program_init(PIO pio,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_EMULATION
|
||||
#if defined(ENABLE_EMULATION)
|
||||
#else
|
||||
#include "usb.h"
|
||||
#ifndef ESP_PLATFORM
|
||||
#include "hardware/rtc.h"
|
||||
#include "bsp/board.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern void do_flash();
|
||||
extern void low_flash_init();
|
||||
|
|
@ -196,6 +182,11 @@ uint32_t board_millis() {
|
|||
}
|
||||
|
||||
#else
|
||||
#ifdef ESP_PLATFORM
|
||||
bool board_button_read() {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
bool button_pressed_state = false;
|
||||
uint32_t button_pressed_time = 0;
|
||||
uint8_t button_press = 0;
|
||||
|
|
@ -289,7 +280,9 @@ void led_off_all() {
|
|||
}
|
||||
|
||||
void init_rtc() {
|
||||
#ifndef ENABLE_EMULATION
|
||||
#if defined(ENABLE_EMULATION)
|
||||
#elif defined(ESP_PLATFORM)
|
||||
#else
|
||||
rtc_init();
|
||||
datetime_t dt = {
|
||||
.year = 2020,
|
||||
|
|
@ -345,15 +338,16 @@ void core0_loop() {
|
|||
|
||||
#ifdef ESP_PLATFORM
|
||||
TaskHandle_t hcore0 = NULL, hcore1 = NULL;
|
||||
void app_main(void) {
|
||||
int app_main() {
|
||||
#else
|
||||
int main(void) {
|
||||
#endif
|
||||
#ifndef ENABLE_EMULATION
|
||||
usb_init();
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
board_init();
|
||||
stdio_init_all();
|
||||
#endif
|
||||
|
||||
#ifdef PIMORONI_TINY2040
|
||||
gpio_init(TINY2040_LED_R_PIN);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#ifndef ENABLE_EMULATION
|
||||
#include "pico/stdlib.h"
|
||||
#endif
|
||||
|
||||
void random_init(void);
|
||||
void random_fini(void);
|
||||
|
|
|
|||
|
|
@ -15,28 +15,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Pico
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
// For memcpy
|
||||
#include <string.h>
|
||||
|
||||
// Include descriptor struct definitions
|
||||
//#include "usb_common.h"
|
||||
// USB register definitions from pico-sdk
|
||||
#include "hardware/regs/usb.h"
|
||||
// USB hardware struct definitions from pico-sdk
|
||||
#include "hardware/structs/usb.h"
|
||||
// For interrupt enable and numbers
|
||||
#include "hardware/irq.h"
|
||||
// For resetting the USB controller
|
||||
#include "hardware/resets.h"
|
||||
|
||||
#include "random.h"
|
||||
#include "pico_keys.h"
|
||||
#if !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
|
||||
#include "hardware/rtc.h"
|
||||
#endif
|
||||
#include "tusb.h"
|
||||
#include "ccid.h"
|
||||
#include "device/usbd_pvt.h"
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@
|
|||
#ifndef _TUSB_CONFIG_H_
|
||||
#define _TUSB_CONFIG_H_
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -64,7 +62,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef CFG_TUSB_OS
|
||||
//#define CFG_TUSB_OS OPT_OS_PICO
|
||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUSB_DEBUG
|
||||
|
|
@ -115,7 +113,7 @@ extern "C" {
|
|||
#ifdef USB_ITF_CCID
|
||||
#define CFG_TUD_VENDOR 2
|
||||
#else
|
||||
#define CFG_TUD_VENDOR 0
|
||||
#define CFG_TUD_VENDOR 2
|
||||
#endif
|
||||
|
||||
// HID buffer size Should be sufficient to hold ID (if any) + Data
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ void usb_clear_rx(uint8_t itf) {
|
|||
|
||||
#define USB_BCD 0x0200
|
||||
|
||||
#if !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
|
||||
#if !defined(ENABLE_EMULATION)
|
||||
queue_t usb_to_card_q;
|
||||
queue_t card_to_usb_q;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue