Coder Social home page Coder Social logo

bosmoment / pinetime-apps Goto Github PK

View Code? Open in Web Editor NEW
79.0 15.0 32.0 965 KB

Firmware for the PineTime based on RIOT, NimBLE and LittleVGL

License: GNU Lesser General Public License v2.1

Makefile 0.88% C 99.12%
pinetime embedded nimble littlevgl c littlefs riot riot-os

pinetime-apps's Introduction

Build Status

Bosmoment-style Pinetime firmware applications

Friendly firmware applications for the Pinetime!

This repository contains a number of applications and helper modules specific for the PineTime open source smartwatch.

Highlights:

  • Built on top of RIOT, an open source embedded operating system
  • Apache NimBLE as an open-source bluetooth 5.0 stack.
  • LittlevGL for the user interface.

Pre-build Binaries

Fresh binaries from the CI:

Features

  • Bluetooth LE: provided by Nimble
  • Bluetooth pairing support
  • Time synchronisation: Bluetooth GATT Current Time Service client
  • Time keeping: nRF52832 RTC for ticks per second time/date updates
  • Graphical user interface: via LittleVGL.
  • Touch screen driver: a cst816s touch screen driver with gesture support is included in the RIOT fork

And the default watch face screen includes:

  • Time/date: Both time and date are shown on the main watch face with the time taking up the majority of the space.
  • Battery status: Battery status is available on the main screen
  • Bluetooth status: Bluetooth connection and advertisement mode is shown on the screen

Multiple watch faces are supported with smooth scrolling between the different faces. For now two dummy watch faces, one for notifications and one for activity, are included as proof of concept.

Structure

The project is separated into a number of directories:

  • RIOT: The RIOT submodule used for compilation
  • apps: Contains firmware applications for the PineTime.
  • modules: Additional modules written to support the firmware applications
  • widgets: A collection of small user applications or watch faces for the end user of the PineTime, for example: a stopwatch widget; a configuration widget; a heartbeat graph widget, a notification watch face.

Getting started

Repository setup

When checking out this repository, don't forget to initialize the RIOT submodule contained within this repository with:

git submodule init
git submodule update

Building applications

Applications are contained in the apps dir with a single application per directory. The pinetime application should give you a good starting point.

Use make all in the application directory to build the firmware, make flash to flash it on the target and make term to get a serial connection to the device.

Development

As the project is based on RIOT, it helps to get familiar with RIOT and check which functionality is provided by the OS. There is a quick start guide available for RIOT to get familiar with RIOT's build system and to validate your toolchain functionality. Doxygen-based API documentation is also available there.

Currently the Segger J-Link tools are used for flashing the application. It is possible to use a different programmer by overriding the settings in the Makefile.include for the pinetime board in the RIOT tree.

Bluetooth LE

Currently the firmware is always advertising if no connection is active. As soon as a host connects to the PineTime, the advertising is stopped and continues when the host disconnects.

Bonding is available and useable, but the bonds are not persistent between reboots. (see Planned features).

A custom UUID is included in the advertisement to recognise the device by:

9851dc0a-b04a-1399-5646-3b38788cb1c5

This UUID can be used for Bluetooth LE filters in Android and such. The device name itself can be customized to your liking and is not used for identifying the device.

Companion phone app

A fork of GadgetBridge is available with support for this firmware. The fork uses the custom UUID specified above to filter and identify the device.

The GadgetBridge app should pick up the device when scanning and allow pairing with the device. As long as the PineTime remembers the bond, the app and the Pinetime should be able to restore the secure connection.

The GadgetBridge fork is configured to only allow encrypted reads to the current time characteristic. The PineTime firmware automatically requests pairing when it receives an insufficient encryption error back from the app when requesting the time.

Tips

  • STDIO is implemented via the Segger RTT protocol. It is non-blocking by default, blocking mode can be enabled by adding STDIO_RTT_ENABLE_BLOCKING_STDOUT to the CFLAGS. Note: the firmware will block (hang) on STDIO if no RTT client is attached.

  • The directory where a RIOT tree is expected can be overridden by setting the RIOTBASE variable in the application makefile or from the command line.

  • A fork of the Android GadgetBridge application is available with basic support for this RIOT PineTime application.

  • By default the watchdog timer is running with a 5 second timeout. Every second the controller will kick the watchdog timer to reset the timeout, unless the button is pressed. A long press of the button will effectively cause a watchdog timer reset of the system.

