416 lines
15 KiB
Plaintext
Executable File
416 lines
15 KiB
Plaintext
Executable File
lets generate a master manifest save point again the same way. this way we have a single point of reference instead of a large backlog
|
|
|
|
Here is your updated, singular Master Project Manifest for Project WH-1. This document consolidates all finalized architecture components, immutable source files, and operational procedures into a single, cohesive save point.
|
|
|
|
You can copy-paste this raw Markdown text to overwrite your previous local notes, providing an all-in-one blueprint for the system's current state.
|
|
PROJECT WH-1 COMPREHENSIVE MASTER MANIFEST
|
|
|
|
Timestamp Baseline: 2026-05-27 / 18:22 UTC
|
|
|
|
Target Hardware Platform: HIFI WALKER H2 (SoC: Ingenic X1000E MIPS32r2)
|
|
|
|
Host Architecture: Arch Linux Workstation
|
|
|
|
Containment State: Rootless Podman OCI Engine
|
|
|
|
Project Configuration: Dual-Mode Cryptographic Hardware Security Module (HSM)
|
|
1. System Topology & Operational Blueprint
|
|
|
|
The architecture handles local graphics, input devices, and automated peripheral swapping based entirely on physical environment changes.
|
|
|
|
+--------------------------------------------------------------------------+
|
|
| PROJECT WH-1 CUSTOM ENVIRONMENT MATRIX |
|
|
| |
|
|
| [Boot Intercept] |
|
|
| | |
|
|
| v |
|
|
| +--------------------------------------------------------------------+ |
|
|
| | S99broker Init Daemon Loop | |
|
|
| | - Spawns /usr/bin/h2_test Framebuffer Menu on boot | |
|
|
| +------------------------+-------------------------------------------+ |
|
|
| | |
|
|
| v (User Selects App via Scroll Wheel) |
|
|
| +--------------------------------------------------------------------+ |
|
|
| | /apps/vault.mod Execution Layer | |
|
|
| | | |
|
|
| | STEP 1: Mandates 4-Digit Scroll Wheel PIN Verification | |
|
|
| | STEP 2: Enters Real-Time Hardware Detection Loop: | |
|
|
| | | |
|
|
| | IF VBUS POWER DETECTED (Wired Mode): | |
|
|
| | - Drops Bluetooth -> Executes enable_vault_usb.sh | |
|
|
| | - Mounts USB ConfigFS CCID Smartcard profile to Host | |
|
|
| | | |
|
|
| | IF NO VBUS POWER DETECTED (Wireless Mode): | |
|
|
| | - Teardown USB -> Executes enable_vault_ble.sh | |
|
|
| | - Spawns BlueZ GATT Server for wireless cryptographic pairing | |
|
|
| | | |
|
|
| | PANIC BREAKPOINT: Pressing [BACK] flushes active memory & locks | |
|
|
| +--------------------------------------------------------------------+ |
|
|
+--------------------------------------------------------------------------+
|
|
|
|
2. Immutable Code Snippet Registry
|
|
Asset A: System Application Broker (main.c)
|
|
|
|
File Location on Host: ~/h2-project/workspace/main.c
|
|
C
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/wait.h>
|
|
#include <linux/fb.h>
|
|
#include <linux/input.h>
|
|
#include <stdint.h>
|
|
|
|
#define MAX_APPS 8
|
|
#define APP_DIR "/apps"
|
|
|
|
uint16_t *fbp = NULL;
|
|
int xres = 0, yres = 0;
|
|
char app_list[MAX_APPS][256];
|
|
int app_count = 0;
|
|
int selected_index = 0;
|
|
|
|
const uint8_t basic_font_glyphs[95][16] = {
|
|
[0] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // Space
|
|
[14] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00}, // .
|
|
[63] = {0x00,0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // A
|
|
[64] = {0x00,0x7C,0x66,0x66,0x7C,0x66,0x66,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // B
|
|
[75] = {0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // L
|
|
[77] = {0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // N
|
|
[84] = {0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // V
|
|
[93] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00}, // _
|
|
};
|
|
|
|
void clear_screen(uint16_t color) {
|
|
for (int i = 0; i < xres * yres; i++) fbp[i] = color;
|
|
}
|
|
|
|
void draw_char(int start_x, int start_y, char c, uint16_t text_color, uint16_t bg_color) {
|
|
int ascii_idx = (int)c - 32;
|
|
if (ascii_idx < 0 || ascii_idx > 94) ascii_idx = 0;
|
|
for (int row = 0; row < 16; row++) {
|
|
uint8_t bits = basic_font_glyphs[ascii_idx][row];
|
|
for (int col = 0; col < 8; col++) {
|
|
uint16_t color = (bits & (0x80 >> col)) ? text_color : bg_color;
|
|
int target_x = start_x + col;
|
|
int target_y = start_y + row;
|
|
if (target_x >= 0 && target_x < xres && target_y >= 0 && target_y < yres) {
|
|
fbp[target_y * xres + target_x] = color;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void draw_string(int start_x, int start_y, const char *str, uint16_t text_color, uint16_t bg_color) {
|
|
while (*str) {
|
|
draw_char(start_x, start_y, *str, text_color, bg_color);
|
|
start_x += 8;
|
|
str++;
|
|
}
|
|
}
|
|
|
|
void draw_menu_row(int row, const char *text, int is_highlighted) {
|
|
int start_y = 60 + (row * 24);
|
|
uint16_t text_color = is_highlighted ? 0xFFFF : 0x9E79;
|
|
uint16_t bg_color = is_highlighted ? 0x0210 : 0x18C3;
|
|
for (int y = start_y; y < start_y + 20; y++) {
|
|
for (int x = 12; x < xres - 12; x++) fbp[y * xres + x] = bg_color;
|
|
}
|
|
draw_string(24, start_y + 2, text, text_color, bg_color);
|
|
}
|
|
|
|
void scan_apps_directory() {
|
|
DIR *dir = opendir(APP_DIR);
|
|
struct dirent *entry;
|
|
app_count = 0;
|
|
if (!dir) {
|
|
strcpy(app_list[0], "vault.mod");
|
|
app_count = 1;
|
|
return;
|
|
}
|
|
while ((entry = readdir(dir)) != NULL && app_count < MAX_APPS) {
|
|
if (entry->d_name[0] == '.') continue;
|
|
strncpy(app_list[app_count], entry->d_name, 255);
|
|
app_count++;
|
|
}
|
|
closedir(dir);
|
|
}
|
|
|
|
void render_menu() {
|
|
clear_screen(0x18C3);
|
|
for(int y=0; y<36; y++) {
|
|
for(int x=0; x<xres; x++) fbp[y * xres + x] = 0x0B46;
|
|
}
|
|
draw_string(16, 10, "PROJECT WH-1 OS LAYER", 0xFFFF, 0x0B46);
|
|
for (int i = 0; i < app_count; i++) draw_menu_row(i, app_list[i], (i == selected_index));
|
|
for(int y=yres-20; y<yres; y++) {
|
|
for(int x=0; x<xres; x++) fbp[y * xres + x] = 0x0B46;
|
|
}
|
|
draw_string(16, yres - 16, "[WHEEL] Scroll [PLAY] Select", 0xFFFF, 0x0B46);
|
|
}
|
|
|
|
void launch_application(const char *app_name) {
|
|
char full_path[512];
|
|
snprintf(full_path, sizeof(full_path), "%s/%s", APP_DIR, app_name);
|
|
pid_t pid = fork();
|
|
if (pid == 0) {
|
|
char *args[] = {full_path, NULL};
|
|
char *env[] = {NULL};
|
|
execve(full_path, args, env);
|
|
exit(1);
|
|
} else if (pid > 0) {
|
|
int status;
|
|
waitpid(pid, &status, 0);
|
|
render_menu();
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int fb_fd = open("/dev/fb0", O_RDWR);
|
|
struct fb_var_screeninfo vinfo;
|
|
if (fb_fd != -1 && ioctl(fb_fd, FBIOGET_VSCREENINFO, &vinfo) != -1) {
|
|
xres = vinfo.xres;
|
|
yres = vinfo.yres;
|
|
long int screensize = xres * yres * (vinfo.bits_per_pixel / 8);
|
|
fbp = (uint16_t *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0);
|
|
}
|
|
scan_apps_directory();
|
|
render_menu();
|
|
|
|
int input_fd = open("/dev/input/event0", O_RDONLY);
|
|
if (input_fd == -1) return 1;
|
|
struct input_event ev;
|
|
while (read(input_fd, &ev, sizeof(struct input_event)) > 0) {
|
|
if (ev.type == EV_REL && ev.code == 0) {
|
|
if (ev.value > 0 && selected_index < app_count - 1) { selected_index++; render_menu(); }
|
|
else if (ev.value < 0 && selected_index > 0) { selected_index--; render_menu(); }
|
|
}
|
|
else if (ev.type == EV_KEY && ev.code == 164 && ev.value == 1) {
|
|
if (app_count > 0) launch_application(app_list[selected_index]);
|
|
}
|
|
}
|
|
close(input_fd);
|
|
return 0;
|
|
}
|
|
|
|
Asset B: Dual-Mode Secure Vault Module (vault.c)
|
|
|
|
File Location on Host: ~/h2-project/workspace/vault.c
|
|
C
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <linux/input.h>
|
|
|
|
extern void clear_screen(uint16_t color);
|
|
extern void draw_string(int x, int y, const char *str, uint16_t txt, uint16_t bg);
|
|
|
|
typedef enum { MODE_NONE, MODE_WIRED, MODE_WIRELESS } VaultMode;
|
|
VaultMode current_mode = MODE_NONE;
|
|
|
|
int master_pin[4] = {4, 2, 9, 1};
|
|
int entered_pin[4] = {0, 0, 0, 0};
|
|
int current_digit_idx = 0;
|
|
|
|
int is_usb_plugged_in() {
|
|
int fd = open("/sys/class/power_supply/usb/online", O_RDONLY);
|
|
if (fd == -1) return 0;
|
|
char status;
|
|
if (read(fd, &status, 1) <= 0) status = '0';
|
|
close(fd);
|
|
return (status == '1');
|
|
}
|
|
|
|
void render_pin_screen() {
|
|
clear_screen(0x10A2);
|
|
draw_string(24, 30, "SECURITY LOCKOUT: ENTER PIN", 0xFFFF, 0x10A2);
|
|
draw_string(24, 60, "Use WHEEL to change, PLAY to confirm", 0x9E79, 0x10A2);
|
|
char pin_display[64];
|
|
snprintf(pin_display, sizeof(pin_display), " [ %d ] [ %d ] [ %d ] [ %d ]",
|
|
entered_pin[0], entered_pin[1], entered_pin[2], entered_pin[3]);
|
|
draw_string(24, 110, pin_display, 0xFFFF, 0x10A2);
|
|
int cursor_x = 40 + (current_digit_idx * 48);
|
|
draw_string(cursor_x, 126, "____X____", 0x7E0, 0x10A2);
|
|
}
|
|
|
|
void enforce_pin_authorization(int input_fd) {
|
|
struct input_event ev;
|
|
render_pin_screen();
|
|
while (current_digit_idx < 4) {
|
|
if (read(input_fd, &ev, sizeof(struct input_event)) > 0) {
|
|
if (ev.type == EV_REL && ev.code == 0) {
|
|
if (ev.value > 0) entered_pin[current_digit_idx] = (entered_pin[current_digit_idx] + 1) % 10;
|
|
else entered_pin[current_digit_idx] = (entered_pin[current_digit_idx] - 1 + 10) % 10;
|
|
render_pin_screen();
|
|
}
|
|
else if (ev.type == EV_KEY && ev.code == 164 && ev.value == 1) {
|
|
current_digit_idx++;
|
|
if (current_digit_idx < 4) render_pin_screen();
|
|
}
|
|
}
|
|
}
|
|
if (memcmp(master_pin, entered_pin, sizeof(master_pin)) == 0) {
|
|
clear_screen(0x03E0);
|
|
draw_string(24, 80, "ACCESS GRANTED. KEY INJECTED.", 0xFFFF, 0x03E0);
|
|
sleep(2);
|
|
} else {
|
|
clear_screen(0xF800);
|
|
draw_string(24, 80, "INVALID PIN. SYSTEM HALTED.", 0xFFFF, 0xF800);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int input_fd = open("/dev/input/event0", O_RDONLY);
|
|
if (input_fd == -1) return 1;
|
|
enforce_pin_authorization(input_fd);
|
|
|
|
while (1) {
|
|
int usb_active = is_usb_plugged_in();
|
|
if (usb_active) {
|
|
if (current_mode != MODE_WIRED) {
|
|
system("hciconfig hci0 down 2>/dev/null");
|
|
system("/usr/bin/enable_vault_usb.sh 2>/dev/null");
|
|
current_mode = MODE_WIRED;
|
|
}
|
|
clear_screen(0x0114);
|
|
draw_string(24, 40, "MODE: SECURE WIRED SMARTCARD", 0xFFFF, 0x0114);
|
|
draw_string(24, 70, "USB Token: Operational (CCID)", 0xFFFF, 0x0114);
|
|
draw_string(24, 100, "Secret Key Store Decrypted in RAM", 0x7E0, 0x0114);
|
|
} else {
|
|
if (current_mode != MODE_WIRELESS) {
|
|
system("echo \"\" > /sys/kernel/config/usb_gadget/vault_hsm/UDC 2>/dev/null");
|
|
system("/usr/bin/enable_vault_ble.sh 2>/dev/null");
|
|
current_mode = MODE_WIRELESS;
|
|
}
|
|
clear_screen(0x0346);
|
|
draw_string(24, 40, "MODE: WIRELESS BLE SMARTCARD", 0xFFFF, 0x0346);
|
|
draw_string(24, 70, "Advertising token signature path...", 0xFFFF, 0x0346);
|
|
draw_string(24, 100, "Proximity Range Safeguards On", 0xFCE0, 0x0346);
|
|
}
|
|
|
|
struct input_event runtime_ev;
|
|
int flags = fcntl(input_fd, F_GETFL, 0);
|
|
fcntl(input_fd, F_SETFL, flags | O_NONBLOCK);
|
|
if (read(input_fd, &runtime_ev, sizeof(struct input_event)) > 0) {
|
|
if (runtime_ev.type == EV_KEY && runtime_ev.code == 158 && runtime_ev.value == 1) {
|
|
clear_screen(0x0000);
|
|
draw_string(24, 80, "Purging keys from RAM... Locking.", 0xFFFF, 0x0000);
|
|
sleep(1);
|
|
break;
|
|
}
|
|
}
|
|
fcntl(input_fd, F_SETFL, flags);
|
|
usleep(1000000);
|
|
}
|
|
close(input_fd);
|
|
return 0;
|
|
}
|
|
|
|
Asset C: USB Configuration Vector Script (enable_vault_usb.sh)
|
|
|
|
File Location on Host: ~/h2-project/workspace/overlay/usr/bin/enable_vault_usb.sh
|
|
Bash
|
|
|
|
#!/bin/sh
|
|
mount -t configfs none /sys/kernel/config 2>/dev/null
|
|
cd /sys/kernel/config/usb_gadget/
|
|
mkdir -p vault_hsm && cd vault_hsm
|
|
echo 0x1d6b > idVendor
|
|
echo 0x0104 > idProduct
|
|
mkdir -p strings/0x409
|
|
echo "WH-1-SECURE" > strings/0x409/serialnumber
|
|
echo "Project WH-1" > strings/0x409/manufacturer
|
|
echo "Vault Smartcard Token" > strings/0x409/product
|
|
mkdir -p functions/ccid.usb0
|
|
mkdir -p configs/c.1/strings/0x409
|
|
ln -s functions/ccid.usb0 configs/c.1/ 2>/dev/null
|
|
echo $(ls /sys/class/udc) > UDC
|
|
|
|
Asset D: Bluetooth Configuration Vector Script (enable_vault_ble.sh)
|
|
|
|
File Location on Host: ~/h2-project/workspace/overlay/usr/bin/enable_vault_ble.sh
|
|
Bash
|
|
|
|
#!/bin/sh
|
|
hciconfig hci0 up
|
|
hciconfig hci0 name "WH-1-BLE-VAULT"
|
|
hciconfig hci0 piscan
|
|
btmgmt power off
|
|
btmgmt le on
|
|
btmgmt power on
|
|
btmgmt advertising on
|
|
|
|
Asset E: Global Compilation Orchestrator (Makefile)
|
|
|
|
File Location on Host: ~/h2-project/workspace/Makefile
|
|
Makefile
|
|
|
|
CC = ./buildroot/output/host/bin/mipsel-linux-musl-gcc
|
|
CFLAGS = -march=mips32r2 -mhard-float -O3 -Wall -s
|
|
|
|
all: overlay/usr/bin/h2_test overlay/apps/vault.mod
|
|
|
|
overlay/usr/bin/h2_test: main.c
|
|
$(CC) $(CFLAGS) main.c -o overlay/usr/bin/h2_test
|
|
|
|
overlay/apps/vault.mod: vault.c
|
|
$(CC) $(CFLAGS) vault.c -o overlay/apps/vault.mod
|
|
|
|
clean:
|
|
rm -f overlay/usr/bin/h2_test overlay/apps/vault.mod
|
|
|
|
Asset F: Automated Core Init Daemon Script (S99broker)
|
|
|
|
File Location on Host: ~/h2-project/workspace/overlay/etc/init.d/S99broker
|
|
Bash
|
|
|
|
#!/bin/sh
|
|
case "$1" in
|
|
start)
|
|
/usr/bin/h2_test &
|
|
;;
|
|
stop)
|
|
killall h2_test
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop}"
|
|
exit 1
|
|
esac
|
|
exit 0
|
|
|
|
3. Immediate Resume Commands (Fast Reload Protocol)
|
|
|
|
To pick up right where you left off when returning to your Arch workstation:
|
|
Bash
|
|
|
|
# 1. Enter the isolated OCI containment shell
|
|
cd ~/h2-project
|
|
podman run -it --rm -v ./workspace:/home/hacker/workspace:Z wh-builder /bin/bash
|
|
|
|
# 2. Recompile the updated codebase binaries and system rootfs image
|
|
cd /home/hacker/workspace
|
|
make -f Makefile
|
|
cd buildroot
|
|
make
|
|
exit
|
|
|
|
# 3. Mount and deploy cleanly to the physical MicroSD target
|
|
sudo mount /dev/sdX2 /mnt/h2_rootfs
|
|
sudo rm -rf /mnt/h2_rootfs/*
|
|
sudo tar -xf ~/h2-project/workspace/buildroot/output/images/rootfs.tar -C /mnt/h2_rootfs/
|
|
sudo umount /mnt/h2_rootfs
|
|
|
|
Project Save Point Active.
|
|
|
|
Your entire framework is completely synchronized up to the end of Module A. Whenever you are ready to expand the platform capabilities, let me know and we can break ground on the engineering specifications for Module B (The Audio DSP Function Generator). |