Skip to content

Commit

Permalink
samples: swap libopencm3 and gecko-sdk
Browse files Browse the repository at this point in the history
Use libopencm3 instead of the gecko-sdk, because it is maintained and
easier to use, as well as being more full-featured.

Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs committed Apr 24, 2018
1 parent 92a9785 commit 09750d0
Show file tree
Hide file tree
Showing 53 changed files with 117 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
@@ -1,3 +1,3 @@
[submodule "libopencm3-samples/libopencm3"]
path = libopencm3-samples/libopencm3
[submodule "libopencm3"]
path = libopencm3
url = https://github.com/libopencm3/libopencm3
File renamed without changes.
File renamed without changes.
77 changes: 22 additions & 55 deletions Makefile
@@ -1,57 +1,24 @@
# Copyright 2016 Google Inc.
#
# 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.

################################################################################
#
# Gecko
#
LSCRIPT = tomu.ld
GECKO_SDK_REV = v5.0.0

################################################################################
#
# PHONY TARGETS
#
.PHONY: all blinky check clean deps

all:
make -C efm32hg-blinky
make -C efm32hg-blinky-usb
all: libopencm3-samples
@true

libopencm3-samples:
git submodule init
git submodule update
make -C libopencm3
make -C miniblink
make -C usb_cdcacm
make -C usb_hid
make -C usb_msc
make -C usb_midi
make -C usb_simple

clean:
make -C efm32hg-blinky clean
make -C efm32hg-blinky-usb clean
@echo "Cleaning Gecko_SDK files..."
@find Gecko_SDK -type f -name \*.bin -delete
@find Gecko_SDK -type f -name \*.dump -delete
@find Gecko_SDK -type f -name \*.d -delete
@find Gecko_SDK -type f -name \*.elf -delete
@find Gecko_SDK -type f -name \*.map -delete
@find Gecko_SDK -type f -name \*.o -delete


dist-clean:
make clean || true
rm -rf Gecko_SDK
rm tomu.ld

deps:
@if [ ! -d Gecko_SDK ]; then \
git clone --depth 1 https://github.com/SiliconLabs/Gecko_SDK --branch ${GECKO_SDK_REV}; \
fi
@if [ ! -f "${LSCRIPT}" ]; then \
echo "Patching linker file to ${LSCRIPT}"; \
patch -o ${LSCRIPT} Gecko_SDK/platform/Device/SiliconLabs/EFM32HG/Source/GCC/efm32hg.ld linker.patch; \
fi

make -C libopencm3 clean
make -C miniblink clean
make -C usb_cdcacm clean
make -C usb_hid clean
make -C usb_msc clean
make -C usb_midi clean
make -C usb_simple clean

.PHONY: libopencm3-samples
62 changes: 36 additions & 26 deletions README.md
@@ -1,41 +1,51 @@
# tomu-samples

## What are these:
# Tomu Samples

