Skip to content

Instantly share code, notes, and snippets.

@fanoush
fanoush / MAGIC3.py
Created Oct 24, 2021
board file for MAGIC3
View MAGIC3.py
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
import pinutils;
info = {
'name' : "Magic 3",
'link' : [ "https://www.kospet.com/products/kospet-magic-3" ],
@fanoush
fanoush / desay-jseval.js
Created Apr 8, 2021
simple javascript evaluator service (to test larger MTU)
View desay-jseval.js
maxlen=56;
NRF.setServices({
0x190A : { // Desay AT commands service ID (DS-D6, HX03W)
0x0002 : {
maxLen: maxlen,
notify: true
},
0x0001 : {
writable : true,
maxLen: maxlen,
@fanoush
fanoush / espruino-configurable-MTU.diff
Last active Apr 12, 2021
make MTU configurable , needs in board file something like 'DEFINES+=-DNRF_BLE_GATT_MAX_MTU_SIZE=59 -DNRF_BLE_MAX_MTU_SIZE=59', 'LDFLAGS += -Xlinker --defsym=LD_APP_RAM_BASE=0x2d18',
View espruino-configurable-MTU.diff
diff --git a/src/jswrap_process.c b/src/jswrap_process.c
index f6c738c3..21470116 100644
--- a/src/jswrap_process.c
+++ b/src/jswrap_process.c
@@ -126,6 +126,9 @@ JsVar *jswrap_process_env() {
#ifndef SAVE_ON_FLASH
// Pointer to a list of predefined exports - eventually we'll get rid of the array above
jsvObjectSetChildAndUnLock(obj, "EXPTR", jsvNewFromInteger((JsVarInt)(size_t)exportPtrs));
+extern uint32_t app_ram_base;
+ jsvObjectSetChildAndUnLock(obj, "APP_RAM_BASE", jsvNewFromInteger((JsVarInt)app_ram_base));
@fanoush
fanoush / SDK14-dfu-bootloader.txt
Last active May 8, 2021
espruino code to update SDK14 DFU bootloader located at 0x78000 (e.g. DaFit watches like P8), if updating from stock DaFit bootloader make sure to fix also UICR MBR settings at 0x10001018 or you will brick device when downgrading to SDK11/12
View SDK14-dfu-bootloader.txt
// -- 0. check https://github.com/fanoush/ds-d6/wiki/Replacing-Nordic-DFU-bootloader for fixing MBR settings UICR at 0x10001018
// this is needed before flashing any softdevice/bootloader upgrading/downgrading package
// basically peek32(0x10001018).toString(16); shoud return 0x7e000 and not 0xffffffff or you will brick device by downgrading SDK/SoftrDevice !!!
/* something like this should work (+disconnect/reconnect)
NRF.onRestart=function(){
poke32(0x4001e504,1);while(!peek32(0x4001e400)); // enable flash writing
poke32(0x10001018,0x7E000);while(!peek32(0x4001e400)); // set mbr settings
poke32(0x4001e504, 0);while(!peek32(0x4001e400)); // disable flash writing
}
NRF.restart();
@fanoush
fanoush / sdk14.2-DfuTarg-LF_RC.diff
Last active Mar 13, 2021
patch to nRF5_SDK_14.2.0_17b948a to build generic DFU bootloader for devices without 32kHz crystal (=internal RC oscillator is used), package signing verification is disabled
View sdk14.2-DfuTarg-LF_RC.diff
diff -Naur nRF5_SDK_14.2.0_17b948a/components/boards/custom_board.h nRF5_SDK_14.2.0/components/boards/custom_board.h
--- nRF5_SDK_14.2.0_17b948a/components/boards/custom_board.h 1970-01-01 01:00:00.000000000 +0100
+++ nRF5_SDK_14.2.0/components/boards/custom_board.h 2021-03-10 19:26:42.386034500 +0100
@@ -0,0 +1,173 @@
+/**
+ * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
View XENON.py
#!/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/.
#
# ----------------------------------------------------------------------------------------
@fanoush
fanoush / E104BT5032A.py
Last active Apr 29, 2021
E104-BT5032A board file
View E104BT5032A.py
#!/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/.
#
# ----------------------------------------------------------------------------------------
View WeActF411.diff
diff --git a/targetlibs/stm32f4/lib/stm32f4xx_conf.h b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
index 2f33cd4f..885f551f 100755
--- a/targetlibs/stm32f4/lib/stm32f4xx_conf.h
+++ b/targetlibs/stm32f4/lib/stm32f4xx_conf.h
@@ -26,7 +26,7 @@
#if defined (HSE_VALUE)
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
#undef HSE_VALUE
- #define HSE_VALUE ((uint32_t)8000000)
+ #define HSE_VALUE ((uint32_t)25000000)
@fanoush
fanoush / WeActF411.py
Last active Nov 13, 2020
WeAct F411 Espruino board file
View WeActF411.py
#!/bin/false
# -*- coding: utf8 -*-
# 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/.
#
@fanoush
fanoush / B5-demo.js
Last active Sep 14, 2021
Espruino demo code for SMA B5 smart band with GPS
View B5-demo.js
E.kickWatchdog();
function KickWd(){
if( (typeof(BTN1)=='undefined')||(!BTN1.read()) ) E.kickWatchdog();
}
var wdint=setInterval(KickWd,2000);
E.enableWatchdog(15, false);
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
// SPI display driver below compiled with options LCD_BPP=12