<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aethel-Systems</title>
    <description>The latest articles on Forem by Aethel-Systems (@aethelsystems).</description>
    <link>https://forem.com/aethelsystems</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3815674%2Fae9edb9e-8e2b-4165-b488-66ef27cff8c5.png</url>
      <title>Forem: Aethel-Systems</title>
      <link>https://forem.com/aethelsystems</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aethelsystems"/>
    <language>en</language>
    <item>
      <title>I Kept Bricking NFC Cards — So I Built a 1KB Crash-Proof Storage Engine</title>
      <dc:creator>Aethel-Systems</dc:creator>
      <pubDate>Fri, 10 Apr 2026 12:52:24 +0000</pubDate>
      <link>https://forem.com/aethelsystems/i-kept-bricking-nfc-cards-so-i-built-a-1kb-crash-proof-storage-engine-1b13</link>
      <guid>https://forem.com/aethelsystems/i-kept-bricking-nfc-cards-so-i-built-a-1kb-crash-proof-storage-engine-1b13</guid>
      <description>&lt;h3&gt;
  
  
  The "Tear-off" Nightmare
&lt;/h3&gt;

&lt;p&gt;If you’ve ever worked with NFC development, you know the "Tear-off" effect. &lt;/p&gt;

&lt;p&gt;You are in the middle of writing a block of data to a MIFARE Classic card. The user’s hand shakes, the phone moves 1cm away from the tag, and &lt;strong&gt;boom&lt;/strong&gt;—the RF field collapses. You just suffered a partial write. The data is corrupted, the checksums fail, and in the worst-case scenario, your application-level logic "bricks" the card because it's now in an inconsistent state.&lt;/p&gt;

&lt;p&gt;In my project &lt;strong&gt;AECardTools&lt;/strong&gt;, I decided that "good enough" wasn't enough. I wanted an NFC storage system that was &lt;strong&gt;physically impossible to brick&lt;/strong&gt;, even if you pull the card away mid-write.&lt;/p&gt;

&lt;p&gt;Here is how I built a &lt;strong&gt;Log-structured Copy-on-Write (LCOW)&lt;/strong&gt; engine that fits inside a tiny 1KB NFC chip.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Challenge: 1024 Bytes of Chaos
&lt;/h3&gt;

&lt;p&gt;A MIFARE Classic 1K card is not a "hard drive." It's a collection of 16 sectors, each protected by keys. Normally, developers overwrite data in place. If the power cuts at byte 8 of 16, you are toast.&lt;/p&gt;

&lt;p&gt;To solve this, I implemented three core concepts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Never Overwrite:&lt;/strong&gt; We never modify the "current" valid data. We always write to a new location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atomic Commits:&lt;/strong&gt; Data is only considered "real" once a single, tiny pointer (the Anchor) is updated at the very end.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maximizing Payload (The 900-Byte Hack):&lt;/strong&gt; Standard MIFARE 1K usually only gives you &lt;strong&gt;752 bytes&lt;/strong&gt; of user data because the "Sector Trailers" (which store Keys A and B) take up space. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Trick:&lt;/strong&gt; In AECardTools, I treat the card as a raw encrypted canvas. I store the Sector Keys locally in the app's encrypted database. This allows me to reclaim the Key A/B areas for data storage, pushing the usable capacity to roughly &lt;strong&gt;900 bytes&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Architecture: How LCOW Works
&lt;/h3&gt;

&lt;p&gt;The engine (written in Python via Chaquopy for the heavy lifting, and Kotlin for the NFC I/O) treats the card as a series of versioned logs.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. The Ping-Pong Anchors
&lt;/h4&gt;

&lt;p&gt;I reserved the very last sector (Sector 15) as the "Command Center." It contains two "Anchors." &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Anchor A&lt;/strong&gt; and &lt;strong&gt;Anchor B&lt;/strong&gt; act like a toggle switch.&lt;/li&gt;
&lt;li&gt;Each anchor contains a &lt;strong&gt;Transaction Sequence Number (TSN)&lt;/strong&gt; and a pointer to the current root block.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. The Write Flow
&lt;/h4&gt;

&lt;p&gt;When you save a new file to the card:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Find Free Space:&lt;/strong&gt; The engine looks for sectors not occupied by the current version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write New Data:&lt;/strong&gt; It writes the new encrypted payload to these "shadow" sectors. If the user pulls the card away now, the &lt;em&gt;old&lt;/em&gt; data is still sitting safely in its original sectors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Atomic Flip:&lt;/strong&gt; Only after the data is 100% verified does the engine write a new &lt;strong&gt;TSN+1&lt;/strong&gt; to the &lt;em&gt;other&lt;/em&gt; Anchor.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  3. The Recovery
&lt;/h4&gt;

