Examples

If any examples below results in an error, please contact us at support@lagerdata.com

Log In To lager-cli

Log into lager-cli so that assigned Gateways are available.

      ~ lager login
      Please confirm the following code appears in your browser: ABCD-EFGH-IJKL
      Lager would like to open a browser window to confirm your login info [y/N]: y
      Awaiting confirmation... (Could take up to 5 seconds after clicking "Confirm" in your browser)
      Success! You're ready to use Lager!
      ~

Log Out Of lager-cli

Log out of lager-cli.

      ~ lager logout
      ~

Set Default Gateway

If users have multiple gateways setting a default gateway allows users to drop the --gateway [GATEWAY] flag when executing a Lager command. A default can always be overridden with the --gateway [GATEWAY] flag.

Setting A Default Gateway With id

  ~ lager list gateways
  name               id
  elegant-einstein    1
  bored-bohr          2
  ~ lager set default gateway 2
  ~

Setting A Default Gateway With name

  ~ lager list gateways
  name               id
  elegant-einstein    1
  bored-bohr          2
  ~ lager set default gateway bored-bohr
  ~

Connect Flasher/Debugger to Device

Built-In Interface

Connect to a nrf52 MCU using the Gateway's built-in debug-probe. This will default to swd.

      ~ lager connect --device nrf52
      Connected!
      ~

Third Party Interface

Connect using an external Segger J-Link debug-probe plugged into the Gateway.

      ~ lager connect --device MIMXRT1064xxx6A --interface jlink
      Connected!
      ~

Fully Specified Connection

      ~ lager connect --device atsame70 --interface cmsis-dap --transport swd --speed 4000 --set RTOSTYPE=FreeRTOS --workareasize 0x8000 --force
      Connected!
      ~

Verify Connection

  ~ lager gateway status
  Debugger running: True
  ---- Debugger config ----
  set ENABLE_ACQUIRE 0
  interface: ftdi_2232
  transport select swd
  target: nrf52
  ---- Logs ----
  0
  Info : FTDI SWD mode enabled
  swd
  Info : Listening on port 6666 for tcl connections
  Info : Listening on port 4444 for telnet connections
  Info : clock speed 1000 kHz
  Info : SWD DPIDR 0x2ba01477
  Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
  Info : starting gdb server for nrf52.cpu on 3333
  Info : Listening on port 3333 for gdb connections
  ~

Disconnect From Device

Before connecting to a different DUT on the same Gateway disconnect from currently connected DUT.

      ~ lager disconnect
      Disconnected!

Flash Device

Flash a device connected to a Gateway via JTAG/SWD with either a hex or binary image file.

Single Hex Image

      ~ lager flash --hexfile image.hex
      Open On-Chip Debugger
      > program /tmp/tmpsdvkq1sj.hex preverify verify
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
      **pre-verifying**
      checksum mismatch - attempting binary compare
      ** Programming Started **
      Adding extra erase range, 0x0000675c .. 0x00006fff
      ** Programming Finished **
      ** Verify Started **
      ** Verified OK **
      > exit
      ~

Multiple Hex Images

      ~ lager flash --hexfile image_1.hex --hexfile image_2.hex
      Open On-Chip Debugger
      > program /tmp/tmp_5_hb6vl.hex preverify verify
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0x00003368 msp: 0x20040000
      **pre-verifying**
      checksum mismatch - attempting binary compare
      ** Programming Started **
      nRF52840-xxAA(build code: AA) 1024kB Flash, 256kB RAM
      Padding image section 0 at 0x00000b00 with 1280 bytes
      Adding extra erase range, 0x00026598 .. 0x00026fff
      ** Programming Finished **
      ** Verify Started **
      ** Verified OK **
      > program /tmp/tmp2yfmpee7.hex preverify verify
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
      **pre-verifying**
      checksum mismatch - attempting binary compare
      ** Programming Started **
      Adding extra erase range, 0x0003976c .. 0x00039fff
      ** Programming Finished **
      ** Verify Started **
      ** Verified OK **
      > exit
      ~

Single Binary Image

A start address must be given when flashing a device with a binary image.

      ~ lager flash --binfile image.bin,0x0
      Open On-Chip Debugger
      > program /tmp/tmpl9wj87zv.bin preverify verify 0x0
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
      **pre-verifying**
      checksum mismatch - attempting binary compare
      ** Programming Started **
      Adding extra erase range, 0x0000675c .. 0x00006fff
      ** Programming Finished **
      ** Verify Started **
      ** Verified OK **
      > exit
      ~

Reset Device

Reset and Run

      ~ lager reset
      Open On-Chip Debugger
      > reset run
      > exit
      ~

