|
| 1 | +# Build |
| 2 | + |
| 3 | +## Build SmallBASIC |
| 4 | + |
| 5 | +Download and build SmallBASIC as described [here](https://github.com/smallbasic/SmallBASIC). |
| 6 | + |
| 7 | +## Configure Tennsy version |
| 8 | + |
| 9 | +Tennsy 4 and Tennsy 4.1 are supported. Both using the same processor and running at the same speed. |
| 10 | +But Tennsy 4.1 offers more features than Tennsy 4. Currently, you have to configure two files depending |
| 11 | +which MCU you use. |
| 12 | + |
| 13 | +1. `src/platform/teensy/Makefile.am` |
| 14 | + `--mcu=TENNSY4` or `--mcu=TENNSY41` |
| 15 | + |
| 16 | + ``` |
| 17 | + install: build/smallbasic.elf |
| 18 | + @build/modules/teensy_loader_cli/teensy_loader_cli --mcu=TEENSY41 -w -v -s build/smallbasic.hex && \ |
| 19 | + sleep 1 && \ |
| 20 | + lsusb | grep -i teensy |
| 21 | + ``` |
| 22 | + |
| 23 | +2. `src/platform/teensy/CMakeLists.txt` |
| 24 | + Comment/Uncomment settings for Teensy 4 / Tennsy 4.1 |
| 25 | + |
| 26 | + ``` |
| 27 | + # settings for teensy 4.0 |
| 28 | + #set(MODULES ${CMAKE_CURRENT_SOURCE_DIR}/build/modules) |
| 29 | + #set(TEENSY_SRC ${MODULES}/cores/teensy4) |
| 30 | + #set(MCU "IMXRT1062") |
| 31 | + #set(MCU_LD ${TEENSY_SRC}/imxrt1062.ld) |
| 32 | + #set(MCU_DEF "ARDUINO_TEENSY4") |
| 33 | + #set(CPU_OPTIONS "-mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb") |
| 34 | +
|
| 35 | + # settings for teensy 4.1 |
| 36 | + set(MODULES ${CMAKE_CURRENT_SOURCE_DIR}/build/modules) |
| 37 | + set(TEENSY_SRC ${MODULES}/cores/teensy4) |
| 38 | + set(MCU "IMXRT1062") |
| 39 | + set(MCU_LD ${TEENSY_SRC}/imxrt1062_t41.ld) |
| 40 | + set(MCU_DEF "ARDUINO_TEENSY41") |
| 41 | + set(CPU_OPTIONS "-mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -mthumb") |
| 42 | + ``` |
| 43 | + |
| 44 | +## Build firmware in Manjaro (arch) |
| 45 | + |
| 46 | +``` |
| 47 | +$ sudo pacman -S arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib libusb-compat |
| 48 | +$ ./configure --enable-teensy |
| 49 | +$ cd src/platform/teensy |
| 50 | +$ ./setup.sh |
| 51 | +$ make |
| 52 | +``` |
| 53 | + |
| 54 | +> If setup.sh displays an error massage that cmake minimum version is not set, |
| 55 | +> open `build/modules/CMSIS-DSP/CMakeLists.txt` |
| 56 | +> and add in the beginning of the file `cmake_minimum_required(VERSION 4.1)` |
| 57 | +
|
| 58 | +## Upload the firmware |
| 59 | + |
| 60 | +``` |
| 61 | +make install |
| 62 | +``` |
| 63 | + |
| 64 | +or |
| 65 | + |
| 66 | +``` |
| 67 | +build/modules/teensy_loader_cli/teensy_loader_cli --mcu=TEENSY41 -w -v -s build/smallbasic.hex |
| 68 | +``` |
| 69 | + |
| 70 | +# Run your SMALLBASIC program |
| 71 | + |
| 72 | +SMALLBASIC for Teensy offers three ways to upload and run a program. |
| 73 | + |
| 74 | +1. Format a SD card using FAT32. Rename your program to `MAIN.BAS` and copy it to the SD card. |
| 75 | +2. Include your program in the firmware. Replace `main.bas` in `src/platform/teensy` by your program and build |
| 76 | + the firmware. |
| 77 | +3. Send your program via USB-serial connection to the Teensy. In Linux use ` cat YourProgram.bas > /dev/ttyACM0` |
| 78 | + Change `/dev/ttyACM0` to the USB-serial port of your Teensy. |
| 79 | +4. Goto 3. |
| 80 | + |
| 81 | +When the Teensy starts up, it will check in the above indicated order for your program. If it finds |
| 82 | +a SD card and the SD card contains a file `MAIN.BAS`, it will execute it. Otherwise it will check, if a program |
| 83 | +was included in the firmware. If no program was included, the Teensy will switch to interactive mode and waits |
| 84 | +for a program upload via USB-serial. |
| 85 | + |
| 86 | +While your program is running, the Teensy will check continuously if data is available at the USB-serial port. |
| 87 | +If data is available for longer than one second your running program will be terminated and the queued data of the |
| 88 | +USB-serial port will be interpreted as the new program. Once the upload is finished, the new program will be executed. |
| 89 | +If you are using the USB-serial port for communication, read the queued data within one second. Alternately, you |
| 90 | +can turn on/off this behavior during runtime. |
| 91 | + |
| 92 | +If an error occurred, for example a syntax error, execution will stop and you have to read the error message from |
| 93 | +the USB-serial port. |
| 94 | + |
| 95 | +If the execution of your program comes to an end, for example when reaching the end of the program or when `STOP` is |
| 96 | +called, the program is terminated and the next section in the above list is performed. |
| 97 | + |
| 98 | +# Read output from your running program |
| 99 | + |
| 100 | +The `PRINT` command can be used to print to the USB-serial port. To access the output, connect to the serial |
| 101 | +port using, i.e. `PUTTY` or any other serial-port monitor / terminal. Using Linux, the easiest way is to run |
| 102 | +`cat /dev/ttyACM0` |
0 commit comments