mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Start work on RuuviTag support
Fix makefile syntax error Add RuuviTag specifics squash squash squash
This commit is contained in:
parent
796884c929
commit
a015e46641
@ -3,9 +3,11 @@ FROM ubuntu:14.04
|
||||
RUN apt-get update && apt-get install -y software-properties-common && apt-get update \
|
||||
&& add-apt-repository ppa:team-gcc-arm-embedded/ppa \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y git gcc-arm-embedded build-essential python
|
||||
&& apt-get install -y git gcc-arm-embedded build-essential python python-pip
|
||||
|
||||
RUN pip install nrfutil
|
||||
|
||||
RUN git clone https://github.com/espruino/Espruino espruino
|
||||
RUN git clone https://github.com/ojousima/Espruino espruino
|
||||
WORKDIR /espruino
|
||||
|
||||
# If compiling for a non-linux target that has internet support, use WIZnet support, not TI CC3000
|
||||
|
||||
22
Makefile
22
Makefile
@ -32,6 +32,7 @@
|
||||
# NRF51TAG=1
|
||||
# NRF51822DK=1
|
||||
# NRF52832DK=1 # Ultra low power BLE (bluetooth low energy) enabled SoC. Arm Cortex-M4f processor. With NFC (near field communication).
|
||||
# RUUVITAG=1 # https://ruuvitag.com
|
||||
# CARAMBOLA=1
|
||||
# DPTBOARD=1 # DPTechnics IoT development board with BlueCherry.io IoT platform integration and DPT-WEB IDE.
|
||||
# RASPBERRYPI=1
|
||||
@ -514,6 +515,19 @@ USE_CRYPTO=1
|
||||
#USE_TLS=1
|
||||
USE_NFC=1
|
||||
|
||||
else ifdef RUUVITAG
|
||||
EMBEDDED=1
|
||||
BOARD=RUUVITAG
|
||||
OPTIMIZEFLAGS+=-O3
|
||||
USE_BLUETOOTH=1
|
||||
USE_NET=1
|
||||
USE_GRAPHICS=1
|
||||
USE_NFC=1
|
||||
USE_CRYPTO=1
|
||||
#USE_BOOTLOADER=1
|
||||
#DFU_UPDATE_BUILD=1
|
||||
|
||||
|
||||
else ifdef ECU
|
||||
# Gordon's car ECU (extremely beta!)
|
||||
USE_TRIGGER=1
|
||||
@ -2331,9 +2345,15 @@ $(PROJ_NAME).hex: $(PROJ_NAME).elf
|
||||
ifdef SOFTDEVICE # Shouldn't do this when we want to be able to perform DFU OTA!
|
||||
ifdef USE_BOOTLOADER
|
||||
ifdef DFU_UPDATE_BUILD
|
||||
ifdef RUUVITAG
|
||||
@echo Not merging softdevice or bootloader with application
|
||||
# nrfutil pkg generate --help
|
||||
nrfutil pkg generate $(PROJ_NAME).zip --application $(PROJ_NAME).hex --debug-mode --key-file targets/nrf5x_dfu/ruuvi_open_private.pem
|
||||
else
|
||||
@echo Not merging softdevice or bootloader with application
|
||||
# nrfutil pkg generate --help
|
||||
nrfutil pkg generate $(PROJ_NAME).zip --application $(PROJ_NAME).hex --application-version 0xff --hw-version 52 --sd-req 0x8C --key-file targets/nrf5x_dfu/dfu_private_key.pem
|
||||
endif
|
||||
else
|
||||
ifdef BOOTLOADER
|
||||
@echo Not merging anything with bootloader
|
||||
@ -2413,8 +2433,8 @@ else
|
||||
# log WRAPPERSOURCES to help Firmware creation tool
|
||||
$(info WRAPPERSOURCES=$(WRAPPERSOURCES));
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@echo Cleaning targets
|
||||
$(Q)find . -name \*.o | grep -v arm-bcm2708 | xargs rm -f
|
||||
$(Q)rm -f $(ROOT)/gen/*.c $(ROOT)/gen/*.h $(ROOT)/gen/*.ld
|
||||
|
||||
112
boards/RUUVITAG.py
Normal file
112
boards/RUUVITAG.py
Normal file
@ -0,0 +1,112 @@
|
||||
#!/bin/false
|
||||
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
|
||||
#
|
||||
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
|
||||
#
|
||||
# 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/.
|
||||
#
|
||||
# ----------------------------------------------------------------------------------------
|
||||
# This file contains information for a specific board - the available pins, and where LEDs,
|
||||
# Buttons, and other in-built peripherals are. It is used to build documentation as well
|
||||
# as various source and header files for Espruino.
|
||||
# ----------------------------------------------------------------------------------------
|
||||
|
||||
import pinutils;
|
||||
|
||||
info = {
|
||||
'name' : "RuuviTag",
|
||||
'link' : [ "https://ruuvitag.com" ],
|
||||
'default_console' : "EV_SERIAL1",
|
||||
'default_console_tx' : "D4",
|
||||
'default_console_rx' : "D5",
|
||||
'default_console_baudrate' : "9600",
|
||||
# Number of variables can be WAY higher on this board
|
||||
'variables' : 2040, # 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_nrf52832.bin',
|
||||
'build' : {
|
||||
'defines' : [
|
||||
'USE_BLUETOOTH',
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
chip = {
|
||||
'part' : "NRF52832",
|
||||
'family' : "NRF52",
|
||||
'package' : "QFN48",
|
||||
'ram' : 64,
|
||||
'flash' : 512,
|
||||
'speed' : 64,
|
||||
'usart' : 1,
|
||||
'spi' : 3,
|
||||
'i2c' : 2,
|
||||
'adc' : 1,
|
||||
'dac' : 0,
|
||||
'saved_code' : {
|
||||
'address' : ((117 - 3) * 4096), # Bootloader takes pages 117-127 on RuuviTag
|
||||
'page_size' : 4096,
|
||||
'pages' : 3,
|
||||
'flash_available' : 512 - ((31 + 11 + 3)*4) # Softdevice uses 31 pages of flash, bootloader 11, code 3. Each page is 4 kb.
|
||||
},
|
||||
};
|
||||
|
||||
devices = {
|
||||
'LED1' : { 'pin' : 'D17', 'inverted' : True },
|
||||
'LED2' : { 'pin' : 'D19', 'inverted' : True },
|
||||
'BTN1' : { 'pin' : 'D13', 'inverted' : True, 'pinstate' : 'IN_PULLUP' },
|
||||
'CSBME' : { 'pin' : 'D3', 'inverted' : True, 'pinstate' : 'IN_PULLUP' },
|
||||
'CSLIS' : { 'pin' : 'D8', 'inverted' : True, 'pinstate' : 'IN_PULLUP' },
|
||||
'RX_PIN_NUMBER' : { 'pin' : 'D5'},
|
||||
'TX_PIN_NUMBER' : { 'pin' : 'D4'},
|
||||
'CTS_PIN_NUMBER' : { 'pin' : 'D31'},
|
||||
'RTS_PIN_NUMBER' : { 'pin' : 'D30'},
|
||||
'NFC': { 'pin_a':'D9', 'pin_b':'D10' }#,
|
||||
# 'BME280': { 'pin_pwr':'D18',
|
||||
# 'pin_int':'D17',
|
||||
# 'pin_sda':'D20',
|
||||
# 'pin_scl':'D19' }#,
|
||||
# 'LIS2DH12': { 'pin_pwr':'D18',
|
||||
# 'pin_int':'D17',
|
||||
# 'pin_sda':'D20',
|
||||
# 'pin_scl':'D19' }
|
||||
};
|
||||
|
||||
# left-right, or top-bottom order
|
||||
board = {
|
||||
'left' : [ 'VDD', 'VDD', 'RESET', 'VDD','5V','GND','GND','PD3','PD4','PD28','PD29','PD30','PD31'],
|
||||
'right' : [ 'PD27', 'PD26', 'PD2', 'GND', 'PD25','PD24','PD23', 'PD22','PD20','PD19','PD18','PD17','PD16','PD15','PD14','PD13','PD12','PD11','PD10','PD9','PD8','PD7','PD6','PD5','PD21','PD1','PD0'],
|
||||
};
|
||||
board["_css"] = """
|
||||
""";
|
||||
|
||||
def get_pins():
|
||||
pins = pinutils.generate_pins(0,31) # 32 General Purpose I/O Pins.
|
||||
pinutils.findpin(pins, "PD0", True)["functions"]["XL1"]=0;
|
||||
pinutils.findpin(pins, "PD1", True)["functions"]["XL2"]=0;
|
||||
pinutils.findpin(pins, "PD5", True)["functions"]["RTS"]=0;
|
||||
pinutils.findpin(pins, "PD6", True)["functions"]["TXD"]=0;
|
||||
pinutils.findpin(pins, "PD7", True)["functions"]["CTS"]=0;
|
||||
pinutils.findpin(pins, "PD8", True)["functions"]["RXD"]=0;
|
||||
pinutils.findpin(pins, "PD9", True)["functions"]["NFC1"]=0;
|
||||
pinutils.findpin(pins, "PD10", True)["functions"]["NFC2"]=0;
|
||||
pinutils.findpin(pins, "PD13", True)["functions"]["Button_1"]=0;
|
||||
pinutils.findpin(pins, "PD14", True)["functions"]["Button_2"]=0;
|
||||
pinutils.findpin(pins, "PD15", True)["functions"]["Button_3"]=0;
|
||||
pinutils.findpin(pins, "PD16", True)["functions"]["Button_4"]=0;
|
||||
pinutils.findpin(pins, "PD17", True)["functions"]["LED_1"]=0;
|
||||
pinutils.findpin(pins, "PD18", True)["functions"]["LED_2"]=0;
|
||||
pinutils.findpin(pins, "PD19", True)["functions"]["LED_3"]=0;
|
||||
pinutils.findpin(pins, "PD20", True)["functions"]["LED_4"]=0;
|
||||
pinutils.findpin(pins, "PD2", True)["functions"]["ADC1_IN0"]=0;
|
||||
pinutils.findpin(pins, "PD3", True)["functions"]["ADC1_IN1"]=0;
|
||||
pinutils.findpin(pins, "PD4", True)["functions"]["ADC1_IN2"]=0;
|
||||
pinutils.findpin(pins, "PD5", True)["functions"]["ADC1_IN3"]=0;
|
||||
pinutils.findpin(pins, "PD28", True)["functions"]["ADC1_IN4"]=0;
|
||||
pinutils.findpin(pins, "PD29", True)["functions"]["ADC1_IN5"]=0;
|
||||
pinutils.findpin(pins, "PD30", True)["functions"]["ADC1_IN6"]=0;
|
||||
pinutils.findpin(pins, "PD31", True)["functions"]["ADC1_IN7"]=0;
|
||||
#The boot/reset button will function as a reset button in normal operation. Pin reset on PD21 needs to be enabled on the nRF52832 device for this to work.
|
||||
return pins
|
||||
@ -745,6 +745,8 @@ static void gap_params_init() {
|
||||
char deviceName[BLE_GAP_DEVNAME_MAX_LEN];
|
||||
#ifdef PUCKJS
|
||||
strcpy(deviceName,"Puck.js");
|
||||
#elif defined(RUUVITAG)
|
||||
strcpy(deviceName,"RuuviTag");
|
||||
#else
|
||||
strcpy(deviceName,"Espruino "PC_BOARD_ID);
|
||||
#endif
|
||||
@ -759,6 +761,15 @@ static void gap_params_init() {
|
||||
deviceName[len++] = itoch((addr>>4)&15);
|
||||
deviceName[len++] = itoch((addr)&15);
|
||||
// not null terminated
|
||||
#elif defined(RUUVITAG)
|
||||
// append last 2 bytes of MAC address to name
|
||||
uint32_t addr = NRF_FICR->DEVICEADDR[0];
|
||||
deviceName[len++] = ' ';
|
||||
deviceName[len++] = itoch((addr>>12)&15);
|
||||
deviceName[len++] = itoch((addr>>8)&15);
|
||||
deviceName[len++] = itoch((addr>>4)&15);
|
||||
deviceName[len++] = itoch((addr)&15);
|
||||
// not null terminated
|
||||
#endif
|
||||
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
|
||||
@ -985,6 +996,10 @@ static void ble_stack_init() {
|
||||
// can only be enabled if we're sure we have a DC-DC
|
||||
err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
#elif defined(RUUVITAG)
|
||||
// can only be enabled if we're sure we have a DC-DC
|
||||
err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
5
targets/nrf5x_dfu/ruuvi_open_private.pem
Normal file
5
targets/nrf5x_dfu/ruuvi_open_private.pem
Normal file
@ -0,0 +1,5 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIDnhIuvR0NthJWUPTcR08w77/lLzV2uL8HG0GE/tnv7voAoGCCqGSM49
|
||||
AwEHoUQDQgAEjvyN3YTgtAOwXXDRa4jueAuRwBCNdcAyGll+llDXjzzLwAxX1a+C
|
||||
E8ZvB2qBWQeUFJsw4qLFpn6nmQPlbDKZbw==
|
||||
-----END EC PRIVATE KEY-----
|
||||
Loading…
x
Reference in New Issue
Block a user