From ea3b8804499312b9a939aadfbd6954761b4dad8a Mon Sep 17 00:00:00 2001 From: philsson Date: Sat, 14 Oct 2017 14:44:06 +0200 Subject: [PATCH] Working debugger on Linux With a simple code example of a blinking led on the F411 target --- .gitignore | 42 +++++++++++++++++++++++++++ .gitmodules | 4 +-- .vscode/c_cpp_properties.json | 53 +++++++++++++++++++++++++++++++++++ .vscode/launch.json | 46 ++++++++++++++++++++++++++++++ .vscode/tasks.json | 50 +++++++++++++++++++++++++++++++++ Makefile | 6 ++++ README.md | 14 +++++++++ prj.conf | 5 ++++ src/Makefile | 1 + src/main.c | 38 +++++++++++++++++++++++++ 10 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Makefile create mode 100644 prj.conf create mode 100644 src/Makefile create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..615d82c --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ + +# Mac files +.DS_Store + +outdir +**outdir + +.built-in.o.cmd +.main.o.cmd +.browse.VC.db* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 2699fbf..55429fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "zephyrRC/zephyr-RC"] - path = zephyrRC/zephyr-RC +[submodule "zephyr-RC"] + path = include/zephyr-RC url = https://github.com/philsson/zephyr-RC.git diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..50603e8 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,53 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/Volumes/CrossToolNG/zephyr/include", + "${workspaceRoot}" + ], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/Volumes/CrossToolNG/zephyr/include", + "${workspaceRoot}" + ] + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] + }, + { + "name": "Linux", + "includePath": [ + "/usr/include", + "${workspaceRoot}" + ], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "${workspaceRoot}" + ] + } + }, + { + "name": "Win32", + "includePath": [ + "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", + "${workspaceRoot}" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", + "${workspaceRoot}" + ] + } + } + ], + "version": 3 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9ea2256 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "debug", + "type": "cppdbg", + "request": "launch", + "windows": { + "miDebuggerPath": "c:/dev/gcc-arm-6.2/bin/arm-none-eabi-gdb.exe" + }, + "linux": { + //"miDebuggerPath": "/usr/bin/gdb" + "miDebuggerPath": "/usr/bin/arm-none-eabi-gdb" + //"debugServerPath": "/usr/bin/openocd" + }, + "targetArchitecture": "arm", + "program": "${workspaceRoot}/outdir/nucleo_f411re/zephyr.elf", + //"preLaunchTask": "debug_server", + "debugServerArgs": "", + "stopAtEntry": false, + "setupCommands": [ + { "text": "file ${workspaceRoot}/outdir/nucleo_f411re/zephyr.elf" }, + { "text": "set remotetimeout 30" }, + { "text": "target remote localhost:3333" }, + { "text": "monitor halt" }, + { "text": "monitor reset init" }, + { "text": "load" }, + { "text": "info target" } + ], + "externalConsole": false, + "cwd": "${workspaceRoot}" + } + ] +} + +//"type": "gdb", +//"request": "attach", + + + +// For OpenOCD which has to run when gdb tries to connect +// $ PATH_TO_OPENOCD/bin/openocd +// -f PATH_TO_OPENOCD/scripts/board/stm32f4discovery.cfg +// -f PATH_TO_OPENOCD/scripts/interface/stlink-v2-1.cfg +// -c init +// -c "reset init" \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..72371a6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,50 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "linux" : { + "command": "bash", + "suppressTaskName": true, + "isShellCommand": true, + "showOutput": "always", + "args": [ + "-c" + ], + "tasks": [ + { + "taskName": "clean", + "suppressTaskName": true, + "args": ["source ${workspaceRoot}/include/zephyr-RC/zephyr-env.sh && make clean && echo DONE"] + }, + { + "taskName": "build", + "suppressTaskName": true, + "isBuildCommand": true, + "args": ["source ${workspaceRoot}/include/zephyr-RC/zephyr-env.sh && make BOARD=nucleo_f411re && echo DONE"], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "deploy", + "suppressTaskName": true, + "args": ["source ${workspaceRoot}/include/zephyr-RC/zephyr-env.sh && make BOARD=nucleo_f411re flash"] + }, + { + "taskName": "debug_server", + "suppressTaskName": true, + //"args": ["source ${workspaceRoot}/include/zephyr-RC/zephyr-env.sh && openocd -s /usr/local/share/openocd/scripts -f ${ZEPHYR_BASE}/boards/arm/nucleo_f411re/support/openocd.cfg -c 'init' -c 'targets' -c 'reset halt'"] + "args": ["source ${workspaceRoot}/include/zephyr-RC/zephyr-env.sh && openocd -s /usr/local/share/openocd/scripts -f ${ZEPHYR_BASE}/boards/arm/nucleo_f411re/support/openocd.cfg -c 'init' -c 'targets' -c 'reset init'"] + } + ] + } +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ee3967f --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +#KERNEL_TYPE = nano +BOARD ?= nucleo_f411re +CONF_FILE = prj.conf + +include ${ZEPHYR_BASE}/Makefile.inc +#include ./zephyr-RC/Makefile.inc \ No newline at end of file diff --git a/README.md b/README.md index f27c224..5ceb88b 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ # RCNoster +This project aims att developing an open-source remote control (RC) for radio controlled aircrafts e.g. drones and airplanes in both software and hardware. + +## Hardware +In the RC hobby they are numerous developers of flight controllers (FC). These boards are powerfull and very cheap and many hobbyists have either a spair or an old unit lying around. Many of these boards derive from the [CC3D Revolution](http://opwiki.readthedocs.io/en/latest/user_manual/revo/revo.html) board based on the STM32F405 processor + +The goal is to provide open CAD and Circuit Board designs for full customization and choice in electronics. + + +## Software +This software builds on the real-time operating system (RTOS) [Zephyr](https://zephyrproject.org/) created by the Linux Foundation. +The fork [Zephyr-RC](https://github.com/philsson/zephyr-RC.git) is included as a module for better support of the [CC3D Revolution](http://opwiki.readthedocs.io/en/latest/user_manual/revo/revo.html). + +A Visual Studio Code project is set up for development and configured to work under Linux. +For dependencies and zephyr specific documentation see [Zephyr Documentation](https://www.zephyrproject.org/doc/) \ No newline at end of file diff --git a/prj.conf b/prj.conf new file mode 100644 index 0000000..fabf972 --- /dev/null +++ b/prj.conf @@ -0,0 +1,5 @@ +CONFIG_GPIO=y +CONFIG_NANO_TIMERS=y +CONFIG_NANO_TIMEOUTS=y +CONFIG_DEBUG=y +CONFIG_SERIAL=n \ No newline at end of file diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..1794009 --- /dev/null +++ b/src/Makefile @@ -0,0 +1 @@ +obj-y = main.o \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..80c7800 --- /dev/null +++ b/src/main.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +/* Change this if you have an LED connected to a custom port */ +//#define PORT "GPIOA" +#define PORT LED0_GPIO_PORT + +/* Change this if you have an LED connected to a custom pin */ +//#define LED 4 +#define LED LED0_GPIO_PIN + +/* 1000 msec = 1 sec */ +#define SLEEP_TIME 500 + +void main(void) +{ + int cnt = 0; + struct device *dev; + + dev = device_get_binding(PORT); + /* Set LED pin as output */ + gpio_pin_configure(dev, LED, GPIO_DIR_OUT); + + while (1) { + /* Set pin to HIGH/LOW every 1 second */ + gpio_pin_write(dev, LED, cnt % 2); + cnt++; + k_sleep(SLEEP_TIME); + } +}