&lt;p&gt;When the app scans a card, it looks at both Anchors. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If Anchor A says &lt;code&gt;TSN: 10&lt;/code&gt; and Anchor B says &lt;code&gt;TSN: 11&lt;/code&gt;, the engine instantly knows that &lt;strong&gt;Version 11&lt;/strong&gt; is the truth. &lt;/li&gt;
&lt;li&gt;If the write was interrupted, Version 11 would have a failed CRC or an older TSN, and the engine would automatically "roll back" to Version 10. &lt;strong&gt;Zero data loss. Zero bricking.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Architecture diagram
&lt;/h4&gt;

&lt;p&gt;To bridge the gap between high-level Python logic and raw Android NFC hardware, I implemented a Neuromorphic FFI Bridge. Here is the high-level architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────────┐
│              AECardTools: Sovereign Architecture                │
├─────────────────────────────────────────────────────────────────┤
│ [UI Layer] (Kotlin / Jetpack Compose)                           │
│  - HexCanvas &amp;amp; Registry Editor UI                               │
│  - Security Disclaimer &amp;amp; Transaction Monitoring                 │
└───────────────┬─────────────────────────────────────────────────┘
                │ Reactive StateFlow
┌───────────────▼─────────────────────────────────────────────────┐
│ [ViewModel / Session Manager]                                   │
│  - Global NFC Session tracking                                  │
│  - Hardware I/O Orchestration                                   │
└───────────────┬─────────────────────────────────────────────────┘
                │ JNI / Chaquopy FFI Bridge
┌───────────────▼─────────────────────────────────────────────────┐
│ [Python Core Engine] (The "Brain")                              │
│  ┌────────────────────┐    ┌─────────────────────────────────┐  │
│  │    LCOW Engine     │    │      Cryptography Module        │  │
│  │ - Virtual Address  │    │ - Argon2id Key Derivation       │  │
│  │ - Transaction Logs │    │ - XChaCha20-Poly1305 (AEAD)     │  │
│  │ - GC Controller    │    │ - Merkle Tree Integrity Check   │  │
│  └──────────┬─────────┘    └─────────────────────────────────┘  │
└─────────────┼───────────────────────────────────────────────────┘
              │ Callbacks
┌─────────────▼───────────────────────────────────────────────────┐
│ [NFC Hardware Layer] (Kotlin / android.nfc.tech)                │
│  - Universal Protocol Manager (IsoDep / NfcA / NfcB)            │
│  - Sensitive Instruction Interceptor (Brick Protection)         │
└──────────────────────────────┬──────────────────────────────────┘
                               │ RF Field (13.56MHz)
                    ┌──────────▼──────────┐
                    │  MIFARE Classic 1K  │
                    └─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real magic happens in the memory remapping. I treat the 16 sectors not as rigid silos, but as a virtualized block pool managed by the LCOW engine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHYSICAL STORAGE (1024B)             LOGICAL VIEW (AEFS v5.5)
┌──────────────────────────┐         ┌──────────────────────────┐
│ Sector 0: Genesis Block  │────────▶│ 0x000 - 0x01F: Metadata  │
├──────────────────────────┤         ├──────────────────────────┤
│ Sectors 1-14:            │         │ 0x020 - 0x2EF:           │
│                          │         │                          │
│ [ LOG-STRUCTURED POOL ]  │────────▶│ [ SEAMLESS PAYLOAD ]     │
│ (42 Data Blocks)         │         │                          │
│                          │         │ (Encrypted Canvas)       │
├──────────────────────────┤         └──────────────────────────┘
│ Sector 15: Superblock    │
│ [Block 0]: Anchor A (Ping)◀───┐      ATOMIC FLIP LOGIC:
│ [Block 1]: Anchor B (Pong)◀───┴──[ Active pointer toggles ]
│ [Block 2]: GC / Bitmap   │       [ only after successful  ]
│ [Block 3]: Keys &amp;amp; ACL    │       [ verify-after-write     ]
└──────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Hardening the Security: Sovereign Keys
&lt;/h3&gt;

&lt;p&gt;Since I'm using the Key A/B sectors for data to hit that &lt;strong&gt;900-byte&lt;/strong&gt; goal, the security model changes. &lt;/p&gt;