Planned features

  • Device side Bluetooth key code confirmation (Only the host verifies the pairing code at the moment, the firmware always confirms the code as valid)
  • Persistent Bluetooth bonds
  • Secure over the air updates

pinetime-apps's People

Contributors

bergzand avatar danielkucera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinetime-apps's Issues

Hard faults

I'll start collecting my hard-faults here:

(gdb) bt
#0  hard_fault_handler (sp=0x20000200 <heap_top>, corrupted=1, exc_return=4294967281, r4_to_r11_stack=0x200001e0 <isr_stack+480>)
    at /storage/Projects/pinetime/PineTime-apps/RIOT/cpu/cortexm_common/vectors_cortexm.c:344
#1  0x0000040e in isr_pendsv () at /storage/Projects/pinetime/PineTime-apps/RIOT/cpu/cortexm_common/thread_arch.c:284
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info registers
r0             0xffffffff	-1
r1             0x2	2
r2             0x2861443	42341443
r3             0x92000000	-1845493760
r4             0x20000200	536871424
r5             0x0	0
r6             0x0	0
r7             0x92	146
r8             0x1	1
r9             0x2000094c	536873292
r10            0x200001e0	536871392
r11            0xfffffff1	-15
r12            0x2	2
sp             0x20000180	0x20000180 <isr_stack+384>
lr             0x597	1431
pc             0x5d4	0x5d4 <hard_fault_handler+108>
xPSR           0x21000003	553648131
fpscr          0x0	0
msp            0x20000180	0x20000180 <isr_stack+384>
psp            0x200009f0	0x200009f0 <sched_threads+40>
primask        0x0	0
basepri        0x0	0
faultmask      0x0	0
control        0x0	0

a.zip

Document flash layout and handling

As of yesterday, the flash chip is formatted and written with the layout specified on the wiki. This should be indicated in the README to warn potential users about overwriting their flash content.

Wake SPI NOR Flash during init

The default firmware puts the SPI NOR flash chip in deep sleep mode. Something the firmware here should also do. However, the current firmware does not wake the flash chip and will try to initialize it while it is in deep sleep. This causes errors during init if the SPI NOR flash is not power cycled after removing the stock firmware.

Change `CONFIG_GUI_SCREEN_TIMEOUT` to milliseconds

Microsecond resolution for configuring the screen timeout is a bit too much. Millisecond or seconds make more sense and are less error prone. It should also get some documentation as it is an important configuration setting.

Gadgetbridge

Could you share back your adjustment made for Gadgetbridge support to the original project, please? There's a user request for that. And wouldn't it be good to have that stuff "upstream"? ๐Ÿ˜ƒ Thanks in advance!

Disable font compression

The font compression enabled for the 80pt font considerably slows down the rendering of the default font face. Quick tests showed that the compression does not impact the flash size that much and is not worth the tradeoff between flash size and rendering speed.

documentation: add riot-os tag

Hi! Really cool project, I was looking for RIOT examples and it took me while to find this, I think it could be more visible if tags like riot-os, riot, etc.. where added to the project! Cheers!

openocd

Hi,
Any way to flash with openocd? Super new to this and I got the stuff working under pinetime-rust-mynewt but dont know how to apply what I learned there to flash this and try it out.

PineTime stays black after flashing

I cloned your repo and building the firmware with make all worked fine.
Then I wanted to flash the PineTime.bin to my watch by using this and that method. No obvious errors.

Output of second method is:

Open On-Chip Debugger 0.10.0+dev-01130-g9d1b46f5 (2020-04-17-15:25)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
force hard breakpoints
Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
Info : clock speed 31200 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Stopping...
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x000018be psp: 0x2000b4f0

Flashing Bootloader...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000004dc msp: 0x20000200
Enabled ARM Semihosting to show debug output
** Programming Started **
Info : nRF52832-QFAA(build code: E0) 512kB Flash, 64kB RAM
Warn : Adding extra erase range, 0x0003e6fc .. 0x0003efff
** Programming Finished **
** Verify Started **
** Verified OK **

Restarting...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000004dc msp: 0x20000200, semihosting

**** Done!

When I now want to turn on my watch with long-press or just by pressing the button, the display stays black - nothing happens.

I used your prebuilt binaries with the same result.

Only this firmware worked so far.

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.