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" ;;
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <[email protected]>
#
# 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 <[email protected]>
import pinutils;
info = {
'name' : "Magic 3",
'link' : [ "https://www.kospet.com/products/kospet-magic-3" ],
@fanoush
fanoush / desay-jseval.js
Created April 8, 2021 06:52
simple javascript evaluator service (to test larger MTU)
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 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));
@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 / sdk14.2-DfuTarg-LF_RC.diff
Last active March 13, 2021 22:33
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
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,
#!/bin/false
# This file is part of Espruino, a JavaScript interpreter for Microcontrollers
#
# Copyright (C) 2013 Gordon Williams <[email protected]>
#
# 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 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 <[email protected]>
#
# 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/.
#
# ----------------------------------------------------------------------------------------
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)