mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-24 02:03:48 +00:00
Compare commits
56
Commits
0.9.2-otafix1
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5aa44bfe1d | ||
|
|
5b8b3fcea2 | ||
|
|
7b1cac6221 | ||
|
|
14d8f3f94b | ||
|
|
f7d1778fb0 | ||
|
|
55d32ba6da | ||
|
|
4b29e6e836 | ||
|
|
96b3e473ea | ||
|
|
a62825be47 | ||
|
|
d2a6c95506 | ||
|
|
04a1315cbb | ||
|
|
8fc85e7ddb | ||
|
|
e6c7f4600d | ||
|
|
dde7c96665 | ||
|
|
038ae7e111 | ||
|
|
ee88df71b8 | ||
|
|
d4a604e48d | ||
|
|
0c0ef4075c | ||
|
|
bc9b190ab2 | ||
|
|
91b336dfee | ||
|
|
ef2114d012 | ||
|
|
da9a778564 | ||
|
|
0325b7f1bb | ||
|
|
1d8194f44f | ||
|
|
08f0f902ea | ||
|
|
287f68ef5f | ||
|
|
c18884724a | ||
|
|
3fa9ed7235 | ||
|
|
e49b3fd2e4 | ||
|
|
51f241024e | ||
|
|
241675ea0d | ||
|
|
656585e9d2 | ||
|
|
711e6d7e22 | ||
|
|
54a9e85788 | ||
|
|
5cb23173c6 | ||
|
|
7e69127005 | ||
|
|
02fc9bdeb9 | ||
|
|
db8dc4d720 | ||
|
|
afc721a5d8 | ||
|
|
6e6c9c6725 | ||
|
|
d0ce3f8ba9 | ||
|
|
cbe95f8832 | ||
|
|
addc04d999 | ||
|
|
68975fc585 | ||
|
|
4774154467 | ||
|
|
1f47704642 | ||
|
|
11e390be4c | ||
|
|
f2ff6c88d1 | ||
|
|
8fd6845784 | ||
|
|
1aa95b4ee5 | ||
|
|
f9f9f51424 | ||
|
|
557f9cbdc6 | ||
|
|
d0d107df3e | ||
|
|
903a05177e | ||
|
|
d130299e54 | ||
|
|
7215059fae |
No files matched your search
@@ -0,0 +1 @@
|
||||
ko_fi: oltaco
|
||||
@@ -1,12 +1,14 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
# pull_request:
|
||||
# push:
|
||||
# repository_dispatch:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
set-matrix:
|
||||
@@ -15,7 +17,7 @@ jobs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set matrix
|
||||
id: set-matrix
|
||||
@@ -34,7 +36,7 @@ jobs:
|
||||
board: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
@@ -53,16 +55,34 @@ jobs:
|
||||
make BOARD=${{ matrix.board }} all
|
||||
make BOARD=${{ matrix.board }} copy-artifact
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: _bin/${{ matrix.board }}
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
draft-release:
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Collect all board artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
path: _bin
|
||||
merge-multiple: true
|
||||
|
||||
- name: List collected files
|
||||
run: ls -lR _bin
|
||||
|
||||
- name: Create draft release
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
files: |
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.zip
|
||||
_bin/${{ matrix.board }}/${{ matrix.board }}_bootloader-*.hex
|
||||
_bin/${{ matrix.board }}/update-${{ matrix.board }}_bootloader-*.uf2
|
||||
_bin/*_bootloader-*.zip
|
||||
_bin/*_bootloader-*.hex
|
||||
_bin/update-*_bootloader-*.uf2
|
||||
@@ -65,3 +65,10 @@ TAGS
|
||||
|
||||
.DS_Store
|
||||
Makefile.user
|
||||
|
||||
# Python virtual environments
|
||||
venv/
|
||||
.python-version
|
||||
lib/python3.13/
|
||||
lib64
|
||||
pyvenv.cfg
|
||||
@@ -1,67 +1,211 @@
|
||||
# Adafruit nRF52 Bootloader with Enhanced OTA DFU
|
||||
|
||||
# Adafruit nRF52 Bootloader w/ Enhanced OTA DFU
|
||||
## Changes in OTAFIX 2.3
|
||||
- **ST7735 Display support**
|
||||
Added ST7735 display driver and refactored display code to allow for configuring different display sizes at the board level.
|
||||
|
||||
The purpose of this fork is to include a few additions/fixes to the bootloader BLE OTA code for NRF52840 based devices which I've noticed around github.
|
||||
- **New boards**
|
||||
Heltec T096
|
||||
Heltec T1
|
||||
RAK 3401
|
||||
|
||||
## Changes in OTAFIX 2.2
|
||||
|
||||
- **Use maximum TX power for BLE**
|
||||
Changed BLE TX power to be set to +8 for nRF52840.
|
||||
|
||||
- **New boards**
|
||||
Elecrow ThinkNode M1, M3, M6
|
||||
LilyGo T-Echo
|
||||
Minewsemi MX25LE01
|
||||
Seeed SenseCAP Solar Node P1
|
||||
|
||||
## Changes in OTAFIX 2.1
|
||||
|
||||
- **Defaults to OTA DFU mode**
|
||||
When no valid application is present, the bootloader defaults to OTA DFU mode.
|
||||
This prevents devices from becoming stuck in UF2 mode after a failed OTA update.
|
||||
|
||||
- **High-MTU BLE support**
|
||||
Enables larger DFU packets for improved throughput when supported by the client.
|
||||
The Android DFU app and [`dfu.py`](https://github.com/recrof/nrf_dfu_py) support large packets; the iOS DFU app is limited to 20-byte packets.
|
||||
|
||||
- **Lazy flash erase**
|
||||
Flash pages are erased on demand during the transfer instead of upfront, significantly reducing the delay during DFU initialisation before the transfer begins.
|
||||
|
||||
- **Small-packet accumulation**
|
||||
Packets smaller than 64 bytes are combined at the transport layer and written to flash in chunks of up to 240 bytes.
|
||||
This improves OTA performance from iOS devices and other small-packet DFU hosts by reducing flash write overhead.
|
||||
|
||||
- **Automatic application boot after OTA over USB**
|
||||
When connected to a USB host, devices now automatically reboot into the application after a successful OTA update, instead of requiring a manual reset.
|
||||
|
||||
- **Unique BLE advertising names per board**
|
||||
In OTA DFU mode, devices advertise using a board-specific name instead of the generic `AdaDFU`.
|
||||
See the [BLE advertising names](#ble-advertising-names) section for the current names.
|
||||
---
|
||||
#### Boards:
|
||||
|
||||
## Boards supported
|
||||
- Elecrow ThinkNode M1
|
||||
- Elecrow ThinkNode M3
|
||||
- Elecrow ThinkNode M6
|
||||
- Heltec T096
|
||||
- Heltec T1
|
||||
- Heltec T114 / HT-nRF5262
|
||||
- LilyGo T-Echo
|
||||
- LilyGo T-Echo Lite
|
||||
- Minewsemi MX25LE01
|
||||
- Nordic PCA10056 (nRF52840 DK)
|
||||
- Nologo ProMicro NRF52840 (aka SuperMini NRF52840)
|
||||
- Seeed Studio XIAO nRF52840 BLE
|
||||
- RAK 4631
|
||||
- RAK 3401
|
||||
- RAK WisMesh Tag
|
||||
- Seeed Studio SenseCAP Card Tracker T1000-E
|
||||
- Seeed SenseCAP Solar Node P1
|
||||
- Seeed Studio Wio Tracker L1
|
||||
- Seeed Studio XIAO nRF52840 BLE ([See note](#notes-on-xiao-nrf52840-ble)
|
||||
- Seeed Studio XIAO nRF52840 BLE SENSE
|
||||
- RAK 4631 ([See note](#notes-on-RAK4631-bootloader))
|
||||
|
||||
Any board already supported by the Adafruit nrf52 bootloader can be added of course.
|
||||
If there is another nRF52840-based board you would like to see supported please raise a github issue and we can make it happen.
|
||||
## BLE advertising names
|
||||
|
||||
When in OTA DFU mode, devices advertise using a board-specific name rather than the generic `AdaDFU`.
|
||||
|
||||
| Board | OTA DFU advertising name |
|
||||
| ---------------------------- | ------------------------ |
|
||||
| Elecrow ThinkNode M1 | `TNM1_DFU` |
|
||||
| Elecrow ThinkNode M3 | `TNM3_DFU` |
|
||||
| Elecrow ThinkNode M6 | `TNM6_DFU` |
|
||||
| Heltec T096 | `T096_DFU` |
|
||||
| Heltec T1 | `T1_DFU` |
|
||||
| Heltec T114 | `T114_DFU` |
|
||||
| LILYGO T-Echo | `LGTE_DFU` |
|
||||
| LILYGO T-Echo Lite | `LTEL_DFU` |
|
||||
| Minewsemi MX25LE01 | `MX25_DFU` |
|
||||
| Nordic PCA10056 | `N056_DFU` |
|
||||
| ProMicro NRF52840 | `PROM_DFU` |
|
||||
| RAK 4631 | `4631_DFU` |
|
||||
| RAK 3401 | `3401_DFU` |
|
||||
| RAK WisMesh Tag | `RTAG_DFU` |
|
||||
| Seeed SenseCAP Solar Node P1 | `SCAP_DFU` |
|
||||
| Seeed T1000e | `T1KE_DFU` |
|
||||
| Seeed WioTracker L1 | `WTL1_DFU` |
|
||||
| XIAO NRF52 BLE / SENSE | `XIAO_DFU` |
|
||||
|
||||
|
||||
---
|
||||
#### Installation:
|
||||
The recommended way to install the bootloader is using the UF2 file.
|
||||
Download the UF2 file for your board, enter UF2 mode (usually by double pressing the reset button within 0.5s) and copy the UF2 file across.
|
||||
|
||||
It's also possible to flash the zip or hex file but this is **not recommended** as on the offchance you get a bad flash you will need a JLink or SWD to recover.
|
||||
## Installation
|
||||
|
||||
**IMPORTANT:** If you are running a MeshCore companion firmware or Ripple firmware on your device **you will need to run an erase after flashing a new bootloader**. Use the MeshCore web flasher to do the erase, it will guide you to the correct erase firmware for your device. Other erase firmwares will not work, they will not erase the ExtraFS area.
|
||||
|
||||
The recommended way to install the bootloader is using the UF2 file.
|
||||
Download the UF2 file for your board (they can be found in the releases with filenames beginning with `update-`), enter UF2 mode (usually by double pressing the reset button within 0.5s) and copy the UF2 file across.
|
||||
|
||||
If you have somehow managed to accidentally flash an incorrect bootloader to your device you will likely require flashing a full bootloader and SoftDevice zip package using ``adafruit-nrfutil``
|
||||
|
||||
---
|
||||
#### Recommended settings and notes for doing OTA update:
|
||||
To perform the OTA update you can use either "nRF Connect" ([Android](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en&gl=US)/[iOS](https://apps.apple.com/gb/app/nrf-connect-for-mobile/id1054362403)) or "nRF Device Firmware Update" ([Android](https://play.google.com/store/apps/details?id=no.nordicsemi.android.dfu&hl=en&gl=US)/[iOS](https://apps.apple.com/sa/app/device-firmware-update/id1624454660)). My preference is the "nRF Device Firmware Update" app.
|
||||
|
||||
I use the following settings with the nRF Device Firmware Update app. Note that with the exception of "Force scanning" these are not set in stone.<br/><br/>
|
||||
## Troubleshooting
|
||||
|
||||
 
|
||||
### Device does not appear as a USB drive or serial port
|
||||
|
||||
If the device does not show up on your computer after flashing the bootloader or performing an OTA update, it may be **waiting in OTA DFU mode**.
|
||||
|
||||
Notes on settings:
|
||||
- Force scanning (called Scan for bootloader in Legacy DFU in nRF Connect) is required, because when initiating OTA DFU mode the device will reboot and start advertising as AdaDFU with a different MAC address, Force scanning is what allows the app to find the device after it reboots.
|
||||
- Packets receipt notification is not strictly required but in my experience it makes the update less likely to fail, at the cost of being much slower.
|
||||
In **OTAFIX 2.0** and above, OTA DFU is the default state when no valid application is present.
|
||||
In this mode:
|
||||
- No UF2 drive is exposed
|
||||
- No serial port is available
|
||||
- The device is waiting for an OTA firmware update over BLE
|
||||
|
||||
**IMPORTANT:** If you do an OTA update while your device is plugged into a computer the device will update but <U>it will not boot into the new application firmware</u>. It will require a manual reset in order to start. Plugged into a USB charger is fine.
|
||||
**What to do:**
|
||||
- Perform an OTA update using a supported DFU app, **or**
|
||||
- Explicitly request UF2/serial mode using **double-reset**.
|
||||
|
||||
This behaviour is intentional and prevents devices from getting stuck in UF2 mode after failed OTA updates.
|
||||
|
||||
---
|
||||
#### Performing an OTA update on a MeshCore repeater
|
||||
First you will need to login to the repeater and issue the 'start ota' CLI command.
|
||||
|
||||
Next open the nRF Device Firmware Update app, select the appropriate MeshCore firmware zip file for your device, select your device (it will be called ProMicro_OTA/RAK4631_OTA etc), and press start.
|
||||
### OTA update fails with `Error: Operation Failed`
|
||||
|
||||
Now cross your fingers and hope for the best!
|
||||
If an OTA update consistently fails early with `Error: Operation Failed`, this is often caused by BLE stack incompatibilities when **Request High MTU** is enabled.
|
||||
|
||||
**What to try:**
|
||||
- Experiment with different PRN settings. Try 12, 8, 1, or even off altogether!
|
||||
- Disable **Request High MTU** in your DFU app
|
||||
|
||||
While high MTU significantly improves performance on supported devices, it is not required for a successful OTA update.
|
||||
|
||||
---
|
||||
#### Notes on RAK4631 bootloader
|
||||
This version of the RAK4631 bootloader is based on a much newer version (0.9.2) of the Adafruit nRF52 bootloader than what RAK Wireless uses on their official bootloader (0.6.1??-need to check).
|
||||
|
||||
I haven't looked to see what changes (if any) that RAK made to the Adafruit bootloader, so I'm not sure if there's any difference but I have tested this bootloader and I haven't found any problems thus far. If you would rather use the original RAK bootloader but with these patches included you can find that [here](https://github.com/oltaco/WisCore_RAK4631_Bootloader/releases).
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
## Recommended OTA DFU settings
|
||||
|
||||
To perform the OTA update you can use **nRF Device Firmware Update**
|
||||
([Android](https://play.google.com/store/apps/details?id=no.nordicsemi.android.dfu&hl=en&gl=US) / [iOS](https://apps.apple.com/sa/app/device-firmware-update/id1624454660))
|
||||
or **nRF Connect**
|
||||
([Android](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en&gl=US) / [iOS](https://apps.apple.com/gb/app/nrf-connect-for-mobile/id1054362403)).
|
||||
|
||||
My preference is the **nRF Device Firmware Update** app.
|
||||
|
||||
For **OTAFIX 2.0**, the following settings are recommended (these may change — feel free to experiment and report your findings):
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
|
||||
**Packet Receipt Notification (PRN):** ON
|
||||
**Number of packets:** 30
|
||||
**Reboot time:** 0ms
|
||||
**Scan timeout:** 2000ms
|
||||
**Request high MTU:** ON for Android (See notes below) / Not available on iOS
|
||||
**Disable resume:** ON
|
||||
**Prepare object delay:** 0ms
|
||||
**Force scanning:** ON
|
||||
**Keep bond:** OFF
|
||||
**External MCU DFU:** OFF
|
||||
|
||||
**Notes:**
|
||||
- Some Android devices and BLE stacks do not behave well with **Request high MTU** enabled.
|
||||
If the transfer fails early with `ERROR: Operation Failed`, retry with **Request high MTU turned OFF**.
|
||||
- For maximum speed, Packet Receipt Notification can be disabled, and the number of packets increased.
|
||||
Android is generally more tolerant of higher values; on iOS and other small-packet hosts, values above ~60 are not recommended.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
[Recommended settings for versions prior to 2.0 can be found here](docs/oldsettings.md).
|
||||
|
||||
**IMPORTANT:**
|
||||
On <u>older versions</u> of the bootloader, performing an OTA update while the device was connected to a computer USB host would complete successfully but **would not automatically boot into the new application firmware**, requiring a manual reset.
|
||||
This issue is fixed in **OTAFIX 2.0**.
|
||||
|
||||
---
|
||||
|
||||
## OTA update on a MeshCore repeater
|
||||
|
||||
First you will need to login to the repeater and issue the `start ota` CLI command.
|
||||
|
||||
Next, open the nRF Device Firmware Update app, select the appropriate MeshCore firmware zip file for your device, select your device (it will be advertised as `ProMicro_OTA` / `RAK4631_OTA`, etc), and press start.
|
||||
|
||||
---
|
||||
|
||||
## Donations
|
||||
|
||||
Although it's not necessary, if you find this useful please consider donating to support my work!
|
||||
|
||||
[](https://ko-fi.com/oltaco)
|
||||
|
||||
---
|
||||
|
||||
## Notes on Xiao NRF52840 BLE
|
||||
|
||||
Many of these boards are shipped with the Sense version of the bootloader installed. If your board has the Sense version installed you must use the Sense version when updating via UF2.
|
||||
|
||||
You can look at the INFO_UF2.TXT file on the UF2 drive to check what version is currently installed.
|
||||
|
||||
To check:
|
||||
1. Enter UF2 DFU mode (double-press reset)
|
||||
2. Open the `INFO_UF2.TXT` file on the mounted drive
|
||||
|
||||
If the file shows: "Board-ID: nRF52840-SeeedXiaoSense-v1" then you must install the ***SENSE*** variant if updating via UF2 file.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 217 KiB |
@@ -0,0 +1,30 @@
|
||||
|
||||
These are the recommended settings for OTAFIX-v1.2 and earlier.<br/><br/>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
|
||||
**Packets Receipt Notification:** ON
|
||||
**Number of packets:** 8
|
||||
**Reboot time:** 0ms
|
||||
**Scan timeout:** 2000ms
|
||||
**Request high MTU:** OFF
|
||||
**Disable resume:** ON
|
||||
**Prepare object delay:** 400ms
|
||||
**Force Scanning:** ON
|
||||
**Keep bond:** OFF
|
||||
**External MCU DFU:** OFF
|
||||
|
||||
</td>
|
||||
<td valign="top">
|
||||
|
||||
Click the screenshot to view full.
|
||||
|
||||
<a href="Screenshot_20251114_142334_DFU.jpg">
|
||||
<img src="Screenshot_20251114_142334_DFU.jpg" width="200">
|
||||
</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <stddef.h>
|
||||
#include "sdk_common.h"
|
||||
|
||||
#define MAX_DFU_PKT_LEN 20 /**< Maximum length (in bytes) of the DFU Packet characteristic. */
|
||||
#define MAX_DFU_PKT_LEN (247 - 3) // MTU - 3 bytes for ATT header /**< Maximum length (in bytes) of the DFU Packet characteristic. */
|
||||
#define PKT_START_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Start DFU Request. */
|
||||
#define PKT_INIT_DFU_PARAM_LEN 2 /**< Length (in bytes) of the parameters for Packet Init DFU Request. */
|
||||
#define PKT_RCPT_NOTIF_REQ_LEN 3 /**< Length (in bytes) of the Packet Receipt Notification Request. */
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
#include "pstorage_platform.h"
|
||||
|
||||
extern uint8_t* dfu_page_erased;
|
||||
extern uint32_t dfu_image_page_count;
|
||||
extern int32_t dfu_pending_erase_page;
|
||||
extern uint32_t dfu_base_address;
|
||||
|
||||
/**@defgroup ps_opcode Persistent Storage Access Operation Codes
|
||||
* @{
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
#error No target defined
|
||||
#endif
|
||||
|
||||
#define PENDING_PACKET_SIZE 256 /**< Maximum size of a single pending packet data buffer. */
|
||||
#define PENDING_PACKET_COUNT 8 /**< Maximum number of packets that can be buffered during lazy erase. */
|
||||
|
||||
uint8_t * dfu_page_erased; /**< Pointer to page erased status array, set by DFU layer. */
|
||||
uint32_t dfu_image_page_count; /**< Number of pages in DFU image, set by DFU layer. */
|
||||
uint32_t dfu_base_address; /**< Base address for DFU image, set by DFU layer. */
|
||||
|
||||
static bool lazy_erase_check_and_trigger(pstorage_handle_t * p_dest, pstorage_size_t size, pstorage_size_t offset);
|
||||
static void process_pending_packets(void);
|
||||
|
||||
/**
|
||||
* @brief Application registration information.
|
||||
@@ -93,10 +102,29 @@ typedef struct
|
||||
cmd_queue_element_t cmd[PSTORAGE_CMD_QUEUE_SIZE]; /**< Array to maintain flash access operation details */
|
||||
}cmd_queue_t;
|
||||
|
||||
static cmd_queue_t m_cmd_queue; /**< Flash operation request queue. */
|
||||
static pstorage_module_table_t m_app_table[PSTORAGE_NUM_OF_PAGES]; /**< Registered application information table. */
|
||||
static pstorage_size_t m_next_app_instance; /**< Points to the application module instance that can be allocated next */
|
||||
static pstorage_size_t m_round_val; /**< Round value for multiple round operations. For erase operations, the round value will contain current round counter which is identical to number of pages erased. For store operations, the round value contains current round of operation * SOC_MAX_WRITE_SIZE to ensure each store to the SoC Flash API is within the SoC limit. */
|
||||
/**@brief Structure for buffering packets during lazy page erase. */
|
||||
typedef struct
|
||||
{
|
||||
bool valid; /**< Whether this slot contains valid data. */
|
||||
pstorage_handle_t handle; /**< Storage handle for destination. */
|
||||
uint32_t offset; /**< Offset within the storage block. */
|
||||
uint32_t size; /**< Size of data in bytes. */
|
||||
uint8_t * p_data_orig; /**< Original data pointer for callback. */
|
||||
uint8_t data[PENDING_PACKET_SIZE] __attribute__((aligned(4))); /**< Buffered packet data. */
|
||||
} pending_packet_t;
|
||||
|
||||
static cmd_queue_t m_cmd_queue; /**< Flash operation request queue. */
|
||||
static pstorage_module_table_t m_app_table[PSTORAGE_NUM_OF_PAGES]; /**< Registered application information table. */
|
||||
static pstorage_size_t m_next_app_instance; /**< Points to the application module instance that can be allocated next */
|
||||
static pstorage_size_t m_round_val; /**< Round value for multiple round operations. For erase operations, the round value will contain current round counter which is identical to number of pages erased. For store operations, the round value contains current round of operation * SOC_MAX_WRITE_SIZE to ensure each store to the SoC Flash API is within the SoC limit. */
|
||||
|
||||
static pending_packet_t m_pending_packets[PENDING_PACKET_COUNT]; /**< Ring buffer for pending packets. */
|
||||
static uint8_t m_pending_read_idx; /**< Read index for pending packet ring buffer. */
|
||||
static uint8_t m_pending_write_idx; /**< Write index for pending packet ring buffer. */
|
||||
static uint8_t m_pending_count; /**< Number of pending packets in buffer. */
|
||||
static bool m_lazy_erase_active; /**< True if a lazy erase is in progress. */
|
||||
static uint32_t m_lazy_erase_page; /**< Page index currently being erased. */
|
||||
static bool m_processing_pending; /**< True if processing a pending packet store. */
|
||||
|
||||
/**
|
||||
* @brief Function for processing of commands and issuing flash access request to the SoftDevice.
|
||||
@@ -160,6 +188,82 @@ static void cmd_queue_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the pending packets buffer.
|
||||
*/
|
||||
static void pending_packets_init(void)
|
||||
{
|
||||
for (int i = 0; i < PENDING_PACKET_COUNT; i++)
|
||||
{
|
||||
m_pending_packets[i].valid = false;
|
||||
}
|
||||
m_pending_read_idx = 0;
|
||||
m_pending_write_idx = 0;
|
||||
m_pending_count = 0;
|
||||
m_lazy_erase_active = false;
|
||||
m_lazy_erase_page = 0;
|
||||
m_processing_pending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for adding a packet to the pending buffer.
|
||||
*
|
||||
* @param[in] p_handle Pointer to the storage handle.
|
||||
* @param[in] p_data Pointer to the data to buffer.
|
||||
* @param[in] size Size of data in bytes.
|
||||
* @param[in] offset Offset within the storage block.
|
||||
*
|
||||
* @retval true If the packet was successfully added.
|
||||
* @retval false If the buffer is full or size exceeds maximum.
|
||||
*/
|
||||
static bool pending_packet_add(pstorage_handle_t * p_handle, uint8_t * p_data,
|
||||
uint32_t size, uint32_t offset)
|
||||
{
|
||||
if (m_pending_count >= PENDING_PACKET_COUNT || size > PENDING_PACKET_SIZE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pending_packet_t * p = &m_pending_packets[m_pending_write_idx];
|
||||
p->handle = *p_handle;
|
||||
p->offset = offset;
|
||||
p->size = size;
|
||||
p->p_data_orig = p_data;
|
||||
memcpy(p->data, p_data, size);
|
||||
p->valid = true;
|
||||
|
||||
m_pending_write_idx = (m_pending_write_idx + 1) % PENDING_PACKET_COUNT;
|
||||
m_pending_count++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for getting a pointer to the next pending packet without removing it.
|
||||
*
|
||||
* @return Pointer to the next pending packet, or NULL if buffer is empty.
|
||||
*/
|
||||
static pending_packet_t * pending_packet_peek(void)
|
||||
{
|
||||
if (m_pending_count == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return &m_pending_packets[m_pending_read_idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for removing the next pending packet from the buffer.
|
||||
*/
|
||||
static void pending_packet_pop(void)
|
||||
{
|
||||
if (m_pending_count > 0)
|
||||
{
|
||||
m_pending_packets[m_pending_read_idx].valid = false;
|
||||
m_pending_read_idx = (m_pending_read_idx + 1) % PENDING_PACKET_COUNT;
|
||||
m_pending_count--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for enqueueing a flash access operation.
|
||||
@@ -196,6 +300,7 @@ static uint32_t cmd_queue_enqueue(uint8_t opcode,
|
||||
m_cmd_queue.cmd[write_index].storage_addr = (*p_storage_addr);
|
||||
m_cmd_queue.cmd[write_index].size = size;
|
||||
m_cmd_queue.cmd[write_index].offset = offset;
|
||||
m_cmd_queue.count++;
|
||||
retval = NRF_SUCCESS;
|
||||
if (m_cmd_queue.flash_access == false)
|
||||
{
|
||||
@@ -206,7 +311,6 @@ static uint32_t cmd_queue_enqueue(uint8_t opcode,
|
||||
retval = NRF_SUCCESS;
|
||||
}
|
||||
}
|
||||
m_cmd_queue.count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -261,15 +365,132 @@ static void app_notify(uint32_t result, cmd_queue_element_t * p_elem)
|
||||
{
|
||||
pstorage_ntf_cb_t ntf_cb;
|
||||
uint8_t op_code = p_elem->op_code;
|
||||
|
||||
ntf_cb = m_app_table[p_elem->storage_addr.module_id].cb;
|
||||
|
||||
// Indicate result to client.
|
||||
ntf_cb(&p_elem->storage_addr,
|
||||
op_code,
|
||||
result,
|
||||
p_elem->p_data_addr,
|
||||
p_elem->size);
|
||||
if (p_elem->storage_addr.module_id < PSTORAGE_NUM_OF_PAGES)
|
||||
{
|
||||
ntf_cb = m_app_table[p_elem->storage_addr.module_id].cb;
|
||||
if (ntf_cb != NULL)
|
||||
{
|
||||
ntf_cb(&p_elem->storage_addr,
|
||||
op_code,
|
||||
result,
|
||||
p_elem->p_data_addr,
|
||||
p_elem->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for notifying application of buffered store completion.
|
||||
*
|
||||
* @param[in] result Result of event being notified.
|
||||
* @param[in] p_handle Pointer to the storage handle.
|
||||
* @param[in] p_data Pointer to the data buffer.
|
||||
* @param[in] size Size of data in bytes.
|
||||
*/
|
||||
static void app_notify_buffered(uint32_t result, pstorage_handle_t * p_handle,
|
||||
uint8_t * p_data, uint32_t size)
|
||||
{
|
||||
if (p_handle->module_id < PSTORAGE_NUM_OF_PAGES)
|
||||
{
|
||||
pstorage_ntf_cb_t ntf_cb = m_app_table[p_handle->module_id].cb;
|
||||
if (ntf_cb != NULL)
|
||||
{
|
||||
ntf_cb(p_handle, PSTORAGE_STORE_OP_CODE, result, p_data, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for processing packets from the pending buffer.
|
||||
*
|
||||
* @details Attempts to process the next pending packet. If the target page needs
|
||||
* erasing, triggers a lazy erase. Otherwise enqueues the store operation.
|
||||
*/
|
||||
static void process_pending_packets(void)
|
||||
{
|
||||
if (m_processing_pending || m_lazy_erase_active || m_cmd_queue.count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pending_packet_t * p = pending_packet_peek();
|
||||
if (p == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this packet needs an erase first
|
||||
if (lazy_erase_check_and_trigger(&p->handle, p->size, p->offset))
|
||||
{
|
||||
// Erase triggered, don't process this packet yet
|
||||
return;
|
||||
}
|
||||
|
||||
// Page is ready, enqueue the store
|
||||
m_processing_pending = true;
|
||||
|
||||
uint32_t ret = cmd_queue_enqueue(PSTORAGE_STORE_OP_CODE, &p->handle, p->data, p->size, p->offset);
|
||||
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
m_processing_pending = false;
|
||||
pending_packet_pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for checking and triggering lazy erase if needed.
|
||||
* @param[in] p_dest Destination address where data is to be stored persistently.
|
||||
* @param[in] size Size of data to be stored expressed in bytes.
|
||||
* @param[in] offset Offset in bytes to be applied when writing to the block.
|
||||
* @retval true Lazy erase was triggered.
|
||||
* @retval false No lazy erase was needed.
|
||||
*/
|
||||
static bool lazy_erase_check_and_trigger(pstorage_handle_t * p_handle, pstorage_size_t size, pstorage_size_t offset)
|
||||
{
|
||||
uint32_t target_addr = p_handle->block_id + offset;
|
||||
|
||||
if (target_addr < dfu_base_address || dfu_page_erased == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t rel_addr = target_addr - dfu_base_address;
|
||||
uint32_t page_index = rel_addr / PSTORAGE_FLASH_PAGE_SIZE;
|
||||
|
||||
// Also check end of packet
|
||||
uint32_t end_addr = target_addr + size - 1;
|
||||
uint32_t end_rel_addr = end_addr - dfu_base_address;
|
||||
uint32_t end_page_index = end_rel_addr / PSTORAGE_FLASH_PAGE_SIZE;
|
||||
|
||||
// Check if start page needs erase
|
||||
bool start_needs_erase = (page_index < dfu_image_page_count && !dfu_page_erased[page_index]);
|
||||
|
||||
// Check if end page needs erase (and is different from start page)
|
||||
bool end_needs_erase = (end_page_index != page_index) &&
|
||||
(end_page_index < dfu_image_page_count && !dfu_page_erased[end_page_index]);
|
||||
|
||||
if (!start_needs_erase && !end_needs_erase)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine which page to erase (start page takes priority)
|
||||
uint32_t erase_page = start_needs_erase ? page_index : end_page_index;
|
||||
|
||||
m_lazy_erase_active = true;
|
||||
m_lazy_erase_page = erase_page;
|
||||
|
||||
pstorage_handle_t erase_handle;
|
||||
erase_handle.block_id = dfu_base_address + (erase_page * PSTORAGE_FLASH_PAGE_SIZE);
|
||||
erase_handle.module_id = p_handle->module_id;
|
||||
|
||||
cmd_queue_enqueue(PSTORAGE_CLEAR_OP_CODE, &erase_handle, NULL,
|
||||
PSTORAGE_FLASH_PAGE_SIZE, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +500,7 @@ static void app_notify(uint32_t result, cmd_queue_element_t * p_elem)
|
||||
* @param[in] sys_evt System event received.
|
||||
*/
|
||||
void pstorage_sys_event_handler(uint32_t sys_evt)
|
||||
{
|
||||
{
|
||||
uint32_t retval = NRF_SUCCESS;
|
||||
|
||||
// The event shall only be processed if requested by this module.
|
||||
@@ -293,13 +514,19 @@ void pstorage_sys_event_handler(uint32_t sys_evt)
|
||||
{
|
||||
p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp];
|
||||
m_round_val++;
|
||||
|
||||
|
||||
bool command_finished = ((m_round_val * SOC_MAX_WRITE_SIZE) >= p_cmd->size);
|
||||
|
||||
if (p_cmd->op_code == PSTORAGE_CLEAR_OP_CODE)
|
||||
{
|
||||
command_finished = true;
|
||||
}
|
||||
|
||||
if (command_finished)
|
||||
{
|
||||
uint8_t queue_rp = m_cmd_queue.rp;
|
||||
|
||||
uint8_t completed_op = p_cmd->op_code;
|
||||
|
||||
m_round_val = 0;
|
||||
m_cmd_queue.count--;
|
||||
m_cmd_queue.rp++;
|
||||
@@ -309,24 +536,78 @@ void pstorage_sys_event_handler(uint32_t sys_evt)
|
||||
m_cmd_queue.rp -= PSTORAGE_CMD_QUEUE_SIZE;
|
||||
}
|
||||
|
||||
app_notify(retval, &m_cmd_queue.cmd[queue_rp]);
|
||||
if (m_lazy_erase_active && completed_op == PSTORAGE_CLEAR_OP_CODE)
|
||||
{
|
||||
// Lazy erase completed
|
||||
if (dfu_page_erased != NULL && m_lazy_erase_page < dfu_image_page_count)
|
||||
{
|
||||
dfu_page_erased[m_lazy_erase_page] = 1;
|
||||
}
|
||||
|
||||
// Initialize/free the element as it is now processed.
|
||||
cmd_queue_element_init(queue_rp);
|
||||
m_lazy_erase_active = false;
|
||||
cmd_queue_element_init(queue_rp);
|
||||
|
||||
process_pending_packets();
|
||||
}
|
||||
else if (m_processing_pending && completed_op == PSTORAGE_STORE_OP_CODE)
|
||||
{
|
||||
// Store from pending buffer completed
|
||||
pending_packet_t * p = pending_packet_peek();
|
||||
if (p != NULL)
|
||||
{
|
||||
pstorage_handle_t cb_handle = p->handle;
|
||||
uint8_t* cb_data = p->p_data_orig;
|
||||
uint32_t cb_size = p->size;
|
||||
|
||||
pending_packet_pop();
|
||||
|
||||
cmd_queue_element_init(queue_rp);
|
||||
|
||||
// Clear flag BEFORE callback
|
||||
m_processing_pending = false;
|
||||
|
||||
// Notify application that buffered this buffered store is done
|
||||
app_notify_buffered(retval, &cb_handle, cb_data, cb_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_processing_pending = false;
|
||||
cmd_queue_element_init(queue_rp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
app_notify(retval, &m_cmd_queue.cmd[queue_rp]);
|
||||
|
||||
// Initialize/free the element as it is now processed.
|
||||
cmd_queue_element_init(queue_rp);
|
||||
}
|
||||
}
|
||||
// Schedule any queued flash access operations.
|
||||
retval = cmd_queue_dequeue();
|
||||
|
||||
// Process next queued command OR next pending packet
|
||||
if (m_cmd_queue.count > 0)
|
||||
{
|
||||
retval = cmd_queue_dequeue();
|
||||
}
|
||||
else if (m_pending_count > 0 && !m_processing_pending && !m_lazy_erase_active)
|
||||
{
|
||||
// Queue is empty but we have pending packets - process one
|
||||
process_pending_packets();
|
||||
}
|
||||
|
||||
if (retval != NRF_SUCCESS)
|
||||
{
|
||||
app_notify(retval, &m_cmd_queue.cmd[m_cmd_queue.rp]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case NRF_EVT_FLASH_OPERATION_ERROR:
|
||||
m_lazy_erase_active = false;
|
||||
m_processing_pending = false;
|
||||
app_notify(NRF_ERROR_TIMEOUT, &m_cmd_queue.cmd[m_cmd_queue.rp]);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
// No implementation needed.
|
||||
break;
|
||||
@@ -348,6 +629,11 @@ static uint32_t cmd_process(void)
|
||||
|
||||
retval = NRF_ERROR_FORBIDDEN;
|
||||
|
||||
if (m_cmd_queue.count == 0)
|
||||
{
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
p_cmd = &m_cmd_queue.cmd[m_cmd_queue.rp];
|
||||
|
||||
storage_addr = p_cmd->storage_addr.block_id;
|
||||
@@ -379,7 +665,7 @@ static uint32_t cmd_process(void)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PSTORAGE_CLEAR_OP_CODE:
|
||||
{
|
||||
uint32_t page_number;
|
||||
@@ -390,12 +676,12 @@ static uint32_t cmd_process(void)
|
||||
retval = sd_flash_page_erase(page_number);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
// Should never reach here.
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (retval == NRF_SUCCESS)
|
||||
{
|
||||
m_cmd_queue.flash_access = true;
|
||||
@@ -409,7 +695,8 @@ static uint32_t cmd_process(void)
|
||||
uint32_t pstorage_init(void)
|
||||
{
|
||||
cmd_queue_init();
|
||||
|
||||
pending_packets_init();
|
||||
|
||||
m_next_app_instance = 0;
|
||||
m_round_val = 0;
|
||||
|
||||
@@ -451,11 +738,22 @@ uint32_t pstorage_store(pstorage_handle_t * p_dest,
|
||||
pstorage_size_t offset)
|
||||
{
|
||||
// Verify word alignment.
|
||||
if ((!is_word_aligned(p_src)) || (!is_word_aligned(p_src+offset)))
|
||||
if ((!is_word_aligned(p_src)) || (!is_word_aligned((void *)(p_dest->block_id + offset))))
|
||||
{
|
||||
return NRF_ERROR_INVALID_ADDR;
|
||||
}
|
||||
|
||||
if (m_lazy_erase_active || lazy_erase_check_and_trigger(p_dest, size, offset))
|
||||
{
|
||||
// Buffer this packet - erase in progress or just triggered
|
||||
if (!pending_packet_add(p_dest, p_src, size, offset))
|
||||
{
|
||||
return NRF_ERROR_NO_MEM;
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
// Page already erased, proceed with store
|
||||
return cmd_queue_enqueue(PSTORAGE_STORE_OP_CODE, p_dest, p_src, size, offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,12 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
case PSTORAGE_CLEAR_OP_CODE:
|
||||
if (m_dfu_state == DFU_STATE_PREPARING)
|
||||
{
|
||||
// Special case for lazy erase - mark first page as erased
|
||||
if (dfu_page_erased != NULL && dfu_image_page_count > 0)
|
||||
{
|
||||
dfu_page_erased[0] = 1;
|
||||
}
|
||||
|
||||
m_functions.cleared();
|
||||
m_dfu_state = DFU_STATE_RDY;
|
||||
if (m_data_pkt_cb != NULL)
|
||||
@@ -80,39 +86,48 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
APP_ERROR_CHECK(result);
|
||||
}
|
||||
|
||||
/**@brief Function for preparing of flash before receiving SoftDevice image.
|
||||
/**@brief Function for preparing flash before receiving image.
|
||||
*
|
||||
* @details This function will erase current application area to ensure sufficient amount of
|
||||
* storage for the SoftDevice image. Upon erase complete a callback will be done.
|
||||
* See \ref dfu_bank_prepare_t for further details.
|
||||
* @details For lazy erase mode (OTA), this sets up the tracking array and erases
|
||||
* only the first page to signal readiness. Subsequent pages are erased
|
||||
* on-demand when stores target them.
|
||||
* For non-OTA mode, all pages are erased upfront.
|
||||
*/
|
||||
static void dfu_prepare_func_app_erase(uint32_t image_size)
|
||||
{
|
||||
mp_storage_handle_active = &m_storage_handle_app;
|
||||
mp_storage_handle_active = &m_storage_handle_app;
|
||||
|
||||
// Doing a SoftDevice update thus current application must be cleared to ensure enough space
|
||||
// for new SoftDevice.
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
m_dfu_state = DFU_STATE_PREPARING;
|
||||
dfu_base_address = m_storage_handle_app.block_id;
|
||||
|
||||
if ( is_ota() )
|
||||
{
|
||||
uint32_t err_code = pstorage_clear(&m_storage_handle_app, m_image_size);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t const page_count = NRFX_CEIL_DIV(m_image_size, CODE_PAGE_SIZE);
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
if ( is_ota() )
|
||||
{
|
||||
uint32_t const addr = DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE;
|
||||
PRINTF("Erase 0x%08lX\r\n", addr);
|
||||
nrfx_nvmc_page_erase(addr);
|
||||
}
|
||||
// Setup for lazy erase
|
||||
dfu_image_page_count = NRFX_CEIL_DIV(m_image_size, CODE_PAGE_SIZE);
|
||||
|
||||
// invoke complete callback
|
||||
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
||||
}
|
||||
if (dfu_image_page_count < 1) dfu_image_page_count = 1; // This should not happen
|
||||
|
||||
static uint8_t dfu_page_erased_static[256];
|
||||
dfu_page_erased = dfu_page_erased_static;
|
||||
memset(dfu_page_erased, 0, dfu_image_page_count);
|
||||
|
||||
uint32_t err_code = pstorage_clear(&m_storage_handle_app, CODE_PAGE_SIZE);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t const page_count = NRFX_CEIL_DIV(m_image_size, CODE_PAGE_SIZE);
|
||||
|
||||
for ( uint32_t i = 0; i < page_count; i++ )
|
||||
{
|
||||
uint32_t const addr = DFU_BANK_0_REGION_START + i * CODE_PAGE_SIZE;
|
||||
PRINTF("Erase 0x%08lX\r\n", addr);
|
||||
nrfx_nvmc_page_erase(addr);
|
||||
}
|
||||
|
||||
// invoke complete callback
|
||||
pstorage_callback_handler(&m_storage_handle_app, PSTORAGE_CLEAR_OP_CODE, NRF_SUCCESS, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +249,11 @@ uint32_t dfu_init(void)
|
||||
|
||||
m_init_packet_length = 0;
|
||||
m_image_crc = 0;
|
||||
|
||||
// Reset lazy erase state
|
||||
dfu_page_erased = NULL;
|
||||
dfu_image_page_count = 0;
|
||||
dfu_base_address = 0;
|
||||
|
||||
err_code = pstorage_register(&storage_module_param, &m_storage_handle_app);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
@@ -363,8 +383,8 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_nrf5x_write(DFU_BANK_0_REGION_START + m_data_received, p_data, data_length, false);
|
||||
pstorage_callback_handler(mp_storage_handle_active, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_data, data_length);
|
||||
flash_nrf5x_write(DFU_BANK_0_REGION_START + m_data_received, p_data, data_length, false);
|
||||
pstorage_callback_handler(mp_storage_handle_active, PSTORAGE_STORE_OP_CODE, NRF_SUCCESS, (uint8_t *) p_data, data_length);
|
||||
}
|
||||
|
||||
m_data_received += data_length;
|
||||
@@ -378,8 +398,8 @@ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet)
|
||||
{
|
||||
if ( !is_ota() ) flash_nrf5x_flush(false);
|
||||
|
||||
// The entire image has been received. Return NRF_SUCCESS.
|
||||
err_code = NRF_SUCCESS;
|
||||
// The entire image has been received. Return NRF_SUCCESS.
|
||||
err_code = NRF_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
|
||||
#define BLEGAP_EVENT_LENGTH 6
|
||||
#define BLEGATT_ATT_MTU_MAX 23
|
||||
#define BLEGATT_ATT_MTU_MAX 247
|
||||
enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
|
||||
#define DFU_REV_MAJOR 0x00 /** DFU Major revision number to be exposed. */
|
||||
@@ -47,7 +47,9 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
#define BLE_HANDLE_MAX 0xFFFF /**< Max handle value is BLE. */
|
||||
|
||||
// limit of 8 chars
|
||||
#ifndef DEVICE_NAME
|
||||
#define DEVICE_NAME "AdaDFU" /**< Name of device. Will be included in the advertising data. */
|
||||
#endif //DEVICE_NAME
|
||||
|
||||
#define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(10, UNIT_1_25_MS)) /**< Minimum acceptable connection interval (11.25 milliseconds). */
|
||||
#define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(30, UNIT_1_25_MS)) /**< Maximum acceptable connection interval (15 milliseconds). */
|
||||
@@ -80,6 +82,16 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
||||
#define BL_IMAGE_SIZE_OFFSET 4 /**< Offset in start packet for the size information for bootloader. */
|
||||
#define APP_IMAGE_SIZE_OFFSET 8 /**< Offset in start packet for the size information for application. */
|
||||
|
||||
// Accumulator buffer for small packets, to reduce flash write overhead
|
||||
#define ACCUMULATE_THRESHOLD 64 /**< Enable accumulator only if the first packet is <= this size */
|
||||
#define ACCUMULATE_TARGET_SIZE 240 /**< Flush when accumulator reaches this size (word-aligned) */
|
||||
|
||||
static uint8_t m_accum_buf[ACCUMULATE_TARGET_SIZE] __attribute__((aligned(4)));
|
||||
static uint16_t m_accum_len = 0;
|
||||
static bool m_accum_active = false;
|
||||
static uint32_t m_accum_bytes_pending = 0; /**< Bytes accumulated but not yet counted in m_num_of_firmware_bytes_rcvd */
|
||||
static uint32_t m_reported_image_size = 0; /**< Size of the incoming image being received over BLE DFU as reported by the host. */
|
||||
|
||||
/**@brief Packet type enumeration.
|
||||
*/
|
||||
typedef enum
|
||||
@@ -111,6 +123,13 @@ static uint8_t * mp_final_packet;
|
||||
static ble_gap_addr_t const * m_whitelist[1]; /**< List of peers in whitelist (only one) */
|
||||
static ble_gap_id_key_t const * m_gap_ids[1];
|
||||
|
||||
static ble_gap_data_length_params_t m_dl_params = {
|
||||
.max_tx_octets = 251,
|
||||
.max_rx_octets = 251,
|
||||
.max_tx_time_us = BLE_GAP_DATA_LENGTH_AUTO,
|
||||
.max_rx_time_us = BLE_GAP_DATA_LENGTH_AUTO
|
||||
};
|
||||
|
||||
// Adafruit
|
||||
static uint8_t _adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
|
||||
|
||||
@@ -324,6 +343,11 @@ static void start_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
start_packet.bl_image_size = uint32_decode(p_length_data + BL_IMAGE_SIZE_OFFSET);
|
||||
start_packet.app_image_size = uint32_decode(p_length_data + APP_IMAGE_SIZE_OFFSET);
|
||||
|
||||
// Store the reported image size for use by the accumulator logic
|
||||
m_reported_image_size = start_packet.sd_image_size +
|
||||
start_packet.bl_image_size +
|
||||
start_packet.app_image_size;
|
||||
|
||||
err_code = dfu_start_pkt_handle(&update_packet);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
@@ -388,6 +412,94 @@ static void init_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
}
|
||||
}
|
||||
|
||||
/**@brief Flush the accumulator buffer to HCI pool for processing
|
||||
*/
|
||||
static void accum_flush(ble_dfu_t * p_dfu)
|
||||
{
|
||||
if (m_accum_len == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t err_code;
|
||||
uint32_t length = m_accum_len;
|
||||
uint32_t original_len = m_accum_len; // Before padding
|
||||
|
||||
PRINTF("OTA: Flushing accumulator buffer (%ld bytes)\r\n", length);
|
||||
|
||||
// Word-align the length (pad with 0xFF for flash compatibility)
|
||||
uint32_t aligned_len = (length + 3) & ~3;
|
||||
while (m_accum_len < aligned_len)
|
||||
{
|
||||
m_accum_buf[m_accum_len++] = 0xFF;
|
||||
}
|
||||
length = m_accum_len;
|
||||
|
||||
err_code = hci_mem_pool_rx_produce(length, (void **) &mp_rx_buffer);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
PRINTF("OTA: hci_mem_pool_rx_produce failed: 0x%08lX\r\n", err_code);
|
||||
dfu_error_notify(p_dfu, err_code);
|
||||
m_accum_len = 0;
|
||||
m_accum_bytes_pending = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(mp_rx_buffer, m_accum_buf, length);
|
||||
|
||||
err_code = hci_mem_pool_rx_data_size_set(length);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
PRINTF("OTA: hci_mem_pool_rx_data_size_set failed: 0x%08lX\r\n", err_code);
|
||||
dfu_error_notify(p_dfu, err_code);
|
||||
m_accum_len = 0;
|
||||
m_accum_bytes_pending = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
err_code = hci_mem_pool_rx_extract(&mp_rx_buffer, &length);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
PRINTF("OTA: hci_mem_pool_rx_extract failed: 0x%08lX\r\n", err_code);
|
||||
dfu_error_notify(p_dfu, err_code);
|
||||
m_accum_len = 0;
|
||||
m_accum_bytes_pending = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dfu_update_packet_t dfu_pkt;
|
||||
dfu_pkt.packet_type = DATA_PACKET;
|
||||
dfu_pkt.params.data_packet.packet_length = length / sizeof(uint32_t);
|
||||
dfu_pkt.params.data_packet.p_data_packet = (uint32_t *)mp_rx_buffer;
|
||||
|
||||
err_code = dfu_data_pkt_handle(&dfu_pkt);
|
||||
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
// All firmware data received - this was the final packet
|
||||
m_num_of_firmware_bytes_rcvd += original_len;
|
||||
mp_final_packet = mp_rx_buffer;
|
||||
PRINTF("OTA: Final packet flushed, total bytes: %ld\r\n", m_num_of_firmware_bytes_rcvd);
|
||||
}
|
||||
else if (err_code == NRF_ERROR_INVALID_LENGTH)
|
||||
{
|
||||
// More data expected - this is the normal case
|
||||
m_num_of_firmware_bytes_rcvd += original_len;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINTF("OTA: dfu_data_pkt_handle failed: 0x%08lX\r\n", err_code);
|
||||
uint32_t hci_error = hci_mem_pool_rx_consume(mp_rx_buffer);
|
||||
if (hci_error != NRF_SUCCESS)
|
||||
{
|
||||
dfu_error_notify(p_dfu, hci_error);
|
||||
}
|
||||
dfu_error_notify(p_dfu, err_code);
|
||||
}
|
||||
|
||||
m_accum_len = 0;
|
||||
m_accum_bytes_pending = 0;
|
||||
}
|
||||
|
||||
/**@brief Function for processing application data written by the peer to the DFU Packet
|
||||
* Characteristic.
|
||||
@@ -398,8 +510,61 @@ static void init_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
static void app_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
{
|
||||
uint32_t err_code;
|
||||
uint16_t pkt_len = p_evt->evt.ble_dfu_pkt_write.len;
|
||||
uint8_t * p_data = p_evt->evt.ble_dfu_pkt_write.p_data;
|
||||
|
||||
if ((p_evt->evt.ble_dfu_pkt_write.len & (sizeof(uint32_t) - 1)) != 0)
|
||||
// Check if this is the first data packet and decide whether to accumulate packets
|
||||
if (m_num_of_firmware_bytes_rcvd == 0 && m_accum_len == 0)
|
||||
{
|
||||
m_accum_active = (pkt_len <= ACCUMULATE_THRESHOLD);
|
||||
PRINTF("OTA: Packet accumulator %s (first packet size %d)\r\n", m_accum_active ? "enabled" : "disabled", pkt_len);
|
||||
}
|
||||
|
||||
if (m_accum_active)
|
||||
{
|
||||
// Flush the accumulator if adding this packet would overflow the buffer
|
||||
if (m_accum_len + pkt_len > ACCUMULATE_TARGET_SIZE)
|
||||
{
|
||||
PRINTF("OTA: Pre-overflow flush of accumulator\r\n");
|
||||
accum_flush(p_dfu);
|
||||
}
|
||||
|
||||
// Add packet to accumulator buffer
|
||||
memcpy(m_accum_buf + m_accum_len, p_data, pkt_len);
|
||||
m_accum_len += pkt_len;
|
||||
m_accum_bytes_pending += pkt_len;
|
||||
|
||||
// Handle PRN - must be based on RECEIVED packets not flushed packets
|
||||
// otherwise host might timeout waiting for notification
|
||||
if (m_pkt_rcpt_notif_enabled)
|
||||
{
|
||||
m_pkt_notif_target_cnt--;
|
||||
|
||||
if (m_pkt_notif_target_cnt == 0)
|
||||
{
|
||||
// Need to flush before sending PRN so byte count is accurate
|
||||
PRINTF("OTA: PRN flush of accumulator\r\n");
|
||||
accum_flush(p_dfu);
|
||||
|
||||
err_code = ble_dfu_pkts_rcpt_notify(p_dfu, m_num_of_firmware_bytes_rcvd);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
m_pkt_notif_target_cnt = m_pkt_notif_target;
|
||||
}
|
||||
}
|
||||
|
||||
// Flush the accumulator if we've received the full image in order to trigger completion
|
||||
if ((m_num_of_firmware_bytes_rcvd + m_accum_len) == m_reported_image_size)
|
||||
{
|
||||
accum_flush(p_dfu);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Original logic for large packets (no accumulation)
|
||||
if ((pkt_len & (sizeof(uint32_t) - 1)) != 0)
|
||||
{
|
||||
// Data length is not a multiple of 4 (word size).
|
||||
err_code = ble_dfu_response_send(p_dfu,
|
||||
@@ -409,7 +574,7 @@ static void app_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t length = p_evt->evt.ble_dfu_pkt_write.len;
|
||||
uint32_t length = pkt_len;
|
||||
|
||||
err_code = hci_mem_pool_rx_produce(length, (void **) &mp_rx_buffer);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
@@ -418,9 +583,7 @@ static void app_data_process(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t * p_data_packet = p_evt->evt.ble_dfu_pkt_write.p_data;
|
||||
|
||||
memcpy(mp_rx_buffer, p_data_packet, length);
|
||||
memcpy(mp_rx_buffer, p_data, length);
|
||||
|
||||
err_code = hci_mem_pool_rx_data_size_set(length);
|
||||
if (err_code != NRF_SUCCESS)
|
||||
@@ -701,8 +864,12 @@ static void advertising_start(void)
|
||||
advertising_init(&gap_adv.adv_data, adv_flag);
|
||||
|
||||
APP_ERROR_CHECK( sd_ble_gap_adv_set_configure(&_adv_handle, &gap_adv, &m_adv_params) );
|
||||
// maximum power for nrf52832, nrf52840 max power is +8
|
||||
// maximum power for nrf52832 is +4, nrf52840 max power is +8
|
||||
#if defined(NRF52840_XXAA)
|
||||
APP_ERROR_CHECK( sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, _adv_handle, 8) );
|
||||
#else
|
||||
APP_ERROR_CHECK( sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, _adv_handle, 4) );
|
||||
#endif
|
||||
APP_ERROR_CHECK( sd_ble_gap_adv_start(_adv_handle, BLE_CONN_CFG_HIGH_BANDWIDTH) );
|
||||
|
||||
m_is_advertising = true;
|
||||
@@ -745,6 +912,11 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
m_is_advertising = false;
|
||||
|
||||
// APP_ERROR_CHECK( sd_ble_gattc_exchange_mtu_request(m_conn_handle, BLEGATT_ATT_MTU_MAX) );
|
||||
|
||||
sd_ble_gap_data_length_update(m_conn_handle, &m_dl_params, NULL);
|
||||
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
@@ -886,7 +1058,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
|
||||
// Let Softdevice decide the data length
|
||||
// ble_gap_data_length_params_t* param = &evt->evt.gap_evt.params.data_length_update_request.peer_params
|
||||
APP_ERROR_CHECK( sd_ble_gap_data_length_update(m_conn_handle, NULL, NULL) );
|
||||
APP_ERROR_CHECK( sd_ble_gap_data_length_update(m_conn_handle, &m_dl_params, NULL) );
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
|
||||
@@ -1023,6 +1195,9 @@ uint32_t dfu_transport_ble_update_start(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
m_accum_len = 0;
|
||||
m_accum_active = false;
|
||||
|
||||
m_tear_down_in_progress = false;
|
||||
m_pkt_type = PKT_TYPE_INVALID;
|
||||
|
||||
@@ -1178,7 +1353,7 @@ lookup_table_t const _strevt_table =
|
||||
|
||||
void print_ble_event(uint16_t evt_id)
|
||||
{
|
||||
// const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
// const char * str = (const char *) lookup_find(&_strevt_table, evt_id);
|
||||
const char * str = NULL;
|
||||
PRINTF("BLE event: ");
|
||||
if ( str == NULL )
|
||||
|
||||
@@ -777,3 +777,147 @@ static void tft_controller_init(void) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CONTROLLER_ST7735
|
||||
|
||||
#define ST_CMD_DELAY 0x80 // special signifier for command lists
|
||||
|
||||
// ST77XX common commands (shared with ST7789)
|
||||
#define ST77XX_NOP 0x00
|
||||
#define ST77XX_SWRESET 0x01
|
||||
#define ST77XX_RDDID 0x04
|
||||
#define ST77XX_RDDST 0x09
|
||||
|
||||
#define ST77XX_SLPIN 0x10
|
||||
#define ST77XX_SLPOUT 0x11
|
||||
#define ST77XX_PTLON 0x12
|
||||
#define ST77XX_NORON 0x13
|
||||
|
||||
#define ST77XX_INVOFF 0x20
|
||||
#define ST77XX_INVON 0x21
|
||||
#define ST77XX_DISPOFF 0x28
|
||||
#define ST77XX_DISPON 0x29
|
||||
#define ST77XX_CASET 0x2A
|
||||
#define ST77XX_RASET 0x2B
|
||||
#define ST77XX_RAMWR 0x2C
|
||||
#define ST77XX_RAMRD 0x2E
|
||||
|
||||
#define ST77XX_PTLAR 0x30
|
||||
#define ST77XX_TEOFF 0x34
|
||||
#define ST77XX_TEON 0x35
|
||||
#define ST77XX_MADCTL 0x36
|
||||
#define ST77XX_VSCSAD 0x37
|
||||
#define ST77XX_COLMOD 0x3A
|
||||
|
||||
#define ST77XX_MADCTL_MY 0x80
|
||||
#define ST77XX_MADCTL_MX 0x40
|
||||
#define ST77XX_MADCTL_MV 0x20
|
||||
#define ST77XX_MADCTL_ML 0x10
|
||||
#define ST77XX_MADCTL_RGB 0x00
|
||||
|
||||
#define ST77XX_RDID1 0xDA
|
||||
#define ST77XX_RDID2 0xDB
|
||||
#define ST77XX_RDID3 0xDC
|
||||
#define ST77XX_RDID4 0xDD
|
||||
|
||||
// ST7735-specific commands
|
||||
#define ST7735_FRMCTR1 0xB1
|
||||
#define ST7735_FRMCTR2 0xB2
|
||||
#define ST7735_FRMCTR3 0xB3
|
||||
#define ST7735_INVCTR 0xB4
|
||||
#define ST7735_PWCTR1 0xC0
|
||||
#define ST7735_PWCTR2 0xC1
|
||||
#define ST7735_PWCTR3 0xC2
|
||||
#define ST7735_PWCTR4 0xC3
|
||||
#define ST7735_PWCTR5 0xC4
|
||||
#define ST7735_VMCTR1 0xC5
|
||||
#define ST7735_GMCTRP1 0xE0
|
||||
#define ST7735_GMCTRN1 0xE1
|
||||
#define ST7735_MADCTL_BGR 0x08
|
||||
|
||||
// Some ready-made 16-bit ('565') color settings:
|
||||
#define ST77XX_BLACK 0x0000
|
||||
#define ST77XX_WHITE 0xFFFF
|
||||
#define ST77XX_RED 0xF800
|
||||
#define ST77XX_GREEN 0x07E0
|
||||
#define ST77XX_BLUE 0x001F
|
||||
#define ST77XX_CYAN 0x07FF
|
||||
#define ST77XX_MAGENTA 0xF81F
|
||||
#define ST77XX_YELLOW 0xFFE0
|
||||
#define ST77XX_ORANGE 0xFC00
|
||||
|
||||
static void tft_controller_init(void) {
|
||||
// Init commands for ST7735 mini 160x80 screens
|
||||
// Based on Adafruit INITR_MINI160x80 sequence
|
||||
uint8_t cmdinit_st7735[] = {
|
||||
#if !defined(DISPLAY_PIN_RST) || (DISPLAY_PIN_RST < 0)
|
||||
// Software reset if rst pin not available
|
||||
ST77XX_SWRESET, ST_CMD_DELAY, 150,
|
||||
#endif
|
||||
// Out of sleep mode, w/delay 255 = 500ms
|
||||
ST77XX_SLPOUT, ST_CMD_DELAY, 255,
|
||||
// Frame rate control - normal mode (3 args)
|
||||
ST7735_FRMCTR1, 3, 0x01, 0x2C, 0x2D,
|
||||
// Frame rate control - idle mode (3 args)
|
||||
ST7735_FRMCTR2, 3, 0x01, 0x2C, 0x2D,
|
||||
// Frame rate control - partial mode (6 args)
|
||||
ST7735_FRMCTR3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D,
|
||||
// Display inversion control (1 arg)
|
||||
ST7735_INVCTR, 1, 0x07,
|
||||
// Power control 1 (3 args)
|
||||
ST7735_PWCTR1, 3, 0xA2, 0x02, 0x84,
|
||||
// Power control 2 (1 arg)
|
||||
ST7735_PWCTR2, 1, 0xC5,
|
||||
// Power control 3 - normal mode (2 args)
|
||||
ST7735_PWCTR3, 2, 0x0A, 0x00,
|
||||
// Power control 4 - idle mode (2 args)
|
||||
ST7735_PWCTR4, 2, 0x8A, 0x2A,
|
||||
// Power control 5 - partial mode (2 args)
|
||||
ST7735_PWCTR5, 2, 0x8A, 0xEE,
|
||||
// VCOM control (1 arg)
|
||||
ST7735_VMCTR1, 1, 0x0E,
|
||||
// Inversion off (required for Heltec T096)
|
||||
ST77XX_INVOFF, 0,
|
||||
// Set color mode, 1 arg: 16-bit color (0x05 for ST7735)
|
||||
ST77XX_COLMOD, 1 + ST_CMD_DELAY, 0x05, 10,
|
||||
// Mem access ctrl, 1 arg: row/col addr, color order
|
||||
ST77XX_MADCTL, 1, DISPLAY_MADCTL,
|
||||
// Column addr set, 4 args: XSTART/XEND (132 wide framebuffer)
|
||||
ST77XX_CASET, 4, 0x00, 0x00, 0x00, 0x83,
|
||||
// Row addr set, 4 args: YSTART/YEND (162 tall framebuffer)
|
||||
ST77XX_RASET, 4, 0x00, 0x00, 0x00, 0xA1,
|
||||
// Positive gamma correction (16 args)
|
||||
ST7735_GMCTRP1, 16,
|
||||
0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D,
|
||||
0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10,
|
||||
// Negative gamma correction (16 args)
|
||||
ST7735_GMCTRN1, 16,
|
||||
0x03, 0x1D, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D,
|
||||
0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10,
|
||||
// Normal display on, w/delay 10ms
|
||||
ST77XX_NORON, ST_CMD_DELAY, 10,
|
||||
// Main screen turn on, w/delay 100ms
|
||||
ST77XX_DISPON, ST_CMD_DELAY, 100
|
||||
};
|
||||
|
||||
size_t count = 0;
|
||||
while (count < sizeof(cmdinit_st7735)) {
|
||||
uint8_t const cmd = cmdinit_st7735[count++];
|
||||
uint8_t const cmd_arg = cmdinit_st7735[count++];
|
||||
uint8_t const has_delay = cmd_arg & ST_CMD_DELAY;
|
||||
uint8_t const narg = cmd_arg & ~ST_CMD_DELAY;
|
||||
|
||||
tft_cmd(cmd, cmdinit_st7735 + count, narg);
|
||||
count += narg;
|
||||
|
||||
if (has_delay) {
|
||||
uint16_t delay = (uint16_t) cmdinit_st7735[count++];
|
||||
if (delay == 255) {
|
||||
delay = 500; // If 255, delay for 500 ms
|
||||
}
|
||||
NRFX_DELAY_MS(delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -122,6 +122,7 @@ void board_display_init(void);
|
||||
void board_display_teardown(void);
|
||||
void board_display_draw_line(uint16_t y, uint8_t const* buf, size_t nbytes);
|
||||
void screen_draw_drag(void);
|
||||
void screen_draw_ble(void);
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _HELTEC_T096_H
|
||||
#define _HELTEC_T096_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 28) // White
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// #define LED_NEOPIXEL _PINNUM(0, 14)
|
||||
// #define NEOPIXEL_POWER_PIN _PINNUM(0, 21)
|
||||
// #define NEOPIXELS_NUMBER 2
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 10)
|
||||
#define BUTTON_2 _PINNUM(1, 2) // stock bootloader has this set to 34
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Display
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// VSensor required to power the display
|
||||
#define DISPLAY_VSENSOR_PIN _PINNUM(0, 26)
|
||||
#define DISPLAY_VSENSOR_ON 1
|
||||
|
||||
// #define DISPLAY_CONTROLLER_ST7789
|
||||
#define DISPLAY_CONTROLLER_ST7735
|
||||
|
||||
#define DISPLAY_PIN_SCK _PINNUM(0, 20)
|
||||
#define DISPLAY_PIN_MOSI _PINNUM(0, 17)
|
||||
|
||||
#define DISPLAY_PIN_CS _PINNUM(0, 22)
|
||||
#define DISPLAY_PIN_DC _PINNUM(0, 15)
|
||||
#define DISPLAY_PIN_RST _PINNUM(0, 13)
|
||||
#define DISPLAY_PIN_BL _PINNUM(1, 12)
|
||||
#define DISPLAY_BL_ON 0 // GPIO state to enable back light
|
||||
|
||||
#define DISPLAY_WIDTH 160
|
||||
#define DISPLAY_HEIGHT 80
|
||||
|
||||
// USB FACING LEFT
|
||||
#define DISPLAY_COL_OFFSET 24
|
||||
#define DISPLAY_ROW_OFFSET 0
|
||||
#define DISPLAY_MADCTL (ST77XX_MADCTL_MY | ST7735_MADCTL_BGR)
|
||||
|
||||
// USB FACING RIGHT
|
||||
//#define DISPLAY_COL_OFFSET 52
|
||||
//#define DISPLAY_ROW_OFFSET 40
|
||||
//#define DISPLAY_MADCTL (ST77XX_MADCTL_MX | ST7735_MADCTL_BGR)
|
||||
|
||||
#define DISPLAY_VSCSAD 0
|
||||
|
||||
#define DISPLAY_TITLE "T096"
|
||||
#define BANNER_TEXT "https://github.com/oltaco"
|
||||
#define FONT_SIZE_LARGE 3
|
||||
#define NOLABELS
|
||||
|
||||
#define SCREEN_BAR1_Y 0
|
||||
#define SCREEN_BAR1_H 32
|
||||
#define SCREEN_BAR2_Y 32
|
||||
#define SCREEN_BAR2_H 36
|
||||
#define SCREEN_BAR3_Y 68
|
||||
#define SCREEN_BAR3_H 12
|
||||
#define BANNER_TEXT_X 0
|
||||
#define BANNER_TEXT_Y 70
|
||||
#define DISPLAY_TITLE_Y 1
|
||||
#define UF2_VERSION_BASE_Y 24
|
||||
#define BLE_OTA_Y 38
|
||||
#define DRAG 34
|
||||
#define DRAGX 4
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Heltec AutoMation"
|
||||
#define BLEDIS_MODEL "Tracker"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0071
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0071
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Heltec-T096"
|
||||
#define UF2_VOLUME_LABEL "HeltecT096"
|
||||
#define UF2_BOARD_ID "Heltec-T096-v1"
|
||||
#define UF2_INDEX_URL "http://heltec.org/"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"T096_DFU"'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _HELTEC_T1_H
|
||||
#define _HELTEC_T1_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 16)
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
// #define LED_NEOPIXEL _PINNUM(0, 14)
|
||||
// #define NEOPIXEL_POWER_PIN _PINNUM(0, 21)
|
||||
// #define NEOPIXELS_NUMBER 2
|
||||
// #define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 10)
|
||||
#define BUTTON_2 _PINNUM(1, 2) // stock bootloader has this set to 34
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Display
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// VSensor required to power the display
|
||||
#define DISPLAY_VSENSOR_PIN _PINNUM(0, 13)
|
||||
#define DISPLAY_VSENSOR_ON 0
|
||||
|
||||
#define DISPLAY_CONTROLLER_ST7735
|
||||
|
||||
#define DISPLAY_PIN_SCK _PINNUM(1, 0)
|
||||
#define DISPLAY_PIN_MOSI _PINNUM(0, 24)
|
||||
|
||||
#define DISPLAY_PIN_CS _PINNUM(0, 12)
|
||||
#define DISPLAY_PIN_DC _PINNUM(0, 22)
|
||||
#define DISPLAY_PIN_RST _PINNUM(0, 20)
|
||||
#define DISPLAY_PIN_BL _PINNUM(0, 15)
|
||||
#define DISPLAY_BL_ON 0 // GPIO state to enable back light
|
||||
|
||||
#define DISPLAY_WIDTH 160
|
||||
#define DISPLAY_HEIGHT 80
|
||||
|
||||
// // USB FACING DOWN
|
||||
// #define DISPLAY_COL_OFFSET 24
|
||||
// #define DISPLAY_ROW_OFFSET 0
|
||||
// #define DISPLAY_MADCTL (ST77XX_MADCTL_MY | ST7735_MADCTL_BGR)
|
||||
|
||||
// USB FACING UP
|
||||
#define DISPLAY_COL_OFFSET 24
|
||||
#define DISPLAY_ROW_OFFSET 0
|
||||
#define DISPLAY_MADCTL (ST77XX_MADCTL_MX | ST7735_MADCTL_BGR)
|
||||
|
||||
#define DISPLAY_VSCSAD 0
|
||||
|
||||
#define DISPLAY_TITLE "T1"
|
||||
#define BANNER_TEXT "https://github.com/oltaco"
|
||||
#define FONT_SIZE_LARGE 3
|
||||
#define NOLABELS
|
||||
|
||||
#define SCREEN_BAR1_Y 0
|
||||
#define SCREEN_BAR1_H 32
|
||||
#define SCREEN_BAR2_Y 32
|
||||
#define SCREEN_BAR2_H 36
|
||||
#define SCREEN_BAR3_Y 68
|
||||
#define SCREEN_BAR3_H 12
|
||||
#define BANNER_TEXT_X 0
|
||||
#define BANNER_TEXT_Y 70
|
||||
#define DISPLAY_TITLE_Y 1
|
||||
#define UF2_VERSION_BASE_Y 24
|
||||
#define BLE_OTA_Y 38
|
||||
#define DRAG 34
|
||||
#define DRAGX 4
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Heltec AutoMation"
|
||||
#define BLEDIS_MODEL "T1"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0071
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0071
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Heltec-T1"
|
||||
#define UF2_VOLUME_LABEL "HeltecT1"
|
||||
#define UF2_BOARD_ID "Heltec-T1"
|
||||
#define UF2_INDEX_URL "http://heltec.org/"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"T1_DFU"'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _HELTEC_T114_H
|
||||
#define _HELTEC_T114_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 3) // Green
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
#define LED_NEOPIXEL _PINNUM(0, 14)
|
||||
#define NEOPIXEL_POWER_PIN _PINNUM(0, 21)
|
||||
#define NEOPIXELS_NUMBER 2
|
||||
#define BOARD_RGB_BRIGHTNESS 0x040404
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 10)
|
||||
#define BUTTON_2 _PINNUM(1, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Display
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// VSensor required to power the display
|
||||
#define DISPLAY_VSENSOR_PIN _PINNUM(0, 3)
|
||||
#define DISPLAY_VSENSOR_ON 0
|
||||
|
||||
#define DISPLAY_CONTROLLER_ST7789
|
||||
|
||||
#define DISPLAY_PIN_SCK _PINNUM(1, 8)
|
||||
#define DISPLAY_PIN_MOSI _PINNUM(1, 9)
|
||||
|
||||
#define DISPLAY_PIN_CS _PINNUM(0, 11)
|
||||
#define DISPLAY_PIN_DC _PINNUM(0, 12)
|
||||
#define DISPLAY_PIN_RST _PINNUM(0, 2)
|
||||
#define DISPLAY_PIN_BL _PINNUM(0, 15)
|
||||
#define DISPLAY_BL_ON 0 // GPIO state to enable back light
|
||||
|
||||
#define DISPLAY_WIDTH 240
|
||||
#define DISPLAY_HEIGHT 135
|
||||
|
||||
// USB FACING LEFT
|
||||
#define DISPLAY_COL_OFFSET 53
|
||||
#define DISPLAY_ROW_OFFSET 40
|
||||
#define DISPLAY_MADCTL (TFT_MADCTL_MX | TFT_MADCTL_RGB)
|
||||
|
||||
// USB FACING RIGHT
|
||||
//#define DISPLAY_COL_OFFSET 52
|
||||
//#define DISPLAY_ROW_OFFSET 40
|
||||
//#define DISPLAY_MADCTL (TFT_MADCTL_MY | TFT_MADCTL_RGB)
|
||||
|
||||
#define DISPLAY_VSCSAD 0
|
||||
|
||||
#define DISPLAY_TITLE "HT-n5262"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Heltec AutoMation"
|
||||
#define BLEDIS_MODEL "HT-n5262"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0071
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0071
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "HT-n5262"
|
||||
#define UF2_VOLUME_LABEL "HT-n5262"
|
||||
#define UF2_BOARD_ID "HT-n5262"
|
||||
#define UF2_INDEX_URL "HT-n5262"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"T114_DFU"'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _LILYGO_TECHO_H
|
||||
#define _LILYGO_TECHO_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 14) // Blue
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // hold down user button on boot to enter OTA DFU mode.
|
||||
#define BUTTON_1 _PINNUM(1, 10) // user button
|
||||
#define BUTTON_2 _PINNUM(1, 10)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "LilyGo"
|
||||
#define BLEDIS_MODEL "T-Echo v1.0"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0029
|
||||
|
||||
#define UF2_PRODUCT_NAME "LilyGo T-Echo"
|
||||
#define UF2_VOLUME_LABEL "TECHOBOOT"
|
||||
#define UF2_BOARD_ID "nRF52840-TEcho-v1"
|
||||
#define UF2_INDEX_URL "https://lilygo.cc/products/t-echo-lilygo"
|
||||
|
||||
#endif // _LILYGO_TECHO_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"LGTE_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _LILYGO_TECHO_LITE_H
|
||||
#define _LILYGO_TECHO_LITE_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
|
||||
#define PIN_LDO_ENABLE _PINNUM(0, 30)
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 7) // Green
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 5) // Blue
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // hold down user button on boot to enter OTA DFU mode.
|
||||
#define BUTTON_1 _PINNUM(0, 24) // user button
|
||||
#define BUTTON_2 _PINNUM(0, 24)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "LilyGo"
|
||||
#define BLEDIS_MODEL "T-Echo-Lite"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00DA
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00DA
|
||||
|
||||
#define UF2_PRODUCT_NAME "Lilygo"
|
||||
#define UF2_VOLUME_LABEL "TECHOLITE"
|
||||
#define UF2_BOARD_ID "T-Echo-Lite-nRF52840"
|
||||
#define UF2_INDEX_URL "https://www.lilygo.cc/"
|
||||
|
||||
#endif // _LILYGO_TECHO_LITE_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"LTEL_DFU"'
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
|
||||
void board_init2(void) {
|
||||
nrf_gpio_cfg_output(PIN_LDO_ENABLE);
|
||||
nrf_gpio_pin_write(PIN_LDO_ENABLE, 1);
|
||||
}
|
||||
|
||||
void board_teardown2(void) {
|
||||
nrf_gpio_pin_write(PIN_LDO_ENABLE, 0);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _MINEWSEMI_MX25LE01_H
|
||||
#define _MINEWSEMI_MX25LE01_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 7)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 5)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 27)
|
||||
#define BUTTON_2 _PINNUM(0, 11)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "MinewSemi"
|
||||
#define BLEDIS_MODEL "MX25LE01"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "MinewSemi MX25LE01"
|
||||
#define UF2_VOLUME_LABEL "MX25LE01"
|
||||
#define UF2_BOARD_ID "MinewSemi-MX25LE01"
|
||||
#define UF2_INDEX_URL "https://www.minewsemi.com"
|
||||
|
||||
#endif // _MINEWSEMI_MX25LE01_H
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"MX25_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PCA10056_H
|
||||
#define PCA10056_H
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN 13
|
||||
#define LED_SECONDARY_PIN 14
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 11
|
||||
#define BUTTON_2 12
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Nordic"
|
||||
#define BLEDIS_MODEL "PCA10056"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Shared VID/PID with Feather nRF52840, will be disabled for building in the future
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00DA
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00DA
|
||||
|
||||
#define UF2_PRODUCT_NAME "Nordic nRF52840 DK"
|
||||
#define UF2_BOARD_ID "nRF52840-pca10056-v1"
|
||||
#define UF2_INDEX_URL "https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK"
|
||||
|
||||
#endif // PCA10056_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"N056_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -39,9 +39,9 @@
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // none connected at all
|
||||
#define BUTTON_1 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_2 _PINNUM(0, 19) // no connection
|
||||
#define BUTTONS_NUMBER 2 // changed to GPIO32, default for meshcore and meshtastic
|
||||
#define BUTTON_1 _PINNUM(1, 0) // user button
|
||||
#define BUTTON_2 _PINNUM(1, 0)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"PROM_DFU"'
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _SEEED_SOLAR_NODE_P1_H
|
||||
#define _SEEED_SOLAR_NODE_P1_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 19)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define NEOPIXELS_NUMBER 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(1, 1) // Hold user button while pressing reset to enter OTA DFU mode
|
||||
#define BUTTON_2 _PINNUM(1, 1)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Seeed"
|
||||
#define BLEDIS_MODEL "SenseCAP Solar Node P1"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x2886
|
||||
#define USB_DESC_UF2_PID 0x0044
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0044
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Seeed Solar Node P1"
|
||||
#define UF2_VOLUME_LABEL "SENSECAP"
|
||||
#define UF2_BOARD_ID "nRF52840-SeeedSenseCAPSolarP1-v1"
|
||||
#define UF2_INDEX_URL "https://www.seeedstudio.com/"
|
||||
|
||||
#endif // _SEEED_SOLAR_NODE_P1_H
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"SCAP_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Yihui Xiong for Makerdiary
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _T1000_E_H
|
||||
#define _T1000_E_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 24) // Green
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 6) // Primary Button
|
||||
#define BUTTON_2 _PINNUM(0, 18) // unusable: RESET
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Seeed Studio"
|
||||
#define BLEDIS_MODEL "T1000-E"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x2886
|
||||
#define USB_DESC_UF2_PID 0x0057
|
||||
#define USB_DESC_CDC_ONLY_PID 0x0057
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// UF2
|
||||
//--------------------------------------------------------------------+
|
||||
#define UF2_PRODUCT_NAME "Seeed T1000-E for Meshtastic"
|
||||
#define UF2_VOLUME_LABEL "T1000-E"
|
||||
#define UF2_BOARD_ID "nRF52840-T1000-E-v1"
|
||||
#define UF2_INDEX_URL "https://www.seeedstudio.com/SenseCAP-Card-Tracker-T1000-E-for-Meshtastic-p-5913.html"
|
||||
|
||||
|
||||
#endif /* _T1000_E_H */
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"T1KE_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
set(MCU_VARIANT nrf52840)
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _THINKNODE_M1_H
|
||||
#define _THINKNODE_M1_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 14) // Blue LED
|
||||
#define LED_STATE_ON 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
// #define BUTTON_1 _PINNUM(1, 7) // Function button (TBN)
|
||||
#define BUTTON_1 _PINNUM(1, 10) // Hold page turn to enter OTA DFU mode.
|
||||
#define BUTTON_2 _PINNUM(1, 10) // Page Turn button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "ELECROW"
|
||||
#define BLEDIS_MODEL "ThinkNodeM1"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00DA
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00DA
|
||||
|
||||
#define UF2_PRODUCT_NAME "ELECROW ThinkNodeM1"
|
||||
#define UF2_VOLUME_LABEL "ThinkNodeM1"
|
||||
#define UF2_BOARD_ID "nRF52840-ThinkNodeM1-v1"
|
||||
#define UF2_INDEX_URL "https://www.elecrow.com"
|
||||
|
||||
#endif // _THINKNODE_M1_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"TNM1_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _THINKNODE_M3_H
|
||||
#define _THINKNODE_M3_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 5) // Blue
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // these pins were reversed from the stock bootloader
|
||||
#define BUTTON_1 _PINNUM(0, 11) // probably unconnected?
|
||||
#define BUTTON_2 _PINNUM(0, 12) // user button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "ELECROW"
|
||||
#define BLEDIS_MODEL "ThinkNode-M3"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00DA
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00DA
|
||||
|
||||
#define UF2_PRODUCT_NAME "ELECROW ThinkNode-M3"
|
||||
#define UF2_VOLUME_LABEL "ThinkNodeM3"
|
||||
#define UF2_BOARD_ID "nRF52840-ThinkNode-M3-v1"
|
||||
#define UF2_INDEX_URL "https://www.elecrow.com"
|
||||
|
||||
#endif // _THINKNODE_M3_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"TNM3_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _THINKNODE_M6_H
|
||||
#define _THINKNODE_M6_H
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(0, 7) // Blue
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2 // hold down user button on boot to enter OTA DFU mode.
|
||||
#define BUTTON_1 _PINNUM(0, 17) // user button
|
||||
#define BUTTON_2 _PINNUM(0, 17)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "ELECROW"
|
||||
#define BLEDIS_MODEL "ThinkNodeM6"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x00DA
|
||||
#define USB_DESC_CDC_ONLY_PID 0x00DA
|
||||
|
||||
#define UF2_PRODUCT_NAME "ELECROW ThinkNodeM6"
|
||||
#define UF2_VOLUME_LABEL "ThinkNodeM6"
|
||||
#define UF2_BOARD_ID "nRF52840-ThinkNodeM6-v1"
|
||||
#define UF2_INDEX_URL "https://www.elecrow.com"
|
||||
|
||||
#endif // _THINKNODE_M6_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"TNM6_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _TRACKER_L1
|
||||
#define _TRACKER_L1
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 1
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 1)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define NEOPIXELS_NUMBER 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 8) // user button
|
||||
#define BUTTON_2 _PINNUM(0, 8)
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "Seeed"
|
||||
#define BLEDIS_MODEL "Wio Tracker L1"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x2886
|
||||
#define USB_DESC_UF2_PID 0x1667
|
||||
#define USB_DESC_CDC_ONLY_PID 0x1667
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "Seeed TRACKER L1"
|
||||
#define UF2_VOLUME_LABEL "TRACKER L1"
|
||||
#define UF2_BOARD_ID "TRACKER L1"
|
||||
#define UF2_INDEX_URL "https://www.seeedstudio.com/"
|
||||
|
||||
#endif // _TRACKER_L1
|
||||
@@ -0,0 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"WTL1_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _WISCORE_RAK3401_BOARD_H
|
||||
#define _WISCORE_RAK3401_BOARD_H
|
||||
|
||||
// change default 1.8v to 3.3v, add by taylor
|
||||
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 3)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 4)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 8) // change default 0.0 to 0.8, add by Michael. This pin is not connected on 4631.
|
||||
#define BUTTON_2 _PINNUM(0, 8) // change default 0.0 to 0.8, add by Michael. This pin is not connected on 4631.
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "RAKWireless"
|
||||
#define BLEDIS_MODEL "WisBlock RAK3401"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "WisBlock RAK3401 Board"
|
||||
#define UF2_VOLUME_LABEL "RAK3401"
|
||||
#define UF2_BOARD_ID "WisBlock-RAK3401-Board"
|
||||
#define UF2_INDEX_URL "https://store.rakwireless.com/collections/wisblock-core"
|
||||
|
||||
#endif // _WISCORE_RAK3401_BOARD_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"3401_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"4631_DFU"'
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Ha Thach for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _WISMESH_TAG_H
|
||||
#define _WISMESH_TAG_H
|
||||
|
||||
// change default 1.8v to 3.3v, add by taylor
|
||||
#define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
|
||||
|
||||
#define _PINNUM(port, pin) ((port)*32 + (pin))
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* LED
|
||||
*------------------------------------------------------------------*/
|
||||
#define LEDS_NUMBER 2
|
||||
#define LED_PRIMARY_PIN _PINNUM(1, 3)
|
||||
#define LED_SECONDARY_PIN _PINNUM(1, 4)
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BUTTON
|
||||
*------------------------------------------------------------------*/
|
||||
#define BUTTONS_NUMBER 2
|
||||
#define BUTTON_1 _PINNUM(0, 9) // Allow booting to OTA DFU from button
|
||||
#define BUTTON_2 _PINNUM(0, 9) // Allow booting to OTA DFU from button
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
|
||||
#define BUTTON_DFU_DELAY_MS 500
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE OTA
|
||||
//--------------------------------------------------------------------+
|
||||
#define BLEDIS_MANUFACTURER "RAKWireless"
|
||||
#define BLEDIS_MODEL "WisMesh Tag"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB
|
||||
//--------------------------------------------------------------------+
|
||||
#define USB_DESC_VID 0x239A
|
||||
#define USB_DESC_UF2_PID 0x0029
|
||||
#define USB_DESC_CDC_ONLY_PID 0x002A
|
||||
|
||||
//------------- UF2 -------------//
|
||||
#define UF2_PRODUCT_NAME "WisMesh Tag"
|
||||
#define UF2_VOLUME_LABEL "RAK4631"
|
||||
#define UF2_BOARD_ID "WisMesh-Tag"
|
||||
#define UF2_INDEX_URL "https://store.rakwireless.com/products/wismesh-tag-meshtastic-gps-lora-tracker-ip66"
|
||||
|
||||
#endif // _WISMESH_TAG_H
|
||||
@@ -0,0 +1,2 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
CFLAGS += -DDEVICE_NAME='"RTAG_DFU"'
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "boards.h"
|
||||
#include "uf2/configkeys.h"
|
||||
|
||||
__attribute__((used, section(".bootloaderConfig")))
|
||||
const uint32_t bootloaderConfig[] =
|
||||
{
|
||||
/* CF2 START */
|
||||
CFG_MAGIC0, CFG_MAGIC1, // magic
|
||||
5, 100, // used entries, total entries
|
||||
|
||||
204, 0x100000, // FLASH_BYTES = 0x100000
|
||||
205, 0x40000, // RAM_BYTES = 0x40000
|
||||
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
|
||||
209, 0xada52840, // UF2_FAMILY = 0xada52840
|
||||
210, 0x20, // PINS_PORT_SIZE = PA_32
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
/* CF2 END */
|
||||
};
|
||||
@@ -1,2 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"XIAO_DFU"'
|
||||
@@ -1,2 +1,3 @@
|
||||
MCU_SUB_VARIANT = nrf52840
|
||||
SD_VERSION = 7.3.0
|
||||
SD_VERSION = 7.3.0
|
||||
CFLAGS += -DDEVICE_NAME='"XIAO_DFU"'
|
||||
+23
-5
@@ -125,9 +125,9 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
|
||||
// DFU_DBL_RESET magic is used to determined which mode is entered
|
||||
#define APP_ASKS_FOR_SINGLE_TAP_RESET() (*((uint32_t*)(DFU_BANK_0_REGION_START + 0x200)) == 0x87eeb07c)
|
||||
|
||||
// These value must be the same with one in dfu_transport_ble.c
|
||||
// These values must match the values in dfu_transport_ble.c and MAX_DFU_PKT_LEN should match BLEGATT_ATT_MTU_MAX - 3
|
||||
#define BLEGAP_EVENT_LENGTH 6
|
||||
#define BLEGATT_ATT_MTU_MAX 23
|
||||
#define BLEGATT_ATT_MTU_MAX 247
|
||||
enum {
|
||||
BLE_CONN_CFG_HIGH_BANDWIDTH = 1
|
||||
};
|
||||
@@ -235,6 +235,7 @@ static void check_dfu_mode(void) {
|
||||
bool const dfu_skip = (gpregret == DFU_MAGIC_SKIP);
|
||||
|
||||
bool const reason_reset_pin = (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk) ? true : false;
|
||||
bool const double_reset = ((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && reason_reset_pin;
|
||||
|
||||
// start either serial, uf2 or ble
|
||||
bool dfu_start = _ota_dfu || serial_only_dfu || uf2_dfu ||
|
||||
@@ -247,6 +248,14 @@ static void check_dfu_mode(void) {
|
||||
if (dfu_skip) return;
|
||||
|
||||
/*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
|
||||
// Allow boards wait for button release so that wake presses don't enter DFU
|
||||
#ifdef BUTTON_DFU_DELAY_MS
|
||||
for (uint16_t waited = 0; waited < BUTTON_DFU_DELAY_MS; waited += 10) {
|
||||
if (!button_pressed(BUTTON_DFU) && !button_pressed(BUTTON_FRESET)) break;
|
||||
NRFX_DELAY_MS(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
// DFU button pressed
|
||||
dfu_start = dfu_start || button_pressed(BUTTON_DFU);
|
||||
|
||||
@@ -259,7 +268,7 @@ static void check_dfu_mode(void) {
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET()) dfu_start = 1;
|
||||
|
||||
// App mode: Double Reset detection or DFU startup for nrf52832
|
||||
if (!(just_start_app || dfu_start || !valid_app)) {
|
||||
if (!(just_start_app || dfu_start)) { // removed !valid_app check to allow double reset even when no app
|
||||
#ifdef NRF52832_XXAA
|
||||
/* Even DFU is not active, we still force an 1000 ms dfu serial mode when startup
|
||||
* to support auto programming from Arduino IDE
|
||||
@@ -285,9 +294,17 @@ static void check_dfu_mode(void) {
|
||||
(*dbl_reset_mem) = 0;
|
||||
}
|
||||
|
||||
if ((dfu_start || !valid_app) && !serial_only_dfu && !uf2_dfu && !double_reset) {
|
||||
_ota_dfu = true; // set default to OTA only when no explicit UF2/serial/dbl-reset
|
||||
}
|
||||
|
||||
// Enter DFU mode accordingly to input
|
||||
if (dfu_start || !valid_app) {
|
||||
if (_ota_dfu) {
|
||||
#ifdef DISPLAY_PIN_SCK
|
||||
board_display_init();
|
||||
screen_draw_ble();
|
||||
#endif
|
||||
led_state(STATE_BLE_DISCONNECTED);
|
||||
if (!_sd_inited) mbr_init_sd();
|
||||
_sd_inited = true;
|
||||
@@ -308,6 +325,7 @@ static void check_dfu_mode(void) {
|
||||
|
||||
if (_ota_dfu) {
|
||||
sd_softdevice_disable();
|
||||
usb_teardown(); // allow booting to app after ota even if usb is connected
|
||||
} else {
|
||||
usb_teardown();
|
||||
}
|
||||
@@ -366,12 +384,12 @@ static uint32_t ble_stack_init(void) {
|
||||
// Note: Interrupt state (enabled, forwarding) is not work properly if not enable ble
|
||||
sd_ble_enable(&ram_start);
|
||||
|
||||
#if 0
|
||||
// #if 0
|
||||
ble_opt_t opt;
|
||||
varclr(&opt);
|
||||
opt.common_opt.conn_evt_ext.enable = 1; // enable Data Length Extension
|
||||
sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
+108
-82
@@ -26,14 +26,17 @@
|
||||
|
||||
#if defined(DISPLAY_PIN_SCK)
|
||||
|
||||
#ifndef BANNER_TEXT
|
||||
#define BANNER_TEXT "made by oltaco / github.com/oltaco"
|
||||
#endif //BANNER_TEXT
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Overlap 4x chars by this much.
|
||||
#define CHAR4_KERNING 3
|
||||
|
||||
// Width of a single 4x char, adjusted by kerning
|
||||
#define CHAR4_KERNED_WIDTH (6 * 4 - CHAR4_KERNING)
|
||||
// Size independent kerning
|
||||
#define CHAR_ADV(n) (5 * (n) + 1) // cursor step between chars
|
||||
#define CHAR_INK(n) (6 * (n)) // columns printch actually writes
|
||||
#define TEXT_WIDTH(n, len) ((len) ? CHAR_ADV(n) * ((len) - 1) + CHAR_INK(n) : 0)
|
||||
|
||||
#define COL0(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
|
||||
#define COL(c) COL0((c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff)
|
||||
@@ -73,6 +76,56 @@ const uint16_t palette[] = {
|
||||
COL(0x000000), // 15
|
||||
};
|
||||
|
||||
// inital display-size agnostic hack
|
||||
#ifndef SCREEN_BAR1_Y
|
||||
#define SCREEN_BAR1_Y 0
|
||||
#endif
|
||||
#ifndef SCREEN_BAR1_H
|
||||
#define SCREEN_BAR1_H 52
|
||||
#endif
|
||||
|
||||
#ifndef SCREEN_BAR2_Y
|
||||
#define SCREEN_BAR2_Y 52
|
||||
#endif
|
||||
#ifndef SCREEN_BAR2_H
|
||||
#define SCREEN_BAR2_H 55
|
||||
#endif
|
||||
|
||||
#ifndef SCREEN_BAR3_Y
|
||||
#define SCREEN_BAR3_Y 107
|
||||
#endif
|
||||
#ifndef SCREEN_BAR3_H
|
||||
#define SCREEN_BAR3_H 14
|
||||
#endif
|
||||
#ifndef fileLogo_X
|
||||
#define fileLogo_X 0
|
||||
#endif
|
||||
#ifndef arrowLogo_X
|
||||
#define arrowLogo_X 65
|
||||
#endif
|
||||
#ifndef pendriveLogo_X
|
||||
#define pendriveLogo_X 129
|
||||
#endif
|
||||
#ifndef DISPLAY_TITLE_Y
|
||||
#define DISPLAY_TITLE_Y 5
|
||||
#endif
|
||||
#ifndef UF2_VERSION_BASE_Y
|
||||
#define UF2_VERSION_BASE_Y 40
|
||||
#endif
|
||||
#ifndef BANNER_TEXT_X
|
||||
#define BANNER_TEXT_X 23
|
||||
#endif
|
||||
#ifndef BANNER_TEXT_Y
|
||||
#define BANNER_TEXT_Y 110
|
||||
#endif
|
||||
#ifndef BLE_OTA_Y
|
||||
#define BLE_OTA_Y 65
|
||||
#endif
|
||||
#ifndef FONT_SIZE_LARGE
|
||||
#define FONT_SIZE_LARGE 4
|
||||
#endif
|
||||
|
||||
|
||||
// TODO only buffer partial screen to save SRAM
|
||||
// ESP32s2 can only statically allocated DRAM up to 160KB.
|
||||
// the remaining 160KB can only be allocated at runtime as heap.
|
||||
@@ -88,38 +141,16 @@ extern const uint8_t arrowLogo[];
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// print character with font size = 1
|
||||
static void printch(int x, int y, int color, const uint8_t* fnt) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
// print character
|
||||
static void printch(int x, int y, int color, const uint8_t* fnt, int size) {
|
||||
for (int i = 0; i < 6 * size; ++i) {
|
||||
uint8_t* p = frame_buf + (x + i) * DISPLAY_HEIGHT + y;
|
||||
uint8_t mask = 0x01;
|
||||
uint8_t b = fnt[i / size];
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
if (*fnt & mask) {
|
||||
*p = color;
|
||||
if (b & (1u << j)) {
|
||||
for (int k = 0; k < size; ++k) p[k] = color;
|
||||
}
|
||||
p++;
|
||||
mask <<= 1;
|
||||
}
|
||||
fnt++;
|
||||
}
|
||||
}
|
||||
|
||||
// print character with font size = 4
|
||||
static void printch4(int x, int y, int color, const uint8_t* fnt) {
|
||||
for (int i = 0; i < 6 * 4; ++i) {
|
||||
uint8_t* p = frame_buf + (x + i) * DISPLAY_HEIGHT + y;
|
||||
uint8_t mask = 0x01;
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
if (*fnt & mask) {
|
||||
*p = color;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
mask <<= 1;
|
||||
}
|
||||
if ((i & 3) == 3) {
|
||||
fnt++;
|
||||
p += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,45 +202,25 @@ static void printicon(int x, int y, int color, const uint8_t* icon) {
|
||||
}
|
||||
}
|
||||
|
||||
// print text with font size = 1
|
||||
static void print(int x, int y, int col, const char* text) {
|
||||
int x0 = x;
|
||||
while (*text) {
|
||||
char c = *text++;
|
||||
if (c == '\r') continue;
|
||||
if (c == '\n') {
|
||||
x = x0;
|
||||
y += 10;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
if (x + 8 > DISPLAY_WIDTH) {
|
||||
x = x0;
|
||||
y += 10;
|
||||
}
|
||||
*/
|
||||
if (c < ' ') c = '?';
|
||||
if (c >= 0x7f) c = '?';
|
||||
c -= ' ';
|
||||
printch(x, y, col, &font8[c * 6]);
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
// Print text with font size = 4
|
||||
static void print4(int x, int y, int color, const char* text) {
|
||||
static void print(int x, int y, int color, const char* text, int size) {
|
||||
while (*text) {
|
||||
char c = *text++;
|
||||
c -= ' ';
|
||||
printch4(x, y, color, &font8[c * 6]);
|
||||
x += CHAR4_KERNED_WIDTH;
|
||||
if (x + CHAR4_KERNED_WIDTH > DISPLAY_WIDTH) {
|
||||
printch(x, y, color, &font8[c * 6], size);
|
||||
x += CHAR_ADV(size);
|
||||
if (x + CHAR_INK(size) > DISPLAY_WIDTH) {
|
||||
// Next char won't fit.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void print_centered(int y, int color, const char* text, int size) {
|
||||
int len = (int) strlen(text);
|
||||
int text_x = (DISPLAY_WIDTH - TEXT_WIDTH(size, len)) / 2;
|
||||
print(text_x >= 0 ? text_x : 0, y, color, text, size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -238,27 +249,42 @@ static void drawBar(int y, int h, int color) {
|
||||
|
||||
// draw drag & drop screen
|
||||
void screen_draw_drag(void) {
|
||||
drawBar(0, 52, COLOR_GREEN);
|
||||
drawBar(52, 55, COLOR_BLUE);
|
||||
drawBar(107, 14, COLOR_ORANGE);
|
||||
drawBar(SCREEN_BAR1_Y, SCREEN_BAR1_H, COLOR_GREEN);
|
||||
drawBar(SCREEN_BAR2_Y, SCREEN_BAR2_H, COLOR_BLUE);
|
||||
drawBar(SCREEN_BAR3_Y, SCREEN_BAR3_H, COLOR_ORANGE);
|
||||
|
||||
// Center UF2_PRODUCT_NAME and UF2_VERSION_BASE.
|
||||
int name_x = (DISPLAY_WIDTH - CHAR4_KERNED_WIDTH * (int) strlen(DISPLAY_TITLE)) / 2;
|
||||
print4(name_x >= 0 ? name_x : 0, 5, COLOR_WHITE, DISPLAY_TITLE);
|
||||
|
||||
int version_x = (DISPLAY_WIDTH - 6 * (int) strlen(UF2_VERSION_BASE)) / 2;
|
||||
print(version_x >= 0 ? version_x : 0, 40, COLOR_PURPLE, UF2_VERSION_BASE);
|
||||
|
||||
// TODO the reset should be center as well
|
||||
print(23, 110, 1, "circuitpython.org");
|
||||
// Print title, version, banner.
|
||||
print_centered(DISPLAY_TITLE_Y, COLOR_WHITE, DISPLAY_TITLE, FONT_SIZE_LARGE);
|
||||
print_centered(UF2_VERSION_BASE_Y, COLOR_PURPLE, UF2_VERSION_BASE, 1);
|
||||
print_centered(BANNER_TEXT_Y, COLOR_WHITE, BANNER_TEXT, 1);
|
||||
|
||||
#ifndef DRAG
|
||||
#define DRAG 70
|
||||
#define DRAGX 10
|
||||
printicon(DRAGX + 20, DRAG + 5, COLOR_WHITE, fileLogo);
|
||||
printicon(DRAGX + 66, DRAG, COLOR_WHITE, arrowLogo);
|
||||
printicon(DRAGX + 108, DRAG, COLOR_WHITE, pendriveLogo);
|
||||
print(10, DRAG - 12, COLOR_WHITE, "firmware.uf2");
|
||||
print(90, DRAG - 12, COLOR_WHITE, UF2_VOLUME_LABEL);
|
||||
#endif
|
||||
#ifndef DRAGX
|
||||
#define DRAGX 47
|
||||
#endif
|
||||
printicon(DRAGX + fileLogo_X, DRAG + 5, COLOR_WHITE, fileLogo);
|
||||
printicon(DRAGX + arrowLogo_X, DRAG, COLOR_WHITE, arrowLogo);
|
||||
printicon(DRAGX + pendriveLogo_X, DRAG, COLOR_WHITE, pendriveLogo);
|
||||
#ifndef NOLABELS
|
||||
print(22, DRAG - 12, COLOR_WHITE, "firmware.uf2", 1);
|
||||
print(160, DRAG - 12, COLOR_WHITE, UF2_VOLUME_LABEL, 1);
|
||||
#endif // NOLABELS
|
||||
|
||||
draw_screen(frame_buf);
|
||||
}
|
||||
|
||||
void screen_draw_ble(void) {
|
||||
drawBar(SCREEN_BAR1_Y, SCREEN_BAR1_H, COLOR_GREEN);
|
||||
drawBar(SCREEN_BAR2_Y, SCREEN_BAR2_H, COLOR_BLUE);
|
||||
drawBar(SCREEN_BAR3_Y, SCREEN_BAR3_H, COLOR_ORANGE);
|
||||
|
||||
// Print title, version, OTA, banner
|
||||
print_centered(DISPLAY_TITLE_Y, COLOR_WHITE, DISPLAY_TITLE, FONT_SIZE_LARGE);
|
||||
print_centered(UF2_VERSION_BASE_Y, COLOR_PURPLE, UF2_VERSION_BASE, 1);
|
||||
print_centered(BLE_OTA_Y, COLOR_WHITE, "BLE OTA", FONT_SIZE_LARGE);
|
||||
print_centered(BANNER_TEXT_Y, COLOR_WHITE, BANNER_TEXT, 1);
|
||||
|
||||
draw_screen(frame_buf);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user