Pull Requests - bus pirate 5 firmware

New Pull Request: Mode Quality of Life improvements
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

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.

Created by: henrygab

New Pull Request: Minor bugfixes
henrygab/BusPirate5-firmwareDangerousPrototypes/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.

Created by: henrygab

New Pull Request: Merged the multiple small PRs so you don’t have to merge / rebase
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Replaces the following PRs:

  • #66
  • #67
  • #68
  • #69

Created by: henrygab

Great updates, especially the inner-core messaging stuff.

2 Likes

New Pull Request: Enable 2Gbit rev10 board firmware
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

  • Add new target in CMakefiles.txt
  • 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…)

( Replaces PR #65 )

Created by: henrygab

2 Likes

New Pull Request: Single firmware for both 1Gbit and 2Gbit Rev10 boards
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

CMakeLists.txt

  • Remove newly added 2Gbit firmware type

nand/nand_ftl_diskio.c

  • 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.

Other random bits

  • Rename SPI_NAND_PAGES_PER_BLOCKSPI_NAND_PAGES_PER_ERASE_BLOCK
  • minor formatting tweaks

Created by: henrygab

1 Like

New Pull Request: RGB - Fix a bunch of bugs
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Highlights:

  • Externally, pixel color is always RGB order, stored in uint32_t.
  • Internally, pixel color uses the CPIXEL_COLOR_RGB format.
  • Moved brightness adjustment to single consolidated location (update of pixels).
  • Fixed name of configuration file’s brightness setting.
  • Prevented invalid values from being set in system configuration.
  • Config file stores pixel color as hex string (“0x00RRGGBB”). This allows setting any color by editing the config file, even if not listed in the UI.

There’s also a number of bugfixes, off-by-one adjustments, formatting updates, and more comments documenting the code’s intended behavior.

Created by: henrygab

2 Likes

New Pull Request: RGB: only need six hex digits printed
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Sorry, one more minor update.

Created by: henrygab

New Pull Request: BigBuf - framework / untested
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Although not exposed yet, the new API allows multiple allocations, and re-initialization of the BigBuffer state.

This should just work compatibly via the old API. Not tested yet …this is just for early feedback.

Summary of changes other than pirate/mem.c:

  • pirate.c – Remove previously reserved 10k buffer
  • pirate.h – Remove global declaration of big buffer’s size (can be API if required later)
  • pirate/memmap_buspirate5.ld – although not a functional change, be explicit about the need for 32k alignment of .bss
  • pirate/storage.c – Remove static assert

Summary of changes within pirate/mem.c:

  • Big buffer is now 138k (128k + 10k) to allow for fuller allocation capability / tracking metadata.
  • Primary focus is on allocation of buffers of at least 1k size (and with alignment requirements)
  • Initially, just allocate large buffers from the lower side, and smaller buffers from the upper side, meeting in the middle

Later, maybe store a 128-bit map (representing 1k chunks) of what’s allocated, or other tracked method to allow free() to be robust.

Created by: henrygab

New Pull Request: Define new BigBuffer_…() APIs
henrygab/BusPirate5-firmwareDangerousPrototypes/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).

Created by: henrygab

1 Like

New Pull Request: More descriptive define names
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Use of BP_REV and BP_VER is not technically wrong.

At the same time, the mind can easily misread one for the other. This is especially true for those with dyslexia.

This just changes these to defines to have slightly more descriptive defines. The meaning stays the same, but readability improves.

Created by: henrygab

New Pull Request: More descriptive define names
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Use of BP_REV and BP_VER is not technically wrong.

At the same time, the mind can easily misread one for the other. This is especially true for those with dyslexia.

This just changes these to defines to have slightly more descriptive defines. The meaning stays the same, but readability improves.

Created by: henrygab

1 Like

New Pull Request: Add legacy mode for third parties
therealdreg/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

image

Created by: therealdreg

1 Like

New Pull Request: Add legacy mode for third parties flashrom avrdude
therealdreg/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

Bus Pirate v5* & v6-> (flashrom, avrdude & asprogrammer dreg mod)

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…)


image

image


image


uf2 files:

build.zip


Example flashrom

flashrom.exe --progress -V -c "W25Q64JV-.Q" -p buspirate_spi:dev=COM5,spispeed=8M -r flash_content.img

Example avrdude

avrdude.exe -V -c buspirate -p m328p -P COM5 -b 115200 -U flash:r:"C:\Users\regue\Desktop\readed.bin":r

Created by: therealdreg

1 Like

New Pull Request: Fix: update for pip and docker
wyattearp/BusPirate5-firmwareDangerousPrototypes/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 :slight_smile:

Created by: wyattearp

shouldn’t be problematic whoops!

New Pull Request: DRAFT: Fix for VSCode Windows Extension
wyattearp/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

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).

Created by: wyattearp

Hey all - sorry to leave these for so long. I’ll start reviewing and accepting now. Thank you all so much!

1 Like

New Pull Request: temporarily disable windows builds due to unrelated failures
henrygab/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

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.

Created by: henrygab

1 Like

New Pull Request: UART: Implement CTS/RTS flow control, add option to invert signals
mblsha/BusPirate5-firmwareDangerousPrototypes/BusPirate5-firmware

  • CTS is implemented in hardware (uart_set_hw_flow).
  • RTS is software-defined, since otherwise it doesn’t get properly raised when inverted signals are used.

Tested this with a Sharp PC-G850 pocket computer:

  • TX connected to Pin6 (RXD)
  • RX connected to Pin7 (TXD)
  • CTS connected to Pin4 (RTS)
  • RTS connected to Pin9 (CTS)

For reference PC-G850 works with these settings:

  • UART speed: 1200 baud (later model variants seem to work at 9600, didn’t test them yet)
  • Data bits: 8
  • Parity: None
  • Stop bits: 1
  • Hardware flow control: RTS/CTS
  • Signal inversion: Inverted

Created by: mblsha