add usb serial support
This commit is contained in:
parent
a0a6586752
commit
eefa769bc8
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
picotool
|
picotool
|
||||||
sdk
|
sdk
|
||||||
freertos*
|
freertos*
|
||||||
|
tinyusb
|
||||||
|
|
||||||
build
|
build
|
||||||
toolchain
|
toolchain
|
||||||
|
|||||||
29
README.md
29
README.md
@ -90,3 +90,32 @@ Metadata Block 1
|
|||||||
image type: ARM Secure
|
image type: ARM Secure
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Show program outputs via USB serial mode
|
||||||
|
In order to show logs from your program running on the microcontroller, you have to integrate [TinyUSB](https://github.com/raspberrypi/tinyusb/tree/pico) in the Pico C SDK.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
To do it, simply launch the following command:
|
||||||
|
```bash
|
||||||
|
./scripts/install_tiny_usb.bash <version>
|
||||||
|
# for the 0.17.0 version
|
||||||
|
./scripts/install_tiny_usb.bash 0.17.0
|
||||||
|
```
|
||||||
|
|
||||||
|
It will download TinyUSB sources and create a symbolic link in the Pico C SDK for integration at compilation.
|
||||||
|
|
||||||
|
**NOTE**: If the SDK is located in specific directory, set the **INSTALL_PATH** variable pointing to the directory of the SDK before to launch the script.
|
||||||
|
|
||||||
|
### Display output on terminal
|
||||||
|
Recompile and push your program on the microcontroller. Then to display the program outputs, you have to use `minicom`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install minicom
|
||||||
|
```
|
||||||
|
|
||||||
|
**NOTE**: if you have the habit to use another tool then, use it !
|
||||||
|
|
||||||
|
After the installation, the microcontroller plug into the USB port, you can launch the command to visualize the program outputs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo minicom -b 115200 -o -D /dev/ttyACM0
|
||||||
|
```
|
||||||
|
|||||||
@ -52,6 +52,7 @@ set(FREERTOS_PORT_FILES
|
|||||||
|
|
||||||
add_executable(buzzer main.c log.c gpio.c jobs.c utils.c ${FREERTOS_SOURCES} ${FREERTOS_PORT_FILES})
|
add_executable(buzzer main.c log.c gpio.c jobs.c utils.c ${FREERTOS_SOURCES} ${FREERTOS_PORT_FILES})
|
||||||
add_definitions(-DPICO)
|
add_definitions(-DPICO)
|
||||||
|
add_definitions(-DLOG_LEVEL=INFO)
|
||||||
|
|
||||||
pico_set_program_name(buzzer "buzzer")
|
pico_set_program_name(buzzer "buzzer")
|
||||||
pico_set_program_version(buzzer "0.1")
|
pico_set_program_version(buzzer "0.1")
|
||||||
|
|||||||
67
scripts/install_tiny_usb.bash
Executable file
67
scripts/install_tiny_usb.bash
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
###############################################
|
||||||
|
#
|
||||||
|
# Download and install Tiny USB.
|
||||||
|
# src: https://github.com/hathach/tinyusb
|
||||||
|
#
|
||||||
|
# ex: ./install_tiny_usb.bash 0.17.0
|
||||||
|
#
|
||||||
|
###############################################
|
||||||
|
|
||||||
|
TINY_USB_VERSION=$1
|
||||||
|
REGEX_VERSION="^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$"
|
||||||
|
|
||||||
|
if [[ -z ${INSTALL_PATH} ]]
|
||||||
|
then
|
||||||
|
INSTALL_PATH=${PWD}
|
||||||
|
fi
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage:"
|
||||||
|
echo "./install_tiny_usb.bash <version> (ex: ./install_tiny_usb.bash 2.1.0)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ ! "${TINY_USB_VERSION}" =~ ${REGEX_VERSION} ]]
|
||||||
|
then
|
||||||
|
echo "error: unable to parse the version: '${TINY_USB_VERSION}'"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d ${INSTALL_PATH}/tinyusb/${TINY_USB_VERSION} ]]
|
||||||
|
then
|
||||||
|
echo "installing Tiny USB ${TINY_USB_VERSION}"
|
||||||
|
|
||||||
|
tar_file="${TINY_USB_VERSION}.tar.gz"
|
||||||
|
wget https://github.com/hathach/tinyusb/archive/refs/tags/${TINY_USB_VERSION}.tar.gz -P ${INSTALL_PATH}
|
||||||
|
if [[ $? != 0 ]]
|
||||||
|
then
|
||||||
|
echo "error: unable to get tiny USB VERSION: ${TINY_USB_VERSION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ${INSTALL_PATH}/tinyusb
|
||||||
|
tar xzvf ${INSTALL_PATH}/${tar_file} -C ${INSTALL_PATH}/tinyusb
|
||||||
|
rm ${INSTALL_PATH}/${tar_file}
|
||||||
|
|
||||||
|
mv ${INSTALL_PATH}/tinyusb/tinyusb-${TINY_USB_VERSION} ${INSTALL_PATH}/tinyusb/${TINY_USB_VERSION}
|
||||||
|
|
||||||
|
echo "find Pico SDK to add TinyUSB support on compilation..."
|
||||||
|
tiny_usb_dir=$(find ${INSTALL_PATH}/sdk -name tinyusb -type d | grep lib | head -1)
|
||||||
|
if [[ ! -z ${tiny_usb_dir} ]]
|
||||||
|
then
|
||||||
|
cd ${tiny_usb_dir}/..
|
||||||
|
lib_dir=${PWD}
|
||||||
|
|
||||||
|
rmdir ${tiny_usb_dir}
|
||||||
|
ln -s ${INSTALL_PATH}/tinyusb/${TINY_USB_VERSION} tinyusb
|
||||||
|
|
||||||
|
echo "Tiny USB soft link added to Pico SDK: $(ls -lrt ${lib_dir}/tinyusb)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Tiny USB installed successfully: ${INSTALL_PATH}/tinyusb/${TINY_USB_VERSION}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Tiny USB already exists: ${INSTALL_PATH}/tinyusb/${TINY_USB_VERSION}"
|
||||||
Loading…
x
Reference in New Issue
Block a user