Skip to content

Instantly share code, notes, and snippets.

#if !ASM_SIZE_HACKS
// 这种方式简单直观,但会占用额外的指令空间(如加载全局变量地址的指令)。
mpu_hw_t *mpu_on_arm = mpu_hw;
#else
mpu_hw_t *mpu_on_arm;
pico_default_asm_volatile(
"ldr %[mpu_on_arm], [%[zero],%[_CPACR_OFFSET]]\n"
"adds %[mpu_on_arm], %[REG_DIFF]\n"
: [mpu_on_arm] "=l" (mpu_on_arm)
@aphlta
aphlta / discard
Created January 23, 2026 03:25
emmc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/fs.h>
#include <errno.h>
import subprocess
import sys
import time
def run_cmd(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
return "", err.decode(errors="ignore").strip()
return out.decode(errors="ignore"), ""
set environment LD_LIBRARY_PATH /usr/local/apr/lib/
@aphlta
aphlta / c-object
Created December 4, 2025 00:33
c-code
#ifndef _object_h
#define _object_h
typedef enum {
NORTH, SOUTH, EAST, WEST
} Direction;
typedef struct {
char *description;
int (*init)(void *self);
@aphlta
aphlta / debug
Created November 28, 2025 06:33
debug code
#ifndef DEBUG_H
#define DEBUG_H
#ifndef DEBUG_H
#define DEBUG_H
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
@aphlta
aphlta / awk
Created November 26, 2025 06:06
tools use
if [ "${CONFIG_CAMERA_SENSOR}" = "BF2257" ]; then
local snippet_path=${basedir_amp}/products/${opt_amp_profile}/BF2257_sensors.xml
if [ -f "${snippet_path}" ]; then
awk -v snip="${snippet_path}" '
BEGIN{replacing=0}
/<Sensors[[:space:]][^>]*>/{replacing=1; while((getline line < snip)>0) print line; next}
replacing && /<\/Sensors>/{replacing=0; next}
{if(!replacing) print}
' "${hw_xml}" > /tmp/berlin_config_hw.new && mv /tmp/berlin_config_hw.new "${hw_xml}"
fi
@aphlta
aphlta / auto rules
Last active January 6, 2026 09:42
makefile
$(objects): %: $(BUILD_DIR)/$(%_BIN)
%_NAME = %
%_OBJ_DIR = $(BUILD_DIR)/obj_dir/$%
%_BIN= $(BUILD_DIR)/$(%_NAME)
%_NXDC_FILES = constr/%.nxdc
%_SRC_AUTO_BIND = $(abspath $(BUILD_DIR)/auto_bind_%.cpp)
$(%_SRC_AUTO_BIND): $(%_NXDC_FILES)
python3 $(NVBOARD_HOME)/scripts/auto_pin_bind.py $^ $@