diff --git a/ChangeLog b/ChangeLog index 4370c9ec6..c3f81e295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,7 @@ Simplified process.env on devices with little memory nRF5x: fixed serial number reporting Move button state setup to jshResetDevices + Had to remove 'dump()' and SW I2C on devices with very little flash memory (Olimexino/Micro:bit) 1v87 : Add support for compiling with float-abi=hard (even if it doesn't give us real-world benefits) Add shortcut for quick execution of common call types diff --git a/Makefile b/Makefile index f2f440e1c..ea1bca8e8 100644 --- a/Makefile +++ b/Makefile @@ -164,7 +164,6 @@ DEFINES+=-DESPRUINO_1V3 USE_NET=1 USE_GRAPHICS=1 USE_FILESYSTEM=1 -USE_TV=1 USE_HASHLIB=1 BOARD=ESPRUINOBOARD STLIB=STM32F10X_XL @@ -709,7 +708,7 @@ endif # Get info out of BOARDNAME.py # --------------------------------------------------------------------------------- -PROJ_NAME=$(shell python scripts/get_board_info.py $(BOARD) "common.get_board_binary_name(board)" | sed -e "s/.bin$$//") +PROJ_NAME=$(shell python scripts/get_board_info.py $(BOARD) "common.get_board_binary_name(board)" | sed -e "s/.bin$$//" | sed -e "s/.hex$$//") ifeq ($(PROJ_NAME),) $(error Unable to work out binary name (PROJ_NAME)) endif diff --git a/boards/MICROBIT.py b/boards/MICROBIT.py index b7b5c8b1b..1e0abadc1 100644 --- a/boards/MICROBIT.py +++ b/boards/MICROBIT.py @@ -24,7 +24,7 @@ info = { 'default_console_rx' : "H1", # pin 25 'default_console_baudrate' : "9600", 'variables' : 100, - 'binary_name' : 'espruino_%v_microbit.bin', + 'binary_name' : 'espruino_%v_microbit.hex', 'build' : { 'defines' : [ 'USE_GRAPHICS', diff --git a/boards/PUCKJS.py b/boards/PUCKJS.py index 6c48a6e41..29c47918e 100644 --- a/boards/PUCKJS.py +++ b/boards/PUCKJS.py @@ -25,7 +25,7 @@ info = { # Number of variables can be WAY higher on this board 'variables' : 2000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile. 'bootloader' : 1, - 'binary_name' : 'espruino_%v_puckjs.bin', + 'binary_name' : 'espruino_%v_puckjs.hex', 'build' : { 'defines' : [ 'USE_BLUETOOTH' diff --git a/dist_readme.txt b/dist_readme.txt index b7840fea2..316bf5f50 100644 --- a/dist_readme.txt +++ b/dist_readme.txt @@ -15,18 +15,26 @@ types of Microcontroller: espruino_#v##_pico_1r3_cc3000.bin espruino_#v##_pico_1r3_wiznet.bin - - The firmware image for the latest Espruino Pico Boards. + - The firmware image for Espruino Pico Boards. We'd strongly suggest that you use the Web IDE to flash this. Each image is for a different type of networking device. If you don't want a network device, it doesn't matter which you choose. espruino_#v##_espruino_1r3.bin espruino_#v##_espruino_1r3_wiznet.bin - - The firmware image for the latest Espruino Boards (rev 1v3 and 1v4) + - The firmware image for Original Espruino Boards We'd strongly suggest that you use the Web IDE to flash this. Each image is for a different type of networking device. If you don't want a network device, it doesn't matter which you choose. +espruino_#v##_wifi.bin + - The firmware image for Espruino WiFi Boards + We'd strongly suggest that you use the Web IDE to flash this. + +espruino_#v##_puckjs.zip + - The firmware image for Espruino Puck.js Devices + Use the nRF Control Panel app to flash this firmware + espruino_#v##_hystm32_24_ve.bin - 'HY'STM32F103VET6 ARM with 2.4" LCD display This is available from eBay diff --git a/scripts/common.py b/scripts/common.py index f9644ffc6..c3ea134e3 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -214,7 +214,7 @@ def get_jsondata(is_for_document, parseArgs = True, board = False): "filename" : "BOARD.py", "include" : "platform_config.h" }) - if "LED1" in board.devices: + if "BTN" in board.devices: jsondatas.append({ "type" : "variable", "name" : "BTN", diff --git a/scripts/create_puckjs_image.sh b/scripts/create_puckjs_image.sh new file mode 100755 index 000000000..344930529 --- /dev/null +++ b/scripts/create_puckjs_image.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# This file is part of Espruino, a JavaScript interpreter for Microcontrollers +# +# Copyright (C) 2016 Gordon Williams +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# ---------------------------------------------------------------------------------------- +# Creates a binary file containing both Espruino and the bootloader +# ---------------------------------------------------------------------------------------- + +cd `dirname $0` # scripts +cd .. # main dir +BASEDIR=`pwd` + +BOARDNAME=PUCKJS +ESPRUINOFILE=`python scripts/get_board_info.py $BOARDNAME "common.get_board_binary_name(board)"` + +rm -f $ESPRUINOFILE + +export PUCKJS=1 +export RELEASE=1 + +BOOTLOADER=1 make clean +BOOTLOADER=1 make || { echo 'Build failed' ; exit 1; } + +make clean +make || { echo 'Build failed' ; exit 1; } + +echo --------------------- +echo Finished! Written to $ESPRUINOFILE +echo nrfjprog --family NRF52 --clockspeed 50000 --program $ESPRUINOFILE --chiperase --reset +echo --------------------- + + diff --git a/scripts/create_zip.sh b/scripts/create_zip.sh index d1e1cb20b..b08315bd8 100755 --- a/scripts/create_zip.sh +++ b/scripts/create_zip.sh @@ -25,14 +25,14 @@ mkdir $ZIPDIR # ESP8266 -export ESP8266_SDK_ROOT=$DIR/esp_iot_sdk_v1.5.0 +export ESP8266_SDK_ROOT=$DIR/esp_iot_sdk_v2.0.0.p1 export PATH=$PATH:$DIR/xtensa-lx106-elf/bin/ echo ------------------------------------------------------ echo Building Version $VERSION echo ------------------------------------------------------ -for BOARDNAME in PICO_1V3_CC3000 PICO_1V3_WIZ ESPRUINO_1V3 ESPRUINO_1V3_WIZ ESPRUINOWIFI NUCLEOF401RE NUCLEOF411RE STM32VLDISCOVERY STM32F3DISCOVERY STM32F4DISCOVERY OLIMEXINO_STM32 HYSTM32_24 HYSTM32_28 HYSTM32_32 RASPBERRYPI MICROBIT ESP8266_BOARD +for BOARDNAME in PICO_1V3_CC3000 PICO_1V3_WIZ ESPRUINO_1V3 ESPRUINO_1V3_WIZ ESPRUINOWIFI PUCKJS NUCLEOF401RE NUCLEOF411RE STM32VLDISCOVERY STM32F3DISCOVERY STM32F4DISCOVERY OLIMEXINO_STM32 HYSTM32_24 HYSTM32_28 HYSTM32_32 RASPBERRYPI MICROBIT ESP8266_BOARD do echo ------------------------------ echo $BOARDNAME @@ -59,8 +59,9 @@ do fi # actually build ESP_BINARY_NAME=`python scripts/get_board_info.py $BOARDNAMEX "common.get_board_binary_name(board)"` - if [ "$BOARDNAME" == "MICROBIT" ]; then - ESP_BINARY_NAME=`basename $ESP_BINARY_NAME .bin`.hex + if [ "$BOARDNAME" == "PUCKJS" ]; then + ESP_BINARY_NAME=`basename $ESP_BINARY_NAME .hex`.zip + EXTRADEFS=DFU_UPDATE_BUILD=1 fi echo "Building $ESP_BINARY_NAME" echo diff --git a/scripts/find_big_rom.sh b/scripts/find_big_rom.sh index cf23162e1..d8c319dae 100755 --- a/scripts/find_big_rom.sh +++ b/scripts/find_big_rom.sh @@ -10,4 +10,4 @@ then exit 1 fi -grep "^00...... [^<]" $1 | sort --key=4 +grep "^0[08]...... [^<]" $1 | sort --key=4 diff --git a/src/jsi2c.c b/src/jsi2c.c index ba2a46505..e569cc16d 100644 --- a/src/jsi2c.c +++ b/src/jsi2c.c @@ -38,6 +38,8 @@ bool jsi2cPopulateI2CInfo( return false; } +#ifndef SAVE_ON_FLASH + // -------------------------------------------------------- I2C Implementation const int I2C_TIMEOUT = 100000; @@ -166,3 +168,5 @@ void jsi2cRead(JshI2CInfo *inf, unsigned char address, int nBytes, unsigned char if (sendStop) i2c_stop(&d); inf->started = d.started; } + +#endif // SAVE_ON_FLASH diff --git a/src/jsutils.h b/src/jsutils.h index d0885e143..be9d8d776 100644 --- a/src/jsutils.h +++ b/src/jsutils.h @@ -26,9 +26,9 @@ #include #ifndef BUILDNUMBER -#define JS_VERSION "1v87" +#define JS_VERSION "1v88" #else -#define JS_VERSION "1v87." BUILDNUMBER +#define JS_VERSION "1v88." BUILDNUMBER #endif /* In code: diff --git a/src/jswrap_interactive.c b/src/jswrap_interactive.c index 31b8cd85c..2e4123744 100644 --- a/src/jswrap_interactive.c +++ b/src/jswrap_interactive.c @@ -115,13 +115,11 @@ void jswrap_interface_trace(JsVar *root) { } } -/*XXX{ "type":"function", "name" : "dotty", - "description" : "Output dotty-format graph of debugging information", - "generate" : "jsvDottyOutput" -}*/ + /*JSON{ "type" : "function", "name" : "dump", + "ifndef" : "SAVE_ON_FLASH", "generate_full" : "jsiDumpState((vcbprintf_callback)jsiConsolePrintString, 0)" } Output current interpreter state in a text form such that it can be copied to a new device diff --git a/src/jswrap_spi_i2c.c b/src/jswrap_spi_i2c.c index 8c0754cf8..3e7b92f46 100644 --- a/src/jswrap_spi_i2c.c +++ b/src/jswrap_spi_i2c.c @@ -540,6 +540,7 @@ void jswrap_i2c_setup(JsVar *parent, JsVar *options) { if (DEVICE_IS_I2C(device)) { jshI2CSetup(device, &inf); } else if (device == EV_NONE) { +#ifndef SAVE_ON_FLASH // software mode - at least configure pins properly if (inf.pinSCL != PIN_UNDEFINED) { jshPinSetValue(inf.pinSCL, 1); @@ -549,6 +550,7 @@ void jswrap_i2c_setup(JsVar *parent, JsVar *options) { jshPinSetValue(inf.pinSDA, 1); jshPinSetState(inf.pinSDA, JSHPINSTATE_GPIO_OUT_OPENDRAIN_PULLUP); } +#endif } // Set up options, so we can initialise it on startup if (options) @@ -595,6 +597,7 @@ void jswrap_i2c_writeTo(JsVar *parent, JsVar *addressVar, JsVar *args) { if (DEVICE_IS_I2C(device)) { jshI2CWrite(device, (unsigned char)address, (int)dataLen, (unsigned char*)dataPtr, sendStop); } else if (device == EV_NONE) { +#ifndef SAVE_ON_FLASH // software JshI2CInfo inf; JsVar *options = jsvObjectGetChild(parent, DEVICE_OPTIONS_NAME, 0); @@ -603,6 +606,7 @@ void jswrap_i2c_writeTo(JsVar *parent, JsVar *addressVar, JsVar *args) { jsi2cWrite(&inf, (unsigned char)address, (int)dataLen, (unsigned char*)dataPtr, sendStop); } jsvUnLock2(jsvObjectSetChild(parent, "started", jsvNewFromBool(inf.started)), options); +#endif } } } @@ -638,6 +642,7 @@ JsVar *jswrap_i2c_readFrom(JsVar *parent, JsVar *addressVar, int nBytes) { if (DEVICE_IS_I2C(device)) { jshI2CRead(device, (unsigned char)address, nBytes, buf, sendStop); } else if (device == EV_NONE) { +#ifndef SAVE_ON_FLASH // software JshI2CInfo inf; JsVar *options = jsvObjectGetChild(parent, DEVICE_OPTIONS_NAME, 0); @@ -646,6 +651,7 @@ JsVar *jswrap_i2c_readFrom(JsVar *parent, JsVar *addressVar, int nBytes) { jsi2cRead(&inf, (unsigned char)address, nBytes, buf, sendStop); } jsvUnLock2(jsvObjectSetChild(parent, "started", jsvNewFromBool(inf.started)), options); +#endif } else return 0; JsVar *array = jsvNewTypedArray(ARRAYBUFFERVIEW_UINT8, nBytes); diff --git a/targets/nrf5x/bluetooth.c b/targets/nrf5x/bluetooth.c index ddec35236..8ddd6a20c 100644 --- a/targets/nrf5x/bluetooth.c +++ b/targets/nrf5x/bluetooth.c @@ -52,6 +52,7 @@ #define SCAN_INTERVAL MSEC_TO_UNITS(100, UNIT_0_625_MS) /**< Scan interval in units of 0.625 millisecond - 100 msec */ #define SCAN_WINDOW MSEC_TO_UNITS(100, UNIT_0_625_MS) /**< Scan window in units of 0.625 millisecond - 100 msec */ +#define ADVERTISING_INTERVAL MSEC_TO_UNITS(750, UNIT_0_625_MS) /**< The advertising interval (in units of 0.625 ms). */ #define APP_ADV_TIMEOUT_IN_SECONDS 180 /**< The advertising timeout (in units of seconds). */ #define MIN_CONN_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS) /**< Minimum acceptable connection interval (7.5 ms), Connection interval uses 1.25 ms units. */ #define MAX_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Maximum acceptable connection interval (20 ms (was 75)), Connection interval uses 1.25 ms units. */ @@ -90,7 +91,7 @@ uint16_t m_central_conn_handle = BLE_CONN_HANDLE_INVALID bool nfcEnabled = false; #endif -uint16_t bleAdvertisingInterval = MSEC_TO_UNITS(375, UNIT_0_625_MS); /**< The advertising interval (in units of 0.625 ms). */ +uint16_t bleAdvertisingInterval = ADVERTISING_INTERVAL; volatile BLEStatus bleStatus = 0; ble_uuid_t bleUUIDFilter; @@ -1017,19 +1018,21 @@ void jsble_kill() { /** Reset BLE to power-on defaults (ish) */ void jsble_reset() { // if we were scanning, make sure we stop at reset! - if (bleStatus & BLE_IS_SCANNING) { - jswrap_nrf_bluetooth_setScan(0); - } - jswrap_nrf_bluetooth_setRSSIHandler(0); + if (bleStatus & BLE_IS_SCANNING) { + jswrap_nrf_bluetooth_setScan(0); + } + jswrap_nrf_bluetooth_setRSSIHandler(0); - #if CENTRAL_LINK_COUNT>0 - // if we were connected to something, disconnect - if (jsble_has_central_connection()) { - sd_ble_gap_disconnect(m_central_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); - } - #endif - // make sure we remove any existing services *AND* HID/UART changes - jswrap_nrf_bluetooth_setServices(0, 0); +#if CENTRAL_LINK_COUNT>0 + // if we were connected to something, disconnect + if (jsble_has_central_connection()) { + sd_ble_gap_disconnect(m_central_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); + } +#endif + // make sure we remove any existing services *AND* HID/UART changes + jswrap_nrf_bluetooth_setServices(0, 0); + // Set advertising interval back to default + bleAdvertisingInterval = ADVERTISING_INTERVAL; } /** Stop and restart the softdevice so that we can update the services in it -