Reset and Halt

      ~ lager reset --halt
      Open On-Chip Debugger
      > reset halt
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0x080004f0 msp: 0x20003000
      > exit
      ~

Run A Halted Device

      ~ lager run
      Open On-Chip Debugger
      > reset
      > exit
      ~

Erase On-Device Flash

The following will erase 0x1000 bytes of flash memory starting at address 0x0

      ~ lager erase 0x0 0x1000
      Open On-Chip Debugger
      > reset halt
      target halted due to debug-request, current mode: Thread
      xPSR: 0x01000000 pc: 0x00003368 msp: 0x20040000
      > flash erase_address 0x0 0x1000
      erased address 0x00000000 (length 4096) in 0.085397s (46.840 KiB/s)
      > exit
      ~

Start GDBServer

Connect over GDB to a device connected to a Gateway via JTAG/SWD by starting a GDBServer on the Gateway.

      ~ lager gdbserver
      Serving GDB on localhost:3333. Press Ctrl+C to quit.

Starting GDB server if Gateway and Host Computer are on same local network. This will reduce latency.

      ~ lager gdbserver --local
      Serving GDB on localhost:3333. Press Ctrl+C to quit.

Add Development Environment To Project

      ~ lager devenv create
      Docker image [lagerdata/devenv-cortexm]: lagerdata/devenv-cortexm-minimal
      Source code mount directory in docker container [/app]: /github/workspace
      ~

Delete Development Environment From Project

      ~ lager devenv delete
      Are you sure you want to delete your devenv? [y/N]: y
      ~

Execute A Docker Command

If lager devenv create was run, then arbitrary commands can be run insde the associated docker container.

      ~ lager exec --command "mkdir -p _build;cd _build;cmake .. -G Ninja;cmake --build ."
-- Configuring done
      -- Generating done
      -- Build files have been written to: /github/workspace/_build
      [10/37] Linking C executable unit-tests/test-suites/test-example/test-example
         text    data     bss     dec     hex filename
         3816     108     160    4084     ff4 /github/workspace/_build/unit-tests/test-suites/test-example/test-example
      [37/37] Linking C executable app/app
         text    data     bss     dec     hex filename
        25960     500    2844   29304    7278 /github/workspace/_build/app/app
        ~

Save Executed Command

      ~ lager exec --command "cd _build;ninja -t clean" --save-as clean
      Cleaning... 37 files.
      ~ lager exec clean
      Cleaning... 0 files.
      ~

UART

List Available Serial Ports and Connect

      ~ lager gateway serial-ports
      /dev/ttyS0 - Lager Gateway serial port
      /dev/ttyUSB0 - FTDI FT232
      ~ lager uart --serial-device /dev/ttyUSB0 --baudrate 115200

Interactive Connection

      ~ lager gateway serial-ports
      /dev/ttyS0 - Lager Gateway serial port
      /dev/ttyUSB0 - FTDI FT232
      ~ lager uart --serial-device /dev/ttyUSB0 --baudrate 115200 --interactive

In interactive mode keystrokes from the user are sent to the device.

GPIO

Set Gateway GPIO Pin to Output

      ~ lager gpio set 0 OUT
      ~

Set Gateway Output GPIO Pin HIGH and LOW

      ~ lager gpio output 0 HIGH
      ~ lager gpio output 0 LOW
      ~

Set Gateway GPIO Pin to Input

      ~ lager gpio set 0 IN
      ~

Read Value On Gateway GPIO Pin

      ~ lager gpio input 0
      1
      ~

SPI

Write 4 Bytes

      lager spi write 0x12 0x34 0x56 0x78

Specify Mode and Speed

      lager spi write --mode 3 --speed 500000 0x12 0x34 0x56 0x78

Write String

      lager spi write hello

Write And Read

      ~ lager spi transfer --type string hello
      Lager SPI Received 5 bytes: world

I2C

Write 0xFFFF to device 0x12

      ~ lager i2c write --type hex 0x12 0xFF 0xFF
      ~

Write "hello" to device 0x12 (18)

      ~ lager i2c write --type string 18 hello
      ~

Read 1 byte from device 0x12 (18)

      ~ lager i2c read 0x12
      0xfe
      ~

Read 2 bytes from device 0x12 (18) register 0x10 (16) in hex format

      ~ lager i2c read --length 2 --type hex --reg 16 0x12
      0xde 0xad
      ~

ADC

      ~ lager adc read --output mV 0
      {'average_count': 0, 'busses': {'VIO': 0.8074, 'VTREF': 3.3332}, 'output': 'mv', 'results': [1.5734]}
      ~ lager adc read --output raw 0
      {'average_count': 0, 'busses': {'VIO': 608, 'VTREF': 2576}, 'output': 'raw', 'results': [1184]}
      ~