diff --git a/bin/install-bootloader.sh b/bin/install-bootloader.sh new file mode 100755 index 00000000..3c7db573 --- /dev/null +++ b/bin/install-bootloader.sh @@ -0,0 +1,29 @@ +# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board + +BOOTDIR=/home/kevinh/development/meshtastic/Adafruit_nRF52_Bootloader + +nrfjprog --eraseall -f nrf52 + +#echo Programming soft device +#nrfjprog --program $BOOTDIR/lib/softdevice/s140_nrf52_6.1.1/s140_nrf52_6.1.1_softdevice.hex -f nrf52 + +echo Programming bootloader and soft device +# the following ling incorrectly enables reset pin, because the running code rewrites it +nrfjprog --program $BOOTDIR/_build/build-ttgo_eink/ttgo_eink_bootloader-0.3.2-122-gf6bfaac-dirty_s140_6.1.1.hex -f nrf52 + +# this generates an intel hex file that can be programmed into a NRF52 to tell the adafruit bootloader that the current app image is valid +# Bootloader settings are at BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000 +# first 4 bytes should be 0x01 to indicate valid app image +# second 4 bytes should be 0x00 to indicate no CRC required for image +echo "01 00 00 00 00 00 00 00" | xxd -r -p - >/tmp/bootconf.bin +srec_cat /tmp/bootconf.bin -binary -offset 0xff000 -output /tmp/bootconf.hex -intel + +echo Programming meshtastic app load +nrfjprog --program .pio/build/eink/firmware.hex -f nrf52 + +echo Telling bootloader app region is valid and telling CPU to run +nrfjprog --program /tmp/bootconf.hex -f nrf52 --reset + +# nrfjprog --readuicr /tmp/uicr.hex; objdump -s /tmp/uicr.hex | less + +echo FIXME use hexmerge diff --git a/src/graphics/EInkDisplay.cpp b/src/graphics/EInkDisplay.cpp index 2156f591..da468af3 100644 --- a/src/graphics/EInkDisplay.cpp +++ b/src/graphics/EInkDisplay.cpp @@ -95,6 +95,11 @@ bool EInkDisplay::connect() { DEBUG_MSG("Doing EInk init\n"); +#ifdef EINK_PIN_PWR_ON + digitalWrite(EINK_PIN_PWR_ON, HIGH); // If we need to assert a pin to power external peripherals + pinMode(EINK_PIN_PWR_ON, OUTPUT); +#endif + #ifdef PIN_EINK_EN digitalWrite(PIN_EINK_EN, HIGH); pinMode(PIN_EINK_EN, OUTPUT); diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index 4a5c93f7..867cdeef 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -93,11 +93,6 @@ void nrf52Setup() // This is the recommended setting for Monitor Mode Debugging NVIC_SetPriority(DebugMonitor_IRQn, 6UL); -#ifdef PIN_PWR_ON - digitalWrite(PIN_PWR_ON, HIGH); // If we need to assert a pin to power external peripherals - pinMode(PIN_PWR_ON, OUTPUT); -#endif - // Not yet on board // pmu.init(); diff --git a/variants/eink/variant.h b/variants/eink/variant.h index e0cdda0d..0c6f4eab 100644 --- a/variants/eink/variant.h +++ b/variants/eink/variant.h @@ -27,25 +27,29 @@ /* @geeksville eink TODO: -confirm that watchdog reset (i.e. all pins now become inputs) won't cause the board to power down when we are not connected to USB -(I bet it will). If this happens recommended fix is to add an external pullup on PWR_ON GPIO. - +soonish: +hook cdc acm device to debug output fix bootloader to use two buttons - remove bootloader hacks -fix battery voltage sensing -fix floating point SEGGER printf on nrf52 - see "new NMEA GPS pos" get second button working in app load -if battery falls too low deassert PWR_ON (to force board to shutdown) fix display width and height clean up eink drawing to not have the nasty timeout hack +measure current draws put eink to sleep when we think the screen is off -enable flash on spi0, share chip selects on spi1. -https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fspi.html enable reset as a button in -bootloader fix battery pin usage drive TCXO DIO3 enable high whenever we want the clock use PIN_GPS_WAKE to sleep the GPS use -tp_ser_io as a button, it goes high when pressed unify eink display classes -make screen.adjustBrightness() a nop on eink screens enable gps sleep mode -use new flash chip +https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fspi.html enable reset as a button +make screen.adjustBrightness() a nop on eink screens + +later: +confirm that watchdog reset (i.e. all pins now become inputs) won't cause the board to power down when we are not connected to USB +(I bet it will). If this happens recommended fix is to add an external pullup on PWR_ON GPIO. +enable flash on spi0, share chip selects on spi1. +fix floating point SEGGER printf on nrf52 - see "new NMEA GPS pos" add factory/power on self test +use tp_ser_io as a button, it goes high when pressed unify eink display classes + +feedback to give: +remove ipx connector for nfc, instead use two caps and loop traces on the back of the board as an antenna? + */ /*---------------------------------------------------------------------------- @@ -122,9 +126,6 @@ work. #define TP_SER_IO (0 + 11) -// Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -#define PIN_PWR_ON (0 + 12) - #define PIN_RTC_INT (0 + 16) // Interrupt from the PCF8563 RTC /* @@ -175,6 +176,9 @@ FIXME define/FIX flash access #define PIN_EINK_SCLK (0 + 31) #define PIN_EINK_MOSI (0 + 29) // also called SDI +// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON +#define PIN_EINK_PWR_ON (0 + 12) + #define HAS_EINK #define PIN_SPI1_MISO \ @@ -186,10 +190,10 @@ FIXME define/FIX flash access * Air530 GPS pins */ -#define PIN_GPS_WAKE (32 + 2) -#define PIN_GPS_PPS (32 + 4) -#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU -#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS +#define PIN_GPS_WAKE (32 + 2) // An output to wake GPS, low means allow sleep, high means force wake +#define PIN_GPS_PPS (32 + 4) // Pulse per second input from the GPS +#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU +#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS #define PIN_SERIAL1_RX PIN_GPS_TX #define PIN_SERIAL1_TX PIN_GPS_RX