Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the T-Echo w/ eInk display #254

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9ccd333
add placeholder support for othernet PPR board
geeksville May 16, 2020
718c310
Merge remote-tracking branch 'root/master'
geeksville Jun 4, 2020
1d77daa
Place data from .uicrREGOUT0 into UICR.REGOUT0 flash word.
geeksville Jun 4, 2020
aba9b52
Update to lastest bootloader/tinyusb code, set regout0 to correct value
geeksville Jun 4, 2020
0645700
Change SEGGER options to non blocking print.
geeksville Jun 15, 2020
da07b56
Do not merge: nasty hacks to make a prototype work
geeksville Jun 15, 2020
d6019de
Place data from .uicrREGOUT0 into UICR.REGOUT0 flash word.
geeksville Jun 4, 2020
9478eb7
address comments from review (warn users, also support 833)
geeksville Jun 16, 2020
778d229
Add support for RAK815 board from here:
geeksville Jul 10, 2020
49865ce
Merge branch 'regout0'
geeksville Jul 10, 2020
25e3f01
Fix RAK815 LEDs
geeksville Jul 10, 2020
3987928
First attempt at TTGO eink bootloader
geeksville Sep 24, 2020
f6bfaac
Don't force CONFIG_GPIO_AS_PINRESET on all boards
geeksville Sep 28, 2020
4f9022d
ttgo_eink bootloader is done (I think)
geeksville Sep 28, 2020
69bd8eb
protect against buttons showing wrong values at power on
geeksville Sep 29, 2020
4582f73
first cut of Othernet PPR1 bootloader
geeksville Oct 14, 2020
f38f8f4
Reenable using P0.18 as RESET on all boards
geeksville Oct 15, 2020
dd3e0e7
allow 200ms for caps to charge up to prevent false button readings
geeksville Oct 15, 2020
c01b9ea
Merge branch 'sd611'
geeksville Oct 28, 2020
b82b101
Merge branch 'master' of https://github.com/adafruit/Adafruit_nRF52_B…
mc-hamster Dec 15, 2021
70aa829
Merge branch 'adafruit-master' into adafruit-update
mc-hamster Dec 15, 2021
d6fcd18
Merge branch 'adafruit:master' into adafruit-update
mc-hamster Dec 22, 2021
c58406b
Merge branch 'adafruit:master' into adafruit-update
mc-hamster Dec 25, 2021
04cffee
Merge branch 'adafruit:master' into adafruit-update
mc-hamster Jan 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/tinyusb"]
path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git
url = https://github.com/meshtastic/tinyusb.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure you are making PR to this repo and not other fork ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good eye.

I started the PR as a draft to take advantage of the CI tests here but would eventually submit it here.

We’re running this through a few tests at the moment and will take it out of draft once we have confidence and I will write up the change description.

Thanks!

[submodule "lib/nrfx"]
path = lib/nrfx
url = https://github.com/NordicSemiconductor/nrfx.git
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ endif

# Defined Symbol (MACROS)
CFLAGS += -D__HEAP_SIZE=0

# We don't want this on all boards
CFLAGS += -DCONFIG_GPIO_AS_PINRESET

# Skip defining CONFIG_NFCT_PINS_AS_GPIOS if the device uses the NFCT.
Expand Down
22 changes: 22 additions & 0 deletions NOTES-kh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
git submodule update --init --recursive

npm install --global xpm
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
Installing globally in '/home/kevinh/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/9.2.1-1.1.1'...

make BOARD=pca10056 all
make BOARD=othernet_ppr all DEBUG=1

pip3 install --user adafruit-nrfutil

# To program with jlink

```

JLinkExe -device nrf52840_xxaa -if swd -speed 4000 -autoconnect 1

objdump -s ./_build/build-othernet_ppr/othernet_ppr_bootloader-0.3.2-108-g718c310-dirty_s140_6.1.1.hex | less


nrfjprog -e -f nrf52; nrfjprog -f nrf52 --program ./_build/build-othernet_ppr/othernet_ppr_bootloader-0.3.2-*-dirty_s140_6.1.1.hex
```
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 1151 files
16 changes: 16 additions & 0 deletions linker/nrf52833.ld
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ MEMORY

/** Location in UICR where mbr params page address is stored. */
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04

/** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot)
*
* IMPORTANT NOTE: This controls the voltage provided on the VCC output of the CPU. Changing this value from the default
* can physically damage parts on your board. If using a SWD debugger you should consider connecting the Vref input
* for that debugger to the VCC rail. Think carefully before using this feature.
* Example usage:
* __attribute__ ((section(".uicrREGOUT0"))) volatile uint32_t m_uicr_regout0 = 0xfffffff4;
*/
UICR_REGOUT0(r) : ORIGIN = 0x10001304, LENGTH = 0x04
}

SECTIONS
Expand Down Expand Up @@ -74,6 +84,12 @@ SECTIONS
KEEP(*(.uicrMbrParamsPageAddress))
} > UICR_MBR_PARAM_PAGE

/* Write REGOUT0 in UICR. */
.uicrREGOUT0 :
{
KEEP(*(.uicrREGOUT0))
} > UICR_REGOUT0

.dbl_reset(NOLOAD) :
{

Expand Down
16 changes: 16 additions & 0 deletions linker/nrf52840.ld
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ MEMORY

/** Location in UICR where mbr params page address is stored. */
UICR_MBR_PARAM_PAGE(r) : ORIGIN = 0x10001018, LENGTH = 0x04

/** Location in UICR of REGOUT0 (used to set voltage levels for VCC at boot)
*
* IMPORTANT NOTE: This controls the voltage provided on the VCC output of the CPU. Changing this value from the default
* can physically damage parts on your board. If using a SWD debugger you should consider connecting the Vref input
* for that debugger to the VCC rail. Think carefully before using this feature.
* Example usage:
* __attribute__ ((section(".uicrREGOUT0"))) volatile uint32_t m_uicr_regout0 = 0xfffffff4;
*/
UICR_REGOUT0(r) : ORIGIN = 0x10001304, LENGTH = 0x04
}

