Reject unsupported color schemes at direct-write START#3
Open
balloob wants to merge 1 commit into
Open
Conversation
nRF firmware only renders BW (color_scheme 0) and BWR (color_scheme 1).
map_panel_ic_to_model_id() maps every nonzero color_scheme to a BWR model
and direct-write START sizes the transfer with a single BWR plane byte
count. For BWY, 2bpp and 4-gray schemes the client streams a differently
sized payload, so the firmware over/under-runs RAM and refreshes garbage
while still ACKing success.
Check display_config->color_scheme at direct-write START and reject any
scheme other than 0/1 with the standard 4-byte NACK frame
{0xFF, cmd, RESP_ERR_UNSUPPORTED_SCHEME, 0x00} before powering the panel.
The client's validate_ack_response() sees 0xFF70 instead of the 0x0070
ACK echo and raises InvalidResponseError, so it fails fast instead of
rendering garbage. BW and BWR are unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
map_panel_ic_to_model_id()(EPD/EPD_driver.c:325) maps any nonzerocolor_schemeto a BWR model, andhandle_direct_write_start()sizes the transfer using a single BWR plane byte count (row_bytes * height). The nRF firmware genuinely renders only two schemes: BW (0) and BWR (1). For BWY (2), 2bpp (3/5) and 4-gray (4/6), the client streams a payload of a different size than the firmware computes, so it over/under-runs display RAM and refreshes garbage — while still ACKing success to the client.Fix
At direct-write START, check the display's configured
color_scheme. If it is anything other than 0 (BW) or 1 (BWR), reply with the standard 4-byte NACK frame{0xFF, cmd, RESP_ERR_UNSUPPORTED_SCHEME, 0x00}and return before powering the panel or streaming. The unsupported color schemes are not implemented; they are cleanly rejected.Accepted vs rejected schemes
0(BW),1(BWR) — behavior unchanged.2(BWY),3/5(2bpp),4/6(4-gray), and any other value; also a NULLdisplay_config.Error frame
{0xFF, 0x70, 0x02, 0x00}—0x70is the low byte ofCMD_DIRECT_WRITE_START,0x02is the newRESP_ERR_UNSUPPORTED_SCHEMEcode. This matches the existing 4-byte NACK convention already used for config errors.Client recognition
The START ACK is
{0x00, 0x70}→ command code0x0070, which the client'svalidate_ack_response()accepts. The NACK's first two bytes are0xFF70, which is not in the valid ACK set{0x0070, 0x8070}, sovalidate_ack_response()raisesInvalidResponseError(protocol/responses.py). The client fails fast — it does not hang or proceed to stream.Testing
arm-none-eabi-gccand the nRF SDK build environment are not available here, so a full firmware build was not run. The changed logic was extracted into an isolated translation unit and compiled clean withgcc -std=c11 -Wall -Wextra -Werror(including the logging-disabled path). Change is surgical: BW and BWR paths are untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR