Skip to content

Commit aac39c6

Browse files
authored
Merge pull request schollz#753 from schollz/v2
feat: upgrade pico sdk Former-commit-id: 6dd61f0
2 parents a67ed2b + 00fc2d5 commit aac39c6

58 files changed

Lines changed: 6468 additions & 3630 deletions

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ jobs:
5151
repository: raspberrypi/pico-sdk
5252
path: pico-sdk
5353
submodules: true
54-
ref: 1.5.1
54+
ref: 2.1.1
55+
- name: Checkout pico-extras
56+
uses: actions/checkout@v4.2.1
57+
with:
58+
repository: raspberrypi/pico-extras
59+
path: pico-extras
60+
submodules: true
61+
ref: sdk-2.1.1
5562
- name: Patch tinyusb
5663
run: |
5764
sed -i 's/OSAL_TIMEOUT_WAIT_FOREVER/OSAL_TIMEOUT_NORMAL/g' $GITHUB_WORKSPACE/pico-sdk/lib/tinyusb/src/tusb.c

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DS_Store
2+
/pico-extras
3+
/pico-sdk
4+
/build
5+
dev/audio2flash/audio2flash
6+
lib/crossfade4_128.h
7+
lib/crossfade4_160.h
8+
lib/crossfade4_192.h
9+
lib/crossfade4_256.h
10+
lib/crossfade4_441.h
11+
lib/crossfade4_64.h
12+
lib/cuedsounds_ectocore.h
13+
lib/cuedsounds_zeptocore.h
14+
lib/fuzz.h
15+
lib/resonantfilter_data.h
16+
zeptomech.uf2
17+
target_compile_definitions.cmake
18+
.vscode/settings.json
19+
/.vscode

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Makefile
2-
export PICO_EXTRAS_PATH ?= $(CURDIR)/pico-extras
3-
export PICO_SDK_PATH ?= $(CURDIR)/pico-sdk
2+
export PICO_EXTRAS_PATH=$(CURDIR)/pico-extras
3+
export PICO_SDK_PATH=$(CURDIR)/pico-sdk
44
NPROCS := $(shell grep -c 'processor' /proc/cpuinfo)
55

66
GOVERSION = go1.21.13
77
GOBIN = $(HOME)/go/bin
88
GOINSTALLPATH = $(GOBIN)/$(GOVERSION)
99

10-
dobuild: pico-extras lib/fuzz.h lib/transfer_saturate2.h lib/sinewaves2.h lib/crossfade4_441.h lib/resonantfilter_data.h lib/cuedsounds.h build
10+
dobuild: pico-sdk pico-extras lib/fuzz.h lib/transfer_saturate2.h lib/sinewaves2.h lib/crossfade4_441.h lib/resonantfilter_data.h lib/cuedsounds.h build
1111
make -C build -j$(NPROCS)
1212

13+
pico-sdk:
14+
git clone https://github.com/raspberrypi/pico-sdk
15+
cd pico-sdk && git checkout 2.1.1
16+
cd pico-sdk && git submodule update --init --recursive
17+
1318
chowdsp:
1419
sudo apt install -y lv2file
1520
wget https://github.com/jatinchowdhury18/AnalogTapeModel/releases/download/v2.11.4/ChowTapeModel-Linux-x64-2.11.4.deb
@@ -179,7 +184,7 @@ lib/cuedsounds_ectocore.h:
179184

180185
pico-extras:
181186
git clone https://github.com/raspberrypi/pico-extras.git pico-extras
182-
cd pico-extras && git checkout sdk-1.5.1
187+
cd pico-extras && git checkout sdk-2.1.1
183188
cd pico-extras && git submodule update --init --recursive
184189

185190
copysamples:

lib/hw_config.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,36 @@ socket, which SPI it is driven by, and how it is wired.
4141
static spi_t spis[] = {
4242
// One for each SPI.
4343
};
44+
/* SDIO Interface */
45+
static sd_sdio_if_t sdio_if = {
46+
.CMD_gpio = SDCARD_CMD_GPIO,
47+
.D0_gpio = SDCARD_D0_GPIO,
48+
.set_drive_strength = true,
49+
.CLK_gpio_drive_strength = GPIO_DRIVE_STRENGTH_12MA,
50+
.CMD_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA,
51+
.D0_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA,
52+
.D1_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA,
53+
.D2_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA,
54+
.D3_gpio_drive_strength = GPIO_DRIVE_STRENGTH_4MA,
55+
.SDIO_PIO = pio1,
56+
.DMA_IRQ_num = DMA_IRQ_0,
57+
#if PICO_RP2040
58+
// The default system clock frequency for SDK is 125MHz.
59+
.baud_rate = 125 * 1000 * 1000 / 4 // 31250000 Hz
60+
#endif
61+
#if PICO_RP2350
62+
//◦The default system clock on RP2350 is 150Mhz.
63+
.baud_rate = 150 * 1000 * 1000 / 6 // 25000000 Hz, clk_div = 1.5
64+
#endif
65+
};
4466

