Commit bcaff146 authored by Martin Horauer's avatar Martin Horauer
Browse files

added first mbed example

parent 090f7fd0
TARGET=XMC_4500_RELAX_KIT
TOOLCHAIN=GCC_ARM
# Blinky Example
The following guide describes the steps to run the first Blinky program on the
XMC 4500 Relax Kit board from Infineon.
## Import the project
```
mbed import https://github.com/mbed-Infineon-XMC/Blinky-Example.git
```
## Compile the project
Navigate into the project folder and execute the following command:
```
cd Blinky-Example.git/
mbed compile -m XMC_4500_RELAX_KIT -t GCC_ARM
```
mbed creates a BUID directory where you can find the executables (bin, elf, hex ...).
## Step 5: Flash to board
* [Segger JLink](https://www.segger.com/downloads/jlink) - Install the JLink software for your platform.
* Navigate to the BUILD directory and execute the following JLinkExe commands.
```
$ JLinkExe
J-LINK> device xmc4500-1024
J-LINK> h
J-Link> loadfile Blinky-Example.git.hex
J-Link> r
J-Link> g
```
* Choose SWD, 4000kHz as interface settings!!
## Step 6: If successful..
When everything has gone well, LED1 will blink with 2Hz.
## Step 7: Eclipse IDE & debugging
If you want to compile and debug the project with eclipse follow this guidline:
* First export and create a makefile for the eclipse platform.
```
mbed export -i eclipse_gcc_arm -m XMC_4500_RELAX_KIT
```
* Install Eclipse C/C++ IDE
* [Install Plugins](https://github.com/mhorauer/XMC4500-Barebone-Projects/blob/master/Setup/plugins.asciidoc) - The following tutorial could be helpful.
* [Debugging with eclipse](https://docs.mbed.com/docs/mbed-os-handbook/en/5.3/debugging/debugging_eclipse_pyocd/) - Also take a look to the mbed debuging guidlines.
/* mbed Example Program
* Copyright (c) 2006-2014 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/******************************************************************* Includes */
#include "mbed.h"
/******************************************************************** Globals */
DigitalOut led(LED1);
/****************************************************************** Functions */
/**
* Main Function
*/
int main() {
/* Toggle LED1 */
while (1) {
led = !led;
wait(0.5);
}
}
/*EOF*/
../mbed-os/
\ No newline at end of file
https://github.com/mbed-Infineon-XMC/mbed-os.git
"""
mbed SDK
Copyright (c) 2016 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from os.path import join, abspath, dirname, subprocess
#ROOT = abspath(join(dirname(__file__), "."))
##############################################################################
# Build System Settings
##############################################################################
#BUILD_DIR = abspath(join(ROOT, "build"))
# ARM
#ARM_PATH = "C:/Program Files/ARM"
# GCC ARM
#GCC_ARM_PATH = ""
GCC_ARM_PATH = dirname(subprocess.check_output(["which", "arm-none-eabi-gcc"]))
# GCC CodeRed
#GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
# IAR
#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
# Goanna static analyser. Please overload it in private_settings.py
#GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
#BUILD_OPTIONS = []
# mbed.org username
#MBED_ORG_USER = ""
[run]
omit =
*/usr/local/lib*
*/tools/test/*
[report]
omit =
*/usr/local/lib*
*/tools/test/*
\ No newline at end of file
*.c text
*.cpp text
*.h text
*.s text
*.sct text
*.ld text
*.txt text
*.xml text
*.py text
*.md text
*.json text
*.tmpl text
*.dia binary
*.elf binary
*.bin binary
Note: This is just a template, so feel free to use/remove the unnecessary things
### Description
- Type: Bug | Enhancement | Question
- Related issue: `#abc`
- Priority: Blocker | Major | Minor
---------------------------------------------------------------
## Bug
**Target**
K64F|??
**Toolchain:**
GCC_ARM|ARM|IAR
**Toolchain version:**
**mbed-cli version:**
(`mbed --version`)
**mbed-os sha:**
(`git log -n1 --oneline`)
**DAPLink version:**
**Expected behavior**
**Actual behavior**
**Steps to reproduce**
----------------------------------------------------------------
## Enhancement
**Reason to enhance or problem with existing solution**
**Suggested enhancement**
**Pros**
**Cons**
-----------------------------------------------------------------
## Question
**How to?**
Notes:
- Pull requests will not be accepted until the submitter has agreed to the [contributer agreement](https://github.com/ARMmbed/mbed-os/blob/master/CONTRIBUTING.md).
- This is just a template, so feel free to use/remove the unnecessary things
## Description
A few sentences describing the overall goals of the pull request's commits.
## Status
**READY/IN DEVELOPMENT/HOLD**
## Migrations
If this PR changes any APIs or behaviors, give a short description of what *API users* should do when this PR is merged.
YES | NO
## Related PRs
List related PRs against other branches:
branch | PR
------ | ------
other_pr_production | [link]()
other_pr_master | [link]()
## Todos
- [ ] Tests
- [ ] Documentation
## Deploy notes
Notes regarding the deployment of this PR. These should note any required changes in the build environment, tools, compilers and so on.
## Steps to test or reproduce
Outline the steps to test or reproduce the PR here.
*.py[cod]
# Distribution dir
dist
# MANIFEST file
MANIFEST
doxygen_objdb_*
# Private settings
mbed_settings.py
# Default Build Directory
.build/
BUILD/
.mbed
venv/
# Eclipse Project Files
.cproject
.project
.pydevproject
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
output.txt
uVision Project/
# Sublime Text Project Files
*.sublime*
*.bak
debug.log
# Ignore OS X Desktop Services Store files
.DS_Store
# Orig diff files
*.orig
# PyCharm
*.idea
# Cscope
cscope.*
# vim swap files
*.swp
*~
# Visual Studio Code
.vscode/
[Format]
max-line-length=80
\ No newline at end of file
language: python
python:
'2.7'
env:
global:
- >
STATUS=$'curl -so/dev/null --user $MBED_BOT --request POST
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}
--data @- << DATA\n{
"state": "$0",
"description": "$1",
"context": "travis-ci/$NAME",
"target_url": "https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID"
}\nDATA'
cache:
pip: true
directories:
- $HOME/.cache/apt
- $HOME/gcc-arm-none-eabi-6-2017-q2-update
before_install:
- bash -c "$STATUS" pending "Local $NAME testing is in progress"
# Make sure pipefail
- set -o pipefail
# Setup apt to cache
- mkdir -p $HOME/.cache/apt/partial
- sudo rm -rf /var/cache/apt/archives
- sudo ln -s $HOME/.cache/apt /var/cache/apt/archives
# Setup ppa to make sure arm-none-eabi-gcc is correct version
- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
- sudo apt-get update -qq
after_success:
- bash -c "$STATUS" success "Local $NAME testing has passed"
after_failure:
- bash -c "$STATUS" failure "Local $NAME testing has failed"
matrix:
include:
- env:
- NAME=docs
install:
# Install dependencies
- sudo apt-get install doxygen
# Print versions we use
- doxygen --version
before_script:
# Create BUILD directory for tests
- mkdir BUILD
script:
# Assert that the Doxygen build produced no warnings.
# The strange command below asserts that the Doxygen command had an
# output of zero length
- >
doxygen doxyfile_options 2>&1 |
tee BUILD/doxygen.out && [ ! -s BUILD/doxygen.out ]
# Assert that all binary libraries are named correctly
# The strange command below asserts that there are exactly 0 libraries
# that do not start with lib
- >
find "(" -name "*.a" -or -name "*.ar" ")" -and -not -name "lib*" |
tee BUILD/badlibs |
sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
# Assert that all assebler files are named correctly
# The strange command below asserts that there are exactly 0 libraries
# that do end with .s
- >
find -name "*.s" | tee BUILD/badasm |
sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
- env:
- NAME=tools
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded
- pip install -r requirements.txt
- pip install pytest pylint hypothesis mock coverage coveralls
# Print versions we use
- arm-none-eabi-gcc --version
- python --version
script:
# Run local testing on tools
- PYTHONPATH=. coverage run -a -m pytest tools/test
- python2 tools/test/pylint.py
- coverage run -a tools/project.py -S | sed -n '/^Total/p'
- coverage html
after_success:
# Coverage for tools
- coveralls
# Report success since we have overridden default behaviour
- bash -c "$STATUS" success "Local $NAME testing has passed"
- env:
- NAME=events
- EVENTS=events
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded
- pip install -r requirements.txt
# Print versions we use
- arm-none-eabi-gcc --version
- gcc --version
- python --version
script:
# Check that example compiles
- sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' $EVENTS/README.md > main.cpp
- python tools/make.py -t GCC_ARM -m K64F --source=. --build=BUILD/K64F/GCC_ARM -j0
# Run local equeue tests
- make -C $EVENTS/equeue test
- env:
- NAME=littlefs
- LITTLEFS=features/filesystem/littlefs
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded fuse libfuse-dev
- pip install -r requirements.txt
- git clone https://github.com/armmbed/spiflash-driver.git
# Print versions
- arm-none-eabi-gcc --version
- gcc --version
- python --version
- fusermount --version
before_script:
# Setup and patch littlefs-fuse
- git clone https://github.com/geky/littlefs-fuse littlefs_fuse
- git -C littlefs_fuse checkout 3f1ed6e37799e49e3710830dc6abb926d5503cf2
- echo '*' > littlefs_fuse/.mbedignore
- rm -rf littlefs_fuse/littlefs/*
- cp -r $(git ls-tree --name-only HEAD $LITTLEFS/littlefs/) littlefs_fuse/littlefs
# Create file-backed disk
- mkdir MOUNT
- sudo chmod a+rw /dev/loop0
- dd if=/dev/zero bs=512 count=2048 of=DISK
- losetup /dev/loop0 DISK
script:
# Check that example compiles
- sed -n '/``` c++/,/```/{/```/d;p;}' $LITTLEFS/README.md > main.cpp
- python tools/make.py -t GCC_ARM -m K82F --source=. --build=BUILD/K82F/GCC_ARM -j0
# Run local littlefs tests
- CFLAGS="-Wno-format" make -C$LITTLEFS/littlefs test QUIET=1
# Run local littlefs tests with set of variations
- CFLAGS="-Wno-format -DLFS_READ_SIZE=64 -DLFS_PROG_SIZE=64" make -C$LITTLEFS/littlefs test QUIET=1
- CFLAGS="-Wno-format -DLFS_READ_SIZE=1 -DLFS_PROG_SIZE=1" make -C$LITTLEFS/littlefs test QUIET=1
- CFLAGS="-Wno-format -DLFS_READ_SIZE=512 -DLFS_PROG_SIZE=512" make -C$LITTLEFS/littlefs test QUIET=1
- CFLAGS="-Wno-format -DLFS_BLOCK_COUNT=1023 -DLFS_LOOKAHEAD=2048" make -C$LITTLEFS/littlefs test QUIET=1
# Self-hosting littlefs fuzz test with littlefs-fuse
- make -Clittlefs_fuse
- littlefs_fuse/lfs --format /dev/loop0
- littlefs_fuse/lfs /dev/loop0 MOUNT
- ls MOUNT
- mkdir MOUNT/littlefs
- cp -r $(git ls-tree --name-only HEAD $LITTLEFS/littlefs/) MOUNT/littlefs
- ls MOUNT/littlefs
- CFLAGS="-Wno-format" make -CMOUNT/littlefs -B test_dirs QUIET=1
- &mbed-2
env: NAME=mbed2-NXP
install:
# Install dependencies
- export GCC_DIR=$HOME/gcc-arm-none-eabi-6-2017-q2-update
- export GCC_ARCHIVE=$HOME/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
- export GCC_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2?revision=2cc92fb5-3e0e-402d-9197-bdfc8224d8a5?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,6-2017-q2-update
- if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME; fi
- export PATH=$PATH:$GCC_DIR/bin
- pip install -r requirements.txt
# Print versions we use
- arm-none-eabi-gcc --version
- python --version
before_script:
# Create BUILD directory for tests
- mkdir BUILD
script:
# Run local mbed 2 testing
- python2 -u tools/build_travis.py --vendor "${NAME#mbed2-}"
- <<: *mbed-2
env: NAME=mbed2-STM
- <<: *mbed-2
env: NAME=mbed2-NORDIC
- <<: *mbed-2
env: NAME=mbed2-SILICON_LABS
- <<: *mbed-2
env: NAME=mbed2-MAXIM
- <<: *mbed-2
env: NAME=mbed2-ATMEL
- <<: *mbed-2
env: NAME=mbed2-NUVOTON
- <<: *mbed-2
env: NAME=mbed2-RENESAS
# Description
This document is cheat sheet for everyone who wants to contribute to [ARMmbed/mbed-os](https://github.com/ARMmbed/mbed-os) GitHub repository at GitHub.
All changes in code base should originate from GitHub Issues and take advantage of existing GitHub flows. Goal is to attract contributors and allow them contribute to code and documentation at the same time.
Guidelines from this document are created to help new and existing contributors understand process workflow and align to project rules before pull request is submitted. It explains how a participant should do things like format code, test fixes, and submit patches.
## Where to get more information?
You can read more on our [documentation page](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/contributing/).
# How to contribute
We really appreciate your contributions! We are Open Source project and we need your help. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
Before a pull request will be merged, the [mbed Contributor Agreement](http://developer.mbed.org/contributor_agreement/) must be signed.
You can pick up existing [mbed-os GitHub Issue](https://github.com/ARMmbed/mbed-os/issues) and solve it or implement new feature you find important, attractive or just necessary. We will review your proposal via pull request mechanism, give you comments and merge your changes if we decide your contribution satisfy criteria such as quality.
# Enhancements vs Bugs
Enhancements are:
* New features implementation.
* Code refactoring.
* Coding rules, coding styles improvements.
* Code comments improvement.
* Documentation work.
Bugs are:
* Issues rose internally or externally by [ARMmbed/mbed-os](https://github.com/ARMmbed/mbed-os) users.
* Internally (within mbed team) created issues from Continuous Integration pipeline and build servers.
* Issues detected using automation tools such as compilers, sanitizers, static code analysis tools etc.
# Gate Keeper role
Gate Keeper is a person responsible for GitHub process workflow execution and is responsible for repository / project code base. Gate Keeper is also responsible for code (pull request) quality stamp and approves or rejects code changes in project’s code base.
Gate Keepers will review your pull request code, give you comments in pull request comment section and in the end if everything goes well merge your pull request to one of our branches (most probably default ```master``` branch).
Please be patient, digest Gate Keeper's feedback and respond promptly :)
# mbed SDK porting
* For more information regarding mbed SDK porting please refer to [mbed SDK porting](http://developer.mbed.org/handbook/mbed-SDK-porting) handbook.
* Before starting the mbed SDK porting, you might want to familiarize with the [mbed SDK library internals](http://developer.mbed.org/handbook/mbed-library-internals) first.
# Glossary
* Gate Keeper – persons responsible for overall code-base quality of [ARMmbed/mbed-os](https://github.com/ARMmbed/mbed-os) project.
* Enhancement – New feature deployment, code refactoring actions or existing code improvements.
* Bugfix – Issues originated from GitHub Issues pool, raised internally within mbed classic team or issues from automated code validators like linters, static code analysis tools etc.
* Mbed classic – mbed SDK 2.0 located in GitHub at [ARMmbed/mbed-os](https://github.com/ARMmbed/mbed-os).
# mbed OS code base
This is the code documentation for mbed OS.
For more information, please see:
* [The mbed OS API References](https://docs.mbed.com/docs/mbed-os-api-reference/)
* [The mbed OS Handbook](https://docs.mbed.com/docs/mbed-os-handbook/)
// List of targets to compile
def targets = [
//"LPC1768",
//"NUCLEO_F401RE",
//"NRF51822",
"K64F"
]
// Map toolchains to compiler labels on Jenkins
def toolchains = [
ARM: "armcc",
//IAR: "iar_arm",
GCC_ARM: "arm-none-eabi-gcc"
]
// mbed.getCurrentBranch returns either local branch name or reference to pull request
def currentBranch = mbed.getCurrentBranch()
// Create a map of predefined build steps
def parallelSteps = mbed.createParalleSteps("mbed-os", targets, toolchains)
// Run build steps parallel, map as paramater
mbed.compile(parallelSteps)
def testApps = [