firmware/misc/gpu
2023-12-05 13:04:40 +01:00
..
external makes binary 2023-12-05 12:42:26 +01:00
releases v1.1.1 2023-12-05 12:42:26 +01:00
.gitignore working in-circuit upgrade 2023-12-05 12:42:26 +01:00
barcode.h cleanups, optimizations 2023-12-05 12:42:26 +01:00
basics.h some lcd pixels 2023-12-05 12:42:26 +01:00
gogo.gdb some lcd pixels 2023-12-05 12:42:26 +01:00
gpu_binary.py compress binary 2023-12-05 13:04:40 +01:00
interrupts.c some lcd pixels 2023-12-05 12:42:26 +01:00
interrupts.h makes binary 2023-12-05 12:42:26 +01:00
lcd.c new cursor types 2023-12-05 13:04:40 +01:00
lcd.h new cursor types 2023-12-05 13:04:40 +01:00
link-script.ld makes binary 2023-12-05 12:42:26 +01:00
main.c new cursor types 2023-12-05 13:04:40 +01:00
main.h cleanups 2023-12-05 12:42:26 +01:00
make_barcode.py cleanups, optimizations 2023-12-05 12:42:26 +01:00
Makefile compress binary 2023-12-05 13:04:40 +01:00
openocd-gpu.cfg makes binary 2023-12-05 12:42:26 +01:00
README.md cleanups, optimizations 2023-12-05 12:42:26 +01:00
repackage.py compress binary 2023-12-05 13:04:40 +01:00
requirements.txt cleanups, optimizations 2023-12-05 12:42:26 +01:00
startup.S working in-circuit upgrade 2023-12-05 12:42:26 +01:00
stm32c0x.cfg makes binary 2023-12-05 12:42:26 +01:00
stm32c0xx_hal_conf.h makes binary 2023-12-05 12:42:26 +01:00
stm32c0xx_hal.c makes binary 2023-12-05 12:42:26 +01:00
stm32c0xx_hal.h makes binary 2023-12-05 12:42:26 +01:00
stm32c0xx_ll_gpio.c some lcd pixels 2023-12-05 12:42:26 +01:00
stm32c0xx_ll_i2c.c cleanups 2023-12-05 12:42:26 +01:00
stm32c0xx_ll_spi.c some lcd pixels 2023-12-05 12:42:26 +01:00
stm32c0xx_ll_utils.c cleanups 2023-12-05 12:42:26 +01:00
version.c makes binary 2023-12-05 12:42:26 +01:00
version.h compress binary 2023-12-05 13:04:40 +01:00

GPU on Q1

The name is a joke. It's not a GPU, just a very simple and cheap micro that can animate a progress bar. And that's all we want it to do.

It is field upgradable, but we will remove that and start locking it down in production once it's features are stable.

Hardware

It's a STM32C011F4:

  • 16k bytes of Flash
  • 6k bytes of RAM
  • 4-48Mhz
  • 18 GPIO
  • 20 pins
  • a newer part, so some challenges there

Of the two TagConnect spots, the GPU is the inboard one; other is for main micro.

OpenOCD

Version 0.12.0 of OpenOCD, the latest release as of this writing, does not yet support this chip.

You'll need to compile from ST Micro's fork of OpenOCD. In particular we need this diff: https://github.com/STMicroelectronics/OpenOCD/commit/21c81a2b2edf5402afbba8c22feaeda6f626554e

I am using brew's install of normal 0.12.0 for config files, and a compiled version named openocd-stm, so my command line is:

openocd-stm -s /usr/local/Cellar/open-ocd/0.12.0/share/openocd/scripts -f openocd-gpu.cfg

Useful commands:

flash erase_sector 0 0 last

Set EMPTY bit, so goes into BL:

> mdw 0x40022000
0x40022000: 00040600 
> mmw 0x40022000 0x10000 0
> mdw 0x40022000          
0x40022000: 00050600 

In-Circuit Programming

  • AN4221 describes the protocol used to load the flash
  • timing is sensitive, but more important is where the i2c start/stops fall:

First Time Boot

  • on a fresh device, there is an EMPTY bit set on power-up (only) if flash looks empty
  • this causes bootmode to happen, regardless of subsequent flash contents, resets, and BOOT0 line
  • so must clear bit 16 of FLASH_ACR after loading image: @ 0x40022000
  • also, main micro has control over BOOT0 (PE2) which stop main flash from running too
  • and the reset line on E6
  • we use this flag to get into boot mode from working code

Getting BOOT0 to work

  • default config in flash bit (option bytes) is to
  • see FLASH_OPTR bit: nBOOT_SEL (bit 24) needs to be zero, default is one
  • NRST_MODE should be 0b01 (input only) not default (0b11 = bidirectional)
  • register FLASH_OPTR at 0x40022020 => found as 0xfffffeaa
  • loads from 0x1FFF7800 at power up
  • TODO XXX still need this!

AN4221 / Bootloader Bugs

  • command 0x00 - 'get' ... returns 19 bytes, but says v1.1 of protocol; clearly v1.2
  • command 0x02 - 'getid' ... returns 1 byte, but math wrong on length part of response
  • command 0x01 - 'getversion' ... return 1 byte, and doesn't include length prefix byte
  • memory read only works from flash, some parts of SRAM... not IO registers
  • undocumented need for N-1 as length in read/write commands
  • flash writes need to be 256-aligned, or else they do nothing and don't fail

Resource Sharing

  • SPI bus to the display is shared by the GPU and main micro.
  • Main micro configures its pins as pull-up, open-drain outputs (there is no input except TEAR).
  • GPU does the same, but no pull-ups (so open drain).

Other References