Use array initializers to ensure that each mode’s data is in the index to which its enum corresponds. This can help catch errors since the changes are across multiple files.
Also update the mode enumeration to have a common BP_MODE_ prefix. It would be better is C supported scoped enumerations, but this is the standard practice to reduce the chance of name collisions in the global namespace.
typedef the bytecode structure so don’t need to keep typing struct _bytecode everywhere.
And mark the modes as const. I had hoped the compiler would place this into a ROM section directly, and thus save a few extra bytes of RAM, but … unfortunately this is not the case. Still, it is good to mark things as const whenever possible.
New Pull Request: Minor bugfixes henrygab/BusPirate5-firmware → DangerousPrototypes/BusPirate5-firmware
Only one change that has potential to modify resulting code:
Mark a global variable modified in ISR as volatile.
Otherwise, these are compile-time only changes with no impact on resulting binary:
Static assertion added
Framework to enable readme to be up to 511 bytes
If you’ve not been bitten by the lack of volatile, consider yourself lucky. Suffice it to say that the compiler’s optimizer needs to know that it really, really should not optimize some things.
Change NAND terms to use ERASE_BLOCK instead of simply BLOCK
Use #define to select between two flash chips for firmware
Pass row_address_t to additional nand functions to support multi-plane
Fix for cross-plane copy (less efficient, but required until command found that copies from one plane’s cache register to the other plane’s cache register…)
Allow SPI NAND initialization to populate the dhara parameters dynamically
nand/spi_nand.c
spi_nand_init() now fills in the struct dhara_nand
static global page buffer is now maximum size for all supported nand chips (64 bytes extra RAM on 1Gbit Rev10) … renamed buffer to catch and replace all uses and replace any sizeof(buffer) style length with a length calculated based on detected NAND chip.
Track pointer to detected chip in global variable g_Actual_Nand_Device
Function read_id() now fills the nand_identity_t structure, does not validate the data (now done in spi_nand_init())
Converted some #define symbols into macros
use void * instead of uint8_t * when buffer type is variable type/size
in spi_nand.c, rename static reset() function as spi_nand_reset() to reduce likelihood of clashing with other functions.
New Pull Request: Define new BigBuffer_…() APIs henrygab/BusPirate5-firmware → DangerousPrototypes/BusPirate5-firmware
Genesis
The code base was facing pressure on the available RAM due to the use of non-const variables that were declared statically. These variables were used in multiple mutually exclusive “modes”, and were not needed when the mode was not active.
Goals
The new BigBuffer_...() APIs support dynamic allocation of those large non-const variables.
Seamless migration from legacy memory allocation APIs (mem_alloc() and mem_free()).
Prior memory allocation APIs (mem_alloc() and mem_free()) are temporarily converted to shims into the new APIs
Prior memory allocation APIs are marked deprecated, to simplify finding all users.
After integration into main branch, deprecated APIs will be removed.
Support most demanding current large RAM consumer (scope)
The APIs must support temporary (per-mode) allocation of 128k @ 32k alignment.
An additional 8k was made available for either temporary or long-lived allocations (or mixture of both).
Callers may specify an alignment requirement for each allocation.
Allocation of zero bytes is supported (and will return NULL).
Freeing NULL is supported (and will not modify the allocation state).
APIs can be reasoned about and are deterministic.
APIs get detailed information about allocations.
Unit tests exercise the APIs, including edge cases.
A simple way to enable extremely verbose debugging of the memory allocation system (at build time).
Non-Goals
The BigBuffer_...() APIs are not intended to be a general replacement for heap. Memory should generally be statically allocated during a mode’s initialization, and then freed when the mode is no longer active.
Overview
A static buffer is reserved that is 128k+8k in size, with a 32k alignment guarantee.
The memory layout will generall be as follows:
Address
Name
Description
high
__BIG_BUFFER_END__
Points just past (higher than) the end of the static buffer
…
…
Long-lived allocations (if any)
adjusts
high_watermark
Points just past (higher than) the last unallocated memory, or equal to low_watermark if all memory allocated.
…
…
Unallocated memory
adjusts
low_watermark
Points to the first (lowest address) unallocated byte of memory
…
…
Temporary allocations (if any)
low
__BIG_BUFFER_START__
Guaranteed to be 32k aligned
Long-lived allocations thus start from higher addresses and grow downwards, while temporary allocations start from lower addresses and grow upwards.
Long-lived allocations are limited to 8k, while temporary allocations are allowed to grow past the 128k boundary and use the full 136k (if not already used by long-lived allocations).
The idea here is to create something small and simple that works with third parties, not to implement everything. So the code I’ve written is a bit tricky (for example, I’m telling flashrom that I’m a Bus Pirate v2.5 (HW) so that it keeps the UART baud rate at 115200 by default…)
New Pull Request: Fix: update for pip and docker wyattearp/BusPirate5-firmware → DangerousPrototypes/BusPirate5-firmware
Sadly the docker build has been broken because the systems started enforcing the “don’t break system packages” for pip installs.
To stay closer to the actually build instructions, I’ve updated to install cmake from the repo as opposed to pip, this should really be problematic because nothing fancy is happening in cmake.
Additionally, I finally took the time to setup a docker hub account to host an image. I’m happy to create a buspirate org and leave it up there, but also, I didn’t want to do that without asking because it wouldn’t be owned by the real maintainers
Looking to fix #87 - I believe the pico-vscode.cmake is likely missing from being commited, but I also think it should probably live in the .vscode directory, which is currently under the .gitignore list.
This is just a draft so I can make sure I’m getting the right items into place, will update with a corrected .vscode/ and .gitignore as well as the corrected pico-vscode.cmake (when I find it).
Windows builds are failing.
This causes the other builds to be cancelled in the middle of the job.
The overall status is also shown as failed, even when the other two jobs succeed.
Finally, GitHub does not support a tag/config setting in the YAML that would simultaneously:
marks a job as being allowed to fail
show the job status as failed when it actually failed, AND
allow the overall action to be shown as succeeded (even if an allowed-to-fail job failed)
Therefore, just remove the Windows builds for the moment, so the action status shows something of value when a code change is good.