@anybody interested - Here is the first go at documenting the installation and usage procedure for MBED CE on the Teensy T40. May try to set it up on Windows 11 (maybe).
MBED CE OS installation instructions for Ubuntu 22.04 with Teensy T40.
1. Open a Linux terminal. and create a sub-directory. I used 'mkdir mbed' then 'cd mbed'.
2. Go to this Internet page:
https://github.com/mbed-ce/mbed-os/wiki/Toolchain-Setup-Guide
3. Drop down to the "On Linux:" section. Skip over step '1.' and start at step '2.'.
4. Install Ninga Build: 'sudo apt-get install ninja-build'
5. Install other needed packages: 'sudo apt-get install libncurses5 libncursesw5'.
6. Next go to this Internet page:
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
7. Again, dropdown to this section: 'x86_64 Linux hosted cross toolchains' 'AArch32 bare-metal target (arm-none-eabi)'
8. Download: 'arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz'
9. Extract the package with: 'tar xf arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz' This may take a little time on a slow computer.
10. Move and rename the resulting directory to /usr/local directory: 'sudo mv arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi /usr/local/gcc-arm'
11. Next 'cd ~/' to get to your home directory.
12. With a text editor open (in my case) '.bash' or '.profile'. Basically, we are adding the path to '/usr/local/gcc-arm' to the existing PATH enviroment variable. Add this to the end of the open file: 'export PATH=/usr/local/gcc-arm/bin:$PATH'. Save the file.
13. Reset the PATH variable with 'source ~/.bashrc' then check to make sure it's set with: 'echo $PATH'. You should see: '/usr/local/gcc-arm/bin:...' at the begining fo the print out.
14. Next install a few python dependency's: 'sudo apt-get install python3-pip python3-setuptools python3-wheel'
15. Now to get Mbed CE Hello World project from GitHub for testing. First cd to the directory you created in step 1. Then execute the following: 'git clone --recursive
https://github.com/mbed-ce/mbed-ce-hello-world.git' Make sure to use the '--recursive' option as this will bring in the needed mbed-os submodule.
16. This next step switches to mbed-os branch we are using for testing with the Teensy T40. First change to the mbed-os directory: 'cd mbed-ce-hello-world/mbed-os/'. Then do: 'git checkout dev/fix-teensy4-issues'.
17. You should now be in 'mbed-ce-hello-world/mbed-os/'. Execute the following: 'cmake .. -GNinja -DCMAKE_BUILD_TYPE=Develop -DMBED_TARGET=TEENSY_40'. Then execute 'ninja'. This will build the project. Output should be something like:
Code:
-- built: /home/wwatson/mbed/mbed-ce-hello-world/mbed-os/HelloWorld.bin
-- built: /home/wwatson/mbed/mbed-ce-hello-world/mbed-os/HelloWorld.hex
| Module | .text | .data | .bss |
|---------------------------|---------------|-------------|-------------|
| CMakeFiles/HelloWorld.dir | 50(+50) | 0(+0) | 0(+0) |
| [fill] | 189(+189) | 4(+4) | 37(+37) |
| [lib]/c.a | 16429(+16429) | 1708(+1708) | 373(+373) |
| [lib]/gcc.a | 752(+752) | 0(+0) | 0(+0) |
| [lib]/mbed-usb.a | 10387(+10387) | 0(+0) | 2(+2) |
| [lib]/misc | 264(+264) | 4(+4) | 25(+25) |
| [lib]/nosys.a | 32(+32) | 0(+0) | 0(+0) |
| [misc] | 0(+0) | 0(+0) | 0(+0) |
| mbed-os/CMakeFiles | 40285(+40285) | 436(+436) | 8379(+8379) |
| Subtotals | 68388(+68388) | 2152(+2152) | 8816(+8816) |
Total Static RAM memory (data + bss): 10968(+10968) bytes
Total Flash memory (text + data): 70540(+70540) bytes
18. To upload the hex file to the T40 open the Teensy UI and click on 'File'. Select 'Open hex file'. Choose the 'HelloWorld.hex' file which is in 'mbed-ce-hello-world/mbed-os/'. Press the program button on the T40. Make sure the 'Auto' mode is selected. This will upload the file.
At this point not much is visibly happening. To see the output from the program you need to setup serial1 to show output from the program. You will also need a serial to USB adaptor and a terminal program setup to use /dev/ttyUSB0. Also we will need to modify a json file in the 'mbed-ce-hello-world' directory (mbed_app.json) to look like the following:
====================================================================================
Code:
{
"target_overrides": {
"*": {
"platform.stdio-baud-rate": 115200,
"platform.stdio-buffered-serial": 1,
"target.console-usb": false,
"target.console-uart": true,
"platform.minimal-printf-enable-floating-point": true
}
}
}
====================================================================================
And to see the floating point printf working, modify 'main.cpp' like so:
====================================================================================
Code:
#include "mbed.h"
int main()
{
float fnum = 0.0;
while(true)
{
printf("Hello world from Mbed CE! : %f\n", fnum+=0.5);
ThisThread::sleep_for(1s);
}
// main() is expected to loop forever.
// If main() actually returns the processor will halt
return 0;
}
====================================================================================
Then execute the 'ninja' command and repeat step #18.
I have tried this with Ubuntu 22.04 and Ubuntu 20.04. Unfortunately there are many issues with Ubuntu 20.04 that I have not worked through yet so suggest using version 22.04. I repeated these steps a few times and they have worked every time.
Hopefully this helps others get started with MBED CE and the T40. T41 anyone?
Please feel free to correct any mistakes I may have made...