Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 43 additions & 47 deletions Nordic Firmware - PAYG output and Thermometer/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Simusolar
## Airlink-Device Project
Airlink-Device Project was primarily focused on the new Bluetooth-enabled fishing light called NURU.
The project has been extended to host other sub-projects for PAYG control boxes that enable simusolar to have a financed model for not only fishing light customers but also for customers who need other products like pumps and solar refrigerators.
This project is based on nrf52 buttonless bootloader, though the project uses BL modules from Laird, the language used is C and not smart-basic.
The choice of C programming is due to its flexibility of it especially on writing the low-level drivers eg. GFX
The project illustrates temperature logging using NRF52 in-built temperature sensor and retrieval via bluetooth using Airlink protocol.

## Sub-Project SSL FL and it's Features
SSL FL is a project based on enabling fishermen to have a better fishing light.
Expand All @@ -15,25 +16,18 @@ This fishing light is compatible with Enaccess Airlink, this allows sharing of c
- 5.0 Bluetooth wireless (No gsm, data can be sent to a server via gsm enabled gateway)
- Other features

## Sub-Project PAYGLV, PAYGHV, PAYGFL (FL Charger) and it's Features
Todo
- Nexus Resource model compatible
- TODO

This project is based on nrf52 buttonless bootloader, though the project uses BL modules from Laird, the language used is C and not smart-basic.
The choice of C programming is due to its flexibility of it especially on writing the low-level drivers eg. GFX

## Tech

Simusolar FL uses several open-source projects to work properly:
This project uses several open-source projects to work properly:

- NRF52 SDK - Project built on top of it.
- Simusolar Airlink - This app acts as a gateway
- EnAccess Airlink App - This app acts as a gateway
- Nexus Keycode - This project provides access to PAYG features

## Installation

