Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,13 @@ jobs:
pattern: "*-report-*"
merge-multiple: true

- run: |
- name: Generate workflow summary
run: |
# gather the array of job metadata (especially name and ID) for the current workflow run
export WORKFLOW_JOBS=$(gh run view ${{ github.run_id }} --attempt ${{ github.run_attempt }} --json jobs --jq '.jobs')
# Run the log inspection script
extra/ci_inspect_logs.py result summary full_log
cat result

# Display the summary and full log in the step summary
cat summary >> $GITHUB_STEP_SUMMARY
Expand All @@ -431,6 +433,12 @@ jobs:
tar jchf size-reports-${{ needs.build-env.outputs.CORE_HASH }}.tar.bz2 arduino-*.json
fi

- name: Compute code size changes
if: ${{ github.event_name == 'pull_request' }}
run: |
export GITHUB_BASE_SHA=$(git describe --always origin/${GITHUB_BASE_REF})
extra/ci_calc_size_reports.py ${GITHUB_BASE_SHA} sketches-reports/

# upload comment request artifact (will be retrieved by leave_pr_comment.yml)
- name: Archive comment information
uses: actions/upload-artifact@v4
Expand All @@ -440,6 +448,15 @@ jobs:
path: comment-request/
retention-days: 1

# upload size delta report artifact (will be retrieved by report_size_deltas.yml)
- name: Archive size deltas report information
uses: actions/upload-artifact@v4
if: ${{ github.event_name == 'pull_request' }}
with:
name: sketches-reports
path: sketches-reports/
retention-days: 1

# upload new official test size artifact (for AWS storage)
- name: Archive sketch report information
uses: actions/upload-artifact@v4
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/report_size_deltas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Arduino s.r.l. and/or its affiliated companies
# SPDX-License-Identifier: Apache-2.0

name: Report size deltas

on:
workflow_run:
workflows: ["Package, test and upload core"]
types:
- completed

permissions:
contents: read
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: arduino/report-size-deltas@v1.1.0
29 changes: 29 additions & 0 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
#include <Arduino.h>
#include "zephyrInternal.h"

#ifdef CONFIG_PINCTRL_DYNAMIC
// create an array of arduino_pins with functions to reinitialize pins if needed
static const struct device *pinmux_array[DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios)] = {
nullptr};

void _reinit_peripheral_if_needed(pin_size_t pin, const struct device *dev) {
if (pinmux_array[pin] != dev) {
pinmux_array[pin] = dev;
if (dev != NULL) {
dev->ops.init(dev);
}
}
}
#endif

static const struct gpio_dt_spec arduino_pins[] = {
DT_FOREACH_PROP_ELEM_SEP(
DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};
Expand Down Expand Up @@ -209,6 +224,9 @@ void yield(void) {
* A high physical level will be interpreted as value 1
*/
void pinMode(pin_size_t pinNumber, PinMode pinMode) {
#ifdef CONFIG_PINCTRL_DYNAMIC
_reinit_peripheral_if_needed(pinNumber, NULL);
#endif
if (pinMode == INPUT) { // input mode
gpio_pin_configure_dt(&arduino_pins[pinNumber], GPIO_INPUT | GPIO_ACTIVE_HIGH);
} else if (pinMode == INPUT_PULLUP) { // input with internal pull-up
Expand Down Expand Up @@ -312,6 +330,9 @@ void analogWrite(pin_size_t pinNumber, int value) {
return;
}

#ifdef CONFIG_PINCTRL_DYNAMIC
_reinit_peripheral_if_needed(pinNumber, arduino_pwm[idx].dev);
#endif
value = map(value, 0, 1 << _analog_write_resolution, 0, arduino_pwm[idx].period);

if (((uint32_t)value) > arduino_pwm[idx].period) {
Expand All @@ -335,6 +356,11 @@ void analogWrite(enum dacPins dacName, int value) {
return;
}

// TODO: add reverse map to find pin name from DAC* define
// In the meantime, consider A0 == DAC0
#ifdef CONFIG_PINCTRL_DYNAMIC
_reinit_peripheral_if_needed((pin_size_t)(dacName + A0), dac_dev);
#endif
dac_channel_setup(dac_dev, &dac_ch_cfg[dacName]);

const int max_dac_value = 1U << dac_ch_cfg[dacName].resolution;
Expand Down Expand Up @@ -385,6 +411,9 @@ int analogRead(pin_size_t pinNumber) {
return -ENOTSUP;
}

#ifdef CONFIG_PINCTRL_DYNAMIC
_reinit_peripheral_if_needed(pinNumber, arduino_adc[idx].dev);
#endif
err = adc_channel_setup(arduino_adc[idx].dev, &arduino_adc[idx].channel_cfg);
if (err < 0) {
return err;
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/zephyrInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ extern "C" {

void enableInterrupt(pin_size_t);
void disableInterrupt(pin_size_t);
#ifdef CONFIG_PINCTRL_DYNAMIC
void _reinit_peripheral_if_needed(pin_size_t pin, const struct device *dev);
#endif

#ifdef __cplusplus
} // extern "C"
Expand Down
4 changes: 4 additions & 0 deletions cores/arduino/zephyrSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ void arduino::ZephyrSerial::begin(unsigned long baud, uint16_t conf) {
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
};

#ifdef CONFIG_PINCTRL_DYNAMIC
uart->ops.init(uart);
#endif

uart_configure(uart, &config);
uart_irq_callback_user_data_set(uart, arduino::ZephyrSerial::IrqDispatch, this);
k_sem_take(&rx.sem, K_FOREVER);
Expand Down
5 changes: 5 additions & 0 deletions cores/arduino/zephyrSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class ZephyrSerial : public HardwareSerial {
void flush();

void end() {
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
if (uart->ops.deinit) {
uart->ops.deinit(uart);
}
#endif
}

size_t write(const uint8_t *buffer, size_t size);
Expand Down
7 changes: 6 additions & 1 deletion extra/artifacts/zephyr_unoq.test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
# copy artifacts under the provided paths.

# ArduinoBLE
get_branch_tip libraries arduino-libraries/ArduinoBLE master
get_branch_tip libraries arduino-libraries/ArduinoBLE master \
examples/Central/LedControl \
examples/Central/Scan \
examples/Peripheral/Advertising/EnhancedAdvertising \
examples/Peripheral/ButtonLED \

Loading
Loading