Skip to content

Commit 4f0fc1e

Browse files
Merge branch 'adafruit:main' into board-pykey87
2 parents ce7cd22 + ba2f32e commit 4f0fc1e

File tree

41 files changed

+142
-45
lines changed

Some content is hidden

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

41 files changed

+142
-45
lines changed

lib/oofatfs/ff.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5392,7 +5392,9 @@ FRESULT f_mkfs (
53925392
const UINT n_fats = 1; /* Number of FATs for FAT/FAT32 volume (1 or 2) */
53935393
const UINT n_rootdir = 512; /* Number of root directory entries for FAT volume */
53945394
static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */
5395+
#if FF_MKFS_FAT32
53955396
static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */
5397+
#endif
53965398
BYTE fmt, sys, *buf, *pte, part; void *pdrv;
53975399
WORD ss; /* Sector size */
53985400
DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n;
@@ -5464,7 +5466,7 @@ FRESULT f_mkfs (
54645466
}
54655467
}
54665468
if (au > 128) LEAVE_MKFS(FR_INVALID_PARAMETER); /* Too large au for FAT/FAT32 */
5467-
if (opt & FM_FAT32) { /* FAT32 possible? */
5469+
if (FF_MKFS_FAT32 && (opt & FM_FAT32)) { /* FAT32 possible? */
54685470
if ((opt & FM_ANY) == FM_FAT32 || !(opt & FM_FAT)) { /* FAT32 only or no-FAT? */
54695471
fmt = FS_FAT32; break;
54705472
}
@@ -5641,6 +5643,7 @@ FRESULT f_mkfs (
56415643
do {
56425644
pau = au;
56435645
/* Pre-determine number of clusters and FAT sub-type */
5646+
#if FF_MKFS_FAT32
56445647
if (fmt == FS_FAT32) { /* FAT32 volume */
56455648
if (pau == 0) { /* au auto-selection */
56465649
n = sz_vol / 0x20000; /* Volume size in unit of 128KS */
@@ -5651,7 +5654,9 @@ FRESULT f_mkfs (
56515654
sz_rsv = 32; /* Number of reserved sectors */
56525655
sz_dir = 0; /* No static directory */
56535656
if (n_clst <= MAX_FAT16 || n_clst > MAX_FAT32) LEAVE_MKFS(FR_MKFS_ABORTED);
5654-
} else { /* FAT volume */
5657+
} else
5658+
#endif
5659+
{ /* FAT volume */
56555660
if (pau == 0) { /* au auto-selection */
56565661
n = sz_vol / 0x1000; /* Volume size in unit of 4KS */
56575662
for (i = 0, pau = 1; cst[i] && cst[i] <= n; i++, pau <<= 1) ; /* Get from table */
@@ -5681,12 +5686,14 @@ FRESULT f_mkfs (
56815686
/* Determine number of clusters and final check of validity of the FAT sub-type */
56825687
if (sz_vol < b_data + pau * 16 - b_vol) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume */
56835688
n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir) / pau;
5689+
#if FF_MKFS_FAT32
56845690
if (fmt == FS_FAT32) {
56855691
if (n_clst <= MAX_FAT16) { /* Too few clusters for FAT32 */
56865692
if (au == 0 && (au = pau / 2) != 0) continue; /* Adjust cluster size and retry */
56875693
LEAVE_MKFS(FR_MKFS_ABORTED);
56885694
}
56895695
}
5696+
#endif
56905697
if (fmt == FS_FAT16) {
56915698
if (n_clst > MAX_FAT16) { /* Too many clusters for FAT16 */
56925699
if (au == 0 && (pau * 2) <= 64) {
@@ -5720,7 +5727,11 @@ FRESULT f_mkfs (
57205727
buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */
57215728
st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */
57225729
buf[BPB_NumFATs] = (BYTE)n_fats; /* Number of FATs */
5730+
#if FF_MKFS_FAT32
57235731
st_word(buf + BPB_RootEntCnt, (WORD)((fmt == FS_FAT32) ? 0 : n_rootdir)); /* Number of root directory entries */
5732+
#else
5733+
st_word(buf + BPB_RootEntCnt, (WORD) n_rootdir); /* Number of root directory entries */
5734+
#endif
57245735
if (sz_vol < 0x10000) {
57255736
st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */
57265737
} else {
@@ -5730,6 +5741,7 @@ FRESULT f_mkfs (
57305741
st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */
57315742
st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */
57325743
st_dword(buf + BPB_HiddSec, b_vol); /* Volume offset in the physical drive [sector] */
5744+
#if FF_MKFS_FAT32
57335745
if (fmt == FS_FAT32) {
57345746
st_dword(buf + BS_VolID32, GET_FATTIME()); /* VSN */
57355747
st_dword(buf + BPB_FATSz32, sz_fat); /* FAT size [sector] */
@@ -5739,7 +5751,9 @@ FRESULT f_mkfs (
57395751
buf[BS_DrvNum32] = 0x80; /* Drive number (for int13) */
57405752
buf[BS_BootSig32] = 0x29; /* Extended boot signature */
57415753
mem_cpy(buf + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */
5742-
} else {
5754+
} else
5755+
#endif
5756+
{
57435757
st_dword(buf + BS_VolID, GET_FATTIME()); /* VSN */
57445758
st_word(buf + BPB_FATSz16, (WORD)sz_fat); /* FAT size [sector] */
57455759
buf[BS_DrvNum] = 0x80; /* Drive number (for int13) */
@@ -5750,6 +5764,7 @@ FRESULT f_mkfs (
57505764
if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) LEAVE_MKFS(FR_DISK_ERR); /* Write it to the VBR sector */
57515765

57525766
/* Create FSINFO record if needed */
5767+
#if FF_MKFS_FAT32
57535768
if (fmt == FS_FAT32) {
57545769
disk_write(pdrv, buf, b_vol + 6, 1); /* Write backup VBR (VBR + 6) */
57555770
mem_set(buf, 0, ss);
@@ -5761,16 +5776,20 @@ FRESULT f_mkfs (
57615776
disk_write(pdrv, buf, b_vol + 7, 1); /* Write backup FSINFO (VBR + 7) */
57625777
disk_write(pdrv, buf, b_vol + 1, 1); /* Write original FSINFO (VBR + 1) */
57635778
}
5779+
#endif
57645780

57655781
/* Initialize FAT area */
57665782
mem_set(buf, 0, (UINT)szb_buf);
57675783
sect = b_fat; /* FAT start sector */
57685784
for (i = 0; i < n_fats; i++) { /* Initialize FATs each */
5785+
#if FF_MKFS_FAT32
57695786
if (fmt == FS_FAT32) {
57705787
st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */
57715788
st_dword(buf + 4, 0xFFFFFFFF); /* Entry 1 */
57725789
st_dword(buf + 8, 0x0FFFFFFF); /* Entry 2 (root directory) */
5773-
} else {
5790+
} else
5791+
#endif
5792+
{
57745793
st_dword(buf + 0, (fmt == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */
57755794
}
57765795
nsect = sz_fat; /* Number of FAT sectors */
@@ -5783,7 +5802,11 @@ FRESULT f_mkfs (
57835802
}
57845803

57855804
/* Initialize root directory (fill with zero) */
5805+
#if FF_MKFS_FAT32
57865806
nsect = (fmt == FS_FAT32) ? pau : sz_dir; /* Number of root directory sectors */
5807+
#else
5808+
nsect = sz_dir; /* Number of root directory sectors */
5809+
#endif
57875810
do {
57885811
n = (nsect > sz_buf) ? sz_buf : nsect;
57895812
if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) LEAVE_MKFS(FR_DISK_ERR);
@@ -5795,7 +5818,7 @@ FRESULT f_mkfs (
57955818
if (FF_FS_EXFAT && fmt == FS_EXFAT) {
57965819
sys = 0x07; /* HPFS/NTFS/exFAT */
57975820
} else {
5798-
if (fmt == FS_FAT32) {
5821+
if (FF_MKFS_FAT32 && fmt == FS_FAT32) {
57995822
sys = 0x0C; /* FAT32X */
58005823
} else {
58015824
if (sz_vol >= 0x10000) {

lib/oofatfs/ffconf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
#define FF_USE_MKFS 1
7373
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
7474

75+
#ifdef MICROPY_FF_MKFS_FAT32
76+
#define FF_MKFS_FAT32 MICROPY_FF_MKFS_FAT32
77+
#else
78+
#define FF_MKFS_FAT32 0
79+
#endif
80+
/* This option switches off FAT32 support in f_mkfs() */
7581

7682
#define FF_USE_FASTSEEK 1
7783
/* This option switches fast seek function. (0:Disable or 1:Enable) */

ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
99
INTERNAL_FLASH_FILESYSTEM = 1
1010
LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
12-
13-
CIRCUITPY_RAINBOWIO = 0

ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

1313
CIRCUITPY_ONEWIREIO = 0
14-
CIRCUITPY_RAINBOWIO = 0

ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
99
INTERNAL_FLASH_FILESYSTEM = 1
1010
LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
12-
13-
CIRCUITPY_RAINBOWIO = 0

ports/litex/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ endif
8888
# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
8989
CFLAGS += $(OPTIMIZATION_FLAGS)
9090

91-
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
91+
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes
9292

9393
# TODO: check this
9494
CFLAGS += -D__START=main -DFOMU

ports/litex/background.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "supervisor/filesystem.h"
2929
#include "supervisor/usb.h"
3030
#include "supervisor/shared/stack.h"
31+
#include "supervisor/port.h"
3132

3233
void port_background_task(void) {
3334
}

ports/litex/common-hal/microcontroller/Processor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "py/runtime.h"
3030

3131
#include "common-hal/microcontroller/Processor.h"
32+
#include "shared-bindings/microcontroller/Processor.h"
3233
#include "shared-bindings/microcontroller/ResetReason.h"
3334
#include "supervisor/shared/translate.h"
3435

ports/litex/common-hal/os/__init__.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "py/objtuple.h"
3131
#include "py/qstr.h"
3232

33+
#include "shared-bindings/os/__init__.h"
34+
3335
STATIC const qstr os_uname_info_fields[] = {
3436
MP_QSTR_sysname, MP_QSTR_nodename,
3537
MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine
@@ -56,6 +58,6 @@ mp_obj_t common_hal_os_uname(void) {
5658
return (mp_obj_t)&os_uname_info_obj;
5759
}
5860

59-
bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) {
61+
bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) {
6062
return false;
6163
}

ports/litex/mphalport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "py/mphal.h"
3232
#include "py/mpstate.h"
3333
#include "py/gc.h"
34+
#include "supervisor/cpu.h"
3435
#include "supervisor/usb.h"
3536

3637
#include "csr.h"
@@ -54,6 +55,7 @@ extern void SysTick_Handler(void);
5455
// be prematurely enabled by interrupt handlers that enable and disable interrupts.
5556
extern volatile uint32_t nesting_count;
5657

58+
void isr(void);
5759
__attribute__((section(".ramtext")))
5860
void isr(void) {
5961
uint8_t irqs = irq_pending() & irq_getmask();

0 commit comments

Comments
 (0)