Load your Custom Boot Logo to PineTime Smart Watch. Works with the PineTime MCUBoot Bootloader.
-
If our PineTime is not running on the MCUBoot Bootloader, flash the bootloader with PineTime Updater
-
Click
Fork
to fork this repo -
In the new repo, click
Actions
→I Understand My Workflows Enable Them
-
Click
Code
→Add File
→Upload Files
-
Upload a PNG image file with the following format...
-
Filename
pinetime-graphic.png
-
240 x 240 resolution
-
24-bit RGB color
-
See sample logos in
logos
-
-
GitHub Actions will auto-build the firmware (see the workflow)
-
Click
Actions
. Click on the latest build. -
Wait about 5 minutes for the build to complete.
Click on the Artifact named
my_sensor_app.img
-
Unzip the downloaded file.
Flash the unzipped firmware
my_sensor_app.img
to PineTime via PineTime Updater at address0x8000
-
When the firmware runs, it will write the Boot Logo to PineTime's External SPI Flash.
PineTime will show
Boot Logo Updated
-
Restore the PineTime firmware by flashing the latest InfiniTime firmware via PineTime Updater
-
PineTime will now boot with the new Boot Logo stored in External SPI Flash...
First ever Custom Boot Logo created by the PineTime Community
The Boot Logo format (RGB565) is explained here...
MCUBoot Bootloader for PineTime Smart Watch (nRF52)
The GitHub Actions Workflow calls pinetime-graphic
to convert the PNG image to C code (which is embedded in the firmware)...
github.com/lupyuen/pinetime-graphic
This repo is a Custom Firmware Build of pinetime-rust-mynewt
...
This master
branch contains the firmware source code for PineTime Smart Watch with Apache Mynewt and Embedded Rust, with Wireless Firmware Updates. Refer to the articles...
-
Build and Flash Rust+Mynewt Firmware for PineTime Smart Watch
-
Sneak Peek of PineTime Smart Watch… And why it's perfect for teaching IoT
-
Firmware Update over Bluetooth Low Energy on PineTime Smart Watch
-
Configure Mynewt for SPI Flash on PineTime Smart Watch (nRF52)
-
Wireless Firmware Update In Action on PineTime Smart Watch (nRF52)
-
Porting MicroPython and wasp-os to Mynewt on PineTime Smart Watch (nRF52)
-
Flutter State Management with Bloc for PineTime Companion App
The code structure is similar to the earlier article on nRF52...
Coding nRF52 with Rust and Apache Mynewt on Visual Studio Code
The MCUBoot Bootloader and Rust+Mynewt Firmware are built automatically in the GitHub Cloud.
Just fork this repo, update the source code and the built firmware will be available for download under "Actions".
The Automated Build is performed according to the following GitHub Actions Workflow...
The Worklow is similar to the one described in this article...
Build PineTime Firmware in the Cloud with GitHub Actions
If you are building from this repository from scratch instead of the Released Packages, here are the steps for Linux (including Raspberry Pi) and macOS...
-
Install OpenOCD from The xPack OpenOCD. Older versions of OpenOCD are known to have problems flashing with ST-Link.
Download and unzip OpenOCD for macOS:
gnu-mcu-eclipse-openocd-0.10.0-11-20190118-1134-macos.tgz
For Raspberry Pi: Install
openocd-spi
according to the instructions here... -
Install GCC and Python build tools for Linux (or the macOS equivalent)...
sudo apt install gcc gcc-arm-none-eabi python3 make
For Majaro and Arch Linux...
sudo pacman -S arm-none-eabi-gcc
-
Install
rustup
with support for nightly targetthumbv7em-none-eabihf
.Follow the instructions at https://rustup.rs/
Press Enter to select
1) Proceed with installation (default)
Then execute...
# Latest nightly-2020-04-20 fails with asm error, so we use nightly-2020-02-16 source $HOME/.cargo/env rustup update rustup default nightly rustup target add thumbv7em-none-eabihf
-
Install the
newt
build tool for Mynewt. Refer to these scripts...-
scripts/install-version.sh
: To set the version numbers -
scripts/install-pi.sh
: To build and installnewt
, look under the section"Build newt"
-
-
Download the source files to
~/pinetime
...mkdir ~/pinetime cd ~/pinetime git clone --recursive https://github.com/lupyuen/pinetime-rust-mynewt
-
Update the MCUBoot version number to 1.3.1. Edit
~/pinetime/pinetime-rust-mynewt/project.yml
Change...
repository.mcuboot: type: github vers: 1.5.0
to...
repository.mcuboot: type: github vers: 1.3.1
-
Download the source code for Mynewt, NimBLE and MCUBoot...
cd ~/pinetime/pinetime-rust-mynewt newt install
We should see...
Downloading repository mynewt-core (commit: master) from https://github.com/apache/mynewt-core.git Downloading repository mynewt-mcumgr (commit: master) from https://github.com/apache/mynewt-mcumgr.git Downloading repository mynewt-nimble (commit: master) from https://github.com/apache/mynewt-nimble.git Downloading repository mcuboot (commit: master) from https://github.com/JuulLabs-OSS/mcuboot.git Making the following changes to the project: install apache-mynewt-core (1.7.0) install apache-mynewt-nimble (1.2.0) install mcuboot (1.3.1) apache-mynewt-core successfully installed version 1.7.0 apache-mynewt-nimble successfully installed version 1.2.0 Error: Error updating "mcuboot": error: The following untracked working tree files would be overwritten by checkout: ext/mbedtls/include/mbedtls/check_config.h ext/mbedtls/include/mbedtls/config.h Please move or remove them before you switch branches. Aborting
Ignore the
mcuboot
error above and proceed to the next step. -
Restore the MCUBoot version number to 1.5.0. Edit
~/pinetime/pinetime-rust-mynewt/project.yml
Change...
repository.mcuboot: type: github vers: 1.3.1
to...
repository.mcuboot: type: github vers: 1.5.0
-
Download version 1.5.0 of MCUBoot to
repos/mcuboot
cd ~/pinetime/pinetime-rust-mynewt/repos rm -rf mcuboot git clone --recursive --branch v1.5.0 https://github.com/JuulLabs-OSS/mcuboot
Why are we doing this? Because we are using a more recent version of MCUBoot (1.5.0), but that's not in sync with the older Mynewt version (1.7.0). This will cause newt install
to fail. Hence we do this workaround to force Mynewt to build with the newer MCUBoot.
Build the MCUBoot Bootloader...
cd ~/pinetime/pinetime-rust-mynewt
scripts/nrf52/build-boot.sh
We should see...
Linking pinetime/pinetime-rust-mynewt/bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf
Target successfully built: targets/nrf52_boot
+ newt size -v nrf52_boot
Size of Application Image: app
Mem FLASH: 0x0-0x6000
Mem RAM: 0x20000000-0x20010000
FLASH RAM
90 229 *fill*
6823 5996 boot_bootutil.a
124 0 boot_mynewt.a
18 0 boot_mynewt_flash_map_backend.a
1182 0 crypto_mbedtls.a
392 444 hw_bsp_nrf52.a
52 0 hw_cmsis-core.a
1280 80 hw_drivers_flash_spiflash.a
654 1 hw_hal.a
4192 72 hw_mcu_nordic_nrf52xxx.a
2006 18776 kernel_os.a
1930 12 libc_baselibc.a
1478 256 libs_pinetime_boot.a
529 40 libs_semihosting_console.a
544 128 sys_flash_map.a
2 0 sys_log_modlog.a
632 29 sys_mfg.a
30 5 sys_sysinit.a
48 0 util_mem.a
100 0 nrf52_boot-sysinit-app.a
756 0 libgcc.a
Loading compiler pinetime/pinetime-rust-mynewt/repos/apache-mynewt-core/compiler/arm-none-eabi-m4, buildProfile debug
objsize
text data bss dec hex filename
22792 132 25504 48428 bd2c pinetime/pinetime-rust-mynewt/bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf
Edit ~/pinetime/pinetime-rust-mynewt/scripts/config.sh
If we're using ST-Link v2 for flashing PineTime, set swd_device
as follows...
# Select ST-Link v2 as SWD Programmer
swd_device=scripts/nrf52/swd-stlink.ocd
If we're using Raspberry Pi SPI for flashing PineTime, set swd_device
as follows...
# Select Raspberry Pi as SWD Programmer
swd_device=scripts/nrf52-pi/swd-pi.ocd
-
Edit
~/pinetime/pinetime-rust-mynewt/scripts/nrf52/flash-boot.sh
-
Change
openocd/bin/openocd
to the path of our installedopenocd
(for ST-Link) oropenocd-spi
(for Raspberry Pi)...# Flash the device openocd/bin/openocd \ -f $swd_device \ -f scripts/nrf52/flash-boot.ocd
-
The path of the built firmware file is defined in
~/pinetime/pinetime-rust-mynewt/scripts/nrf52/flash-boot.ocd
. We shouldn't need to change this.# For MCUBoot (debugging not supported): program bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf.bin verify 0x00000000
-
Flash the bootloader...
scripts/nrf52/flash-boot.sh
-
We should see...
> Executing task in folder pinetime-rust-mynewt: bash -c -l ' scripts/nrf52/flash-boot.sh && echo ✅ ◾ ️Done! ' < + source scripts/config.sh ++ swd_device=scripts/nrf52/swd-stlink.ocd + openocd/bin/openocd -f scripts/nrf52/swd-stlink.ocd -f scripts/nrf52/flash-boot.ocd GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-15-13:49) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html debug_level: 0 adapter speed: 1000 kHz force hard breakpoints Stopping... target halted due to breakpoint, current mode: Thread xPSR: 0x21000000 pc: 0x000023a4 msp: 0x2000ff9c Flashing Bootloader... target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000 Enabled ARM Semihosting to show debug output semihosting is enabled ** Programming Started ** auto erase enabled target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000001e msp: 0x20010000, semihosting wrote 24576 bytes from file bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf.bin in 0.729124s (32.916 KiB/s) ** Programming Finished ** ** Verify Started ** target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000002e msp: 0x20010000, semihosting verified 22876 bytes in 0.114145s (195.715 KiB/s) ** Verified OK ** Restarting... target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting **** Done!
-
For ST-Link, check that the Adapter Speed is set to 1000 kHz. OpenOCD won't work at higher speeds.
adapter speed: 1000 kHz
-
If the flashing fails, check whether any
openocd
processes are running in the background, and kill them.
-
Build the Application Firmware...
scripts/build-app.sh
If we see the error
Undefined main
, runscripts/build-app.sh
again. It should fix the error. -
Create the application firmware image...
scripts/nrf52/image-app.sh
-
Edit
~/pinetime/pinetime-rust-mynewt/scripts/nrf52/flash-app.sh
-
Change
openocd/bin/openocd
to the path of our installedopenocd
(for ST-Link) oropenocd-spi
(for Raspberry Pi)...# Flash the device openocd/bin/openocd \ -f $swd_device \ -f scripts/nrf52/flash-app.ocd
-
The path of the built firmware file is defined in
~/pinetime/pinetime-rust-mynewt/scripts/nrf52/flash-app.ocd
. We shouldn't need to change this.program bin/targets/nrf52_my_sensor/app/apps/my_sensor_app/my_sensor_app.img verify 0x00008000
-
Flash the application...
scripts/nrf52/flash-app.sh
-
We should see...
> Executing task in folder pinetime-rust-mynewt: bash -c -l ' scripts/nrf52/flash-app.sh && echo ✅ ◾ ️Done! ' < + source scripts/config.sh ++ swd_device=scripts/nrf52/swd-stlink.ocd + openocd/bin/openocd -f scripts/nrf52/swd-stlink.ocd -f scripts/nrf52/flash-app.ocd GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-15-13:49) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html debug_level: 0 adapter speed: 1000 kHz force hard breakpoints Stopping... target halted due to debug-request, current mode: Thread xPSR: 0x61000000 pc: 0x000001ca msp: 0x2000ffd8 Flashing Application... target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000 Enabled ARM Semihosting to show debug output semihosting is enabled ** Programming Started ** auto erase enabled target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000001e msp: 0x20010000, semihosting wrote 143360 bytes from file bin/targets/nrf52_my_sensor/app/apps/my_sensor_app/my_sensor_app.img in 3.606276s (38.821 KiB/s) ** Programming Finished ** ** Verify Started ** target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000002e msp: 0x20010000, semihosting verified 139268 bytes in 0.363909s (373.731 KiB/s) ** Verified OK **
-
For ST-Link, check that the Adapter Speed is set to 1000 kHz. OpenOCD won't work at higher speeds.
adapter speed: 1000 kHz
-
If the flashing fails, check whether any
openocd
processes are running in the background, and kill them. -
PineTime reboots (with the
reset init
OpenOCD Command)...Restarting... target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting Enabled ARM Semihosting to show debug output semihosting is enabled
-
PineTime starts MCUBoot Bootloader...
**** Done! Press Ctrl-C to exit... Starting Bootloader... Displaying image... Image displayed Check button: 0 [INF] Primary image: magic=good, swap_type=0x4, copy_done=0x1, image_ok=0x1 [INF] Scratch: magic=bad, swap_type=0x1, copy_done=0x2, image_ok=0x2 [INF] Boot source: none [INF] Swap type: none Waiting 5 seconds for button... Waited for button: 0 Bootloader done
-
Finally PineTime starts the Application Firmware...
TMP create temp_stub_0 NET hwid 4a f8 cf 95 6a be c1 f6 89 ba 12 1a NET standalone node
Alternatively, flash the following two files to PineTime with PineTime Updater...
-
MCUBoot Bootloader
File:
bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf
Address:
0x0
-
Rust+Mynewt Firmware
File:
bin/targets/nrf52_my_sensor/app/apps/my_sensor_app/my_sensor_app.elf
Address:
0x8000
Sample logs for Linux, macOS and Windows may be found in the logs folder
This repository contains...
rust
: Rust Application
Cargo.toml
: Rust Build Settings
.cargo
: Rust Target Settings
my_sensor_app
: Mynewt Application Stub
boot_stub
: Mynewt Bootloader Stub
adc_stm32f1
: Mynewt Driver for ADC on STM32 F103 (Blue Pill). Used by temp_stm32
internal temperature sensor.
adc_stm32l4
: Mynewt Driver for ADC on STM32 L476. Used by temp_stm32
internal temperature sensor.
bc95g
: Mynewt Driver for Quectel BC95 NB-IoT module
buffered_serial
: Buffered Serial Library used by bc95g
NB-IoT driver and gps_l70r
GPS driver
custom_sensor
: Custom Sensor Definitions for Raw Temperature and Geolocation
esp8266
: Mynewt Driver for ESP8266 WiFi module
gps_l70r
: Mynewt Driver for Quectel L70-R GPS module
hmac_prng
: HMAC pseudorandom number generator with entropy based on internal temperature sensor
low_power
: Low Power functions for STM32 F103 (Blue Pill)
mynewt_rust
: Helper functions for hosting Rust on Mynewt
nrf24l01
: Mynewt Driver for nRF24L01
remote_sensor
: Mynewt Driver for Remote Sensor
rust_app
: Stub library that will be replaced by the compiled Rust application and Rust crates
rust_libcore
: Stub library that will be replaced by the Rust Core Library
semihosting_console
: Mynewt Console for Arm Semihosting
sensor_coap
: Sensor CoAP Library
sensor_network
: Sensor Network Library
temp_stm32
: Mynewt Driver for Internal Temperature Sensor on STM32
temp_stub
: Mynewt Driver for Stub Temperature Sensor that returns a fixed value
tiny_gps_plus
: TinyGPS++ Library ported from Arduino. Used by gps_l70r
GPS driver.
scripts
: Install, build and deploy scripts
.vscode
: Visual Studio Code macros for install, build and deploy
The Windows version of the newt
command-line tool in newt/newt.exe
was created from
github.com/lupyuen/mynewt-newt
The Mynewt application was originally based on:
mynewt.apache.org/latest/tutorials/sensors/sensor_thingy_lis2dh12_onb.html
mynewt.apache.org/latest/tutorials/sensors/sensor_nrf52_bno055.html
cd /mnt/c
newt new stm32bluepill-mynewt-sensor
cd stm32bluepill-mynewt-sensor
cat project.yml
newt install
newt pkg new -t app apps/my_sensor_app
newt pkg new -t lib libs/semihosting_console
newt target create bluepill_boot
newt target set bluepill_boot bsp=@apache-mynewt-core/hw/bsp/bluepill
newt target set bluepill_boot app=@apache-mynewt-core/apps/boot
newt target set bluepill_boot build_profile=optimized
newt target create bluepill_my_sensor
newt target set bluepill_my_sensor bsp=@apache-mynewt-core/hw/bsp/bluepill
newt target set bluepill_my_sensor app=apps/my_sensor_app
newt target set bluepill_my_sensor build_profile=debug
project.yml
should contain
project.name: "my_project"
project.repositories:
- apache-mynewt-core
repository.apache-mynewt-core:
type: github
vers: 1.7.0
user: apache
repo: mynewt-core