Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JF002 committed Nov 10, 2020
2 parents 65ecb65 + f0e1f98 commit 04abc91
Show file tree
Hide file tree
Showing 193 changed files with 45,848 additions and 1,525 deletions.
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
.idea/
# CMake
cmake-build-*/
**/CMakeCache.txt
CMakeFiles/
**/CMakeCache.txt
cmake_install.cmake
Makefile

# Resulting binary files
*.a
*.so
*.s
*.hex
*.bin
!bootloader/bootloader-5.0.4.bin
*.map
*.out
pinetime*.cbp

# InfiniTime's files
core
sdk
src/Version.h
docker/post_build.sh
Testing/Temporary/

# Linux
**/.directory
Expand Down
31 changes: 31 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.10)
project(pinetime VERSION 0.8.2 LANGUAGES C CXX ASM)
project(pinetime VERSION 0.9.0 LANGUAGES C CXX ASM)

set(NRF_TARGET "nrf52")

if (NOT ARM_NONE_EABI_TOOLCHAIN_PATH)
message(FATAL_ERROR "The path to the toolchain (arm-non-eabi) must be specified on the command line (add -DARM_NONE_EABI_TOOLCHAIN_PATH=<path>")
message(FATAL_ERROR "The path to the toolchain (arm-none-eabi) must be specified on the command line (add -DARM_NONE_EABI_TOOLCHAIN_PATH=<path>")
endif ()

if (NOT NRF5_SDK_PATH)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ As of now, here is the list of achievements of this project:
## Documentation

### Develop
- [Generate the fonts and symbols](src/DisplayApp/Fonts/Readme.md)
- [Generate the fonts and symbols](src/displayapp/fonts/Readme.md)

### Build, flash and debug
- [Project branches](doc/branches.md)
- [Versioning](doc/versioning.md)
- [Files included in the release notes](doc/filesInReleaseNotes.md)
- [Build the project](doc/buildAndProgram.md)
- [Flash the firmware using OpenOCD and STLinkV2](doc/openOCD.md)
- [Build the project with Docker](doc/buildWithDocker.md)
- [Bootloader, OTA and DFU](./bootloader/README.md)
- [Stub using NRF52-DK](./doc/PinetimeStubWithNrf52DK.md)
Expand Down
2 changes: 1 addition & 1 deletion bootloader/ota-dfu-python/nrf_ble_dfu_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _get_handles(self, uuid):
self.ble_conn.sendline('characteristics')

try:
self.ble_conn.expect([uuid], timeout=2)
self.ble_conn.expect([uuid], timeout=10)
handles = re.findall(b'.*handle: (0x....),.*char value handle: (0x....)', self.ble_conn.before)
(handle, value_handle) = handles[-1]
except pexpect.TIMEOUT as e:
Expand Down
4 changes: 2 additions & 2 deletions doc/MemoryAnalysis.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Memory analysis
## FreeRTOS heap and task stack
FreeRTOS statically allocate its own heap buffer in a global variable named `ucHeap`. This is an aray of *uint8_t*. Its size is specified by the definition `configTOTAL_HEAP_SIZE` in *FreeRTOSConfig.h*
FreeRTOS statically allocate its own heap buffer in a global variable named `ucHeap`. This is an array of *uint8_t*. Its size is specified by the definition `configTOTAL_HEAP_SIZE` in *FreeRTOSConfig.h*
FreeRTOS uses this buffer to allocate memory for tasks stack and all the RTOS object created during runtime (timers, mutexes,...).

The function `xPortGetFreeHeapSize()` returns the amount of memory available in this *ucHeap* buffer. If this value reaches 0, FreeRTOS runs out of memory.
Expand Down Expand Up @@ -75,4 +75,4 @@ add_definitions(-D__STACK_SIZE=8192)
*TODO*

#Tools
- https://github.com/eliotstock/memory : display the memory usage (FLASH/RAM) using the .map file from GCC.
- https://github.com/eliotstock/memory : display the memory usage (FLASH/RAM) using the .map file from GCC.
2 changes: 1 addition & 1 deletion doc/buildAndProgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CMake configures the project according to variables you specify the command line