&lt;p&gt;Most NFC apps rely on the card's hardware to check keys. But MIFARE Classic's "Crypto1" algorithm is famously broken. Instead, I implement &lt;strong&gt;Sovereign Encryption&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The card is just a "dumb" encrypted block device.&lt;/li&gt;
&lt;li&gt;The encryption (XChaCha20-Poly1305) and key derivation (Argon2id) happen entirely inside the Android app. &lt;/li&gt;
&lt;li&gt;Even if someone cracks the RFID hardware layer, they just see a 900-byte blob of high-entropy noise.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;By combining a &lt;strong&gt;Copy-on-Write&lt;/strong&gt; strategy with a &lt;strong&gt;Local Key Management&lt;/strong&gt; system, I turned a cheap $0.50 RFID tag into a robust, atomic, and encrypted mini-vault.&lt;/p&gt;

&lt;p&gt;It’s a reminder that even when working with "ancient" hardware from the 90s, modern software patterns like &lt;strong&gt;LCOW&lt;/strong&gt; can solve physical-layer reliability problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you're building anything with NFC, you might find this useful 👇&lt;br&gt;&lt;br&gt;
👉 GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Aethel-Systems/AECardTools" rel="noopener noreferrer"&gt;AECardTools&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nfc</category>
      <category>android</category>
      <category>security</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Escaping EDK II bloat: Building a linker-less systems language that weaves its own PE32+ binaries</title>
      <dc:creator>Aethel-Systems</dc:creator>
      <pubDate>Thu, 12 Mar 2026 02:52:50 +0000</pubDate>
      <link>https://forem.com/aethelsystems/escaping-edk-ii-bloat-building-a-linker-less-systems-language-that-weaves-its-own-pe32-binaries-18l</link>
      <guid>https://forem.com/aethelsystems/escaping-edk-ii-bloat-building-a-linker-less-systems-language-that-weaves-its-own-pe32-binaries-18l</guid>
      <description>&lt;p&gt;If you have ever tried to write a lightweight UEFI application or a custom bootloader, you probably know the friction involved. &lt;br&gt;
 &lt;br&gt;
You either wrestle with the massive, convoluted build system of EDK II, or you spend hours tweaking fragile linker scripts just to force a standard C/Rust compiler to output a valid PE32+ image. Traditional toolchains are built on a philosophy of separation: the compiler handles the logic, and the linker handles the physical geometry. &lt;br&gt;
 &lt;br&gt;
But in bare-metal environments, physical geometry &lt;em&gt;is&lt;/em&gt; logic. &lt;br&gt;
 &lt;br&gt;
I wanted a toolchain that deeply understands the binary format it is producing, without the historical baggage of POSIX or traditional build systems. So, I started building &lt;strong&gt;Aethelium&lt;/strong&gt;—a system language and "kernel forge" designed exclusively for bare-metal and UEFI development.&lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  Not for your Host OS (The "Compiler Strike")
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
Before getting into the architecture, I should clarify what Aethelium is &lt;em&gt;not&lt;/em&gt;. It does not target macOS, Linux, or Windows. It does not generate ELF or Mach-O executables for your host machine. &lt;br&gt;
 &lt;br&gt;
It is so strictly separated from the traditional OS ecosystem that if you try to pull in C-style legacy code like &lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt; or call &lt;code&gt;malloc()&lt;/code&gt;, the compiler physically intercepts the token, prints &lt;code&gt;[COMPILER STRIKE] The paradigm barrier starts here&lt;/code&gt;, and terminates with exit code 1010. &lt;br&gt;
 &lt;br&gt;
It is designed from the ground up to target raw x86 silicon and UEFI firmware. &lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  Bypassing the Linker: The "Weaver-Filler" Architecture
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
In a traditional pipeline (&lt;code&gt;Compiler -&amp;gt; Assembler -&amp;gt; Linker&lt;/code&gt;), the compiler generates intermediate object files, leaving the linker to "guess" where the code should go based on abstract symbols. This creates unnecessary friction when all you need is a raw binary payload or a specific EFI header.&lt;br&gt;
 &lt;br&gt;
Aethelium completely drops the assembler and the linker. Instead, it uses a dual-engine architecture in a single pass:&lt;br&gt;
 &lt;br&gt;
1.  &lt;strong&gt;The Weaver&lt;/strong&gt;: Before a single line of logic is translated, the Weaver pre-calculates the entire physical "skeleton" of the binary. It manually constructs the PE32+ headers, section alignments, base relocations, and fixed memory slots.&lt;br&gt;
2.  &lt;strong&gt;The Filler&lt;/strong&gt;: The compiler frontend then lowers the AST and encodes raw x86-64 machine code (handling REX prefixes and ModR/M bytes directly in C) directly into these pre-calculated physical offsets.&lt;br&gt;
 &lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  Hardware as a First-Class Citizen
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
Because Aethelium is deeply tied to the metal, hardware constraints are baked directly into the language grammar. You don't need &lt;code&gt;__attribute__((...))&lt;/code&gt; hacks or opaque inline assembly blocks.&lt;br&gt;
 &lt;br&gt;