These projects are simple programs for the [Tomu](http://tomu.im). They do
various things, and are intended to offer code examples and simple testing to
ease your introduction to the Tomu platform.

## How to use:
These are based on the libopencm3 library. To build projects using the `Gecko_SDK` provided by Silicon Labs, see the [gecko-sdk](./gecko-sdk) directory.

## libopencm3

[libopencm3](http://libopencm3.org/) is an Open-Source lowlevel hardware
library for ARM Cortex-M3 microcontrollers (but also M0, M4 are supported and
more to come).

Upstream libopencm3 now supports the EFM32HG. The examples located here
were modified to support the EFM32HG and tested on the Tomu with a Linux host:

* A USB-Serial CDCACM device example (`usb_cdcacm`)
* A USB HID mouse emulation example (`usb_hid`)
* A USB Mass Storage Device example (`usb_msc`)
* A USB MIDI example (`usb_midi`)
* A raw endpoint example with a sample python program that controls an LED

## Building

1. To compile these, you'll need a cross-compiling toolchain to arm-none-eabi.
* Debian/Ubuntu/... : `sudo apt-get install gcc-arm-none-eabi`
* Fedora : `sudo yum install arm-none-eabi-gcc-cs arm-none-eabi-newlib`
* Arch : `sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib`
* Other Linux : check your package manager, or
* Anything else (Windows, OSX, Linux): [https://developer.arm.com/open-source/gnu-toolchain/gnu-rm](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm)
1. Run `make` to build all examples

- Debian/Ubuntu/... : `sudo apt-get install gcc-arm-none-eabi`
- Fedora : `sudo yum install arm-none-eabi-gcc-cs arm-none-eabi-newlib`
- Arch : `sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib`
- Other Linux : check your package manager, or
- Anything else (Windows, OSX, Linux) : [https://developer.arm.com/open-source/gnu-toolchain/gnu-rm ](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm )
## Bootloader assumptions

If the cross compiling toolchain is in your PATH then the Makefile will
auto-detect it; else (or to override it) specify it using the environment
variable "CROSS_COMPILE".
There might be additional dependencies, depending on which specific project
you're using, and the instructions for compilation are included in each
project's README.md
These examples are compatible with the non-DFU serial AN0042 bootloader. They will run in legacy mode with a DFU-enabled bootloader, such as the one shipped on v0.4 boards. They run from flash offset 0x4000, and do not auto-boot. To get back into the bootloader, reset the board (e.g. by unplugging it and plugging it back in).

2. Run `make deps .` to patch the linker with support for the Tomu and clone the [Gecko SDK](https://github.com/SiliconLabs/Gecko_SDK) locally
If you have a DFU-enabled bootloader, upload programs using `dfu-util`. For example, to upload miniblink, run:

3. Now you can build the examples
````
dfu-util -d 1209:70b1 -D ./usb_hid/usb_hid.bin
````

## Flashing:
If you're using the serial bootloader, upload the binary using XMODEM.

Once you've compiled the code, you can flash the Tomu using `minicom` on linux
and OSX, or some other serial I/O utility on Windows. To do that, set it up with
`115200 8n1`, then use `i` to show the bootloader version.
## License

To upload the binary, press `u`, wait till the bootloader replies with `Ready`,
then press `^A-S`, choose XMODEM, choose the `.bin` file produced by the
compilation, and wait until it's uploaded.
The libopencm3 code & examples are released under the terms of the GNU Lesser
General Public License (LGPL), version 3 or later.

Once that's done, press `b` to boot into the firmware. The bootloader will hang
for 5-7 seconds, then the Tomu will boot.
See COPYING.GPL3 and COPYING.LGPL3 for details.
File renamed without changes.
57 changes: 57 additions & 0 deletions gecko-sdk/Makefile
@@ -0,0 +1,57 @@
# Copyright 2016 Google Inc.
#
# 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.

################################################################################
#
# Gecko
#
LSCRIPT = tomu.ld
GECKO_SDK_REV = v5.0.0

################################################################################
#
# PHONY TARGETS
#
.PHONY: all blinky check clean deps

all:
make -C efm32hg-blinky
make -C efm32hg-blinky-usb

clean:
make -C efm32hg-blinky clean
make -C efm32hg-blinky-usb clean
@echo "Cleaning Gecko_SDK files..."
@find Gecko_SDK -type f -name \*.bin -delete
@find Gecko_SDK -type f -name \*.dump -delete
@find Gecko_SDK -type f -name \*.d -delete
@find Gecko_SDK -type f -name \*.elf -delete
@find Gecko_SDK -type f -name \*.map -delete
@find Gecko_SDK -type f -name \*.o -delete


dist-clean:
make clean || true
rm -rf Gecko_SDK
rm tomu.ld

deps:
@if [ ! -d Gecko_SDK ]; then \
git clone --depth 1 https://github.com/SiliconLabs/Gecko_SDK --branch ${GECKO_SDK_REV}; \
fi
@if [ ! -f "${LSCRIPT}" ]; then \
echo "Patching linker file to ${LSCRIPT}"; \
patch -o ${LSCRIPT} Gecko_SDK/platform/Device/SiliconLabs/EFM32HG/Source/GCC/efm32hg.ld linker.patch; \
fi

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions libopencm3-samples/Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions libopencm3-samples/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 09750d0

Please sign in to comment.