4567
// Hardware Configuration of the SD Card "objects"
4668
static sd_card_t sd_cards[] = { // One for each SD card
4769
{
4870
.pcName = "0:", // Name used to mount device
4971
.type = SD_IF_SDIO,
50-
/*
51-
Pins CLK_gpio, D1_gpio, D2_gpio, and D3_gpio are at offsets from pin
52-
D0_gpio. The offsets are determined by sd_driver\SDIO\rp2040_sdio.pio.
53-
CLK_gpio = (D0_gpio + SDIO_CLK_PIN_D0_OFFSET) % 32;
54-
As of this writing, SDIO_CLK_PIN_D0_OFFSET is 30,
55-
which is -2 in mod32 arithmetic, so:
56-
CLK_gpio = D0_gpio -2.
57-
D1_gpio = D0_gpio + 1;
58-
D2_gpio = D0_gpio + 2;
59-
D3_gpio = D0_gpio + 3;
60-
*/
61-
.sdio_if = {.CMD_gpio = SDCARD_CMD_GPIO,
62-
.D0_gpio = SDCARD_D0_GPIO,
63-
.SDIO_PIO = pio1,
64-
.DMA_IRQ_num = DMA_IRQ_0},
72+
.sdio_if_p = &sdio_if,
73+
// SD Card detect:
6574
.use_card_detect = SDCARD_USE_CD,
6675
.card_detect_gpio = SDCARD_CD_GPIO, // Card detect
6776
.card_detected_true = 1 // What the GPIO read returns when a card is

lib/sdcard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static sd_card_t *sd_get_by_name(const char *const name) {
99
static FATFS *sd_get_fs_by_name(const char *name) {
1010
for (size_t i = 0; i < sd_get_num(); ++i)
1111
if (0 == strcmp(sd_get_by_num(i)->pcName, name))
12-
return &sd_get_by_num(i)->fatfs;
12+
return &sd_get_by_num(i)->state.fatfs;
1313
DBG_PRINTF("%s: unknown name %s\n", __func__, name);
1414
return NULL;
1515
}
@@ -31,7 +31,7 @@ bool run_mount() {
3131
}
3232
sd_card_t *pSD = sd_get_by_name(arg1);
3333
myASSERT(pSD);
34-
pSD->mounted = true;
34+
pSD->state.mounted = true;
3535
return true;
3636
}
3737

lib/sdio/CMakeLists.txt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,23 @@ target_sources(FatFs_SPI INTERFACE
1010
${CMAKE_CURRENT_LIST_DIR}/ff15/source/ff.c
1111
${CMAKE_CURRENT_LIST_DIR}/ff15/source/ffsystem.c
1212
${CMAKE_CURRENT_LIST_DIR}/ff15/source/ffunicode.c
13+
${CMAKE_CURRENT_LIST_DIR}/sd_driver/dma_interrupts.c
1314
${CMAKE_CURRENT_LIST_DIR}/sd_driver/sd_card.c
15+
${CMAKE_CURRENT_LIST_DIR}/sd_driver/sd_timeouts.c
1416
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SDIO/rp2040_sdio.c
1517
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SDIO/sd_card_sdio.c
16-
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/crc.c
17-
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/sd_spi.c
18+
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/my_spi.c
1819
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/sd_card_spi.c
19-
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/spi.c
20-
${CMAKE_CURRENT_LIST_DIR}/source/f_util.c
21-
${CMAKE_CURRENT_LIST_DIR}/source/ff_stdio.c
22-
${CMAKE_CURRENT_LIST_DIR}/source/glue.c
23-
${CMAKE_CURRENT_LIST_DIR}/source/my_debug.c
24-
${CMAKE_CURRENT_LIST_DIR}/source/rtc.c
20+
${CMAKE_CURRENT_LIST_DIR}/sd_driver/SPI/sd_spi.c
21+
${CMAKE_CURRENT_LIST_DIR}/src/crash.c
22+
${CMAKE_CURRENT_LIST_DIR}/src/crc.c
23+
${CMAKE_CURRENT_LIST_DIR}/src/f_util.c
24+
${CMAKE_CURRENT_LIST_DIR}/src/ff_stdio.c
25+
${CMAKE_CURRENT_LIST_DIR}/src/file_stream.c
26+
${CMAKE_CURRENT_LIST_DIR}/src/glue.c
27+
${CMAKE_CURRENT_LIST_DIR}/src/my_debug.c
28+
${CMAKE_CURRENT_LIST_DIR}/src/my_rtc.c
29+
${CMAKE_CURRENT_LIST_DIR}/src/util.c
2530
)
2631
target_include_directories(FatFs_SPI INTERFACE
2732
ff15/source
@@ -32,8 +37,10 @@ target_include_directories(FatFs_SPI INTERFACE
3237
target_link_libraries(FatFs_SPI INTERFACE
3338
hardware_dma
3439
hardware_pio
35-
hardware_rtc
3640
hardware_spi
41+
hardware_sync
42+
pico_aon_timer
43+
hardware_rtc
3744
pico_stdlib
3845
cmsis_core
3946
)

lib/sdio/ff15/documents/res/app4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/ WARNING: The data on the target drive will be lost!
55
*/
66

7+
#include <stdio.h>
78
#include <string.h>
8-
#include "my_debug.h"
99
#include "ff.h" /* Declarations of sector size */
1010
#include "diskio.h" /* Declarations of disk functions */
1111

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
/ 3: f_lseek() function is removed in addition to 2. */
2626

2727

28-
#define FF_USE_FIND 1
28+
#define FF_USE_FIND 0
2929
/* This option switches filtered directory read functions, f_findfirst() and
3030
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
3131

3232

33-
#define FF_USE_MKFS 1
33+
#define FF_USE_MKFS 0
3434
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
3535

3636

37-
#define FF_USE_FASTSEEK 1
37+
#define FF_USE_FASTSEEK 0
3838
/* This option switches fast seek function. (0:Disable or 1:Enable) */
3939

4040

@@ -56,7 +56,7 @@
5656
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
5757

5858

59-
#define FF_USE_STRFUNC 1
59+
#define FF_USE_STRFUNC 0
6060
#define FF_PRINT_LLI 1
6161
#define FF_PRINT_FLOAT 1
6262
#define FF_STRF_ENCODE 3
@@ -84,7 +84,7 @@
8484
/ Locale and Namespace Configurations
8585
/---------------------------------------------------------------------------*/
8686

87-
#define FF_CODE_PAGE 437
87+
#define FF_CODE_PAGE 932
8888
/* This option specifies the OEM code page to be used on the target system.
8989
/ Incorrect code page setting can cause a file open failure.
9090
/
@@ -113,7 +113,7 @@
113113
*/
114114

115115

116-
#define FF_USE_LFN 3
116+
#define FF_USE_LFN 0
117117
#define FF_MAX_LFN 255
118118
/* The FF_USE_LFN switches the support for LFN (long file name).
119119
/
@@ -133,7 +133,7 @@
133133
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
134134

135135

136-
#define FF_LFN_UNICODE 2
136+
#define FF_LFN_UNICODE 0
137137
/* This option switches the character encoding on the API when LFN is enabled.
138138
/
139139
/ 0: ANSI/OEM in current CP (TCHAR = char)
@@ -153,7 +153,7 @@
153153
/ on character encoding. When LFN is not enabled, these options have no effect. */
154154

155155

156-
#define FF_FS_RPATH 2
156+
#define FF_FS_RPATH 0
157157
/* This option configures support for relative path.
158158
/
159159
/ 0: Disable relative path and remove related functions.
@@ -166,7 +166,7 @@
166166
/ Drive/Volume Configurations
167167
/---------------------------------------------------------------------------*/
168168

169-
# define FF_VOLUMES 2
169+
#define FF_VOLUMES 1
170170
/* Number of volumes (logical drives) to be used. (1-10) */
171171

172172

@@ -203,7 +203,7 @@
203203
/ GET_SECTOR_SIZE command. */
204204

205205

206-
#define FF_LBA64 1
206+
#define FF_LBA64 0
207207
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
208208
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
209209

@@ -231,7 +231,7 @@
231231
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
232232

233233

234-
#define FF_FS_EXFAT 1
234+
#define FF_FS_EXFAT 0
235235
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
236236
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
237237
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
@@ -263,7 +263,7 @@
263263
*/
264264

265265

266-
#define FF_FS_LOCK 16
266+
#define FF_FS_LOCK 0
267267
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
268268
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
269269
/ is 1.

lib/sdio/ff15/source/diskio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef _DISKIO_DEFINED
66
#define _DISKIO_DEFINED
77

8+
#include "ff.h"
9+
810
#ifdef __cplusplus
911
extern "C" {
1012
#endif

0 commit comments

Comments
 (0)