Skip to content

Commit 20756f3

Browse files
author
Jamie Smith
authored
Upversion RPi Pico SDK (ARMmbed#176)
* Remove old pico SDK, import latest version using new importer script * Add new importer script, update CMakeLists * Merge changes from newer SDK into init assembly and linker script * Update pico hal code for new SDK version * Clean up linker script a bit, revert ram size * Fix accidental breakage of watchdog-reset test from warning fixing! Also better document USB setup procedure and disable reset as part of the test runner.
1 parent eb231be commit 20756f3

File tree

421 files changed

+52139
-88422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

421 files changed

+52139
-88422
lines changed

drivers/usb/tests/TESTS/usb_device/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Additional, platform-specific setup is described below.
1212
See also [Known issues](#known-issues).
1313

1414
### Windows
15+
1. Install libusb0.dll somewhere on your PATH. The bitness of the DLL should match the bitness of your python interpreter. This DLL can be downloaded from the project [here](https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/). Note that libusb1 does NOT work, it has to be libusb0! See the comments in host_tests/pyusb_basic.py for details.
1516
1. Install a **generic USB driver** for two test devices.
1617
1. Download `Zadig` application from [the Zadig website][LN-zadig].
1718
1. Unplug the Mbed device.

hal/include/hal/i2c_api.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,12 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave);
318318
*/
319319
int i2c_slave_receive(i2c_t *obj);
320320

321-
/** Configure I2C as slave or master.
321+
/**
322+
* @brief Read specified number of bytes from an I2C master.
322323
* @param obj The I2C object
323324
* @param data The buffer for receiving
324325
* @param length Number of bytes to read
325-
* @return non-zero if a value is available
326+
* @return non-zero if a value is available, or zero on error
326327
*/
327328
int i2c_slave_read(i2c_t *obj, char *data, int length);
328329

hal/tests/TESTS/mbed_hal/watchdog_reset/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void test_kick_reset()
255255
for (int i = 3; i; i--) {
256256
// The reset is prevented as long as the watchdog is kicked
257257
// anytime before the timeout.
258-
wait_us(2 * std::chrono::duration_cast<std::chrono::microseconds>(TIMEOUT_MS - KICK_ADVANCE_MS).count());
258+
wait_us(std::chrono::duration_cast<std::chrono::microseconds>(TIMEOUT_MS - KICK_ADVANCE_MS).count());
259259
hal_watchdog_kick();
260260
}
261261
if (!send_reset_notification(&current_case, 2 * TIMEOUT_MS + SERIAL_FLUSH_TIME_MS)) {
@@ -269,7 +269,7 @@ void test_kick_reset()
269269
// Watchdog reset should have occurred during a wait above.
270270

271271
hal_watchdog_kick();
272-
wdg_kicking_ticker.attach_us(mbed::callback(hal_watchdog_kick), 20000); // For testsuite failure handling.
272+
wdg_kicking_ticker.attach(mbed::callback(hal_watchdog_kick), 20ms); // For testsuite failure handling.
273273
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected.");
274274
}
275275

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,113 @@
11
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
add_subdirectory(TARGET_RP2040 EXCLUDE_FROM_ALL)
5-
64
add_library(mbed-raspberrypi INTERFACE)
75

6+
# The Pico SDK relies on a couple of generated files in order to work.
7+
# We generate those files here.
8+
9+
# Version header -- needs version information from CMake.
10+
# Helpfully, that info lives in its own file, so we can just include it.
11+
include(pico-sdk/pico_sdk_version.cmake)
12+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pico-sdk-generated/pico)
13+
configure_file(pico-sdk/src/common/pico_base/include/pico/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pico-sdk-generated/pico/version.h)
14+
15+
# Autogen config header.
16+
# The below settings discovered by analyzing the build system.
17+
set(PICO_CONFIG_HEADER_FILES boards/pico.h)
18+
19+
# The following code copied from generate_config_header.cmake
20+
macro(add_header_content_from_var VAR)
21+
set(header_content "${header_content}\n\n// based on ${VAR}:\n")
22+
foreach(var IN LISTS ${VAR})
23+
set(header_content "${header_content}\n#include \"${var}\"")
24+
endforeach()
25+
endmacro()
26+
set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES\n// DO NOT EDIT!\n")
27+
add_header_content_from_var(PICO_CONFIG_HEADER_FILES)
28+
file(GENERATE
29+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pico-sdk-generated/pico/config_autogen.h
30+
CONTENT "${header_content}"
31+
)
32+
33+
# Now, add includes and headers from the Pico SDK
834
target_include_directories(mbed-raspberrypi
935
INTERFACE
1036
.
37+
pico-sdk/src/rp2_common/hardware_adc/include
38+
pico-sdk/src/rp2_common/hardware_gpio/include
39+
pico-sdk/src/rp2_common/hardware_resets/include
40+
pico-sdk/src/rp2_common/hardware_pwm/include
41+
pico-sdk/src/rp2_common/hardware_base/include
42+
pico-sdk/src/rp2_common/hardware_uart/include
43+
pico-sdk/src/rp2_common/hardware_spi/include
44+
pico-sdk/src/rp2_common/hardware_i2c/include
45+
pico-sdk/src/rp2_common/hardware_irq/include
46+
pico-sdk/src/rp2_common/hardware_flash/include
47+
pico-sdk/src/rp2_common/hardware_clocks/include
48+
pico-sdk/src/rp2_common/hardware_rtc/include
49+
pico-sdk/src/rp2_common/hardware_watchdog/include
50+
pico-sdk/src/rp2_common/hardware_timer/include
51+
pico-sdk/src/rp2_common/hardware_pll/include
52+
pico-sdk/src/rp2_common/hardware_sync/include
53+
pico-sdk/src/rp2_common/hardware_xosc/include
54+
pico-sdk/src/rp2_common/pico_platform/include
55+
pico-sdk/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/include/
56+
pico-sdk/src/rp2_common/pico_bootrom/include
57+
pico-sdk/src/rp2_common/hardware_claim/include
58+
pico-sdk/src/common/pico_sync/include
59+
pico-sdk/src/common/pico_time/include
60+
pico-sdk/src/common/pico_base/include
61+
pico-sdk/src/common/pico_binary_info/include
62+
pico-sdk/src/common/pico_util/include
63+
pico-sdk/src/boards/include
64+
pico-sdk/src/generated
65+
pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Device/RaspberryPi/RP2040/Include
66+
pico-sdk/src/rp2_common/cmsis/include
67+
${CMAKE_CURRENT_BINARY_DIR}/pico-sdk-generated/
1168
)
1269

1370
target_sources(mbed-raspberrypi
1471
INTERFACE
15-
.
72+
pico-sdk/src/rp2_common/hardware_flash/flash.c
73+
pico-sdk/src/rp2_common/hardware_uart/uart.c
74+
pico-sdk/src/rp2_common/hardware_spi/spi.c
75+
pico-sdk/src/rp2_common/hardware_i2c/i2c.c
76+
pico-sdk/src/rp2_common/hardware_gpio/gpio.c
77+
pico-sdk/src/rp2_common/hardware_xosc/xosc.c
78+
pico-sdk/src/rp2_common/hardware_irq/irq.c
79+
pico-sdk/src/rp2_common/hardware_irq/irq_handler_chain.S
80+
pico-sdk/src/rp2_common/hardware_pll/pll.c
81+
pico-sdk/src/rp2_common/hardware_watchdog/watchdog.c
82+
pico-sdk/src/rp2_common/hardware_clocks/clocks.c
83+
pico-sdk/src/rp2_common/hardware_claim/claim.c
84+
pico-sdk/src/rp2_common/hardware_timer/timer.c
85+
pico-sdk/src/rp2_common/hardware_sync/sync.c
86+
pico-sdk/src/rp2_common/hardware_rtc/rtc.c
87+
pico-sdk/src/rp2_common/pico_bootrom/bootrom.c
88+
pico-sdk/src/rp2_common/pico_platform/platform.c
89+
pico-sdk/src/common/pico_time/time.c
90+
pico-sdk/src/common/pico_sync/lock_core.c
91+
pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Device/RaspberryPi/RP2040/Source/system_RP2040.c
92+
)
93+
94+
target_compile_definitions(mbed-raspberrypi
95+
INTERFACE
96+
LIB_CMSIS_CORE # Enables renaming interrupt vectors to their CMSIS names
1697
)
1798

1899
target_link_libraries(mbed-raspberrypi INTERFACE mbed-cmsis-cortex-m)
100+
101+
# Create RP2040 target (will have more sources added in subdir)
102+
add_library(mbed-rp2040 INTERFACE)
103+
target_include_directories(mbed-rp2040
104+
INTERFACE
105+
pico-sdk/src/rp2040/hardware_structs/include
106+
pico-sdk/src/rp2040/hardware_regs/include
107+
)
108+
target_sources(mbed-rp2040
109+
INTERFACE
110+
pico-sdk/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
111+
)
112+
113+
add_subdirectory(TARGET_RP2040 EXCLUDE_FROM_ALL)

