Skip to content

Commit 1c0371c

Browse files
author
Agathiyan Bragadeesh
committed
Add page for setup information for raspberry pico
Signed-off-by: Agathiyan Bragadeesh <[email protected]>
1 parent c399a71 commit 1c0371c

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Arm Mbed TLS in Raspberry Pi Pico SDK
2+
3+
## Introduction
4+
5+
This tutorial shows how to use the Mbed TLS cryptography library from the pico sdk (source at https://github.com/raspberrypi/pico-sdk) in projects. As of writing this only Mbed TLS 2.28 is supported with the SDK. This project will ultimately end up with setting up programs/hash/hello.c from the mbedtls repository on your own Pico board.
6+
7+
## Setting up the SDK
8+
9+
First, you will need to clone the sdk in your prefered place with
10+
```
11+
git clone https://github.com/raspberrypi/pico-sdk
12+
```
13+
Next we need to initialise and update the submodules. If you are developing for the Pico W you need to run
14+
15+
```
16+
git submodule add https://github.com/georgerobotics/cyw43-driver
17+
```
18+
19+
Then set all the submodules up with
20+
21+
```
22+
git submodule update --init
23+
```
24+
Mbed TLS 2.28 will now be ready to use from the sdk
25+
26+
## Setting up the project for PICO board
27+
28+
Then outside of the sdk, make a directory where you would like to do development. You can find the example we are trying to build at `<path-to-sdk>/lib/mbedtls/programs/hash/hello.c` and copy it into the development directory. Some changes need to be made to this file to make it compatible for the pico board. Add the line `stdio_init_all();` at the top of the main loop to set up the I/O functionality. Also to be able to see the output once the board is running you might want to surround the body of the program in a while true loop.
29+
30+
Now you'll need to copy the cmake file which finds the sdk from your project:
31+
```
32+
cp <path-to-sdk>/external/pico_sdk_import.cmake .
33+
```
34+
Then make a `CMakeLists.txt` file with the following
35+
```
36+
cmake_minimum_required(VERSION 3.13)
37+
38+
include(pico_sdk_import.cmake)
39+
40+
project(hello C CXX ASM)
41+
set(CMAKE_C_STANDARD 11)
42+
set(CMAKE_CXX_STANDARD 17)
43+
44+
pico_sdk_init()
45+
46+
add_executable(hello
47+
hello.c
48+
)
49+
50+
pico_enable_stdio_usb(hello 1)
51+
pico_enable_stdio_uart(hello 1)
52+
pico_add_extra_outputs(hello)
53+
54+
target_link_libraries(test pico_stdlib pico_mbedtls)
55+
target_include_directories(test PRIVATE ${CMAKE_CURRENT_LIST_DIR} )
56+
```
57+
When including `pico_mbedtls`, a config file is automatically searched for with the name `mbedtls_config.h` so make a new file for new with the line
58+
```
59+
#define MBEDTLS_MD5_C
60+
```
61+
so we can run the main loop in our program. Then make a build a directory and run
62+
```
63+
cmake .. && make
64+
```
65+
This will generate a .uf2 file that you can use on your pico board. To put the firmware on your pico baord, hold down the BOOTSEL button on the board, and then connect it to your device. Hold it down until the board mounts as mass storage device. Once it's mounted you can copy the uf2 file onto the board, at which point the board will reboot and start running the firmware. We enabled USB I/O in makefile, so we need to connect to the serial port the pico's usb is connected to.
66+
67+
### Linux systems
68+
69+
On linux by default this will be visible at `/dev/ttyACM0`. To connect and see the output to ensure your board is running, run:
70+
```
71+
minicom -b 115200 -o -D /dev/ttyACM0
72+
```
73+
And you should be able to see your program running.
74+
75+
### Other systems
76+
77+
You can use any serial monitor, such as putty, and connect to the port you find your raspberry board connected to with a baud rate of 115200.
78+
79+
## Extra considerations for the PICO W
80+
81+
Although this example doesn't utilise it, you may want to use some Pico W functionality, for many other projects. In this case, you will need to also target a cyw43 library in the cmake file. For more information on this, see [here](https://www.raspberrypi.com/documentation/pico-sdk/networking.html).
82+
83+
<!--- "This quickstart manual is intended for C/C++ developers who are interesting in developing Mbed TLS based projects in Eclipse C/C++ Development Tool (CDT) on Windows.","Eclipse CDT, Cygwin, Eclipse installation","eclipse, cygwin, tutorial",published,"2013-01-04 15:39:00",6,47375,"2015-07-24 11:51:00","Paul Bakker"--->

0 commit comments

Comments
 (0)