Skip to content

Add DEVEBOX_H750 Board #15191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4b4f601
rp2/rp2_flash: Lockout second core only when doing flash erase/write.
dpgeorge Jan 1, 2024
61b8361
rp2/mutex_extra: Implement additional mutex functions.
dpgeorge Jan 2, 2024
ac5e0b9
rp2/mpthreadport: Fix race with IRQ when entering atomic section.
dpgeorge Jan 1, 2024
9b8c64c
all: Bump version to 1.22.1.
dpgeorge Jan 5, 2024
d5f3fcd
rp2/rp2_dma: Fix fetching 'write' buffers for writing not reading.
nickovs Jan 6, 2024
068aa28
rp2/machine_uart: Fix event wait in uart.flush() and uart.read().
robert-hh Jan 7, 2024
4c7d955
renesas-ra/ra: Fix SysTick clock source.
iabdalkader Jan 12, 2024
1e8cc6c
renesas-ra/boards/ARDUINO_PORTENTA_C33: Fix the RTC clock source.
iabdalkader Jan 17, 2024
a2e9ab3
extmod/asyncio: Support gather of tasks that finish early.
dpgeorge Jan 18, 2024
8b6e89a
mimxrt/modmachine: Fix deepsleep wakeup pin ifdef.
kwagyeman Jan 22, 2024
2531a15
extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers.
dpgeorge Jan 29, 2024
f53ee9f
rp2: Change machine.I2S and rp2.DMA to use shared DMA IRQ handlers.
dpgeorge Jan 30, 2024
b979c5a
py/compile: Fix potential Py-stack overflow in try-finally with return.
dpgeorge Jan 31, 2024
cc7cfc7
renesas-ra/ra/ra_i2c: Fix 1 byte and 2 bytes read issue.
TakeoTakahashi2020 Jan 29, 2024
e7ff724
extmod/btstack: Reset pending_value_handle before calling write-done cb.
dpgeorge Feb 8, 2024
02df2b0
extmod/btstack: Reset pending_value_handle before calling read-done cb.
dpgeorge Feb 11, 2024
e72d038
esp32/mpnimbleport: Release the GIL while doing NimBLE port deinit.
dpgeorge Feb 14, 2024
ee3c9cc
esp32: Increase NimBLE task stack size and overflow detection headroom.
dpgeorge Feb 15, 2024
8cd1582
all: Bump version to 1.22.2.
dpgeorge Feb 20, 2024
57a959a
new file: ports/stm32/boards/DEVEBOX_H750VB/board.json
ArduinoTM Jun 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ used during the build process and is not part of the compiled source code.
/FreeRTOS (GPL-2.0 with FreeRTOS exception)
/esp32
/ppp_set_auth.* (Apache-2.0)
/rp2
/mutex_extra.c (BSD-3-clause)
/stm32
/usbd*.c (MCD-ST Liberty SW License Agreement V2)
/stm32_it.* (MIT + BSD-3-clause)
Expand Down
5 changes: 5 additions & 0 deletions extmod/asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ def run_until_complete(main_task=None):
elif t.state is None:
# Task is already finished and nothing await'ed on the task,
# so call the exception handler.

# Save exception raised by the coro for later use.
t.data = exc

# Create exception context and call the exception handler.
_exc_context["exception"] = exc
_exc_context["future"] = t
Loop.call_exception_handler(_exc_context)
Expand Down
49 changes: 32 additions & 17 deletions extmod/asyncio/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ def remove(t):

# async
def gather(*aws, return_exceptions=False):
if not aws:
return []

def done(t, er):
# Sub-task "t" has finished, with exception "er".
nonlocal state
Expand All @@ -86,26 +83,39 @@ def done(t, er):
# Gather waiting is done, schedule the main gather task.
core._task_queue.push(gather_task)

# Prepare the sub-tasks for the gather.
# The `state` variable counts the number of tasks to wait for, and can be negative
# if the gather should not run at all (because a task already had an exception).
ts = [core._promote_to_task(aw) for aw in aws]
state = 0
for i in range(len(ts)):
if ts[i].state is not True:
# Task is not running, gather not currently supported for this case.
if ts[i].state is True:
# Task is running, register the callback to call when the task is done.
ts[i].state = done
state += 1
elif not ts[i].state:
# Task finished already.
if not isinstance(ts[i].data, StopIteration):
# Task finished by raising an exception.
if not return_exceptions:
# Do not run this gather at all.
state = -len(ts)
else:
# Task being waited on, gather not currently supported for this case.
raise RuntimeError("can't gather")
# Register the callback to call when the task is done.
ts[i].state = done

# Set the state for execution of the gather.
gather_task = core.cur_task
state = len(ts)
cancel_all = False

# Wait for the a sub-task to need attention.
gather_task.data = _Remove
try:
yield
except core.CancelledError as er:
cancel_all = True
state = er
# Wait for a sub-task to need attention (if there are any to wait for).
if state > 0:
gather_task.data = _Remove
try:
yield
except core.CancelledError as er:
cancel_all = True
state = er

# Clean up tasks.
for i in range(len(ts)):
Expand All @@ -118,8 +128,13 @@ def done(t, er):
# Sub-task ran to completion, get its return value.
ts[i] = ts[i].data.value
else:
# Sub-task had an exception with return_exceptions==True, so get its exception.
ts[i] = ts[i].data
# Sub-task had an exception.
if return_exceptions:
# Get the sub-task exception to return in the list of return values.
ts[i] = ts[i].data
elif isinstance(state, int):
# Raise the sub-task exception, if there is not already an exception to raise.
state = ts[i].data