Simusolar FL requires [todo](https://) v17+ to run.
The project is built on top of NRF5 SDK, examples referenced by this project can be found inside the SDK using download link below.
SDK(https://www.nordicsemi.com/Products/Development-software/nrf5-sdk) v17+ to run.

Install the dependencies and devDependencies
```sh
Expand Down Expand Up @@ -63,7 +57,7 @@ There are two options:

Want to contribute? Great!

Simusolar-FL uses Keil MDK or GCC fast developing.
This Project uses Keil MDK or GCC fast developing.
Make a change in your file, compile and instantaneously see your updates!

For Debug, The project uses Segger J-link hardware and SWD pins.
Expand All @@ -84,7 +78,7 @@ Below Steps are necessary to get started.
a) For ARM-MDK (Windows) the way is straight and easy, however the advantages comes with high price.
Step1: Download and install keil from: https://www2.keil.com/mdk5
Step2: Install targets (nrf52832 and nrf52833) packages using package installer
Step3: Compile but don not load (project under either firmware\...\arm5_no_packs)
Step3: Compile but do not load (project under either firmware\...\arm5_no_packs)

b) For GCC (Windows), you have a long way to go.
Step1: Read carefully the resource attached: https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/development-with-eclipse-and-gcc
Expand All @@ -110,26 +104,20 @@ Below Steps are necessary to get started.

4. Learning Resources:
a) Advertising, service and characteristics:
https://www.notion.so/simusolar/Create-foundation-for-connectable-adverts-with-encoded-status-capability-on-FL-714c08c233634e0cbaf35c2066a77fcb
https://www.notion.so/simusolar/BL652-3-Formated-advertising-7ed4b6e1b26447f78c5ec367069d57df
SDK17: ble_peripheral\ble_app_blinky example

b) OTA Capability:
https://www.notion.so/simusolar/Create-foundation-for-OTA-capability-on-FL-443d547aedc44794af54007df8388989
SDK17: ble_peripheral\ble_app_buttonless_dfu example

c) Flash storage:
https://www.notion.so/simusolar/Foundational-for-data-storage-16bae219953a469ca5943bfeca5232c9
SDK17: peripheral\flash_fstorage example

d) Uart:
SDK17: ble_peripheral\ble_app_uart example

e) LCD and GFX Library:
SDK17: peripheral\gfx example
https://www.notion.so/simusolar/Customer-can-turn-SSL-fishing-light-on-off-and-view-status-fef5ddb0934044a6abe3538515e406c2
http://www.eran.io/the-dot-factory-an-lcd-font-and-image-generator/


f) Timers and rtc:
SDK17: peripheral\rtc example
SDK17: peripheral\timer example
Expand All @@ -140,75 +128,83 @@ g) GPIOs,buttons and LEDs
h) Temperature
SDK17: peripheral\temperature example

i) Battery decision and logic:
https://www.notion.so/simusolar/Create-low-power-mode-power-budget-for-Fishing-Light-for-BL653-fdff43ad9d1e47fabfa978dfc4b1ba49#09748d9f6ff14b7f815377282f962fce

j) CBOR:
i) CBOR:
https://en.wikipedia.org/wiki/CBOR
https://cbor.io/
https://cbor.me/

5) Important files and roles:
sdk_config.h: Master configuration file
ssl_config.h: SSL Based configuration
ssl_config.h: Second level configuration
ssl_global_variables.h: Master varibles and structures
```
#### Building for source

Simusolar-FL uses a secure bootloader, which requires both private and public keys.
The project uses a secure bootloader, which requires both private and public keys.
```sh
**Steps for keys creation:**
source: https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader

1. Download nrfutil from https://github.com/NordicSemiconductor/pc-nrfutil/releases

2. Generate a private key using the command: nrfutil.exe keys generate private.key
copy this file to \collectable\Working

3. Generate a public key using the command: nrfutil keys display --key pk --format code private.key --out_file public_key.c
3. Generate a public key using the command: nrfutil keys display --key pk --format code private.key --out_file dfu_public_key.c
copy this file to \firmware\dfu

4. Use Oberon crypto library instead of uECC in sdk_config.h change the following:
NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED to 0
NRF_CRYPTO_BACKEND_OBERON_ENABLED to 1
And remove micro_ecc_lib_nrf52.lib file in the project list.

5. Make an ota application:
a) nrf52832:
5. Make an ota application (for nrf52832 only):
nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52832_xxaa.hex --sd-req 0x0101 --key-file private.key app_dfu_package.zip
--sd-req 0x0101 ***** check documentation

6) To test, copy the file to the phone and use the nRf connect APP to flash the ble device using OTA.(for nrf52832 only)

b) nrf52833:

**Steps for merging the softdevice, bootloader and application into one file:**
I. Generate bootloader setting and Merge with bootloader:
nrfutil settings generate --family NRF52 --application nrf52832_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting652.hex

II. Start to merge:
a) with debug:
mergehex --merge nrf52832_xxaa_s132.hex bootloader_setting652.hex --output bootloader_with_setting652.hex
mergehex --merge bootloader_with_setting652.hex nrf52832_xxaa.hex --output bootloader_with_setting_app652.hex
mergehex --merge bootloader_with_setting_app652.hex s132_nrf52_7.2.0_softdevice.hex --output bl652_debug.hex

7. Make an ota application (for nrf52833 only):
nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52833_xxaa.hex --sd-req 0x0100 --key-file private.key 0pa1_dfu_package.zip
--sd-req 0x0100 ***** check documentation

6) To test, copy the file to the phone and use the nRf connect APP to flash the ble device using OTA.
8) To test, copy the file to the phone and use the nRf connect APP to flash the ble device using OTA. (for nrf52833 only)


**Steps for merging the softdevice, bootloader and application into one file:**
1. Generate bootloader setting and Merge with bootloader:
a) nrf52832:
nrfutil settings generate --family NRF52 --application nrf52832_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting652.hex

b) nrf52833:
I. Generate bootloader setting and Merge with bootloader:
nrfutil settings generate --family NRF52 --application nrf52833_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting.hex

2. Start to merge:
a) nrf52832 with debug:
mergehex --merge nrf52832_xxaa_s132.hex bootloader_setting652.hex --output bootloader_with_setting652.hex
mergehex --merge bootloader_with_setting652.hex nrf52832_xxaa.hex --output bootloader_with_setting_app652.hex
mergehex --merge bootloader_with_setting_app652.hex s132_nrf52_7.2.0_softdevice.hex --output bl652_debug.hex

b) nrf52833:
II. Start to merge:
a) nrf52833: without bootloader debug
mergehex --merge nrf52833_xxaa_s140.hex bootloader_setting.hex --output bootloader_with_setting.hex
mergehex --merge bootloader_with_setting.hex nrf52833_xxaa.hex --output bootloader_with_setting_app.hex
mergehex --merge bootloader_with_setting_app.hex s140_nrf52_7.2.0_softdevice.hex --output bootloader_with_setting_app_softdevice.hex

c) nrf52833 with debug:
b) nrf52833 with debug:
mergehex --merge nrf52833_xxaa_s140_debug.hex bootloader_setting.hex --output bootloader_with_setting_debug.hex
mergehex --merge bootloader_with_setting_debug.hex nrf52833_xxaa.hex --output bootloader_with_setting_app_debug.hex
mergehex --merge bootloader_with_setting_app_debug.hex s140_nrf52_7.2.0_softdevice.hex --output bl653_debug.hex
```
#### Using Build script in windows
The steps 5-8 above are summarized in build script that is available in \collectable\Flash.
The script uses Keil as primary compiler and gcc as secondary compiler.
If Keil is not available and you would wish to build using GCC, the line from 13-68 in build script can be removed, also the lines 90-96 should be modified by replacing arm5_no_packs by armgcc.


***** Make sure the said files are in the directory

## License

*Simusolar and Dev partners*
*MIT*
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@echo off
SET PROJECT_PATH=D:\Workspace\Simusolar\AIRLINK-DEVICE - OPEN SOURCE
SET WORKING_PATH=D:\Workspace\Simusolar\collectables\
cd..
cd..
SET PROJECT_PATH=%CD%
cd collectable\Working
SET WORKING_PATH=%CD%

cd /d "%PROJECT_PATH%\collectable\Flash"
attrib +r ble_build_all.bat
Expand Down Expand Up @@ -64,11 +67,34 @@ IF EXIST "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble_debug\
pause
)

REM Build gcc-based projects
@echo Start building from GCC
@echo off
REM Compile arm-mdk projects
cd /d "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10040\s132\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10100\s140\armgcc"
make

cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble_debug\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble_debug\armgcc"
make


REM Copy files to ouput, for now we use arm-mdk as primary compiler
copy "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10040\s132\arm5_no_packs\_build\nrf52832_xxaa.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble\arm5_no_packs\_build\nrf52832_xxaa_s132.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble_debug\arm5_no_packs\_build\nrf52832_xxaa_s132.hex" "%WORKING_PATH%\nrf52832_xxaa_s132_debug.hex"

copy "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10100\s140\arm5_no_packs\_build\nrf52833_xxaa.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble\arm5_no_packs\_build\nrf52833_xxaa_s140.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble_debug\arm5_no_packs\_build\nrf52833_xxaa_s140.hex" "%WORKING_PATH%\nrf52833_xxaa_s140_debug.hex"

REM Copy softdevice
copy "%PROJECT_PATH%\components\softdevice\s132\hex\s132_nrf52_7.2.0_softdevice.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\components\softdevice\s140\hex\s140_nrf52_7.2.0_softdevice.hex" "%WORKING_PATH%"
Expand All @@ -84,9 +110,6 @@ mergehex --merge nrf52832_xxaa_s132_debug.hex bootloader_setting652.hex --output
mergehex --merge bootloader_with_setting652.hex nrf52832_xxaa.hex --output bootloader_with_setting_app652.hex
mergehex --merge bootloader_with_setting_app652.hex s132_nrf52_7.2.0_softdevice.hex --output bl652_debug.hex

copy "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10100\s140\arm5_no_packs\_build\nrf52833_xxaa.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble\arm5_no_packs\_build\nrf52833_xxaa_s140.hex" "%WORKING_PATH%"
copy "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble_debug\arm5_no_packs\_build\nrf52833_xxaa_s140.hex" "%WORKING_PATH%\nrf52833_xxaa_s140_debug.hex"

cd /d "%WORKING_PATH%"
nrfutil settings generate --family NRF52 --application nrf52833_xxaa.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting.hex
Expand Down Expand Up @@ -165,22 +188,4 @@ copy "%WORKING_PATH%\bl652_debug_app_dfu_package.zip" "%PROJECT_PATH%\collectabl
copy "%WORKING_PATH%\bl653_debug_app_dfu_package.zip" "%PROJECT_PATH%\collectable\Flash\%today%_%mytime%_bl653_x_debug_ota_x_package.zip"
copy "%WORKING_PATH%\bl653_debug_app_dfu_package.zip" "%PROJECT_PATH%\collectable\Flash\%today%_%mytime%_bl653_x_airlink_x_dfu_package.zip"

REM Build gcc-based projects
@echo Start building from GCC
@echo off
REM Compile arm-mdk projects
cd /d "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10040\s132\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\ble_peripheral\ble_app_x_ota\pca10100\s140\armgcc"
make

cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10040_s132_ble_debug\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble\armgcc"
make
cd /d "%PROJECT_PATH%\firmware\dfu\secure_bootloader\pca10100_s140_ble_debug\armgcc"
make

pause
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIGusBRZ7l0dUOC3kQc/Tstqx3my4iE2dmy6pfnuk57fqoAoGCCqGSM49
AwEHoUQDQgAE3wHJeqpuF9P1AQjchuY/EqDrNU6hE9PojPhx9pbGeLk/ns3yYAPo
GJXqysTldp4HhdiJ/8iITHHvFZoWLHLf4A==
-----END EC PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x00000000 0x00080000 { ; load region size_region
ER_IROM1 0x00000000 0x00080000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}
RW_IRAM1 0x20000000 0x00020000 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x00800000 0x00020000 {
.ANY (+RW +ZI)
}
}

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# Compiled binaries
qcbortest
qcbormin

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
os:
- linux

language: c
compiler:
- gcc

env:
sudo: false
addons:
apt:
packages:
- make

install:
- make

script:
- ./qcbortest

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default:\
:langmap=c\:.c.h.function:\

Loading