Variable | Description | Example|
----------|-------------|--------|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/`|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2020-q2-update/`|
**NRF5_SDK_PATH**|path to the NRF52 SDK|`-DNRF5_SDK_PATH=/home/jf/nrf52/Pinetime/sdk`|
**USE_JLINK, USE_GDB_CLIENT and USE_OPENOCD**|Enable *JLink* mode, *GDB Client* (Black Magic Probe) mode or *OpenOCD* mode (set the one you want to use to `1`)|`-DUSE_JLINK=1`
**CMAKE_BUILD_TYPE**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug`
Expand Down
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: 21 additions & 1 deletion doc/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,24 @@ Then, you can submit a pull-request for review. Try to describe your pull reques

Other contributors can post comments about the pull request, maybe ask for more info or adjustements in the code.

Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware.
Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware.

# Coding convention
## Language
The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction.

It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK.

## Coding style
The most important rule to follow is to try to keep the code as easy to read and maintain as possible.

- **Identation** : 2 spaces, no tabulation
- **Opening brace** at the end of the line
- **Naming** : Choose self-describing variable name
- **class** : PascalCase
- **namespace** : PascalCase
- **variable** : camelCase, **no** prefix/suffix ('_', 'm_',...) for class members
- **Include guard** : `#pragma once` (no `#ifdef __MODULE__ / #define __MODULE__ / #endif`)
- **Includes** :
- files from the project : `#include "relative/path/to/the/file.h"`
- external files and std : `#include <file.h>`
2 changes: 1 addition & 1 deletion doc/filesInReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This firmware is intended to be used with our [MCUBoot-based bootloader](../boot

The following files are not directly usable by the bootloader:

- **pinetime-mcuboot-app.bin** : Output file of GCC containing debug symbols, useful is you want to debug the firmware using GDB.
- **pinetime-mcuboot-app.out** : Output file of GCC containing debug symbols, useful is you want to debug the firmware using GDB.
- **pinetime-mcuboot-app.hex** : Firmware in Intel HEX file format.
- **pinetime-mcuboot-app.bin** : Firmware in binary format.
- **pinetime-mcuboot-app.map** : Map file containing all the symbols, addresses in memory,...
Expand Down
105 changes: 105 additions & 0 deletions doc/openOCD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# OpenOCD and STLink
OpenOCD (**Open O**n **C**hip **D**ebugger) is an open source tool that interfaces with many SWD/JTAG debugger to provide debugging and *in-system* programming for embedded target devices.

It supports the **NRF52** (the CPU of the PineTime) and the **STLinkV2**, a cheap SWD debugger.

It works on X86 computers, as well as ARM/ARM64 computers and SBC (like the RaspberryPi and Pine64 Pinebook Pro) !

## Installation
We will build OpenOCD from sources, as packages from Linux distributions are most of the time outdated and do not support the NRF52 correctly.

- Fetch the sources from GIT, and build and install it:

```
git clone https://git.code.sf.net/p/openocd/code openocd-code
cd openocd-code
./bootstrap
./configure --enable-stlink
make -j 4
sudo make install
```

- Configure UDEV to allow OpenOCD to open the interface to your STLinkV2:
```
sudo cp contrib/60-openocd.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
```

- You can now plug your STLinkV2 in a USB port and run OpenOCD to see if it's working correctly:

```
$ openocd -f interface/stlink.cfg -f target/nrf52.cfg
Open On-Chip Debugger 0.10.0+dev-01411-g051e80812-dirty (2020-09-28-20:16)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
nRF52 device has a CTRL-AP dedicated to recover the device from AP lock.
A high level adapter (like a ST-Link) you are currently using cannot access
the CTRL-AP so 'nrf52_recover' command will not work.
Do not enable UICR APPROTECT.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J34S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.294340
Error: init mode failed (unable to connect to the target)
```
Ok, OpenOCD is running and it detects my STLinkV2. The last error shows that I've not connected the STLinkV2 to the PineTime.

## Configuration files
OpenOCD is configured using configuration files.
First, we need a common configuration file for the project : **openocd-stlink.ocd**:
```
source [find interface/stlink.cfg]
gdb_flash_program enable
gdb_breakpoint_override hard
source [find target/nrf52.cfg]
```
This file specifies to OpenOCD which debugger and target it will be connected to..

Then, we use various *user files* to use OpenOCD to flash InfiniTime binary files.

This files flashes the bootloader and the application firmware : **flash_bootloader_app.ocd**:
```
init
program <build directory>/bootloader.bin verify 0x00000000
program <build directory>/image-0.8.2.bin verify 0x00008000
reset
```

And this one flashes the graphics flasher (it writes the bootloader graphics into the SPI NOR flash memory) : **flash_graphics.ocd**:
```
init
program <build directory>/pinetime-graphics-0.8.2.bin verify 0x00000000
reset
```

## Examples
### Flash bootloader and application
```
openocd -f ./openocd-stlink.cfg -f ./flash_bootloader_app.ocd
```

### Flash graphics flasher
```
openocd -f ./openocd-stlink.cfg -f ./flash_graphics.ocd
```

## Connect the STLinkV2 to the PineTime
Here is an example using the pogo pins:
![SWD pinout](../images/swd_pinout.jpg)
![Pogo pins](../images/pogopins.jpg)

You can find more information about the SWD wiring [on the wiki](https://wiki.pine64.org/index.php?title=PineTime_devkit_wiring).
Binary file added images/pogopins.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/swd_pinout.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 04abc91

Please sign in to comment.