Project

General

Profile

Hello World on the M4

Objectives

  • Build a hello world program for the mcu
  • Load the program over JTAG, step through the program, see the output
  • Load the program using the remoteproc system
  • Load the program at boot time

Reference Documentation

Prerequisites

Steps - building the hello world program

  • Start Code Composer with a new workspace
  • Import a CCS Project from ~/ti/mcu_plus_sdk_am62x_08_06_00_18/examples/hello_world
    • pick am62x-sk/m4fss0-0_freertos
  • Correct the JTAG emulator type if needed. Default is XDS110
    • Open the targetConfigs/AM62.ccxml target configuration
      • Use the drop-down list for Connection to pick the correct debug probe type
      • Click on the Save Configuration button to save the modification
    • If you get an error on the target configuration, make sure you followed the steps listed above about fixing the target configuration paths.
  • Build program for debug

Steps - Load the program over JTAG, step through the program, see the output

  • Launch Am62x Target configuration
    • Open Target Configurations View
    • Expand the Projects, expand hello_world..., expand targetConfigs
    • Select AM62.ccxml, right-mouse->Launch Selected Configuration
  • Connect to target.
    • Select BLAZER_Cortex_M4F_1, right-mouse->Connect Target
  • Reset CPU.
    • Menu Bar->Run->Reset->CPU Reset
  • Load program.
    • Menu Bar->Run->Load->Load Program.
    • Browse Project. Pick debug executable (hello_world_....arm_clang.out)
      • The am62-mcu-m4f0_0-fw is a stripped version of the .out file so it is not suitable for debugging.
      • Press OK
    • Press OK
  • Put breakpoint after call to DebugP_log() in hello_world.c
  • Continue
  • See output in console in Code Composer
    • Output will also appear on the M4 uart

Steps - Load the program using the remoteproc system

  • Apply patches to the imported project
    • Without the patches, the program can be loaded via JTAG but not through the remoteproc process.
    • With the patches, the program can be loaded through the remoteproc process, but not through JTAG.
    • See m4_hello_world_patches_for_use_with_remoteproc
  • Build release version
  • Copy release version to /lib/firmware/hello_world/am62-mcu-m4f0_0-fw
    ssh target_62x mkdir -p /lib/firmware/hello_world
    scp Release/am62-mcu-m4f0_0-fw target_62x:/lib/firmware/hello_world
    
  • link /lib/firmware/am62-mcu-m4f0_0-fw to hello_world
    ssh target_62x ln -sf /lib/firmware/hello_world/am62-mcu-m4f0_0-fw /lib/firmware/am62-mcu-m4f0_0-fw
    
  • On the target
    • See the different remote processors
      cd /sys/class/remoteproc
      
      root@mitysom-am62x:/sys/class/remoteproc# tail */name
      ==> remoteproc0/name <==
      5000000.m4fss
      
      ==> remoteproc1/name <==
      78000000.r5f
      
      ==> remoteproc2/name <==
      30074000.pru
      
      ==> remoteproc3/name <==
      30078000.pru
      
    • Pick out the one for the mcu. e.g. remoteproc0
    • See the current state of the processor.
      tail *0/state
      running
      
    • Stop the processor
      echo 'stop' > *0/state
      [73439.834056] remoteproc remoteproc0: stopped remote processor 5000000.m4fss
      
    • Start the processor (will load the new program)
      echo 'start' > *0/state
      [73473.037249] remoteproc remoteproc0: powering up 5000000.m4fss
      [73473.044197] remoteproc remoteproc0: Booting fw image am62-mcu-m4f0_0-fw, size 79552
      [73473.052693]  remoteproc0#vdev0buffer: assigned reserved memory node m4f-dma-memory@9cb00000
      [73473.061740] virtio_rpmsg_bus virtio0: rpmsg host is online
      [73473.068466]  remoteproc0#vdev0buffer: registered virtio0 (type 7)
      [73473.074680] remoteproc remoteproc0: remote processor 5000000.m4fss is now up
      
    • Should see Hello World on the mcu uart.

Steps - Load the program at boot time

  • Change program to repeatedly print hello world.
    • In hello_world.c change
          DebugP_log("Hello World!\r\n");
      

      to
          for (int ii = 0; ii < 1000; ++ii)
          {
              DebugP_log("%3d: Hello World!\r\n", ii);
              ClockP_sleep(5);
          }
      
    • Build release version
    • Copy Release/am62-mcu-m4f0_0-fw to target at /lib/firmware/hello_world/am62-mcu-m4f0_0-fw
      scp Release/am62-mcu-m4f0_0-fw target_62x:/lib/firmware/hello_world/am62-mcu-m4f0_0-fw
      
    • Reboot the target
    • Monitor the mcu uart. Should see lines like:
        0: Hello World!
        1: Hello World!
        2: Hello World!
        3: Hello World!
        4: Hello World!
        5: Hello World!
        6: Hello World!
        7: Hello World!
        8: Hello World!
        9: Hello World!
       10: Hello World!
       11: Hello World!
      

      with a new line being printed every 5 seconds up to 1000 times

Summary

This wiki page has demonstrated the following:

  • Building, running and debugging hello world on the M4 processorusing a JTAG connection within Code Composer Studio
  • Starting the hello world program using remoteproc
  • Starting a hello world program when booting the target.

Go to top
Add picture from clipboard (Maximum size: 1 GB)