-
Notifications
You must be signed in to change notification settings - Fork 1
mbed TLS example
This page documents getting the mbed-os TLS sample program running on an STM NUCLEO_F746ZG board.
##Install mbed-cli
sudo pip install mbed-cli
I seem to recall that I had to install some additional dependencies afterwards (they were shown as part of running the above).
##Install toolchain This assumes that you have arm-none-eabi installed and in your path. You can either install it using:
sudo apt install gcc-arm-none-eabi
or install it from: https://launchpad.net/gcc-arm-embedded. Install one of the 4.9 versions of the toolchain and not 5.0 (I read that mbed has some issues with 5.0).
##Get the example project Grab a copy of the mbed-os-example-tls project:
git clone https://github.com/ARMmbed/mbed-os-example-tls.git
cd mbed-os-example-tls/tls-client
mbed target NUCLEO_F746ZG
mbed toolchain GCC_ARM
mbed deploy
##Edit main.cpp I then edited main.cpp in the tls-client directory. Change DEBUG_LEVEL as desired.
Optional Just before the main function add the line:
Serial pc(USBTX, USBRX);
and just inside the main function add:
pc.baud(115200);
If you choose not to do this, then use 9600 baud when connecting the serial terminal below.
##Compile Compile the project:
mbed compile
##Satrt terminal program Connect the USB port (CN1 labelled USB_PWR) and start a terminal emulator. You may need to make your user be a member of the dialout group. Connect to /dev/ttyACM0 at 115200 baud (9600 baud if you didn't edit main.cpp).
##Flash image When you plug the board in, it will create a filesystem which looks like a USB thumb drive. Under ubuntu, mine showed up under /media/dhylands/NODE_F746ZG
Copy the image you just built (./BUILD/NUCLEO_F746ZG/GCC_ARM/tls-client.bin) to the flash drive:
cp ./BUILD/NUCLEO_F746ZG/GCC_ARM/tls-client.bin /media/dhylands/NODE_F746ZG
You should see some LEDs flash while it's flashing the image, and then see something like the following output:
Using Ethernet LWIP
Client IP Address is 192.168.0.157
Connecting with developer.mbed.org
Starting the TLS handshake...
TLS connection to developer.mbed.org established
Server certificate:
cert. version : 3
serial number : 11:21:B8:47:9B:21:6C:B1:C6:AF:BC:5D:0C:19:52:DC:D7:C3
issuer name : C=BE, O=GlobalSign nv-sa, CN=GlobalSign Organization Validation CA - SHA256 - G2
subject name : C=GB, ST=Cambridgeshire, L=Cambridge, O=ARM Ltd, CN=*.mbed.com
issued on : 2016-03-03 12:26:08
expires on : 2017-04-05 10:31:02
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=false
subject alt name : *.mbed.com, mbed.org, *.mbed.org, mbed.com
key usage : Digital Signature, Key Encipherment
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
Certificate verification passed
HTTPS: Received 439 chars from server
HTTPS: Received 200 OK status ... [OK]
HTTPS: Received 'Hello world!' status ... [OK]
HTTPS: Received message:
HTTP/1.1 200 OK
Server: nginx/1.7.10
Date: Wed, 05 Oct 2016 22:27:00 GMT
Content-Type: text/plain
Content-Length: 14
Connection: keep-alive
Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT
Accept-Ranges: bytes
Cache-Control: max-age=36000
Expires: Thu, 06 Oct 2016 08:27:00 GMT
X-Upstream-L3: 172.17.0.3:80
X-Upstream-L2: developer-sjc-indigo-2-nginx
Strict-Transport-Security: max-age=31536000; includeSubdomains
Hello world!