Skip to content

Commit 8bcdd9e

Browse files
authored
Merge branch 'micropython:master' into samd_i2c
2 parents ab4036e + ca6723b commit 8bcdd9e

File tree

90 files changed

+5754
-250
lines changed

Some content is hidden

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

90 files changed

+5754
-250
lines changed

.github/workflows/ports_zephyr.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ jobs:
2020
build:
2121
runs-on: ubuntu-latest
2222
steps:
23+
- uses: jlumbroso/free-disk-space@main
24+
with:
25+
# Only free up a few things so this step runs quickly.
26+
android: false
27+
dotnet: true
28+
haskell: true
29+
large-packages: false
30+
docker-images: false
31+
swap-storage: false
2332
- uses: actions/checkout@v4
2433
- name: Install packages
2534
run: source tools/ci.sh && ci_zephyr_setup

docs/zephyr/quickref.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
3636

3737
from machine import Pin
3838

39-
pin = Pin(("GPIO_1", 21), Pin.IN) # create input pin on GPIO1
39+
pin = Pin(("gpiob", 21), Pin.IN) # create input pin on GPIO port B
4040
print(pin) # print pin port and number
4141

4242
pin.init(Pin.OUT, Pin.PULL_UP, value=1) # reinitialize pin
@@ -47,14 +47,14 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
4747
pin.on() # set pin to high
4848
pin.off() # set pin to low
4949

50-
pin = Pin(("GPIO_1", 21), Pin.IN) # create input pin on GPIO1
50+
pin = Pin(("gpiob", 21), Pin.IN) # create input pin on GPIO port B
5151

52-
pin = Pin(("GPIO_1", 21), Pin.OUT, value=1) # set pin high on creation
52+
pin = Pin(("gpiob", 21), Pin.OUT, value=1) # set pin high on creation
5353

