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¶
- https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/10_01_00_33/exports/docs/api_guide_am62x/GETTING_STARTED_BUILD.html
- https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/10_01_00_33/exports/docs/api_guide_am62x/CCS_LAUNCH_PAGE.html
Prerequisites¶
- Install CCS and SDK
- Fix target configuration paths in CCS 12.2
- Setup a name (target_62x) for your target
- See Ssh_target_naming_and_port_forwarding
- If you don't set up a name, replace the target_62x in the comands below with your target ip address
- Monitor the M4 uart
- Use your favorite terminal connection program
- Code Composer Terminal View
- tera-term
- putty
- Use your favorite terminal connection program
Steps - building the hello world program¶
- Navigate to toolbar>View>Project Explorer
- In the project explorer window go to import projects.
- Hit the drop down arrow for the "Code Composer Studio" Folder and click "CCS Projects"
- Click the browse button and open the following folder <MCU_PLUS_SDK_INSTALL_DIR>/ti/mcu_plus_sdk_am62x_10_01_00_33/examples/hello_world/{am62ax/px}-sk/mcu-r5fss0-0_freertos/ti-arm-clang
- Right Click the opened project and select "Build Project"
- Hit the drop down arrow for the "Code Composer Studio" Folder and click "CCS Projects"
- In the project explorer window go to import projects.
- Create new target configuration at toolbar>View>Target Configuration.
- Right Click on "User Defined" and select "New Target Configuration"
- Name the file {som name}_XDS2XX.ccxml.
- Under the "General Setup" section, next to "Connection" open the drop-down arrow and select "Texas Instruments XDS2xx USB Debug Probe"
- Under the "General Setup" section, next to "Board or Device" scroll and select AM62.
- Click the "Save" button under the "Save Configuration" section.
- Name the file {som name}_XDS2XX.ccxml.
- Right click on target configuration you just made and select "Launch Selected Configuration"
- Right Click on "User Defined" and select "New Target Configuration"
- In the debug window right click on "Texas Instruments XDS2xx USB Debug Probe_0/BLAZAR_Cortex_M4F_0(Disconnected:Unkown) and select "Connect Target"
- In the debug toolbar navigate to the CPU reset drop-down arrow and select CPU Reset
- Navigate to toolbar>Run>Load>Load Program and select "Browse project..."
- Select the following file hello_world_am62x-sk_mcu-m4fss0-0_freertos_ti-arm-clang/Debug/hello_world_am62x-sk_mcu-m4fss0-0_freertos_ti-arm-clang.out
- The program is now paused and must be resumed. Go to toolbar>Run>Resume
- You should now see "Hello World!" printed to the CCS and MCU Console
- Navigate to toolbar>Run>Load>Load Program and select "Browse project..."
- In the debug toolbar navigate to the CPU reset drop-down arrow and select CPU Reset
CCS Console
{som name}_XDS2XX.ccxml:CIO [BLAZAR_Cortex_M4F_0] Hello World!
MCU Console
[IPC RPMSG ECHO] Version: REL.MCUSDK.K3.10.00.00.05+ (Jul 11 2024 03:09:17): [IPC RPMSG ECHO] Remote Core waiting for messages at end point 13 ... !!! [IPC RPMSG ECHO] Remote Core waiting for messages at end point 14 ... !!! Hello World!
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/
ssh target_62x mkdir -p /lib/firmware/hello_world scp Release/hello_world.mcu-m4f0_0.strip.out 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/hello_world.mcu-m4f0_0.strip.out /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.
- See the different remote processors
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");
tofor (int ii = 0; ii < 1000; ++ii) { DebugP_log("%3d: Hello World!\r\n", ii); ClockP_sleep(5); }
- Build release version
- Copy Release/hello_world.mcu-m4f0_0.strip.out to target at /lib/firmware/hello_world/hello_world.mcu-m4f0_0.strip.out
scp Release/hello_world.mcu-m4f0_0.strip.out target_62x:/lib/firmware/hello_world/hello_world.mcu-m4f0_0.strip.out
- 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
- In hello_world.c change
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