root@Teensy:/128GEXFAT>ld
Found 2 logical drives.
Logical Drive Information For Attached Drives
Logical Drive #: 4: | Volume Label: 128GEXFAT | valid: 1 | Drive Type: USB
Logical Drive #: 5: | Volume Label: CIRCUITPY | valid: 1 | Drive Type: USB
2 Logical Drives Found
Default Logical Drive: /128GEXFAT/ (4:)
root@Teensy:/128GEXFAT>ls /CIRCUITPY/
Volume Label: CIRCUITPY
Full Path: /CIRCUITPY/
.fseventsd/ <DIR>
lib/ <DIR>
.metadata_never_index 0 January 01 2098 00:00:00
.Trashes 0 January 01 2098 00:00:00
code.py 22 March 26 2022 08:05:30
boot_out.txt 95 March 24 2022 19:19:12
Free Space: 0
root@Teensy:/128GEXFAT>ls 5:
Volume Label: CIRCUITPY
Full Path: 5:
.fseventsd/ <DIR>
lib/ <DIR>
.metadata_never_index 0 January 01 2098 00:00:00
.Trashes 0 January 01 2098 00:00:00
code.py 22 March 26 2022 08:05:30
boot_out.txt 95 March 24 2022 19:19:12
Free Space: 0
root@Teensy:/128GEXFAT>cat /CIRCUITPY/code.py
print("Hello World!")
root@Teensy:/128GEXFAT>
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
loop_count = 0
while True:
led.value = True
time.sleep(0.2)
led.value = False
time.sleep(0.2)
led.value = True
time.sleep(0.2)
led.value = False
time.sleep(0.2)
led.value = True
time.sleep(0.2)
led.value = False
time.sleep(0.8)
loop_count += 1
if (loop_count & 0x1F) == 0:
print(loop_count)
I did some more hacking on my sketch:
and if you in the terminal monitor type lines starting with $ the rest of the line is sent to the userial object which in this case is the circuit python serial connection.
I have not yet changed the python file to read this in, but another part of the hack is any remaining $ followed by a character in the line are converted to ctrl+char.
So typing: $$c
will enter into REPL mode.
If after that you type $$d - it will do soft reset to run the new python.
My updated python is nothing special:
The last change went from double blink to triple blinkCode:import board import digitalio import time led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT loop_count = 0 while True: led.value = True time.sleep(0.2) led.value = False time.sleep(0.2) led.value = True time.sleep(0.2) led.value = False time.sleep(0.2) led.value = True time.sleep(0.2) led.value = False time.sleep(0.8) loop_count += 1 if (loop_count & 0x1F) == 0: print(loop_count)
With MTP I could not directly edit the file and update directly... Once of the advantages of MSC, where it is an FS object.
But what I have done is to copy the file down using the MTP (i.e. copy it from mtp window to another window... Then edit that file...
Then drag and drop it back into the MTP window, which will ask if you wish to overwrite... Say yes.
teensy41.menu.usb.mtpserial=MTP Disk Serial (Experimental)
teensy41.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
teensy41.menu.usb.mtpdserial=MTP Disk Dual Serial (Experimental)
teensy41.menu.usb.mtpdserial.build.usbtype=USB_MTPDISK_DUAL_SERIAL
teensyMM.menu.usb.mtpserial=MTP Disk Serial (Experimental)
teensyMM.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
teensyMM.menu.usb.mtpdserial=MTP Disk Dual Serial (Experimental)
teensyMM.menu.usb.mtpdserial.build.usbtype=USB_MTPDISK_DUAL_SERIAL
teensy40.menu.usb.mtpserial=MTP Disk Serial (Experimental)
teensy40.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
teensy40.menu.usb.mtpdserial=MTP Disk Dual Serial (Experimental)
teensy40.menu.usb.mtpdserial.build.usbtype=USB_MTPDISK_DUAL_SERIAL
teensy36.menu.usb.mtpserial=MTP Disk SERIAL (Experimental)
teensy36.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
teensy35.menu.usb.mtpserial=MTP Disk SERIAL (Experimental)
teensy35.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
teensy31.menu.usb.mtpserial=MTP Disk SERIAL (Experimental)
teensy31.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
#if defined(USB_MTPDISK_DUAL_SERIAL)
if (userial && userial.available()) {
while (userial.available()) SerialUSB1.write(userial.read());
}
if (SerialUSB1.available()) {
for (;;) {
int ch = SerialUSB1.read();
if (ch == -1) break;
if (userial)userial.write(ch);
//Serial.println(ch, HEX);
}
}
#else
if (userial && userial.available()) {
Serial.print("$$USerial:");
while (userial.available()) Serial.write(userial.read());
}
#endif
typedef struct panels panels_t;
struct panels {
char **fname = NULL;
uint32_t *size = NULL;
bool *attr = NULL;
bool *tag = NULL;
int entries;
uint16_t index;
uint16_t offset;
uint8_t curDrvNum = 4;
char *drv;
char *path;
bool tagFlag = false;
};
int allocDirMem(panels_t *panel) {
int i = 0;
File dEntry;
#ifdef sortDirectories
char buf[256];
#endif
if(panel->entries != 0) {
panelFree(panel);
}
panel->entries = getDirEntryCnt(panel->path);
if(panel->entries < 0) return -1;
dioIM.openDir(panel->path); // Open the directory
panel->fname = (char **)malloc(panel->entries*sizeof(char *)); // array of string pointers
panel->size = (uint32_t *)malloc(panel->entries * sizeof(uint32_t));
panel->attr = (bool *)malloc(panel->entries * sizeof(bool));
panel->tag = (bool *)malloc(panel->entries * sizeof(bool));
for(i = 0; i <= panel->entries; i++) {
if(i == 0) {
panel->fname = (char **)realloc(panel->fname,(i+1)*sizeof(char *));
panel->size = (uint32_t *)realloc(panel->size,(i+1)*sizeof(uint32_t));
panel->attr = (bool *)realloc(panel->attr,(i+1)*sizeof(bool));
panel->tag = (bool *)realloc(panel->tag,(i+1)*sizeof(bool));
if(panel->path[0] == '\0')
panel->fname[0] = strdup("~");
else
panel->fname[0] = strdup("/..");
panel->size[0] = 0;
panel->attr[0] = 0;
panel->tag[0] = false;
} else {
panel->fname = (char **)realloc(panel->fname,(i+1)*sizeof(char *));
panel->size = (uint32_t *)realloc(panel->size,(i+1)*sizeof(uint32_t));
panel->attr = (bool *)realloc(panel->attr,(i+1)*sizeof(bool));
panel->tag = (bool *)realloc(panel->tag,(i+1)*sizeof(bool));
dioIM.readDir(&dEntry, nameBuf); // Read a directory item.
sprintf(STMP, "/%s", dEntry.name()); // Add foward slash.
panel->fname[i] = strdup(STMP);
#ifndef sortDirectories
panel->size[i] = dEntry.size();
panel->attr[i] = dEntry.isDirectory();
#endif
panel->tag[i] = false;
}
}
dioIM.closeDir(&dEntry);
// Sort directory and read in file sizes and attribute.
#ifdef sortDirectories
if(panel->entries > 0)
qsort(panel->fname+1, panel->entries, sizeof(char *), fnameCmp);
for(i = 1; i <= panel->entries; i++) {
sprintf(buf,"%s%s%s",panel->drv,panel->path,panel->fname[i]);
if(!dioIM.open(&dEntry, buf, FILE_READ))
printf("Failed to open %s\n",panel->fname[i]);
panel->size[i] = dEntry.size();
panel->attr[i] = dEntry.isDirectory();
dioIM.close(&dEntry);
}
#endif
return 0;
}
// qsort struct compare function (directory fname field only) */
int fnameCmp(const void *a, const void *b)
{
char * ppc1 = *(char **)a;
char * ppc2 = *(char **)b;
return strcmp(ppc1, ppc2);
}
for(i = 1; i <= panel->entries; i++) {
sprintf(buf,"%s%s%s",panel->drv,panel->path,panel->fname[i]);
if(!dioIM.open(&dEntry, buf, FILE_READ))
printf("Failed to open %s\n",panel->fname[i]);
panel->size[i] = dEntry.size();
panel->attr[i] = dEntry.isDirectory();
dioIM.close(&dEntry);
}
Memory Usage on Teensy MicroMod:
FLASH: code:83252, data:14412, headers:8828 free for files:16408580
RAM1: variables:16544, code:81544, padding:16760 free for local variables:409440
RAM2: variables:28800 free for malloc/new:495488
Multiple libraries were found for "SD.h"
Used: C:\Users\kurte\Documents\Arduino\libraries\SD
Not used: C:\arduino-1.8.19\libraries\SD
Not used: C:\arduino-1.8.19\hardware\teensy\avr\libraries\SD
Multiple libraries were found for "SdFat.h"
Used: C:\Users\kurte\Documents\Arduino\libraries\SdFat
Not used: C:\arduino-1.8.19\hardware\teensy\avr\libraries\SdFat
Using library SD at version 2.0.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\SD
Using library SdFat at version 2.1.2 in folder: C:\Users\kurte\Documents\Arduino\libraries\SdFat
Using library SPI at version 1.0 in folder: C:\arduino-1.8.19\hardware\teensy\avr\libraries\SPI
Using library MTP_Teensy at version 1.0.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\MTP_Teensy
Arduino: 1.8.16 (Windows 10), TD: 1.56, Board: "Teensy 4.1, MTP Disk (Experimental), 600 MHz, Faster, US English"
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'void MTP_class::loop()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:244:26: error: 'usb_mtp_status' was not declared in this scope
if (return_code && usb_mtp_status == 0x01) {
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:269:7: error: 'usb_mtp_status' was not declared in this scope
if (usb_mtp_status != 0x01) {
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'uint32_t MTP_class::GetObject(MTP_class::MTPContainer&)':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:569:9: error: 'usb_mtp_status' was not declared in this scope
if (usb_mtp_status != 0x01) {
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'uint32_t MTP_class::GetPartialObject(MTP_class::MTPContainer&)':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:609:9: error: 'usb_mtp_status' was not declared in this scope
if (usb_mtp_status != 0x01) {
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'bool MTP_class::receive_bulk(uint32_t)':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:1561:7: error: 'usb_mtp_status' was not declared in this scope
if (usb_mtp_status != 0x01) return false;
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'int MTP_class::transmit_bulk()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:1591:7: error: 'usb_mtp_status' was not declared in this scope
if (usb_mtp_status == 0x01) {
^
Multiple libraries were found for "SD.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Using library SD at version 2.0.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
Using library SdFat at version 2.1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
Using library MTP_Teensy-main at version 1.0.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main
Error compiling for board Teensy 4.1.
Thanks for the reply, yeah it looks like SD and SDFat used are the Teensy versionsCode:Arduino: 1.8.16 (Windows 10), TD: 1.56, Board: "Teensy 4.1, MTP Disk (Experimental), 600 MHz, Faster, US English" ... C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp: In member function 'void MTP_class::loop()': C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:244:26: error: 'usb_mtp_status' was not declared in this scope if (return_code && usb_mtp_status == 0x01) { ^ C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MTP_Teensy-main\src\MTP_Teensy.cpp:269:7: error: 'usb_mtp_status' was not declared in this scope if (usb_mtp_status != 0x01) { ^
C:\Users\maher\OneDrive\Documents\Arduino\libraries\MTP_Teensy-main\examples\mtp-logger\mtp-logger.ino: In function 'void loop()':
C:\Users\maher\OneDrive\Documents\Arduino\libraries\MTP_Teensy-main\examples\mtp-logger\mtp-logger.ino:149:5: error: 'mtpd' was not declared in this scope
mtpd.loop();
^
I tried installing the latest IDE(1.8.19) but still get the same error
...
is there any additional installation step(copying files into core or something) other than just downloading the zip folder
#if TEENSYDUINO < 157
#error "Teensyduino 1.57-beta is required, get it at https://forum.pjrc.com/threads/70196"
#endif