54-
pin = Pin(("GPIO_1", 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
54+
pin = Pin(("gpiob", 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
5555

56-
switch = Pin(("GPIO_2", 6), Pin.IN) # create input pin for a switch
57-
switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed
56+
switch = Pin(("gpioc", 6), Pin.IN) # create input pin for a switch
57+
switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed
5858

5959
Hardware I2C bus
6060
----------------
@@ -63,7 +63,7 @@ Hardware I2C is accessed via the :ref:`machine.I2C <machine.I2C>` class::
6363

6464
from machine import I2C
6565

66-
i2c = I2C("I2C_0") # construct an i2c bus
66+
i2c = I2C("i2c0") # construct an i2c bus
6767
print(i2c) # print device name
6868

6969
i2c.scan() # scan the device for available I2C slaves
@@ -84,11 +84,11 @@ Hardware SPI is accessed via the :ref:`machine.SPI <machine.SPI>` class::
8484

8585
from machine import SPI
8686

87-
spi = SPI("SPI_0") # construct a spi bus with default configuration
87+
spi = SPI("spi0") # construct a spi bus with default configuration
8888
spi.init(baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB) # set configuration
8989

9090
# equivalently, construct spi bus and set configuration at the same time
91-
spi = SPI("SPI_0", baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB)
91+
spi = SPI("spi0", baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB)
9292
print(spi) # print device name and bus configuration
9393

9494
spi.read(4) # read 4 bytes on MISO
@@ -146,7 +146,7 @@ Use the :ref:`zsensor.Sensor <zsensor.Sensor>` class to access sensor data::
146146
import zsensor
147147
from zsensor import Sensor
148148

149-
accel = Sensor("FXOX8700") # create sensor object for the accelerometer
149+
accel = Sensor("fxos8700") # create sensor object for the accelerometer
150150

151151
accel.measure() # obtain a measurement reading from the accelerometer
152152

docs/zephyr/tutorial/repl.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ With your serial program open (PuTTY, screen, picocom, etc) you may see a
3131
blank screen with a flashing cursor. Press Enter (or reset the board) and
3232
you should be presented with the following text::
3333

34-
*** Booting Zephyr OS build zephyr-v3.1.0 ***
35-
MicroPython v1.19.1-9-g4fd54a475 on 2022-06-17; zephyr-frdm_k64f with mk64f12
34+
*** Booting Zephyr OS build v3.7.0 ***
35+
MicroPython v1.24.0-preview.179.g5b85b24bd on 2024-08-05; zephyr-frdm_k64f with mk64f12
3636
Type "help()" for more information.
3737
>>>
3838

extmod/vfs_blockdev.c

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,38 @@ void mp_vfs_blockdev_init(mp_vfs_blockdev_t *self, mp_obj_t bdev) {
4646
}
4747
}
4848

49+
// Helper function to minimise code size of read/write functions
50+
// note the n_args argument is moved to the end for further code size reduction (args keep same position in caller and callee).
51+
static int mp_vfs_blockdev_call_rw(mp_obj_t *args, size_t block_num, size_t block_off, size_t len, void *buf, size_t n_args) {
52+
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, len, buf};
53+
args[2] = MP_OBJ_NEW_SMALL_INT(block_num);
54+
args[3] = MP_OBJ_FROM_PTR(&ar);
55+
args[4] = MP_OBJ_NEW_SMALL_INT(block_off); // ignored for n_args == 2
56+
mp_obj_t ret = mp_call_method_n_kw(n_args, 0, args);
57+
58+
if (ret == mp_const_none) {
59+
return 0;
60+
} else {
61+
// Block device functions are expected to return 0 on success
62+
// and negative integer on errors. Check for positive integer
63+
// results as some callers (i.e. littlefs) will produce corrupt
64+
// results from these.
65+
int i = MP_OBJ_SMALL_INT_VALUE(ret);
66+
return i > 0 ? (-MP_EINVAL) : i;
67+
}
68+
}
69+
4970
int mp_vfs_blockdev_read(mp_vfs_blockdev_t *self, size_t block_num, size_t num_blocks, uint8_t *buf) {
5071
if (self->flags & MP_BLOCKDEV_FLAG_NATIVE) {
5172
mp_uint_t (*f)(uint8_t *, uint32_t, uint32_t) = (void *)(uintptr_t)self->readblocks[2];
5273
return f(buf, block_num, num_blocks);
5374
} else {
54-
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, num_blocks *self->block_size, buf};
55-
self->readblocks[2] = MP_OBJ_NEW_SMALL_INT(block_num);
56-
self->readblocks[3] = MP_OBJ_FROM_PTR(&ar);
57-
mp_call_method_n_kw(2, 0, self->readblocks);
58-
// TODO handle error return
59-
return 0;
75+
return mp_vfs_blockdev_call_rw(self->readblocks, block_num, 0, num_blocks * self->block_size, buf, 2);
6076
}
6177
}
6278

6379
int mp_vfs_blockdev_read_ext(mp_vfs_blockdev_t *self, size_t block_num, size_t block_off, size_t len, uint8_t *buf) {
64-
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, len, buf};
65-
self->readblocks[2] = MP_OBJ_NEW_SMALL_INT(block_num);
66-
self->readblocks[3] = MP_OBJ_FROM_PTR(&ar);
67-
self->readblocks[4] = MP_OBJ_NEW_SMALL_INT(block_off);
68-
mp_obj_t ret = mp_call_method_n_kw(3, 0, self->readblocks);
69-
if (ret == mp_const_none) {
70-
return 0;
71-
} else {
72-
return MP_OBJ_SMALL_INT_VALUE(ret);
73-
}
80+
return mp_vfs_blockdev_call_rw(self->readblocks, block_num, block_off, len, buf, 3);
7481
}
7582

7683
int mp_vfs_blockdev_write(mp_vfs_blockdev_t *self, size_t block_num, size_t num_blocks, const uint8_t *buf) {
@@ -83,12 +90,7 @@ int mp_vfs_blockdev_write(mp_vfs_blockdev_t *self, size_t block_num, size_t num_
8390
mp_uint_t (*f)(const uint8_t *, uint32_t, uint32_t) = (void *)(uintptr_t)self->writeblocks[2];
8491
return f(buf, block_num, num_blocks);
8592
} else {
86-
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, num_blocks *self->block_size, (void *)buf};
87-
self->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(block_num);
88-
self->writeblocks[3] = MP_OBJ_FROM_PTR(&ar);
89-
mp_call_method_n_kw(2, 0, self->writeblocks);
90-
// TODO handle error return
91-
return 0;
93+
return mp_vfs_blockdev_call_rw(self->writeblocks, block_num, 0, num_blocks * self->block_size, (void *)buf, 2);
9294
}
9395
}
9496

@@ -97,17 +99,7 @@ int mp_vfs_blockdev_write_ext(mp_vfs_blockdev_t *self, size_t block_num, size_t
9799
// read-only block device
98100
return -MP_EROFS;
99101
}
100-
101-
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, len, (void *)buf};
102-
self->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(block_num);
103-
self->writeblocks[3] = MP_OBJ_FROM_PTR(&ar);
104-
self->writeblocks[4] = MP_OBJ_NEW_SMALL_INT(block_off);
105-
mp_obj_t ret = mp_call_method_n_kw(3, 0, self->writeblocks);
106-
if (ret == mp_const_none) {
107-
return 0;
108-
} else {
109-
return MP_OBJ_SMALL_INT_VALUE(ret);
110-
}
102+
return mp_vfs_blockdev_call_rw(self->writeblocks, block_num, block_off, len, (void *)buf, 3);
111103
}
112104

113105
mp_obj_t mp_vfs_blockdev_ioctl(mp_vfs_blockdev_t *self, uintptr_t cmd, uintptr_t arg) {

lib/tinyusb

Submodule tinyusb updated 312 files

ports/esp32/mpconfigport.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@
4747
#define MICROPY_EMIT_RV32 (1)
4848
#endif
4949

50-
// workaround for xtensa-esp32-elf-gcc esp-2020r3, which can generate wrong code for loops
51-
// see https://github.com/espressif/esp-idf/issues/9130
52-
// this was fixed in newer versions of the compiler by:
53-
// "gas: use literals/const16 for xtensa loop relaxation"
54-
// https://github.com/jcmvbkbc/binutils-gdb-xtensa/commit/403b0b61f6d4358aee8493cb1d11814e368942c9
55-
#define MICROPY_COMP_CONST_FOLDING_COMPILER_WORKAROUND (1)
56-
5750
// optimisations
5851
#ifndef MICROPY_OPT_COMPUTED_GOTO
5952
#define MICROPY_OPT_COMPUTED_GOTO (1)

ports/mimxrt/lwip_inc/lwipopts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define LWIP_IPV6 0
2929
#define LWIP_DHCP 1
3030
#define LWIP_DHCP_CHECK_LINK_UP 1
31-
#define DHCP_DOES_ARP_CHECK 0 // to speed DHCP up
31+
#define LWIP_DHCP_DOES_ACD_CHECK 0 // to speed DHCP up
3232
#define LWIP_DNS 1
3333
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
3434
#define LWIP_MDNS_RESPONDER 1

ports/renesas-ra/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)"
157157
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))"
158158
endif
159159

160+
# Hook tinyusb USB interrupt if used to service usb task.
161+
LDFLAGS += --wrap=dcd_event_handler
162+
160163
# Options for mpy-cross
161164
MPY_CROSS_FLAGS += -march=armv7m
162165

ports/renesas-ra/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ passed as the argument to `BOARD=`; for example `RA4M1_CLICKER`, `EK_RA4M1`,
6363
The above command should produce binary images `firmware.hex` in the
6464
build-EK_RA6M2/` subdirectory (or the equivalent directory for the board specified).
6565

66+
## Board definition auto-generated code
67+
68+
The supported board definitions contain auto-generated configuration files in
69+
the `boards/<BOARD_NAME>/ra_cfg` and `boards/<BOARD_NAME>/ra_gen` folders.
70+
71+
These are generated with the [RA Smart Configurator](https://www.renesas.com/us/en/software-tool/ra-smart-configurator)
72+
tool which is used to define peripheral configuration, pinouts, interrupts etc. for each board.
73+
74+
This tool can be installed either as part of the "Renesas e² studio", or separately with
75+
the fsp driver package from https://github.com/renesas/fsp/releases eg.
76+
* [setup_fsp_v4_4_0_rasc_v2023-04.exe](https://github.com/renesas/fsp/releases/download/v4.4.0/setup_fsp_v4_4_0_rasc_v2023-04.exe)
77+
* [setup_fsp_v4_4_0_rasc_v2023-04.exe](https://github.com/renesas/fsp/releases/download/v4.4.0/setup_fsp_v4_4_0_rasc_v2023-04.AppImage)
78+
79+
This tool can be used to create new board definitions or modify existing ones
80+
by opening one of the `configuration.xml` files in the board folders.
81+
82+
Once the `configuration.xml` file is opened in RA Smart Configurator and modified as
83+
needed, the "Generate Project Content" button can be pressed to export new copies
84+
of the `ra_cfg` and `ra_gen` folders.
85+
6686
## Supported/Unsupported functions
6787
Please refer to the `renesas-ra` quick reference.
6888

0 commit comments

Comments
 (0)