# Either this gather was cancelled, or one of the sub-tasks raised an exception with
# return_exceptions==False, so reraise the exception here.
Expand Down
6 changes: 4 additions & 2 deletions extmod/btstack/modbluetooth_btstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,9 @@ STATIC void btstack_packet_handler_read(uint8_t packet_type, uint16_t channel, u
if (!conn) {
return;
}
mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_READ_DONE, conn_handle, conn->pending_value_handle, status);
uint16_t value_handle = conn->pending_value_handle;
conn->pending_value_handle = 0xffff;
mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_READ_DONE, conn_handle, value_handle, status);
} else if (event_type == GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT) {
DEBUG_printf(" --> gatt characteristic value query result\n");
uint16_t conn_handle = gatt_event_characteristic_value_query_result_get_handle(packet);
Expand All @@ -490,11 +491,12 @@ STATIC void btstack_packet_handler_write_with_response(uint8_t packet_type, uint
if (!conn) {
return;
}
mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_WRITE_DONE, conn_handle, conn->pending_value_handle, status);
uint16_t value_handle = conn->pending_value_handle;
conn->pending_value_handle = 0xffff;
m_del(uint8_t, conn->pending_write_value, conn->pending_write_value_len);
conn->pending_write_value = NULL;
conn->pending_write_value_len = 0;
mp_bluetooth_gattc_on_read_write_status(MP_BLUETOOTH_IRQ_GATTC_WRITE_DONE, conn_handle, value_handle, status);
}
}
#endif // MICROPY_PY_BLUETOOTH_ENABLE_GATT_CLIENT
Expand Down
2 changes: 1 addition & 1 deletion extmod/modbluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ STATIC mp_obj_t invoke_irq_handler(uint16_t event,
if (ts_orig == NULL) {
mp_thread_set_state(&ts);
mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
mp_stack_set_limit(MICROPY_PY_BLUETOOTH_SYNC_EVENT_STACK_SIZE - 1024);
mp_stack_set_limit(MICROPY_PY_BLUETOOTH_SYNC_EVENT_STACK_SIZE);
ts.gc_lock_depth = 0;
ts.nlr_jump_callback_top = NULL;
ts.mp_pending_exception = MP_OBJ_NULL;
Expand Down
4 changes: 0 additions & 4 deletions extmod/modssl_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,6 @@ STATIC mp_obj_t ssl_context_get_ciphers(mp_obj_t self_in) {
for (const int *cipher_list = mbedtls_ssl_list_ciphersuites(); *cipher_list; ++cipher_list) {
const char *cipher_name = mbedtls_ssl_get_ciphersuite_name(*cipher_list);
mp_obj_list_append(list, MP_OBJ_FROM_PTR(mp_obj_new_str(cipher_name, strlen(cipher_name))));
cipher_list++;
if (!*cipher_list) {
break;
}
}
return list;
}
Expand Down
4 changes: 4 additions & 0 deletions ports/esp32/boards/sdkconfig.ble
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4
CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=n
CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y
CONFIG_BT_NIMBLE_PINNED_TO_CORE=1

# Increase NimBLE task stack size from the default, because Python code
# (BLE IRQ handlers) will most likely run on this task.
CONFIG_BT_NIMBLE_TASK_STACK_SIZE=6144
2 changes: 1 addition & 1 deletion ports/esp32/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
#define MICROPY_PY_BLUETOOTH (1)
#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS (1)
#define MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS_WITH_INTERLOCK (1)
#define MICROPY_PY_BLUETOOTH_SYNC_EVENT_STACK_SIZE (CONFIG_BT_NIMBLE_TASK_STACK_SIZE)
#define MICROPY_PY_BLUETOOTH_SYNC_EVENT_STACK_SIZE (CONFIG_BT_NIMBLE_TASK_STACK_SIZE - 2048)
#define MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE (1)
#define MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING (1)
#define MICROPY_BLUETOOTH_NIMBLE (1)
Expand Down
9 changes: 9 additions & 0 deletions ports/esp32/mpnimbleport.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ void mp_bluetooth_nimble_port_start(void) {
void mp_bluetooth_nimble_port_shutdown(void) {
DEBUG_printf("mp_bluetooth_nimble_port_shutdown\n");

#if MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS_WITH_INTERLOCK
// Release the GIL so any callbacks can run during the shutdown calls below.
MP_THREAD_GIL_EXIT();
#endif

// Despite the name, these is an ESP32-specific (no other NimBLE ports have these functions).
// Calls ble_hs_stop() and waits for stack shutdown.
nimble_port_stop();

// Shuts down the event queue.
nimble_port_deinit();

#if MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS_WITH_INTERLOCK
MP_THREAD_GIL_ENTER();
#endif

// Mark stack as shutdown.
mp_bluetooth_nimble_ble_state = MP_BLUETOOTH_NIMBLE_BLE_STATE_OFF;
}
Expand Down
4 changes: 2 additions & 2 deletions ports/mimxrt/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ NORETURN STATIC void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
}
}

#ifdef MIMXRT117x_SERIES
#if defined(MIMXRT117x_SERIES)
machine_pin_config(pin_WAKEUP_DIG, PIN_MODE_IT_RISING, PIN_PULL_DISABLED, PIN_DRIVE_OFF, 0, PIN_AF_MODE_ALT5);
GPC_CM_EnableIrqWakeup(GPC_CPU_MODE_CTRL_0, GPIO13_Combined_0_31_IRQn, true);
#elif defined IOMUXC_SNVS_WAKEUP_GPIO5_IO00
#elif defined(pin_WAKEUP)
machine_pin_config(pin_WAKEUP, PIN_MODE_IT_RISING, PIN_PULL_DISABLED, PIN_DRIVE_OFF, 0, PIN_AF_MODE_ALT5);
GPC_EnableIRQ(GPC, GPIO5_Combined_0_15_IRQn);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// peripheral config
#define MICROPY_HW_ENABLE_RNG (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_RTC_SOURCE (1)
#define MICROPY_HW_RTC_SOURCE (0)
#define MICROPY_HW_ENABLE_ADC (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_USBDEV (1)
Expand Down
1 change: 1 addition & 0 deletions ports/renesas-ra/ra/ra_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define RA_RA_CONFIG_H_

#include <stdint.h>
#include "py/mpconfig.h"

#if defined(RA4M1) | defined(RA4W1)
#define SCI_CH_MAX 10
Expand Down
36 changes: 35 additions & 1 deletion ports/renesas-ra/ra/ra_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void ra_i2c_init(R_IIC0_Type *i2c_inst, uint32_t scl, uint32_t sda, uint32_t bau
i2c_inst->ICCR1_b.ICE = 1; // I2C enable
ra_i2c_set_baudrate(i2c_inst, baudrate);
i2c_inst->ICSER = 0x00; // I2C reset bus status enable register
i2c_inst->ICMR3_b.ACKWP = 0x01; // I2C allow to write ACKBT (transfer acknowledge bit)
i2c_inst->ICMR3_b.ACKWP = 0x00; // I2C not allow to write ACKBT (transfer acknowledge bit)
i2c_inst->ICIER = 0xFF; // Enable all interrupts
i2c_inst->ICCR1_b.IICRST = 0; // I2C internal reset
ra_i2c_irq_enable(i2c_inst);
Expand Down Expand Up @@ -480,6 +480,7 @@ void ra_i2c_xunit_read_byte(R_IIC0_Type *i2c_inst, xaction_unit_t *unit) {
void ra_i2c_xunit_init(xaction_unit_t *unit, uint8_t *buf, uint32_t size, bool fread, void *next) {
unit->m_bytes_transferred = 0;
unit->m_bytes_transfer = size;
unit->m_bytes_total = size;
unit->m_fread = fread;
unit->buf = buf;
unit->next = (void *)next;
Expand Down Expand Up @@ -531,6 +532,37 @@ static void ra_i2c_iceri_isr(R_IIC0_Type *i2c_inst) {
static void ra_i2c_icrxi_isr(R_IIC0_Type *i2c_inst) {
xaction_unit_t *unit = current_xaction_unit;
xaction_t *action = current_xaction;
// 1 byte or 2 bytes
if (unit->m_bytes_total <= 2) {
if (action->m_status == RA_I2C_STATUS_AddrWriteCompleted) {
action->m_status = RA_I2C_STATUS_FirstReceiveCompleted;
i2c_inst->ICMR3_b.WAIT = 1;
// need dummy read processes for 1 byte and 2 bytes receive
if (unit->m_bytes_total == 2) {
(void)i2c_inst->ICDRR; // dummy read for 2 bytes receive
} else { // m_bytes_total == 1
i2c_inst->ICMR3_b.ACKWP = 0x01; // enable write ACKBT (transfer acknowledge bit)
i2c_inst->ICMR3_b.ACKBT = 1;
i2c_inst->ICMR3_b.ACKWP = 0x00; // disable write ACKBT (transfer acknowledge bit)
(void)i2c_inst->ICDRR; // dummy read for 1 byte receive
}
return;
}
if (unit->m_bytes_transfer == 2) { // last two data
i2c_inst->ICMR3_b.ACKWP = 0x01; // enable write ACKBT (transfer acknowledge bit)
i2c_inst->ICMR3_b.ACKBT = 1;
i2c_inst->ICMR3_b.ACKWP = 0x00; // disable write ACKBT (transfer acknowledge bit)
ra_i2c_xunit_read_byte(i2c_inst, unit);
} else { // last data
action->m_status = RA_I2C_STATUS_LastReceiveCompleted;
if (action->m_stop == true) {
i2c_inst->ICCR2_b.SP = 1; // request top condition
}
ra_i2c_xunit_read_byte(i2c_inst, unit);
}
return;
}
// 3 bytes or more
if (action->m_status == RA_I2C_STATUS_AddrWriteCompleted) {
(void)i2c_inst->ICDRR; // dummy read
action->m_status = RA_I2C_STATUS_FirstReceiveCompleted;
Expand All @@ -542,7 +574,9 @@ static void ra_i2c_icrxi_isr(R_IIC0_Type *i2c_inst) {
}
ra_i2c_xunit_read_byte(i2c_inst, unit);
} else if (unit->m_bytes_transfer == 2) {
i2c_inst->ICMR3_b.ACKWP = 0x01; // enable write ACKBT (transfer acknowledge bit)
i2c_inst->ICMR3_b.ACKBT = 1;
i2c_inst->ICMR3_b.ACKWP = 0x00; // disable write ACKBT (transfer acknowledge bit)
ra_i2c_xunit_read_byte(i2c_inst, unit);
} else {
// last data
Expand Down
9 changes: 5 additions & 4 deletions ports/renesas-ra/ra/ra_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ typedef enum
RA_I2C_STATUS_AddrWriteCompleted = 3,
RA_I2C_STATUS_DataWriteCompleted = 4,
RA_I2C_STATUS_DataSendCompleted = 5,
RA_I2C_STATUS_FirstReceiveCompleted = 5,
RA_I2C_STATUS_LastReceiveCompleted = 6,
RA_I2C_STATUS_Stopped = 7,
RA_I2C_STATUS_FirstReceiveCompleted = 6,
RA_I2C_STATUS_LastReceiveCompleted = 7,
RA_I2C_STATUS_Stopped = 8,
} xaction_status_t;

typedef enum
Expand All @@ -64,6 +64,7 @@ typedef enum
typedef struct {
volatile uint32_t m_bytes_transferred;
volatile uint32_t m_bytes_transfer;
uint32_t m_bytes_total;
bool m_fread;
uint8_t *buf;
void *next;
Expand All @@ -75,7 +76,7 @@ typedef struct {
uint32_t m_current;
uint32_t m_address;
volatile xaction_status_t m_status;
xaction_error_t m_error;
volatile xaction_error_t m_error;
bool m_stop;
} xaction_t;

Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/ra/ra_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

void ra_init(void) {
ra_int_init();
SysTick_Config(PCLK / 1000);
SysTick_Config(MICROPY_HW_MCU_SYSCLK / 1000);
internal_flash_init();
}

Expand Down
2 changes: 2 additions & 0 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(MICROPY_SOURCE_PORT
mphalport.c
mpnetworkport.c
mpthreadport.c
mutex_extra.c
pendsv.c
rp2_flash.c
rp2_pio.c
Expand Down Expand Up @@ -473,6 +474,7 @@ target_compile_definitions(${MICROPY_TARGET} PRIVATE
PICO_FLOAT_PROPAGATE_NANS=1
PICO_STACK_SIZE=0x2000
PICO_CORE1_STACK_SIZE=0
PICO_MAX_SHARED_IRQ_HANDLERS=8 # we need more than the default
PICO_PROGRAM_NAME="MicroPython"
PICO_NO_PROGRAM_VERSION_STRING=1 # do it ourselves in main.c
MICROPY_BUILD_TYPE="${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_BUILD_TYPE}"
Expand Down
6 changes: 2 additions & 4 deletions ports/rp2/machine_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,18 @@ STATIC void feed_dma(machine_i2s_obj_t *self, uint8_t *dma_buffer_p) {

STATIC void irq_configure(machine_i2s_obj_t *self) {
if (self->i2s_id == 0) {
irq_set_exclusive_handler(DMA_IRQ_0, dma_irq0_handler);
irq_add_shared_handler(DMA_IRQ_0, dma_irq0_handler, PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY);
irq_set_enabled(DMA_IRQ_0, true);
} else {
irq_set_exclusive_handler(DMA_IRQ_1, dma_irq1_handler);
irq_add_shared_handler(DMA_IRQ_1, dma_irq1_handler, PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY);
irq_set_enabled(DMA_IRQ_1, true);
}
}

STATIC void irq_deinit(machine_i2s_obj_t *self) {
if (self->i2s_id == 0) {
irq_set_enabled(DMA_IRQ_0, false);
irq_remove_handler(DMA_IRQ_0, dma_irq0_handler);
} else {
irq_set_enabled(DMA_IRQ_1, false);
irq_remove_handler(DMA_IRQ_1, dma_irq1_handler);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ports/rp2/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
return i;
}
}
mp_event_wait_ms(timeout - elapsed);
mp_event_handle_nowait();
}
*dest++ = ringbuf_get(&(self->read_buffer));
start = mp_hal_ticks_ms(); // Inter-character timeout
Expand Down Expand Up @@ -559,7 +559,7 @@ STATIC mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uint
if (now >= timeout) {
break;
}
mp_event_wait_ms((timeout - now) / 1000);
mp_event_handle_nowait();
}
*errcode = MP_ETIMEDOUT;
ret = MP_STREAM_ERROR;
Expand Down
Loading