From 99a21a1bf35c5af6188abdcb87e894b371bbffa5 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Wed, 31 Dec 2025 21:51:40 +0800 Subject: Fix date tag h5 and broken html. --- _log/arduino-due.md | 26 +++++----------- _log/fpm-door-lock-rf.md | 2 ++ _log/neo4j-a-star-search.md | 2 +- _log/search-with-cgi.md | 73 --------------------------------------------- 4 files changed, 11 insertions(+), 92 deletions(-) delete mode 100644 _log/search-with-cgi.md (limited to '_log') diff --git a/_log/arduino-due.md b/_log/arduino-due.md index 0d4f495..f604e89 100644 --- a/_log/arduino-due.md +++ b/_log/arduino-due.md @@ -4,25 +4,15 @@ date: 2024-09-16 layout: post --- -Notes on programming ATSAM3X8E chips (Arduino Due) without bootloader. Tested -on OpenBSD. +Notes on programming bare-metal ATSAM3X8E chips (Arduino Due) using Serial Wire +Debug (SwD) protocol. ## Toolchain -Need to bypass embedded bootloader—requires hardware programmer that speaks -Serial Wire Debug (SWD). ST-LINK/V2 works as SWD-USB adapter. - -OpenOCD translates commands to binary sequences the chip understands. Runs -telnet server on startup for issuing commands. - -ARM GNU Compiler Toolchain for compiling C programs. Both OpenOCD and ARM -toolchain available on OpenBSD. +ST-LINK/V2 programmer, OpenOCD, ARM GNU Compiler Toolchain. ## Electrical connections -Arduino Due exposes ATSAM3X8E's SWD interface via DEBUG port. ST-LINK/V2 -connects there. -
@@ -41,8 +31,7 @@ ST-LINK/v2 programmer connects to that to communicate with the chip. ## Upload procedure -Sample LED blink program with OpenOCD config and linker scripts in tarball -below. +Build. Magic is in the script.ld linker script. ``` $ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -T script.ld \ @@ -51,7 +40,8 @@ $ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -T script.ld \ -o a.elf main.c ``` -Upload: + +Upload using OpenOCD: ``` $ openocd -f openocd-due.cfg @@ -81,8 +71,8 @@ Program goes in flash0, so set GPNVM1=1 to boot our code instead of bootloader. ## Linker script notes -Vector table must be at first flash address--mandatory for ARM chips unless -using VTOR register for relocation. +Vector table must be at first flash address--required for ARM chips unless +relocated using VTOR register. First vector table entry: stack pointer. Initialize to highest memory location (ATSAM3X8E has descending stack). diff --git a/_log/fpm-door-lock-rf.md b/_log/fpm-door-lock-rf.md index 46f4dbe..76f64d7 100644 --- a/_log/fpm-door-lock-rf.md +++ b/_log/fpm-door-lock-rf.md @@ -2,6 +2,8 @@ title: Fingerprint door lock (RF) date: 2025-06-05 layout: post +project: true +thumbnail: thumb_sm.jpeg --- Wanted to unlock door with fingerprint, wirelessly to avoid drilling. diff --git a/_log/neo4j-a-star-search.md b/_log/neo4j-a-star-search.md index a8882d1..3233428 100644 --- a/_log/neo4j-a-star-search.md +++ b/_log/neo4j-a-star-search.md @@ -4,7 +4,7 @@ date: 2018-03-06 layout: post --- -Replaced Dijkstra's for vessel route tracking in Neo4J. +Replaced Dijkstra's search for vessel route tracking in Neo4J. Tracking 13,000 marine vessel route points. Needed shortest paths between ports for arrival prediction. Neo4j's Dijkstra's algorithm slows after 4,000 route diff --git a/_log/search-with-cgi.md b/_log/search-with-cgi.md deleted file mode 100644 index 0109294..0000000 --- a/_log/search-with-cgi.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Site search using Perl + CGI -date: 2025-12-29 -layout: post ---- - -Number of articles on the site are growing. Need a way to search site. - -Searching the RSS feed client-side using JavaScript is not an option. That -would make the feed much heavier and break the site for text-based web browsers -like Lynx. - -Not gonna use an inverted index--More than an evening's effort, especially if I -want partial matching. I want partial matching. - -Few lines of Perl could do a regex search and send the result back via CGI. -OpenBSD httpd speaks CGI. Perl and slowcgi are in the base system. No -dependencies. - -Perl: traverse directory with File::Find. If search text is found grab the file -name, title and up to 50 chars from the first paragraph to include in the -search result. - -``` -find({ - wanted => sub { - return unless -f $_ && $_ eq 'index.html'; - # ... file reading ... - if ($content =~ /\Q$search_text\E/i) { - # Extract title, snippet - push @results, { - path => $File::Find::name, - title => $title, - snippet => $snippet - }; - } - }, - follow => 0, -}, $dir); -``` - -httpd sets the search text in QUERY_STRING env. Don't need Perl's CGI module. - -``` -my %params; -if ($ENV{QUERY_STRING}) { - foreach my $pair (split /&/, $ENV{QUERY_STRING}) { - my ($key, $value) = split /=/, $pair; - $value =~ tr/+/ /; - $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; - $params{$key} = $value; - } -} -``` - -Security. - -ReDOS, XSS, command injection, symlink attacks. Did I miss anything? Probably. - -ReDOS: sanitized user input, length-limit search text, quote metacharacters -with `\Q$search_text\E`. - -XSS: sanitized user input. Escaped HTML. - -Command injection: no exec()/system() calls. Non-privileged user (www). - -Symlink attacks: File::Find don't follow symlinks (follow => 0). chroot. - -Access controls: files (444), directories and CGI script: 554. - -Verdict: O(n) speed. Works on every conceivable browser. Good enough. - -Commit: [9fec793](https://git.asciimx.com/www/commit/?h=term&id=9fec793abe0a73e5cd502a1d1e935e2413b85079) -- cgit v1.2.3