Bangle.js 2 new bootloader build

This commit is contained in:
Gordon Williams 2021-10-19 10:22:01 +01:00
parent 8cf17c7fdf
commit 82d441b948
4 changed files with 19 additions and 7 deletions

View File

@ -47,8 +47,6 @@ info = {
'DEFINES += -DESPR_DCDC_ENABLE=1', # Use DC/DC converter
'ESPR_BLUETOOTH_ANCS=1', # Enable ANCS (Apple notifications) support
'DEFINES += -DSPIFLASH_SLEEP_CMD', # SPI flash needs to be explicitly slept and woken up
'DEFINES += -DNRF_BOOTLOADER_NO_WRITE_PROTECT=1', # By default the bootloader protects flash. Avoid this (a patch for NRF_BOOTLOADER_NO_WRITE_PROTECT must be applied first)
'DEFINES += -DBUTTONPRESS_TO_REBOOT_BOOTLOADER',
'DEFINES += -DAPP_TIMER_OP_QUEUE_SIZE=6', # Bangle.js accelerometer poll handler needs something else in queue size
'DEFINES+=-DBLUETOOTH_NAME_PREFIX=\'"Bangle.js"\'',
'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
@ -69,7 +67,10 @@ info = {
'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0xa9,0xae,0xb6',
'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem',
'DEFINES += -DNRF_BOOTLOADER_NO_WRITE_PROTECT=1', # By default the bootloader protects flash. Avoid this (a patch for NRF_BOOTLOADER_NO_WRITE_PROTECT must be applied first)
'DEFINES += -DBUTTONPRESS_TO_REBOOT_BOOTLOADER',
'BOOTLOADER_SETTINGS_FAMILY=NRF52840',
'DEFINES += -DESPR_BOOTLOADER_SPIFLASH', # Allow bootloader to flash direct from SPI flash
'NRF_SDK15=1'
]
}

View File

@ -517,12 +517,13 @@ ifeq ($(BOARD),MICROBIT)
if [ -d "/media/$(USER)/MICROBIT" ]; then cp $(PROJ_NAME).hex /media/$(USER)/MICROBIT;sync; fi
if [ -d "/media/MICROBIT" ]; then cp $(PROJ_NAME).hex /media/MICROBIT;sync; fi
else
# nrfjprog --family NRF52 --clockspeed 50000 --recover; will recover a chip if write-protect was set on it
if type nrfjprog 2>/dev/null; then nrfjprog --family $(FAMILY) --clockspeed 50000 --program $(PROJ_NAME).hex --chiperase --reset; \
elif [ -d "/media/$(USER)/JLINK" ]; then cp $(PROJ_NAME).hex /media/$(USER)/JLINK;sync; \
elif [ -d "/media/JLINK" ]; then cp $(PROJ_NAME).hex /media/JLINK;sync; fi
nrfjprog --family NRF52 --clockspeed 50000 --recover
nrfjprog --family $(FAMILY) --clockspeed 50000 --program $(PROJ_NAME).hex --chiperase --reset
endif
partflash: all
nrfjprog --family $(FAMILY) --clockspeed 50000 --program $(PROJ_NAME).hex --sectorerase --reset;
ifdef DFU_UPDATE_BUILD_WITH_HEX
proj: $(PROJ_NAME).hex $(PROJ_NAME).zip
else

View File

@ -175,7 +175,8 @@ bool flashEqual(FlashHeader header) {
return true;
}
// Inline LCD calls for general SPI LCDs
#if defined(LCD_CONTROLLER_GC9A01)
// LCD output for generic SPI LCDs
__attribute__( ( long_call, section(".data") ) ) void xlcd_wr(int data) {
for (int bit=7;bit>=0;bit--) {
NRF_GPIO_PIN_WRITE_FAST(LCD_SPI_SCK, 0 );
@ -183,8 +184,10 @@ __attribute__( ( long_call, section(".data") ) ) void xlcd_wr(int data) {
NRF_GPIO_PIN_WRITE_FAST(LCD_SPI_SCK, 1 );
}
}
#endif
__attribute__( ( long_call, section(".data") ) ) void xlcd_rect(int x1,int y1, int x2, int y2, bool white) {
#if defined(LCD_CONTROLLER_GC9A01)
NRF_GPIO_PIN_WRITE_FAST(LCD_SPI_DC, 0); // command
NRF_GPIO_PIN_WRITE_FAST(LCD_SPI_CS, 0);
xlcd_wr(0x2A);
@ -217,6 +220,7 @@ __attribute__( ( long_call, section(".data") ) ) void xlcd_rect(int x1,int y1, i
for (int x=0;x<l*2;x++)
xlcd_wr(white ? 0xFF : 0);
NRF_GPIO_PIN_WRITE_FAST(LCD_SPI_CS,1);
#endif
}
__attribute__( ( long_call, section(".data") ) ) void flashDoUpdate(FlashHeader header) {

View File

@ -96,7 +96,11 @@ void turn_off() {
flashPowerDown(); // Put the SPI Flash into deep power-down
#endif
jshPinOutput(VIBRATE_PIN,1); // vibrate on
#if defined(BTN2_PININDEX)
while (get_btn1_state() || get_btn2_state()) {}; // wait for BTN1 and BTN2 to be released
#else
while (get_btn1_state()) {}; // wait for BTN1 and BTN2 to be released
#endif
jshPinSetValue(VIBRATE_PIN,0); // vibrate off
#ifdef DICKENS
NRF_P0->OUT=0x03300f04; // 00000011 00110000 00001111 00000100 - high pins: D2, D8, SDA, SCL, LCD_CS, FLASH_CS, FLASH_WP, FLASH_RST, FLASH_SCK
@ -121,8 +125,10 @@ void turn_off() {
NRF_GPIO_PIN_CNF(BTN1_PININDEX,0x0003000c); // D46 = BTN1 input (with pullup and low-level sense)
#else // !DICKENS
set_led_state(0,0);
#if defined(BTN2_PININDEX)
nrf_gpio_cfg_sense_set(BTN2_PININDEX, NRF_GPIO_PIN_NOSENSE);
nrf_gpio_cfg_sense_set(BTN3_PININDEX, NRF_GPIO_PIN_NOSENSE);
#endif
nrf_gpio_cfg_sense_input(pinInfo[BTN1_PININDEX].pin, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_set(pinInfo[BTN1_PININDEX].pin, NRF_GPIO_PIN_SENSE_LOW);
#endif