Here is what a bare-metal UEFI entry point looks like:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// =========================================================
// Aethelium UEFI Entry Point
// =========================================================
 
// Direct entry point with gate-specific calling conventions
@entry
@gate(type: \efi)
func efi/main(image/handle: ptr&amp;lt;Void&amp;gt;, sys/table: ptr&amp;lt;EFI/SystemTable&amp;gt;) : UInt64 {
 
    // The compiler natively understands the UEFI ConOut protocol
    print("Hello, Bare-Metal World!")
 
    // First-class Hardware block:
    // Direct processor state control. The compiler emits raw opcodes here.
    hardware {
        loop {
            hardware\isa\pause()
        }
    }
 
    return 0 // EFI/SUCCESS
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  Navigable Namespaces
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
One of the more opinionated design choices in the language is the strict rejection of flat namespaces. Instead of &lt;code&gt;snake_case&lt;/code&gt; with underscores (e.g., &lt;code&gt;sys_cpu_id&lt;/code&gt;), Aethelium uses &lt;code&gt;/&lt;/code&gt; for namespaces (e.g., &lt;code&gt;sys/cpu/id&lt;/code&gt;). &lt;br&gt;
 &lt;br&gt;
It treats system capabilities as a navigable, hierarchical tree. To accommodate this logically at the lexer level, mathematical division uses the &lt;code&gt;÷&lt;/code&gt; operator. It’s a controversial shift, but it fundamentally changes how you architect low-level APIs.&lt;br&gt;
 &lt;/p&gt;
&lt;h3&gt;
  
  
  The Current State
&lt;/h3&gt;

&lt;p&gt; &lt;br&gt;
Aethelium is currently a self-hosted bootstrap effort written entirely in C and &lt;br&gt;
assembly. It is fully capable of producing zero-dependency, zero-bloat UEFI "Hello World" binaries, performing hardware state snapshots, and directly probing VGA/COM1 ports without any external dependencies.&lt;br&gt;
 &lt;br&gt;
If you are interested in compiler architecture, manual x86 opcode encoding, or how to manually construct PE32+/ISO files from scratch in memory, the complete source code of the compiler is open. &lt;br&gt;
 &lt;br&gt;
You can explore the raw plumbing here:&lt;br&gt;
 &lt;br&gt;


&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Aethel-Systems" rel="noopener noreferrer"&gt;
        Aethel-Systems
      &lt;/a&gt; / &lt;a href="https://github.com/Aethel-Systems/Aethelium" rel="noopener noreferrer"&gt;
        Aethelium
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Aethelium: A hardware-first, runtime-less language for modern systems programming. Bypassing linkers and bulky frameworks to emit UEFI and bare-metal binaries directly.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Aethelium: A Hardware-First, Runtime-Less Systems Language Toolchain&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/Aethel-Systems/Aethelium/README_CN.md" rel="noopener noreferrer"&gt;中文&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A hardware-first, runtime-less systems language toolchain built for modern low-level programming.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Aethelium&lt;/strong&gt; is an independent, self-contained systems programming language toolchain. It bypasses the cumbersome traditional "compiler-assembler-linker" workflow, focusing on providing an ultra-streamlined build solution for &lt;strong&gt;UEFI environments&lt;/strong&gt; and &lt;strong&gt;bare-metal&lt;/strong&gt; development.&lt;/p&gt;

&lt;p&gt;This repository contains the &lt;strong&gt;Bootstrap Core&lt;/strong&gt; of Aethelium. It is capable of generating native machine code or UEFI PE executables for target architectures directly on a host machine (macOS/Linux), without relying on standard object files (&lt;code&gt;.obj&lt;/code&gt;/&lt;code&gt;.o&lt;/code&gt;) or external linkers.&lt;/p&gt;




&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🏗 Core Architecture&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;Aethelium utilizes a unique &lt;strong&gt;"Weaver-Filler"&lt;/strong&gt; dual-engine architecture, achieving a direct mapping from high-level semantics to silicon logic:&lt;/p&gt;


&lt;ul&gt;

&lt;li&gt;

&lt;strong&gt;Binary Weaver (&lt;code&gt;toolsASM&lt;/code&gt;)&lt;/strong&gt;
Responsible for the physical orchestration of the low-level binary layout.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Logic Filler (&lt;code&gt;toolsC&lt;/code&gt;)&lt;/strong&gt;
A compiler frontend implemented in C. It handles semantic analysis and AST construction for Aethelium syntax, precisely…&lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Aethel-Systems/Aethelium" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;





</description>
      <category>compilers</category>
      <category>lowlevel</category>
      <category>osdev</category>
      <category>uefi</category>
    </item>
  </channel>
</rss>