SECTIONS
Expand Down Expand Up @@ -81,6 +91,12 @@ SECTIONS
KEEP(*(.uicrMbrParamsPageAddress))
} > UICR_MBR_PARAM_PAGE

/* Write REGOUT0 in UICR. */
.uicrREGOUT0 :
{
KEEP(*(.uicrREGOUT0))
} > UICR_REGOUT0

.dbl_reset(NOLOAD) :
{

Expand Down
11 changes: 10 additions & 1 deletion src/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
void neopixel_teardown(void);
#endif

#ifndef BUTTON_SENSE
#define BUTTON_SENSE BUTTON_PULL
#endif

//------------- IMPLEMENTATION -------------//
void button_init(uint32_t pin)
{
Expand All @@ -58,7 +62,7 @@ void button_init(uint32_t pin)

bool button_pressed(uint32_t pin)
{
uint32_t const active_state = (BUTTON_PULL == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
uint32_t const active_state = (BUTTON_SENSE == NRF_GPIO_PIN_PULLDOWN ? 1 : 0);
return nrf_gpio_pin_read(pin) == active_state;
}

Expand All @@ -71,6 +75,11 @@ void board_init(void)
NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC;
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;

#ifdef FORCE_HIGH
nrf_gpio_cfg_output(FORCE_HIGH);
nrf_gpio_pin_write(FORCE_HIGH, 1);
#endif

button_init(BUTTON_DFU);
button_init(BUTTON_FRESET);
NRFX_DELAY_US(100); // wait for the pin state is stable
Expand Down
65 changes: 65 additions & 0 deletions src/boards/othernet_ppr/board.h
Original file line number Diff line number Diff line change
@@ -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 PPR_H
#define PPR_H

/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 0
#define LED_SECONDARY_PIN 1
#define LED_STATE_ON 1

/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 4 // center
#define BUTTON_2 2
#define BUTTON_PULL \
NRF_GPIO_PIN_PULLUP // really should be NOPULL but the bootloader code only
// checks for PULLUP vs PULLDOWN

//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "Othernet"
#define BLEDIS_MODEL "PPR"

//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+

#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x0029

#define UF2_PRODUCT_NAME "Othernet PPR"
#define UF2_VOLUME_LABEL "PPRBOOT "
#define UF2_BOARD_ID "nRF52840-ppr-v1"
#define UF2_INDEX_URL "https://www.meshtastic.org"

#endif
1 change: 1 addition & 0 deletions src/boards/othernet_ppr/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MCU_SUB_VARIANT = nrf52840
22 changes: 22 additions & 0 deletions src/boards/othernet_ppr/pinconfig.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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 */
};

__attribute__ ((section(".uicrREGOUT0")))
volatile uint32_t m_uicr_regout0 = 0xfffffff4;
69 changes: 69 additions & 0 deletions src/boards/othernet_ppr1/board.h
Original file line number Diff line number Diff line change
@@ -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 OTHERNET_PPR1_H
#define OTHERNET_PPR1_H

/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 25 // green
#define LED_SECONDARY_PIN 11 // red
#define LED_STATE_ON 1

/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 5
#define BUTTON_1 (2)
#define BUTTON_2 (3)
#define BUTTON_3 (4)
#define BUTTON_4 (5)
#define BUTTON_5 (6)
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP

/// This is VUSB_EN, we need it forced high to power VBUS_nRF (hw bug)
#define FORCE_HIGH 21

//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "othernet"
#define BLEDIS_MODEL "ppr1"

//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+

#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0029
#define USB_DESC_CDC_ONLY_PID 0x0029

#define UF2_PRODUCT_NAME "PPR1"
#define UF2_VOLUME_LABEL "PPR1Boot "
#define UF2_BOARD_ID "othernet-ppr1"
#define UF2_INDEX_URL "https://othernet.is/ppr1"

#endif
1 change: 1 addition & 0 deletions src/boards/othernet_ppr1/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MCU_SUB_VARIANT = nrf52833
22 changes: 22 additions & 0 deletions src/boards/othernet_ppr1/pinconfig.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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, 0x80000, // FLASH_BYTES = 0x100000
205, 0x20000, // 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 */
};

// We want output pin voltages to be 3.3V
__attribute__((section(".uicrREGOUT0"))) volatile uint32_t m_uicr_regout0 = 0xfffffff5;
62 changes: 62 additions & 0 deletions src/boards/rak815/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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 _RAK815_H
#define _RAK815_H

/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN 25
#define LED_SECONDARY_PIN 26
#define LED_STATE_ON 1

/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 27
#define BUTTON_2 24
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP

/*------------------------------------------------------------------*/
/* UART (only used by nRF52832)
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER 28
#define TX_PIN_NUMBER 29
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false

//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
#define BLEDIS_MANUFACTURER "RAK"
#define BLEDIS_MODEL "RAK815"

#define UF2_PRODUCT_NAME "RAK815"
#define UF2_INDEX_URL "https://store.rakwireless.com/products/rak815-hybrid-location-tracker"

#endif // _RAK815_H
2 changes: 2 additions & 0 deletions src/boards/rak815/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# nrf52 is nrf52832
MCU_SUB_VARIANT = nrf52
Loading