targets/TARGET_RASPBERRYPI/TARGET_RP2040/CMakeLists.txt

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,10 @@
33

44
add_subdirectory(TARGET_RASPBERRY_PI_PICO EXCLUDE_FROM_ALL)
55

6-
set(LINKER_FILE TOOLCHAIN_GCC_ARM//memmap_default.ld)
7-
8-
add_library(mbed-rp2040 INTERFACE)
6+
set(LINKER_FILE TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld)
97

108
target_include_directories(mbed-rp2040
119
INTERFACE
12-
pico-sdk/rp2_common/hardware_adc/include
13-
pico-sdk/rp2_common/hardware_gpio/include
14-
pico-sdk/rp2_common/hardware_resets/include
15-
pico-sdk/rp2_common/hardware_pwm/include
16-
pico-sdk/rp2_common/hardware_base/include
17-
pico-sdk/rp2_common/hardware_uart/include
18-
pico-sdk/rp2_common/hardware_spi/include
19-
pico-sdk/rp2_common/hardware_i2c/include
20-
pico-sdk/rp2_common/hardware_irq/include
21-
pico-sdk/rp2_common/hardware_flash/include
22-
pico-sdk/rp2_common/hardware_clocks/include
23-
pico-sdk/rp2_common/hardware_rtc/include
24-
pico-sdk/rp2_common/hardware_watchdog/include
25-
pico-sdk/rp2_common/hardware_timer/include
26-
pico-sdk/rp2_common/hardware_pll/include
27-
pico-sdk/rp2_common/hardware_sync/include
28-
pico-sdk/rp2_common/hardware_xosc/include
29-
pico-sdk/rp2_common/pico_platform/include
30-
pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/include/
31-
pico-sdk/rp2_common/pico_bootrom/include
32-
pico-sdk/rp2_common/hardware_claim/include
33-
pico-sdk/rp2040/hardware_structs/include
34-
pico-sdk/rp2040/hardware_regs/include
35-
pico-sdk/common/pico_sync/include
36-
pico-sdk/common/pico_time/include
37-
pico-sdk/common/pico_base/include
38-
pico-sdk/common/pico_binary_info/include
39-
pico-sdk/common/pico_util/include
40-
pico-sdk/boards/include
41-
pico-sdk/generated
4210
.
4311
)
4412

@@ -59,27 +27,7 @@ target_sources(mbed-rp2040
5927
us_ticker.c
6028
USBPhy_RP2040.cpp
6129
watchdog_api.c
62-
pico-sdk/rp2_common/pico_standard_link/crt0.S
63-
pico-sdk/rp2_common/hardware_flash/flash.c
64-
pico-sdk/rp2_common/hardware_uart/uart.c
65-
pico-sdk/rp2_common/hardware_spi/spi.c
66-
pico-sdk/rp2_common/hardware_i2c/i2c.c
67-
pico-sdk/rp2_common/hardware_gpio/gpio.c
68-
pico-sdk/rp2_common/hardware_xosc/xosc.c
69-
pico-sdk/rp2_common/hardware_irq/irq.c
70-
pico-sdk/rp2_common/hardware_irq/irq_handler_chain.S
71-
pico-sdk/rp2_common/hardware_pll/pll.c
72-
pico-sdk/rp2_common/hardware_watchdog/watchdog.c
73-
pico-sdk/rp2_common/hardware_clocks/clocks.c
74-
pico-sdk/rp2_common/hardware_claim/claim.c
75-
pico-sdk/rp2_common/hardware_timer/timer.c
76-
pico-sdk/rp2_common/hardware_sync/sync.c
77-
pico-sdk/rp2_common/hardware_rtc/rtc.c
78-
pico-sdk/rp2_common/pico_bootrom/bootrom.c
79-
pico-sdk/rp2_common/pico_platform/platform.c
80-
pico-sdk/common/pico_time/time.c
81-
pico-sdk/common/pico_sync/lock_core.c
82-
pico-sdk/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c
30+
TOOLCHAIN_GCC_ARM/crt0_mbed.S
8331
)
8432

8533
mbed_set_linker_script(mbed-rp2040 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})

targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ target_include_directories(mbed-raspberry-pi-pico
1010

1111
target_sources(mbed-raspberry-pi-pico
1212
INTERFACE
13-
board.c
1413
bs2_default_padded_checksummed.S
1514
)
1615

targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/board.c

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)