Skip to content

Instantly share code, notes, and snippets.

View tridge's full-sized avatar

Andrew Tridgell tridge

View GitHub Profile
void check_ecc_errors(void)
{
auto *dma = dmaStreamAlloc(STM32_DMA_STREAM_ID(1, 1), 0, nullptr, nullptr);
uint32_t buf[32];
uint32_t ofs = 0;
while (ofs < BOARD_FLASH_SIZE*1024 && FLASH->SR1 == 0 && FLASH->SR2 == 0) {
__disable_fault_irq();
dmaStartMemCopy(dma,
STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_BYTE |
STM32_DMA_CR_MSIZE_BYTE,
/*
create a thread that checks for ECC errors in flash. We disable
fault IRQs in the thread and monitor it from the main thread. If it
doesn't complete in 1s then erase flash This is the only way I've
found to check for ECC errors without causing a bus fault or
unconditionally erasing flash
*/
struct ecccheck {
const uint32_t *start;
uint32_t size;
/*
create a thread that checks for ECC errors in flash. We disable
fault IRQs in the thread and monitor it from the main thread. If it
doesn't complete in 1s then erase flash This is the only way I've
found to check for ECC errors without causing a bus fault or
unconditionally erasing flash
*/
struct ecccheck {
const uint32_t *start;
uint32_t size;
/*
create a thread that checks for ECC errors in flash. We disable
fault IRQs in the thread and monitor it from the main thread. If it
doesn't complete in 1s then erase flash This is the only way I've
found to check for ECC errors without causing a bus fault or
unconditionally erasing flash
*/
struct ecccheck {
const uint32_t *start;
uint32_t size;
@tridge
tridge / gist:5d52813cdd0c14ea389fea576852b2d3
Created December 13, 2022 23:30
ArduPilot lua differences from lua 5.4.4
diff -urN lua/lauxlib.c APM/libraries/AP_Scripting/lua/src/lauxlib.c
--- lua/lauxlib.c 2022-12-14 08:41:37.443587208 +1100
+++ APM/libraries/AP_Scripting/lua/src/lauxlib.c 2022-12-14 10:11:20.343728284 +1100
@@ -32,7 +32,6 @@
#define MAX_SIZET ((size_t)(~(size_t)0))
#endif
-
/*
** {======================================================
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
#define STM32_ADC_ADC1_DMA_CHAN 0
#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) // shared I2C1_RX,UART8_TX
#define STM32_I2C_I2C1_RX_DMA_CHAN 1
#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) // shared I2C1_TX,USART2_TX,TIM4_UP
#define STM32_I2C_I2C1_TX_DMA_CHAN 1
#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) // shared SPI2_RX,I2C2_RX
#define STM32_I2C_I2C2_RX_DMA_CHAN 7
#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
#define STM32_I2C_I2C2_TX_DMA_CHAN 7
======================================================================
FAIL: demos/various/RT-Posix-Simulator/Makefile (make all)
----------------------------------------------------------------------
CMD: /usr/bin/env make -C /home/tridge/project/UAV/APM.chibios/modules/ChibiOS/demos/various/RT-Posix-Simulator -f Makefile all
STDOUT:
make[1]: Entering directory '/home/tridge/project/UAV/APM.chibios/modules/ChibiOS/demos/various/RT-Posix-Simulator'
Compiler Options
gcc -c -O2 -ggdb -m32 -ffunction-sections -fdata-sections -fno-common -Wall -Wextra -Wundef -Wstrict-prototypes -Wa,-alms=./build/lst/ -DSIMULATOR -DTEST_CFG_SIZE_REPORT=0 -MD -MP -MF ./.dep/build.d -I. -I./cfg -I../../../os/license -I../../../os/hal/include -I../../../os/hal/boards/simulator -I../../../os/hal/ports/simulator/posix -I../../../os/hal/ports/simulator -I../../../os/hal/osal/rt-nil -I../../../os/rt/include -I../../../os/oslib/include -I../../../os/common/portability/GCC -I../../../os/common/ports/SIMIA32/compilers/GCC -I../../../os/co
@tridge
tridge / __core_init
Last active September 5, 2021 23:03
non-debug (-O2):
Dump of assembler code for function __core_init:
0x08002a50 <+0>: push {r4, r5, r6, r7, lr}
0x08002a52 <+2>: nop
0x08002a54 <+4>: nop
0x08002a56 <+6>: nop
0x08002a58 <+8>: dsb sy
0x08002a5c <+12>: isb sy
0x08002a60 <+16>: nop
0x08002a62 <+18>: nop
-- a PI controller with feed-forward
local function PIFF(kFF,kP,kI,iMax)
-- the new instance
local self = {}
-- private fields as locals
local _kFF = kFF
local _kP = kP or 0.0
local _kI = kI or 0.0
local _kD = kD or 0.0
good:
0:0:00=0xEA 1:0:03=0x70 2:0:05=0x40 3:0:06=0x01 4:0:07=0x00 5:0:0F=0x00 6:0:10=0x00 7:0:11=0x01
8:0:12=0x00 9:0:13=0x00 10:0:17=0x00 11:0:19=0x00 12:0:1A=0x01 13:0:1B=0x00 14:0:1C=0x00 15:0:28=0x00
16:0:29=0x00 17:0:2D=0x00 18:0:2E=0x74 19:0:2F=0x00 20:0:30=0xA7 21:0:31=0xF7 22:0:32=0xE8 23:0:33=0x00
24:0:34=0x27 25:0:35=0x00 26:0:36=0x38 27:0:37=0x00 28:0:38=0x03 29:0:39=0x1C 30:0:3A=0x80 31:0:3B=0x01
32:0:3C=0xFC 33:0:3D=0xFF 34:0:3E=0xE8 35:0:3F=0x00 36:0:40=0x7C 37:0:41=0x01 38:0:42=0x00 39:0:43=0x30
40:0:44=0x00 41:0:45=0x00 42:0:46=0x00 43:0:47=0x00 44:0:48=0x00 45:0:49=0x00 46:0:4A=0x00 47:0:4B=0x00
48:0:4C=0x00 49:0:4D=0x00 50:0:4E=0x00 51:0:4F=0x00 52:0:50=0x00 53:0:51=0x00 54:0:52=0x00 55:0:66=0x00
56:0:68=0x00 57:0:69=0x0F 58:0:70=0x00 59:0:71=0x46 60:0:72=0x00 61:0:74=0x0B 62:0:76=0x00 63:1:02=0xB2