This master
branch contains the firmware source code for PineTime Smart Watch with Apache Mynewt and Embedded Rust. 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
The code structure is similar to the earlier article on nRF52...
Coding nRF52 with Rust and Apache Mynewt on Visual Studio Code
If you are building from this repository from scratch instead of the Released Packages, here are the steps:
-
Install
rustup
with support for nightly targetthumbv7em-none-eabihf
. Also install Arm toolchaingcc-arm-none-eabi
and thenewt
build tool for Mynewt. Refer to this script... -
repos
folder should contain the Mynewt source code, installed by thenewt install
command:cd pinetime-rust-mynewt newt install
Ignore the error
Error: Error updating "mcuboot"
-
Check the
rust
folder for additional sub-repositories that should be cloned in order to build this project. -
Build the bootloader...
cd pinetime-rust-mynewt scripts/nrf52/build-boot.sh
-
Build the application...
scripts/build-app.sh
If you 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
-
Flash the bootloader...
scripts/nrf52-pi/flash-boot.sh
-
Flash the application and run it...
scripts/nrf52-pi/flash-app.sh
-
Check this article in case of problems...
Build and Flash Rust+Mynewt Firmware for PineTime Smart Watch
These fixes should be applied manually when upgrading Mynewt or installing Mynewt from scratch. They suppress the compiler warning messages that stop the Mynewt build for C++ source files.
1️⃣ repos/apache-mynewt-core/kernel/os/include/os/os_mutex.h
line 122
return mu->mu_level;
Change to
return (os_error_t) mu->mu_level;
2️⃣ repos/apache-mynewt-core/hw/sensor/include/sensor/sensor.h
line 847
return (sensor->s_types & sensor->s_mask & type);
Change to
return (sensor_type_t) (sensor->s_types & sensor->s_mask & type);
3️⃣ repos/apache-mynewt-core/encoding/tinycbor/include/tinycbor/cbor.h
line 201
{ return encoder->writer->bytes_written; }
Change to
{ return (CborError) encoder->writer->bytes_written; }
Sample logs for 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