global: fix MD007 unordered list indentation in markdown files
Normalize unordered list indentation to use 2-space multiples:
- Top-level list items start at column 0
- Nested list items use 2 additional spaces per level
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
global: fix MD009 trailing whitespace in markdown files
Remove trailing whitespace from all affected markdown files.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
global: fix MD010 hard tabs in markdown files
Replace hard tab characters with 4 spaces.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
global: fix MD012 multiple consecutive blank lines in markdown
Collapse multiple consecutive blank lines to single blank lines
across all markdown files (excluding vendored code).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
global: fix MD007 list indentation base level in markdown
Shift list indentation left by 2 spaces so top-level list items
start at column 0 instead of column 2.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD022 blank lines around headings in markdown
Ensure headings are surrounded by blank lines as required by
markdownlint MD022 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD032 blank lines around lists in markdown
Ensure lists are surrounded by blank lines as required by
markdownlint MD032 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD031 blank lines around code blocks in markdown
Ensure fenced code blocks are surrounded by blank lines as required
by markdownlint MD031 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD047 files should end with single newline
Ensure all markdown files end with exactly one newline character
as required by markdownlint MD047 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD023 headings must start at beginning of line
Remove leading whitespace from heading lines as required by
markdownlint MD023 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD007 remaining list indentation in markdown
Fix unordered list indentation to use correct spacing as required
by markdownlint MD007 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD030 spaces after list markers in markdown
Reduce multiple spaces after list markers to single space as
required by markdownlint MD030 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD022 blank lines around setext headings
Ensure setext-style headings (underlined with === or ---) are
surrounded by blank lines as required by markdownlint MD022 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD018 missing space after hash in headings
Add space after hash marks in atx-style headings as required by
markdownlint MD018 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD019 multiple spaces after hash in headings
Reduce multiple spaces after hash marks to single space in
atx-style headings as required by markdownlint MD019 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD012 multiple consecutive blank lines in markdown
Remove multiple consecutive blank lines and ensure files end with
exactly one newline as required by markdownlint MD012 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD023 headings with leading whitespace
Remove leading whitespace from setext-style heading text lines
as required by markdownlint MD023 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD022 blank line after heading in markdown
Add missing blank line after heading as required by markdownlint
MD022 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD009 trailing non-breaking space in markdown
Remove trailing non-breaking space (U+00A0) as required by
markdownlint MD009 rule.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tools/scripts: fix MD012 remaining multiple blank lines in markdown
Remove leading blank lines and whitespace-only lines that create
multiple consecutive blank lines.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
LittleFS always calls us with properly aligned and sized reads and
writes so we don't need to keep track of partial blocks (and they were
broken anyway).
Also fixes an issue where we would read too much of a JEDEC NOR page
when doing multi-page reads, though this had no effect except to waste
time since they are designed for it.
Doing the modulus in the loop body made it incorrect for the next loop
if doing a multi-page read. However, LittleFS doesn't seem to do these
with our cache size and filesytem usage.
Fix by only modifying the argument when sending the command.
The `wait_until_device_is_ready` and thus `write_enable` functions both
check for death before doing anything, and the flash access functions
call these before doing anything.
64K blocks are supported by all chips and have a higher bytes-per-second
erase rate than 4K "sectors". The block counts previously were in 64K
units so they don't change.
Also cleans up the calculations a bit.
The address in the `JEDEC_READ_DATA` command for JEDEC NOR chips is
absolute, not relative like for W25NXX. Fix erroneous reads by only
using relative `JEDEC_READ_DATA` address on W25NXX.
Match the chips which use the JEDEC driver in AP_Logger. Other chips are
(or should be) compatible. They are all NOR; NAND chips seem to use a
slightly different protocol described by AP_FILESYSTEM_FLASH_W25NXX.
Studied by copying and pasting the equations into a simple program to
step through each file offset and print the results.
* The equations return nonsense results for small file positions. This
is expected (and noted by the LittleFS author) as block 0 does not
have any pointers according to the LittleFS design; it's entirely
filled with data. Therefore, check and avoid calculating them when we
know we're in the first block.
* This function always assumes we are writing a full block, so
`block_size - block_offset <= nbytes` is always true.
* `block_size == block_offset` can never be true, `block_offset` is at
maximum `block_size-1`. Therefore we can remove the logic to sync when
they are equal and we will always calculate the result to be
`block_size - block_offset`.
We will reserve BOARD_FLASH_SIZE for the internal flash on stm32 flash processors, use HAL_PROGRAM_SIZE_LIMIT_KB in the general code base.
Notable change here is that boards with external flash will start to get features only available with more than 2MB of program storage
The file handle and object are always allocated together. Combine them
to avoid overhead from extra allocations and additional error cases.
Also simplify by using strdup for the pathname.
In Standard C, the first three file descriptors are usually standard in,
out, and error. However, ArduPilot doesn't have a concept of this and
other backends (such as LittleFS) don't bother to reject them.
Remove this logic to simplify implementation and allow use of more open
files.
lseek must return the current file position. Previously, the littlefs
version always returned 0, which broke terrain I/O as it checks that the
position returned is the one it seeked to. Fix to return the current
position, which is correctly returned from littlefs.
This problem was originally and incorrectly diagnosed as an issue with
littlefs seeking past the end of the file, but this functionality works
fine and fixing the incorrect return completely fixes terrain.
Terrain functionality was verified using `TERRAIN_DEBUG` on
KakuteH7Mini-Nand running sim on HW. Terrain data is correctly
downloaded from the GCS and loaded from the filesystem after reboot.
Lua opens scripts to load them into memory, then the logger opens them
after to stream them into the dataflash log. When loading multiple large
Lua scripts from ROMFS, decompression takes a significant amount of
time. This creates the opportunity for the Lua interpreter and logging
threads to both be inside `AP_Filesystem_ROMFS::open()` decompressing a
file.
If this happens, the function can return the same `fd` for two different
calls as the `fd` is chosen before decompression starts, but only marked
as being used after that finishes. The read pointers then stomp on each
other, so Lua loads garbled scripts (usually resulting in a syntax
error) and the logger dumps garbled data.
Fix the issue by locking before searching for a free record (or marking
a record as free). Apply the same fix to directories as well. This
doesn't protect against using the same `fd`/`dirp` from multiple
threads, but that behavior is to be discouraged anyway and is not the
root cause here.
optimize configured defaults on littlefs and address review comments
support lseek() in littlefs in a way that enables terrain to work
rename file and directory structures in littlefs
code in littlefs glue should be C++ rather than C
check for strdup failure on littlefs
use correct read status for nor flash
implement format on littlefs
optimize device calls in littlefs flash usage
check for fileops allowed in littlefs
littlefs optimization and support for mtime
The delays will be canceled on return by the EXPECT_DELAY_MS(3000)
destructor at the start of the function. The current behavior will
unexpectedly cancel delays from higher levels up the stack and is likely
not what was intended.
normally fgets is on a buffered FILE handle. For AP_Filesystem we use
an unbuffered file descriptor. This means we were reading one byte at
a time from the file
this uses lseek to make fgets() much more efficient by reading the max
buffer size at a time in the file