Skip to content

Instantly share code, notes, and snippets.

@fanoush
fanoush / wakeup.sh
Created November 9, 2024 11:23
disable/enable wake up of ACPI devices
#!/bin/sh
wakeup(){
wakeup=/proc/acpi/wakeup
if [ "$#" -lt 2 ]; then
devices=$(grep -e 'bled' $wakeup | cut -f 1 | tr -s '\n' ' ')
echo "$0 disable|enable [ $devices]"
return 1
fi
case $1 in
*dis*) state="enabled" ; msg="disabling" ;;
@fanoush
fanoush / E104BT5032A.py
Last active August 29, 2024 16:26
E104-BT5032A board file
#!/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/.
#
# ----------------------------------------------------------------------------------------
#!/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 / MAGIC3.py
Created October 24, 2021 17:32
board file for MAGIC3
#!/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 / P8-SPILCD-demo.js
Last active September 22, 2021 12:33
Inline C P8 LCD DMA demo
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/
var SPI2 = E.compiledC(`
@fanoush
fanoush / B5-demo.js
Last active September 14, 2021 05:16
Espruino demo code for SMA B5 smart band with GPS
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
E.kickWatchdog();
function KickWd(){
if( (typeof(BTN1)=='undefined')||(!BTN1.read()) ) E.kickWatchdog();
}
var wdint=setInterval(KickWd,2000);
E.enableWatchdog(15, false);
// set name to F10
// NRF.setAdvertising({},{name:"F10 "+NRF.getAddress().split(':').slice(-2).join('')});
var SPI2 = (function(){
var bin=atob("AAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////8QtQNMfEQigGCAoYDjgBC92P///wdLe0QbiUOxBEoTaAAr/NAAIxNgA0p6RBOBcEcYMQJAxv///7L///8t6fBHkEYZTBlO//fl/xlK3/hkwAAjASUTYE/w/w5TYKlGI2AQMh9G/ykA6wMKwvgAoIu//zMxYMb4AOAAIYi//znM+ACQuPEADwbQKbkLS3tEHYEAIL3o8IfU+ACguvEAD/rQJ2AAKd7R8+cYMQJASDUCQDQ1AkAQMAJAUP///y3p8E+bsM3pARJQSnpEBkaS+ACQACgA8JGAACkA8I6ACfH/MwcrAPKJgAEjA/oJ8wE727IDkwR4Q3iXiETqAyQCmxxB02gA8QILpLILsT1KE2BP6kkD27IEkz1Le0QRqAWTCKvN6QYwT/AACEFGBZsCnbP4AqADmwGaI0BE+gn0MvgTwAObI0BE+gn0MvgTIASbHUTtsgctQNiksk/qLBNDVBMSAfECDkPqDBxDGAMxqvECCiMpg/gBwB/6ivoA+A4gCd0BIv/3W//Y8QEIC78HmAaYQUYAIbrxAA/L0R1Le0QBP9uIHkS/snN4NHhE6gMkApscQQbxAguksgAvttHJsTpG//c8/xNLe0TYaBCxDUsYYAAgG7C96PCP3kYIPR74ATvtssXxCAsD+gvzHEOksvN
@fanoush
fanoush / DK08.js
Last active May 27, 2021 07:49
DK08 demo
function KickWd(){
if(!BTN1.read())E.kickWatchdog();
}
var wdint=setInterval(KickWd,5000); // 5 secs
E.enableWatchdog(20, false); // 20 secs
E.kickWatchdog();
/*
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
var SPI2 = E.compiledC(`
@fanoush
fanoush / SDK14-dfu-bootloader.txt
Last active May 8, 2021 10:21
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
// -- 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 / espruino-configurable-MTU.diff
Last active April 12, 2021 13:27
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',
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));