Snowy Screen

Jakob edited this page Jan 14, 2017 · 3 revisions

Snowy Screen/FPGA Communication

Two Commandsets:

PDISPLAY_CMD_SET_0:

This is used by the boot loader and has cmd IDs that tell the FPGA to display pre-canned images.

  • Commands:

  • PSDISPLAYCMD0_NULL = 0

  • PSDISPLAYCMD0_SET_PARAMETER = 1

  • PSDISPLAYCMD0_DISPLAY_OFF = 2

  • PSDISPLAYCMD0_DISPLAY_ON = 3

  • PSDISPLAYCMD0_DRAW_SCENE = 4

  • Scene numbers put into cmd_parameter and used by the PSDISPLAYCMD0_DRAW_SCENE command:

  • PSDISPLAYSCENE_BLACK = 0

  • PSDISPLAYSCENE_SPLASH = 1 // splash screen

  • PSDISPLAYSCENE_UPDATE = 2 // firmware update

  • PSDISPLAYSCENE_ERROR = 3 // display error code

PDISPLAY_CMD_SET_1:

The display expects complete frames to be sent through the SPI bus, one column at a time starting from the left-most column, each column sent from bottom to top. The bits and bytes in each column are scrambled however and need to be unscrambled before placing them into the framebuffer.

  • Commands for PSDISPLAY_CMD_SET_1. We accept these while in the PSDISPLAYSTATE_ACCEPTING_CMD state. These are implemented in the firmware

  • PSDISPLAYCMD1_FRAME_BEGIN = 5

  • 8 Bits MSB first:

  • 2 bits unused (00)

  • 2 bits red

  • 2 bits green

  • 2 bits blue

Additional IO Pins

  • INTN interrupt:
  • display done (de-assert=true)
  • DONE interrupt:
  • asserted (=false) on reset
  • sclk
  • ?? (not used in qemu)

How To Dump FPGA Code

  • Download Pebble qemu source code
  • Open hw/display/pebble_snowy_display.c
  • Edit the prog_header array to be at least 33000 byte big
  • Add the following lines to the ps_display_determine_command_set method:
FILE *myfile = fopen("/tmp/fpga.bin", "w");
fwrite(s->prog_header, sizeof(uint8_t), s->prog_byte_offset, myfile);
fclose(myfile);
  • Run the Pebble emulator
  • Profit

Sample "SPI Dump"

// Recovery screen mode (no FPGA Firmware loaded)
PEBBLE_SNOWY_DISPLAY: state change from 0 (PSDISPLAYSTATE_PROGRAMMING) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 0
PEBBLE_SNOWY_DISPLAY: DISPLAY POWER CTL changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: RESET changed to 1
PEBBLE_SNOWY_DISPLAY: Asserting done interrupt
PEBBLE_SNOWY_DISPLAY: Resetting state to accept command
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 0
PEBBLE_SNOWY_DISPLAY: BACKLIGHT ENABLE changed to 0
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 4, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set0: cmd: 4 -- cs: CS
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 3 (PSDISPLAYSTATE_ACCEPTING_SCENE_BYTE) frame: 0 - bytes: 1
PEBBLE_SNOWY_DISPLAY: received scene ID: 1
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set0: cmd: 4 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: DRAW_SCENE: 1
PEBBLE_SNOWY_DISPLAY: Asserting done interrupt
PEBBLE_SNOWY_DISPLAY: Resetting state to accept command
PEBBLE_SNOWY_DISPLAY: state change from 3 (PSDISPLAYSTATE_ACCEPTING_SCENE_BYTE) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 2
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 3, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set0: cmd: 3 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: DISPLAY_ON
PEBBLE_SNOWY_DISPLAY: Asserting done interrupt
PEBBLE_SNOWY_DISPLAY: Resetting state to accept command
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 3
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0

