Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2026-09-26 (12.34)
TEENSY: Add flash and SD card file system
WINDOWS: Remove __p__environ warning when building

2026-04-28 (12.34)
COMMON: implement plugin_refresh_id for variable lifecycle handling
COMMON: fix bug with comma in string assigned as local #283
Expand Down
4 changes: 2 additions & 2 deletions src/common/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <dir.h>
#endif

extern char **environ;

#define BUFSIZE 1024

#if defined(_Win32)
Expand Down Expand Up @@ -126,6 +124,8 @@ int dev_run(const char *cmd, var_t *r, int wait) {
}

#else
extern char **environ;

int dev_run(const char *cmd, var_t *r, int wait) {
int result = 1;
if (r != NULL) {
Expand Down
6 changes: 6 additions & 0 deletions src/platform/teensy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(CMAKE_EXE_LINKER_FLAGS "-Os -Wl,--gc-sections,--relax ${SPECS} ${CPU_OPTIONS
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_SIZE arm-none-eabi-size)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)

# Include the module directories
add_subdirectory(libs)
Expand All @@ -58,6 +59,7 @@ include_directories(${MODULES}/USBHost_t36)
include_directories(${MODULES}/Wire)
include_directories(${MODULES}/SD/src)
include_directories(${MODULES}/SdFat/src)
include_directories(${MODULES}/LittleFS/src)

# include config.h and common headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
Expand All @@ -71,6 +73,10 @@ set(SOURCES
src/module.cpp
src/teensy.cpp
src/ssd1306.cpp
src/i2c.cpp
src/serial.cpp
src/pinio.cpp
src/fs.cpp
)

# Add executable with the list of source files
Expand Down
5 changes: 5 additions & 0 deletions src/platform/teensy/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ build/smallbasic.elf : \
src/device.cpp \
src/teensy.cpp \
src/ssd1306.cpp \
src/fs.cpp \
src/i2c.cpp \
src/serial.cpp \
src/pinio.cpp \
src/module.cpp \
src/main_bas.h
@cd build && make -j 32

Expand Down
14 changes: 7 additions & 7 deletions src/platform/teensy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ build/modules/teensy_loader_cli/teensy_loader_cli --mcu=TEENSY40 -w -v -s build/
SMALLBASIC for Teensy offers three ways to upload and run a program.

1. Format a SD card using FAT32. Rename your program to `MAIN.BAS` and copy it to the SD card.
2. Include your program in the firmware. Replace `main.bas` in `src/platform/teensy` by your program and build
2. Upload your program as `MAIN.BAS` to the flash memory file system (i.e. use `console.bas`)
3. Include your program in the firmware. Replace `main.bas` in `src/platform/teensy` by your program and build
the firmware.
3. Send your program via USB-serial connection to the Teensy. In Linux use ` cat YourProgram.bas > /dev/ttyACM0`
5. Send your program via USB-serial connection to the Teensy. In Linux use ` cat YourProgram.bas > /dev/ttyACM0`
Change `/dev/ttyACM0` to the USB-serial port of your Teensy.
4. Goto 3.

When the Teensy starts up, it will check in the above indicated order for your program. If it finds
a SD card and the SD card contains a file `MAIN.BAS`, it will execute it. Otherwise it will check, if a program
was included in the firmware. If no program was included, the Teensy will switch to interactive mode and waits
for a program upload via USB-serial.
a SD card and the SD card contains a file `MAIN.BAS`, it will execute it. Otherwise it will check flash for
the file `MAIN.bas` and executes it. Otherwise it will check, if a program was included in the firmware. If no
program was included, the Teensy will switch to interactive mode and waits for a program upload via USB-serial.

While your program is running, the Teensy will check continuously if data is available at the USB-serial port.
If data is available for longer than one second your running program will be terminated and the queued data of the
Expand All @@ -114,7 +114,7 @@ If an error occurred, for example a syntax error, execution will stop and you ha
the USB-serial port.

If the execution of your program comes to an end, for example when reaching the end of the program or when `STOP` is
called, the program is terminated and the next section in the above list is performed.
called, the program is terminated and the teensy switches to interactive mode.

# Read output from your running program

Expand Down
6 changes: 6 additions & 0 deletions src/platform/teensy/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(USB_DIR ${MODULES_DIR}/USBHost_t36)
set(WIRE_DIR ${MODULES_DIR}/Wire)
set(SD_DIR ${MODULES_DIR}/SD/src)
set(SDFAT_DIR ${MODULES_DIR}/SdFat/src)
set(LITTLEFS_DIR ${MODULES_DIR}/LittleFS/src)

set(SOURCES
${ADC_DIR}/ADC.cpp
Expand Down Expand Up @@ -162,6 +163,10 @@ set(SOURCES
${SDFAT_DIR}/common/FsUtf.cpp
${SDFAT_DIR}/common/PrintBasic.cpp
${SDFAT_DIR}/common/upcase.cpp
${LITTLEFS_DIR}/LittleFS.cpp
${LITTLEFS_DIR}/LittleFS_NAND.cpp
${LITTLEFS_DIR}/littlefs/lfs.c
${LITTLEFS_DIR}/littlefs/lfs_util.c
)

add_library(libs STATIC ${SOURCES})
Expand All @@ -176,4 +181,5 @@ target_include_directories(libs PRIVATE ${TEENSY_DIR})
target_include_directories(libs PRIVATE ${WIRE_DIR})
target_include_directories(libs PRIVATE ${SD_DIR})
target_include_directories(libs PRIVATE ${SDFAT_DIR})
target_include_directories(libs PRIVATE ${LITTLEFS_DIR})

Loading