You are here

Re-Targeting My ModusToolbox 2.0 Project | Cypress Semiconductor

Re-Targeting My ModusToolbox 2.0 Project

Last time out we got hello world running on the PROTO-062-4343W kit. That was a lot of fun for me… because I have that kit! Actually, I have about 20 of them because they arrived too late for the training event last week. But most of you don’t have 20 kits so, today, I am going to show you how to re-target an application to another kit.

All ModusToolbox applications have a BSP. It is the thing that defines the PSoC device, the memory layout, the connection to the Wi-Fi device over SDIO, the CapSense buttons and sliders, the I2C and UART peripherals, and the mechanical buttons and LEDs. We give these things standard names, like CYBSP_USER_LED, so that applications using those names can run on just about any kit even if the physical pins connected to the LED are different. So, to re-target our application we only have to do two things; add a new BSP to the project and tell the build tools to use it instead of the original BSP. Some examples actually include more than one BSP, for convenience, so you can often skip the first step!

I’ve been writing about CY8CPROTO-063-BLE kit recently (github.com/cypresssemiconductorco/TARGET_CY8CPROTO-063-BLE) so let’s switch our program to that one. You can read about the BSP on the GitHub site or you can just get on with it and download the thing (as you can tell, I’m a type-first, read-later guy). Just jump into the libs folder and clone the BSP.

yfs@YFS-T550 ~/MyFirstProject/mtb-example-psoc6-hello-world
$ cd libs

yfs@YFS-T550 ~/MyFirstProject/mtb-example-psoc6-hello-world/libs
$ git clone https://github.com/cypresssemiconductorco/TARGET_CY8CPROTO-063-BLE
Cloning into 'TARGET_CY8CPROTO-063-BLE'...
remote: Enumerating objects: 156, done.
remote: Counting objects: 100% (156/156), done.
remote: Compressing objects: 100% (106/106), done.
Receiving objectsremote: Total 156 (delta 43), reused 153 (delta 43), pack-reused 0:   % (85/
Receiving objects: 100% (156/156), 391.77 KiB | 1.42 MiB/s, done.
Resolving deltas: 100% (43/43), done.
Checking out files: 100% (135/135), done.

yfs@YFS-T550 ~/MyFirstProject/mtb-example-psoc6-hello-world/libs
$ ls -la
total 34
drwxr-xr-x 1 yfs 1049089  0 Nov  4 09:24 .
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:24 ..
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:12 capsense
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:12 core-lib
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:12 psoc6cm0p
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:13 psoc6hal
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:13 psoc6make
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:14 psoc6pdl
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:12 retarget-io
-rw-r--r-- 1 yfs 1049089 67 Nov  1 15:40 retarget-io.lib
drwxr-xr-x 1 yfs 1049089  0 Nov  1 16:12 TARGET_CY8CPROTO-062-4343W
-rw-r--r-- 1 yfs 1049089 82 Nov  1 15:40 TARGET_CY8CPROTO-062-4343W.lib
drwxr-xr-x 1 yfs 1049089  0 Nov  4 09:24 TARGET_CY8CPROTO-063-BLE

As you can see, you have added a new TARGET folder. Great, now let’s build for it. I can almost feel you gearing up for a stream of edit-this and move-that with a little bit of delete-the-other and a frustrating time. Not exactly, just add the name of the target to the build command.

yfs@YFS-T550 ~/MyFirstProject/mtb-example-psoc6-hello-world/libs
$ cd ..

yfs@YFS-T550 ~/MyFirstProject/mtb-example-psoc6-hello-world
$ make build TARGET=CY8CPROTO-063-BLE
Tools Directory: C:/Users/yfs/ModusToolbox/tools_2.0

Initializing build: mtb-example-psoc6-hello-world Debug CY8CPROTO-063-BLE GCC_ARM
    Stale device files detected. Running device configurator to regenerate files...

Auto-discovery in progress...
-> Found 158 .c file(s)
-> Found 36 .S file(s)
-> Found 18 .s file(s)
-> Found 0 .cpp file(s)
-> Found 0 .o file(s)
-> Found 4 .a file(s)
-> Found 377 .h file(s)
-> Found 0 .hpp file(s)
-> Found 0 resource file(s)
Applying filters...
Auto-discovery complete

==============================================================================
= Building application =
==============================================================================
Building 142 file(s)
    Compiling app file startup_psoc6_01_cm4.S
    Compiling app file cy_syslib_gcc.S
    Compiling app file cycfg.c
    Compiling app file cycfg_clocks.c
    Compiling app file cycfg_peripherals.c
    Compiling app file cycfg_pins.c
    Compiling app file cycfg_routing.c
    Compiling app file cycfg_system.c
    Compiling app file cybsp.c
    Compiling app file system_psoc6_cm4.c
    Compiling app file cy_capsense_centroid.c
    Compiling app file cy_capsense_control.c
    Compiling app file cy_capsense_csd.c
    Compiling app file cy_capsense_csx.c
    Compiling app file cy_capsense_filter.c
    Compiling app file cy_capsense_processing.c
    Compiling app file cy_capsense_sensing.c
    Compiling app file cy_capsense_structure.c
    Compiling app file cy_capsense_tuner.c
    Compiling app file psoc6_01_cm0p_sleep.c
    Compiling app file psoc6_02_cm0p_sleep.c
    Compiling app file psoc6_03_cm0p_sleep.c
    Compiling app file cyhal_adc.c
    Compiling app file cyhal_analog_common.c
    Compiling app file cyhal_crc.c
    Compiling app file cyhal_crypto_common.c
    Compiling app file cyhal_dac.c
    Compiling app file cyhal_flash.c
    Compiling app file cyhal_gpio.c
    Compiling app file cyhal_hwmgr.c
    Compiling app file cyhal_i2c.c
    Compiling app file cyhal_interconnect.c
    Compiling app file cyhal_lptimer.c
    Compiling app file cyhal_not_implemented.c
    Compiling app file cyhal_pwm.c
    Compiling app file cyhal_qspi.c
    Compiling app file cyhal_rtc.c
    Compiling app file cyhal_scb_common.c
    Compiling app file cyhal_sdhc.c
    Compiling app file cyhal_spi.c
    Compiling app file cyhal_system.c
    Compiling app file cyhal_tcpwm_common.c
    Compiling app file cyhal_timer.c
    Compiling app file cyhal_trng.c
    Compiling app file cyhal_uart.c
    Compiling app file cyhal_udb_sdio.c
    Compiling app file cyhal_usb_dev.c
    Compiling app file cyhal_utils.c
    Compiling app file cyhal_wdt.c
    Compiling app file cyhal_psoc6_01_104_m_csp_ble.c
    Compiling app file cyhal_psoc6_01_104_m_csp_ble_usb.c
    Compiling app file cyhal_psoc6_01_116_bga_ble.c
    Compiling app file cyhal_psoc6_01_116_bga_usb.c
    Compiling app file cyhal_psoc6_01_124_bga.c
    Compiling app file cyhal_psoc6_01_124_bga_sip.c
    Compiling app file cyhal_psoc6_01_43_smt.c
    Compiling app file cyhal_psoc6_01_68_qfn_ble.c
    Compiling app file cyhal_psoc6_01_80_wlcsp.c
    Compiling app file cyhal_psoc6_02_100_wlcsp.c
    Compiling app file cyhal_psoc6_02_124_bga.c
    Compiling app file cyhal_psoc6_02_128_tqfp.c
    Compiling app file cyhal_psoc6_02_68_qfn.c
    Compiling app file cyhal_psoc6_03_100_tqfp.c
    Compiling app file cyhal_psoc6_03_49_wlcsp.c
    Compiling app file cyhal_psoc6_03_68_qfn.c
    Compiling app file cy_ble_clk.c
    Compiling app file cy_canfd.c
    Compiling app file cy_crypto.c
    Compiling app file cy_crypto_core_aes_v1.c
    Compiling app file cy_crypto_core_aes_v2.c
    Compiling app file cy_crypto_core_cmac_v1.c
    Compiling app file cy_crypto_core_cmac_v2.c
    Compiling app file cy_crypto_core_crc_v1.c
    Compiling app file cy_crypto_core_crc_v2.c
    Compiling app file cy_crypto_core_des_v1.c
    Compiling app file cy_crypto_core_des_v2.c
    Compiling app file cy_crypto_core_ecc_domain_params.c
    Compiling app file cy_crypto_core_ecc_ecdsa.c
    Compiling app file cy_crypto_core_ecc_key_gen.c
    Compiling app file cy_crypto_core_ecc_nist_p.c
    Compiling app file cy_crypto_core_hmac_v1.c
    Compiling app file cy_crypto_core_hmac_v2.c
    Compiling app file cy_crypto_core_hw.c
    Compiling app file cy_crypto_core_hw_v1.c
    Compiling app file cy_crypto_core_mem_v1.c
    Compiling app file cy_crypto_core_mem_v2.c
    Compiling app file cy_crypto_core_prng_v1.c
    Compiling app file cy_crypto_core_prng_v2.c
    Compiling app file cy_crypto_core_rsa.c
    Compiling app file cy_crypto_core_sha_v1.c
    Compiling app file cy_crypto_core_sha_v2.c
    Compiling app file cy_crypto_core_trng_v1.c
    Compiling app file cy_crypto_core_trng_v2.c
    Compiling app file cy_crypto_core_vu.c
    Compiling app file cy_crypto_server.c
    Compiling app file cy_csd.c
    Compiling app file cy_ctb.c
    Compiling app file cy_ctdac.c
    Compiling app file cy_device.c
    Compiling app file cy_dma.c
    Compiling app file cy_dmac.c
    Compiling app file cy_efuse.c
    Compiling app file cy_flash.c
    Compiling app file cy_gpio.c
    Compiling app file cy_i2s.c
    Compiling app file cy_ipc_drv.c
    Compiling app file cy_ipc_pipe.c
    Compiling app file cy_ipc_sema.c
    Compiling app file cy_lpcomp.c
    Compiling app file cy_lvd.c
    Compiling app file cy_mcwdt.c
    Compiling app file cy_pdm_pcm.c
    Compiling app file cy_profile.c
    Compiling app file cy_prot.c
    Compiling app file cy_rtc.c
    Compiling app file cy_sar.c
    Compiling app file cy_scb_common.c
    Compiling app file cy_scb_ezi2c.c
    Compiling app file cy_scb_i2c.c
    Compiling app file cy_scb_spi.c
    Compiling app file cy_scb_uart.c
    Compiling app file cy_sd_host.c
    Compiling app file cy_seglcd.c
    Compiling app file cy_smartio.c
    Compiling app file cy_smif.c
    Compiling app file cy_smif_memslot.c
    Compiling app file cy_sysanalog.c
    Compiling app file cy_sysclk.c
    Compiling app file cy_sysint.c
    Compiling app file cy_syslib.c
    Compiling app file cy_syspm.c
    Compiling app file cy_systick.c
    Compiling app file cy_tcpwm_counter.c
    Compiling app file cy_tcpwm_pwm.c
    Compiling app file cy_tcpwm_quaddec.c
    Compiling app file cy_trigmux.c
    Compiling app file cy_usbfs_dev_drv.c
    Compiling app file cy_usbfs_dev_drv_io.c
    Compiling app file cy_usbfs_dev_drv_io_dma.c
    Compiling app file cy_wdt.c
    Compiling app file cy_retarget_io.c
    Compiling app file main.c
    Linking output file mtb-example-psoc6-hello-world.elf
==============================================================================
= Build complete =
==============================================================================

Calculating memory consumption: CYBLE-416045-02 GCC_ARM -Og

   --------------------------------------------------
  | Section Name         |  Address      |  Size     |
   --------------------------------------------------
  | .cy_m0p_image        |  0x10000000   |  5328     |
  | .text                |  0x10002000   |  36180    |
  | .ARM.exidx           |  0x1000ad54   |  8        |
  | .copy.table          |  0x1000ad5c   |  24       |
  | .zero.table          |  0x1000ad74   |  8        |
  | .data                |  0x0800228c   |  1892     |
  | .cy_sharedmem        |  0x080029f0   |  12       |
  | .noinit              |  0x08002a00   |  148      |
  | .bss                 |  0x08002a94   |  976      |
  | .heap                |  0x08002e68   |  276888   |
   --------------------------------------------------

  Total Internal Flash (Available)          1048576
  Total Internal Flash (Utilized)           46324

  Total Internal SRAM (Available)           292864
  Total Internal SRAM (Utilized)            279916

Now you can just run ”make qprogram” and hello world will run just the same way as it did on the original kit. That was cool, let’s do it again!

When you type as haphazardly as I do, that extra text at the end of the command is just asking for a typo. So I need a more permanent solution. It’s easy to do… just open the Makefile in a text editor, look for the line “TARGET=CY8CPROTO-062-4343W” and change the name of the board to CY8CPROTO-063-BLE, like this.


################################################################################
# Basic Configuration
################################################################################

# Target board/hardware
# TARGET=CY8CPROTO-062-4343W
TARGET=CY8CPROTO-063-BLE

Now you can build and program your kit in one step with the almost-impossible-to-mistype command “make program”. You’ll never guess how to go back to the other kit!

OK, that’s enough typing for me. Next time I’ll show off the new GUI tools we have created to automate all this make shenanigans.

Blog: 

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.