//Switch to FPGA programming mode
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: RESET changed to 0
PEBBLE_SNOWY_DISPLAY: RESET changed to 1
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 0 (PSDISPLAYSTATE_PROGRAMMING) frame: 0 - bytes: 3
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: Exiting programming mode
PEBBLE_SNOWY_DISPLAY: Asserting done interrupt
PEBBLE_SNOWY_DISPLAY: Resetting state to accept command
PEBBLE_SNOWY_DISPLAY: state change from 0 (PSDISPLAYSTATE_PROGRAMMING) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 32301
PEBBLE_SNOWY_DISPLAY: ps_display_determine_command_set: found 'Lattice' string in programming header
PEBBLE_SNOWY_DISPLAY: ps_display_determine_command_set: found 'iCEcube2 2016.02.27810' string in programming header
PEBBLE_SNOWY_DISPLAY: ps_display_determine_command_set: found 'Part: iCE40LP1K-CM36' string in programming header
PEBBLE_SNOWY_DISPLAY: ps_display_determine_command_set: found 'Date: Jul 6 2016 11:48:2' string in programming header
PEBBLE_SNOWY_DISPLAY: PEBBLE_SNOWY_DISPLAY: Unknown FPGA programming with a date stamp of 'Date: Jul 6 2016 11:48:2'. Defaulting to command set 2
PEBBLE_SNOWY_DISPLAY: BACKLIGHT ENABLE changed to 0
PEBBLE_SNOWY_DISPLAY: BACKLIGHT ENABLE changed to 1
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 63
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 5, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set1: cmd: 5 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: FRAME_BEGIN
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) frame: 0 - bytes: 32302
PEBBLE_SNOWY_DISPLAY: New frame?  -- 0x3F,  row 169, col 2 -- bytes: 32303 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Got last byte in frame (col) row 169, col 146
PEBBLE_SNOWY_DISPLAY: state change from 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 0 - bytes: 56494
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 5, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set1: cmd: 5 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: FRAME_BEGIN
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) frame: 1 - bytes: 56495
PEBBLE_SNOWY_DISPLAY: New frame?  -- 0x3F,  row 169, col 2 -- bytes: 56496 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Got last byte in frame (col) row 169, col 146
PEBBLE_SNOWY_DISPLAY: state change from 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 1 - bytes: 80687
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 5, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set1: cmd: 5 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: FRAME_BEGIN
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) frame: 2 - bytes: 80688
PEBBLE_SNOWY_DISPLAY: New frame?  -- 0x3F,  row 169, col 2 -- bytes: 80689 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Got last byte in frame (col) row 169, col 146
PEBBLE_SNOWY_DISPLAY: state change from 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 2 - bytes: 104880
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 5, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set1: cmd: 5 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: FRAME_BEGIN
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) frame: 3 - bytes: 104881
PEBBLE_SNOWY_DISPLAY: New frame?  -- 0x3F,  row 169, col 2 -- bytes: 104882 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Got last byte in frame (col) row 169, col 146
PEBBLE_SNOWY_DISPLAY: state change from 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 3 - bytes: 129073
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: CS changed to 0
PEBBLE_SNOWY_DISPLAY: received command 5, deasserting done interrupt
PEBBLE_SNOWY_DISPLAY: ps_display_execute_current_cmd_set1: cmd: 5 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Executing command: FRAME_BEGIN
PEBBLE_SNOWY_DISPLAY: state change from 1 (PSDISPLAYSTATE_ACCEPTING_CMD) to 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) frame: 4 - bytes: 129074
PEBBLE_SNOWY_DISPLAY: New frame?  -- 0x3F,  row 169, col 2 -- bytes: 129075 -- cs: CS
PEBBLE_SNOWY_DISPLAY: Got last byte in frame (col) row 169, col 146
PEBBLE_SNOWY_DISPLAY: state change from 4 (PSDISPLAYSTATE_ACCEPTING_FRAME_DATA) to 1 (PSDISPLAYSTATE_ACCEPTING_CMD) frame: 4 - bytes: 153266
PEBBLE_SNOWY_DISPLAY: CS changed to 1
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 60
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 57
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 54
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 51
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 47
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 44
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 41
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 38
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 35
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 31
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 28
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 25
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 22
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 19
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 15
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 12
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 9
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 6
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 3
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: Backlight level changed to 0
PEBBLE_SNOWY_DISPLAY: BACKLIGHT ENABLE changed to 0
PEBBLE_SNOWY_DISPLAY: BACKLIGHT ENABLE changed to 0
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.