Skip to content

Commit

Permalink
Merge pull request #2799 from hathach/add-pico2
Browse files Browse the repository at this point in the history
add pico2 rp2350 (arm) board
  • Loading branch information
hathach authored Sep 13, 2024
2 parents 91c8700 + c419b1e commit 3ff128b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions hw/bsp/rp2040/boards/feather_rp2040_max3421/board.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(PICO_PLATFORM rp2040)
set(PICO_BOARD adafruit_feather_rp2040)

# Enable MAX3421E USB Host
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
set(PICO_PLATFORM rp2040)
set(PICO_BOARD pico)
2 changes: 2 additions & 0 deletions hw/bsp/rp2040/boards/raspberry_pi_pico2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(PICO_PLATFORM rp2350-arm-s)
set(PICO_BOARD pico2)
27 changes: 19 additions & 8 deletions hw/bsp/rp2040/family.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,32 @@ if (NOT BOARD)
set(BOARD pico_sdk)
endif()

if (TOOLCHAIN STREQUAL "clang")
set(PICO_COMPILER "pico_arm_clang")
else()
set(PICO_COMPILER "pico_arm_gcc")
endif()
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)

#if (TOOLCHAIN STREQUAL "clang")
# set(PICO_COMPILER "pico_arm_clang")
#else()
# set(PICO_COMPILER "pico_arm_gcc")
#endif()

# add the SDK in case we are standalone tinyusb example (noop if already present)
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)

# include basic family CMake functionality
set(FAMILY_MCUS RP2040)
set(JLINK_DEVICE rp2040_m0_0)
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"")

include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
if (PICO_PLATFORM STREQUAL "rp2040")
set(JLINK_DEVICE rp2040_m0_0)
set(OPENOCD_TARGET rp2040)
elseif (PICO_PLATFORM STREQUAL "rp2350-arm-s" OR PICO_PLATFORM STREQUAL "rp2350")
set(JLINK_DEVICE rp2350_m33_0)
set(OPENOCD_TARGET rp2350)
elseif (PICO_PLATFORM STREQUAL "rp2350-riscv")
set(JLINK_DEVICE rp2350_riscv_0)
set(OPENOCD_TARGET rp2350-riscv)
endif()

set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/${OPENOCD_TARGET}.cfg -c \"adapter speed 5000\"")

if (NOT PICO_TINYUSB_PATH)
set(PICO_TINYUSB_PATH ${TOP})
Expand Down
20 changes: 14 additions & 6 deletions test/hil/hil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
STATUS_FAILED = "\033[31mFailed\033[0m"
STATUS_SKIPPED = "\033[33mSkipped\033[0m"

verbose = False

# get usb serial by id
def get_serial_dev(id, vendor_str, product_str, ifnum):
if vendor_str and product_str:
Expand Down Expand Up @@ -111,7 +113,6 @@ def read_disk_file(uid, lun, fname):
# Flashing firmware
# -------------------------------------------------------------
def run_cmd(cmd):
#print(cmd)
r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if r.returncode != 0:
title = f'COMMAND FAILED: {cmd}'
Expand All @@ -123,6 +124,9 @@ def run_cmd(cmd):
else:
print(title)
print(r.stdout.decode("utf-8"))
elif verbose:
print(cmd)
print(r.stdout.decode("utf-8"))
return r


Expand Down Expand Up @@ -260,14 +264,14 @@ def test_device_cdc_dual_ports(board):
str1 = b"test_no1"
ser1.write(str1)
ser1.flush()
assert ser1.read(100) == str1.lower(), 'Port1 wrong data'
assert ser2.read(100) == str1.upper(), 'Port2 wrong data'
assert ser1.read(len(str1)) == str1.lower(), 'Port1 wrong data'
assert ser2.read(len(str1)) == str1.upper(), 'Port2 wrong data'

str2 = b"test_no2"
ser2.write(str2)
ser2.flush()
assert ser1.read(100) == str2.lower(), 'Port1 wrong data'
assert ser2.read(100) == str2.upper(), 'Port2 wrong data'
assert ser1.read(len(str2)) == str2.lower(), 'Port1 wrong data'
assert ser2.read(len(str2)) == str2.upper(), 'Port2 wrong data'


def test_device_cdc_msc(board):
Expand All @@ -279,7 +283,7 @@ def test_device_cdc_msc(board):
str = b"test_str"
ser.write(str)
ser.flush()
assert ser.read(100) == str, 'CDC wrong data'
assert ser.read(len(str)) == str, 'CDC wrong data'

# Block test
data = read_disk_file(uid,0,'README.TXT')
Expand Down Expand Up @@ -447,13 +451,17 @@ def main():
"""
Hardware test on specified boards
"""
global verbose

parser = argparse.ArgumentParser()
parser.add_argument('config_file', help='Configuration JSON file')
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to test, all if not specified')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
args = parser.parse_args()

config_file = args.config_file
boards = args.board
verbose = args.verbose

# if config file is not found, try to find it in the same directory as this script
if not os.path.exists(config_file):
Expand Down
10 changes: 10 additions & 0 deletions test/hil/rpi.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
"dual_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002470"}]
}
},
{
"name": "raspberry_pi_pico2",
"uid": "560AE75E1C7152C9",
"flasher": "openocd",
"flasher_sn": "E6633861A3978538",
"flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2350.cfg -c \"adapter speed 5000\"",
"tests": {
"dual_attached": [{"vid_pid": "1a86_55d4", "serial": "533D004242"}]
}
},
{
"name": "stm32f072disco",
"uid": "3A001A001357364230353532",
Expand Down

0 comments on commit 3ff128b

Please sign in to comment.