Skip to content

Instantly share code, notes, and snippets.

View rikka0w0's full-sized avatar

Rikka0_0小六花 rikka0w0

  • UNSW
  • Sydney
View GitHub Profile
@rikka0w0
rikka0w0 / Readme.md
Last active August 15, 2021 17:59
CCS10.4 on Java 16

The DVT module calls "sun.reflect.Reflection.getCallerClass".

The alternative method using StackWalker (since Java 9):

    public static Class<?> getCallerClass(int n) {
        try {
        	List<StackFrame> stack = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(s -> s.limit(n).collect(Collectors.toList()));
        	StackFrame stackFrame = stack.get(stack.size()-1);
        	return stackFrame.getDeclaringClass();
        } catch (Exception e) {
@rikka0w0
rikka0w0 / Readme.md
Last active July 29, 2021 16:31
OpenSTM32 on Eclispe 2021-06 and Java 16

The problem

https://www.openstm32.org/forumthread8387#form

ENTRY org.eclipse.ui 4 0 2021-02-21 14:00:13.956
MESSAGE Unhandled event loop exception
STACK 0
java.lang.NoClassDefFoundError: org/eclipse/cdt/launch/ui/CMainTab
@rikka0w0
rikka0w0 / .config
Last active July 12, 2022 13:12
Thunder_TimeCloud_OpenWrt
#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_sunxi is not set
# CONFIG_TARGET_apm821xx is not set
# CONFIG_TARGET_ath25 is not set
# CONFIG_TARGET_ath79 is not set
@rikka0w0
rikka0w0 / config.c
Last active June 11, 2021 15:57
Reliable config data storage on the built-in flash of STM32. Tolerate to power loss and flash damage.
/**
* Resource used:
* Flash, CRC
*/
/**
* A utility which reliably stores config data on the built-in flash of the MCU.
* Data integrity is guaranteed by CRC32. If a power loss happens during a flash
* write operation, upon next start-up, the last valid configuration will be used.
*/
@rikka0w0
rikka0w0 / crc.c
Created March 17, 2021 09:10
STM32F0 CRC32, supports unaligend memory as input.
/*
* Resource used:
* CRC32 peripheral
*/
#include "crc.h"
#include "stm32f0xx_ll_bus.h"
void crc32_init(void) {
@rikka0w0
rikka0w0 / STM32_Flash_User_Data.md
Created March 16, 2021 14:45
Change the linkerscript to allocate some space for storing non-volatile user data

Solution 1: User Data at the end of flash

Define constants before MEMORY section:

/* EEPROM emulator */
_Flash_Page_Size = 0x400;	/* Page size of the flash in bytes, see MCU datasheet */
_User_Config_Size = 0x400;	/* Size of the emulated EEPROM in bytes, must be multiples of _Flash_Page_Size */

Define the section for non-volatile user data:

 /* Flash reserved for the EEPROM emulation at the end of the Flash*/
@rikka0w0
rikka0w0 / Add_System_to_ThisPC_Win10_20H2.reg
Created March 15, 2021 13:12
Add an menu item for the legacy "System" control panel page in the context menu of ThisPC, run as TrustedInstaller, use NSudo
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\System]
"Icon"="imageres.dll,143"
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\System\command]
@="explorer /same,shell:::{BB06C0E4-D293-4f75-8A90-CB05B6477EEE}"
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage]
"Icon"="imageres.dll,313"
@rikka0w0
rikka0w0 / openocd_stm32.zip
Last active January 31, 2021 16:11
Gdb+OpenOCD remote STM32 debugging
This file has been truncated, but you can view the full file.
@rikka0w0
rikka0w0 / debian-i386.sh
Created January 24, 2021 15:44
Install a Debian 10 i386 proot enviroment in Termux
#!/data/data/com.termux/files/usr/bin/bash
## --- README ---
## Download and run this script and wait....
## The key is to have qemu-i386-static in /data/data/com.termux/files/usr/bin/
## Reference: https://github.com/AllPlatform/Termux-UbuntuX86_64/blob/master/Ubuntu-i386.sh
pkg install proot -y
folder=debian-fs
if [ -d "$folder" ]; then
first=1
echo "skipping downloading"
@rikka0w0
rikka0w0 / intro.md
Last active January 17, 2021 05:29
A linux bash script which helps the developer to convert the address from core dump to meaningful filenames and line numbers

Usage

  1. Download xtensa-lx106-elf-backtrace and place it anywhere that is in the $PATH variable.
  2. cd to your project/build
  3. Run xtensa-lx106-elf-backtrace "xxxxxxx", xxxxxxx is the list of addresses shown in a core dump.

Example

Core dump:

Guru Meditation Error: Core  0 panic'ed (LoadStoreAlignment). Exception was unhandled.
Core 0 register dump: