I hesitated to post this, since it requires admission of substantial ignorance on my part concerning both CMake and mbed-os.
I am attempting to get USB communication between a (mbed-os 6 bare-metal) program running on MAX32620FTHR and a MacBook Pro (Apple M1, macOS Ventura 13.0). Basically, what I want to do is figure out:
- A way to build up a buffer containing information regards the condition of switches and voltages measured by a program running on the FTHR,
- Transmit that buffer back to a host (in the initial case, that host would be my MacBook),
- Receive and display the contents of that buffer on my MacBook.
I am stuck on step #2 above. There is lots of I/O available on the FTHR, but USB seemed like it would be easiest, since the project will eventually use some serial communication between processors in the system (probably CAN bus; there are available adapters for CAN <==> USB).
The FTHR has a micro USB connector, and I saw some hints that it could even be programmed via that connector in lieu of using the DAPLINK facility of the MAX32625PICO, using an on-board bootloader (although I havenāt figured that one out, either).
When I just added #include āUSBSerial.hā to my main.cpp, I just got an error that USBSerial.h could not be found. I tracked that down (I thinkā¦) to a missing reference to mbed-os in the top-level CMakeLists.txt, and a possible missing USBDEVICE in mbed_lib.json. However, there was a hint that this was for the 32630, and not for the 32620, so Iām confused.
Here is my top-level CMakeLists.txt:
cmake_minimum_required(VERSION 3.24)
cmake_policy(VERSION 3.24)
#enable firmware upload and remote debugging
set(PYOCD_UPLOAD_ENABLED TRUE)
set(PYOCD_TARGET_NAME max32620)
set(PYOCD_CLOCK_SPEED 4000k)
# Initialize Mbed OS build system.
# Note: This block must be before the include of app.cmake
set(MBED_APP_JSON_PATH mbed_app.json)
include(mbed-os/tools/cmake/app.cmake)
add_subdirectory(mbed-os)
project(Example)
# add subdirectories and build targets here
add_executable(Example Example.cpp)
# Choose mbed-os or mbed-baremetal here
target_link_libraries(Example
PRIVATE
mbed-baremetal
mbed-usb
)
mbed_set_post_build(Example)
mbed_finalize_build()
Here is my mbed_app.json:
{
"target_overrides": {
"*": {
"platform.stdio-baud-rate": 115200,
"platform.stdio-buffered-serial": 1,
"target.printf_lib": "std",
"target.device_has_add": ["USBDEVICE"]
}
}
}
I initially just got some warnings, but when I tried to instantiate a USBSerial object, I started getting build errors, such as:
[build] /Users/howardharkness/arm-workspace/mbed-os/drivers/usb/source/USBSerial.cpp:24: undefined reference to `get_usb_phy()ā
Am I barking up the wrong tree?
Am I just leaving out something important?
Is there a better or simpler way to get a serial communication working with the FTHR?