Remove carriage return \r for better debug.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-04-10 18:16:38 +02:00
parent 6adfe4344f
commit 7def35f87c
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
8 changed files with 25 additions and 29 deletions

View file

@ -124,9 +124,9 @@ uint16_t apdu_process(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size)
}
}
}
//printf("apdu.nc %ld, apdu.ne %ld\r\n",apdu.nc,apdu.ne);
//printf("apdu.nc %ld, apdu.ne %ld\n",apdu.nc,apdu.ne);
if (apdu.header[1] == 0xc0) {
//printf("apdu.ne %u, apdu.rlen %d, bk %x\r\n",apdu.ne,apdu.rlen,rdata_bk);
//printf("apdu.ne %u, apdu.rlen %d, bk %x\n",apdu.ne,apdu.rlen,rdata_bk);
timeout_stop();
*(uint16_t *) rdata_gr = rdata_bk;
if (apdu.rlen <= apdu.ne) {
@ -225,7 +225,7 @@ done: ;
vTaskDelay(pdMS_TO_TICKS(10));
#endif
}
//printf("EXIT !!!!!!\r\n");
//printf("EXIT !!!!!!\n");
if (current_app && current_app->unload) {
current_app->unload();
current_app = NULL;

View file

@ -43,7 +43,7 @@ typedef struct cmd {
#if defined(DEBUG_APDU) && DEBUG_APDU == 1
#define DEBUG_PAYLOAD(_p, _s) { \
printf("Payload %s (%d bytes):\r\n", #_p, (int) (_s)); \
printf("Payload %s (%d bytes):\n", #_p, (int) (_s)); \
for (int _i = 0; _i < _s; _i += 16) { \
printf("%" PRIxPTR "h : ", (uintptr_t) (_i + _p)); \
for (int _j = 0; _j < 16; _j++) { \
@ -56,12 +56,12 @@ typedef struct cmd {
else printf(" "); \
if (_j == 7) printf(" "); \
} \
printf("\r\n"); \
} printf("\r\n"); \
printf("\n"); \
} printf("\n"); \
}
#define DEBUG_DATA(_p, _s) \
{ \
printf("Data %s (%d bytes):\r\n", #_p, (int) (_s)); \
printf("Data %s (%d bytes):\n", #_p, (int) (_s)); \
char *tmp = (char *) calloc(1, 2 * _s + 1); \
for (int _i = 0; _i < _s; _i++) \
{ \

View file

@ -58,11 +58,7 @@ static inline bool multicore_lockout_start_timeout_us(int a) {
vTaskSuspend(hcore1); return true; }
static inline bool multicore_lockout_end_timeout_us(int a) {
vTaskResume(hcore1); return true; }
#define save_and_disable_interrupts() 1
#define flash_range_erase(a,b) esp_partition_erase_range(part0, a, b)
#define flash_range_program(a,b,c) esp_partition_write(part0, a, b, c)
#define restore_interrupts(a) (void)a
#endif
#endif

View file

@ -247,7 +247,7 @@ void scan_region(bool persistent) {
}
uint16_t fid = flash_read_uint16(base + sizeof(uintptr_t) + sizeof(uintptr_t));
printf("[%x] scan fid %x, len %d\r\n", (unsigned int) base, fid,
printf("[%x] scan fid %x, len %d\n", (unsigned int) base, fid,
flash_read_uint16(base + sizeof(uintptr_t) + sizeof(uintptr_t) + sizeof(uint16_t)));
file_t *file = (file_t *) search_by_fid(fid, NULL, SPECIFY_EF);
if (!file) {
@ -267,7 +267,7 @@ void scan_flash() {
initialize_flash(false); //soft initialization
if (*(uintptr_t *) flash_read(end_rom_pool) == 0xffffffff &&
*(uintptr_t *) flash_read(end_rom_pool + sizeof(uintptr_t)) == 0xffffffff) {
printf("First initialization (or corrupted!)\r\n");
printf("First initialization (or corrupted!)\n");
uint8_t empty[sizeof(uintptr_t) * 2 + sizeof(uint32_t)];
memset(empty, 0, sizeof(empty));
flash_program_block(end_data_pool, empty, sizeof(empty));
@ -275,7 +275,7 @@ void scan_flash() {
//low_flash_available();
//wait_flash_finish();
}
printf("SCAN\r\n");
printf("SCAN\n");
scan_region(true);
scan_region(false);
}

View file

@ -83,8 +83,8 @@ uintptr_t allocate_free_addr(uint16_t size, bool persistent) {
uintptr_t addr_alg = base & -FLASH_SECTOR_SIZE; //start address of sector
uintptr_t potential_addr = base - real_size;
next_base = flash_read_uintptr(base);
//printf("nb %x %x %x %x\r\n",base,next_base,addr_alg,potential_addr);
//printf("fid %x\r\n",flash_read_uint16(next_base+sizeof(uintptr_t)));
//printf("nb %x %x %x %x\n",base,next_base,addr_alg,potential_addr);
//printf("fid %x\n",flash_read_uint16(next_base+sizeof(uintptr_t)));
if (next_base == 0x0) { //we are at the end
//now we check if we fit in the current sector
if (addr_alg <= potential_addr) { //it fits in the current sector
@ -129,7 +129,7 @@ int flash_clear_file(file_t *file) {
(uintptr_t)(file->data - sizeof(uintptr_t) - sizeof(uint16_t) - sizeof(uintptr_t));
uintptr_t prev_addr = flash_read_uintptr(base_addr + sizeof(uintptr_t));
uintptr_t next_addr = flash_read_uintptr(base_addr);
//printf("nc %lx->%lx %lx->%lx\r\n",prev_addr,flash_read_uintptr(prev_addr),base_addr,next_addr);
//printf("nc %lx->%lx %lx->%lx\n",prev_addr,flash_read_uintptr(prev_addr),base_addr,next_addr);
flash_program_uintptr(prev_addr, next_addr);
flash_program_halfword((uintptr_t) file->data, 0);
if (next_addr > 0) {
@ -138,7 +138,7 @@ int flash_clear_file(file_t *file) {
flash_program_uintptr(base_addr, 0);
flash_program_uintptr(base_addr + sizeof(uintptr_t), 0);
file->data = NULL;
//printf("na %lx->%lx\r\n",prev_addr,flash_read_uintptr(prev_addr));
//printf("na %lx->%lx\n",prev_addr,flash_read_uintptr(prev_addr));
return CCID_OK;
}
@ -173,7 +173,7 @@ int flash_write_data_to_file_offset(file_t *file, const uint8_t *data, uint16_t
}
uintptr_t new_addr = allocate_free_addr(len, (file->type & FILE_PERSISTENT) == FILE_PERSISTENT);
//printf("na %x\r\n",new_addr);
//printf("na %x\n",new_addr);
if (new_addr == 0x0) {
return CCID_ERR_NO_MEMORY;
}

View file

@ -140,7 +140,7 @@ int driver_process_usb_nopacket_ccid() {
int driver_process_usb_packet_ccid(uint8_t itf, uint16_t rx_read) {
if (rx_read >= 10) {
driver_init_ccid(itf);
//printf("%ld %d %x %x\r\n",ccid_header->dwLength,rx_read-10,ccid_header->bMessageType,ccid_header->bSeq);
//printf("%ld %d %x %x\n",ccid_header->dwLength,rx_read-10,ccid_header->bMessageType,ccid_header->bSeq);
if (ccid_header[itf]->dwLength <= rx_read - 10) {
size_t apdu_sent = 0;
if (ccid_header[itf]->bMessageType != CCID_SLOT_STATUS) {
@ -163,7 +163,7 @@ int driver_process_usb_packet_ccid(uint8_t itf, uint16_t rx_read) {
ccid_response[itf]->bSeq = ccid_header[itf]->bSeq;
ccid_response[itf]->abRFU0 = 0;
ccid_response[itf]->abRFU1 = 0;
//printf("1 %x %x %x || %x %x %x\r\n",ccid_response->apdu,apdu.rdata,ccid_response,ccid_header,ccid_header->apdu,apdu.data);
//printf("1 %x %x %x || %x %x %x\n",ccid_response->apdu,apdu.rdata,ccid_response,ccid_header,ccid_header->apdu,apdu.data);
memcpy(&ccid_response[itf]->apdu, ccid_atr + 1, size_atr);
if (ccid_status == 1) {
card_start(apdu_thread);
@ -267,19 +267,19 @@ uint8_t *driver_prepare_response_ccid(uint8_t itf) {
#define MAX_USB_POWER 1
static void ccid_init_cb(void) {
TU_LOG1("-------- CCID INIT\r\n");
TU_LOG1("-------- CCID INIT\n");
vendord_init();
}
static void ccid_reset_cb(uint8_t rhport) {
TU_LOG1("-------- CCID RESET\r\n");
TU_LOG1("-------- CCID RESET\n");
itf_num = 0;
vendord_reset(rhport);
}
static uint16_t ccid_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len) {
uint8_t *itf_vendor = (uint8_t *) malloc(sizeof(uint8_t) * max_len);
//TU_LOG1("-------- CCID OPEN\r\n");
//TU_LOG1("-------- CCID OPEN\n");
TU_VERIFY(
itf_desc->bInterfaceClass == TUSB_CLASS_SMART_CARD && itf_desc->bInterfaceSubClass == 0 && itf_desc->bInterfaceProtocol == 0,
0);
@ -310,13 +310,13 @@ static bool ccid_control_xfer_cb(uint8_t __unused rhport,
uint8_t stage,
tusb_control_request_t const *request) {
// nothing to do with DATA & ACK stage
TU_LOG2("-------- CCID CTRL XFER\r\n");
TU_LOG2("-------- CCID CTRL XFER\n");
if (stage != CONTROL_STAGE_SETUP) {
return true;
}
if (request->wIndex == itf_num) {
TU_LOG2("-------- bmRequestType %x, bRequest %x, wValue %x, wLength %x\r\n",
TU_LOG2("-------- bmRequestType %x, bRequest %x, wValue %x, wLength %x\n",
request->bmRequestType,
request->bRequest,
request->wValue,
@ -354,7 +354,7 @@ static bool ccid_xfer_cb(uint8_t rhport,
uint8_t ep_addr,
xfer_result_t result,
uint32_t xferred_bytes) {
//printf("------ CALLED XFER_CB\r\n");
//printf("------ CALLED XFER_CB\n");
return vendord_xfer_cb(rhport, ep_addr, result, xferred_bytes);
//return true;
}

View file

@ -283,7 +283,7 @@ void usb_task() {
uint32_t m = 0x0;
bool has_m = queue_try_remove(&card_to_usb_q, &m);
//if (m != 0)
// printf("\r\n ------ M = %lu\r\n",m);
// printf("\n ------ M = %lu\n",m);
if (has_m) {
if (m == EV_EXEC_FINISHED) {
timeout_stop();

View file

@ -331,7 +331,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
if (request->bRequest == 0x22) {
web_serial_connected = (request->wValue != 0);
if (web_serial_connected) {
printf("\r\nWebUSB interface connected\r\n");
printf("\nWebUSB interface connected\n");
}
return tud_control_status(rhport, request);
}