Test SPI flash is readable

- Update hello_world to read the SPI flash chip ID in a loop.
- README
  - Revised flashing instructions
  - Add a pin map
- Update flash-with-blackmagic-probe.sh to reset after loading.

Bug: b/310962981
Change-Id: I772ef135bda1d1397d802a0e45aa5b82b556290a
Reviewed-on: https://pigweed-review.googlesource.com/c/gonk/+/177990
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Eric Holland <hollande@google.com>
7 files changed
tree: 68e70c738540ec284318cdd5d6129a378bbea4cd
  1. applications/
  2. build_overrides/
  3. scripts/
  4. targets/
  5. third_party/
  6. tools/
  7. .gitignore
  8. .gitmodules
  9. .gn
  10. banner.txt
  11. bootstrap.sh
  12. BUILD.gn
  13. BUILDCONFIG.gn
  14. OWNERS
  15. pigweed.json
  16. README.md
README.md

Gonk

Getting Started

  1. Clone the repo

    git clone https://pigweed.googlesource.com/pigweed/gonk
    
  2. Source bootstrap.sh to download all compilers and tooling into the environment directory:

    . ./bootstrap.sh
    

    This should init all git submodules for you.

  3. From here on the Pigweed environment is activated. You can activate the environment in a new shell without re-running bootstrap by sourcing activate.sh

    . ./activate.sh
    

Compile:

Build for the host and device by running:

pw build

This is mostly a shortcut with nice output for running gn gen out/gn and ninja -C out/gn.

The build commands are defined in: //tools/gonk_tools/build_project.py.

Gonk spi_flash_test Example

Flash with dfu-util

  1. Create a bin file from the elf. This will be automated later.

    arm-none-eabi-objcopy -O binary \
      ./out/gn/arduino_size_optimized/obj/applications/spi_flash_test/bin/spi_flash_test.elf \
      ./out/gn/arduino_size_optimized/obj/applications/spi_flash_test/bin/spi_flash_test.bin
    
  2. Unplug gonk from USB and replug with MODE button held down.

  3. Run dfu-util to flash.

    dfu-util -d 0483:df11 -s 0x08000000:leave \
      --serial STM32FxSTM32 -a 0 \
      -D ./out/gn/arduino_size_optimized/obj/applications/spi_flash_test/bin/spi_flash_test.bin
    
  4. Unplug Gonk from USB and replug to reset the hardware. SPI bus issues have been observed without this step.

  5. Connect over serial.

    python -m serial.tools.miniterm --raw /dev/ttyGonk 115200
    

    You should see output matching:

    --- Miniterm on /dev/ttyGonk  115200,8,N,1 ---
    --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
    INF  Device id: 1f 84 1
    INF  Device id: 1f 84 1
    INF  Device id: 1f 84 1
    INF  Device id: 1f 84 1
    

Flash with BlackMagic Probe:

./scripts/flash-with-blackmagic-probe.sh ./out/gn/arduino_size_optimized/obj/applications/spi_flash_test/bin/spi_flash_test.elf

pw_system Example

Run on Host

Run the host app and connect to it via pw-system-console:

./out/gn/host_device_simulator.speed_optimized/obj/applications/system_example/bin/system_example & \
  pw-system-console --socket-addr default \
    --proto-globs third_party/pigweed/pw_rpc/echo.proto ; \
  killall system_example

Run on Device

Flashing

openocd -s $PW_PIGWEED_CIPD_INSTALL_DIR/share/openocd/scripts \
  -f $GONK_ROOT/targets/stm32f769i_disc0_stm32cube/openocd_stm32f7xx.cfg \
  -c "program out/gn/stm32f769i_disc0_stm32cube.size_optimized/obj/applications/system_example/bin/system_example.elf reset exit"

Updating STM32Cube

Checkout the desired commits in each of these submodules:

third_party/stm32cube_f7/cmsis_core
third_party/stm32cube_f7/cmsis_device
third_party/stm32cube_f7/hal_driver

Then run from Gonk root:

python -m pw_stm32cube_build gen_file_list third_party/stm32cube_f7

Pin Map

Misc

| Net | STM32 Pin | STM32 Function | Function | |--------+-----------+----------------+----------| | STATUS | PB13 | GPIO_Output | STAT LED |

SPI Flash Connection

NetSTM32 PinSTM32 FunctionFlash Pin
ICE_SPI_SSPD2GPIO_OutputS#
ICE_SPI_MISOPB4SPI1_MISODQ1
ICE_SPI_MOSIPB5SPI1_MOSIDQ0
ICE_SPI_SCKPB3SPI1_SCKC
FLASH_HOLDPC11GPIO_OutputHOLD#/DQ3
FLASH_WPPC12GPIO_OutputW#/VPP/DQ2

FPGA Connection

NetFunctionFPGA IO#STM32 PinSTM32 FunctionNotes
FPGA_IO_SPARE_0_2rst_i135PA0GPIO_OutputActive high
FPGA_IO_SPARE_0_0mode_i137PB11GPIO_OutputFPGA operation mode
FPGA_IO_SPARE_0_1valid_o136PB10GPIO_OutputData/Transfer Valid
DSPI_SCKsclk_i76PB2QUADSPI_CLK
DSPI_CScs_n75PB6QUADSPI_BK1_NCS
DSPI_IO1mosi_i74PC10QUADSPI_BK1_IO1
DSPI_IO0miso_i73PC9QUADSPI_BK1_IO0