8000 ports/zephyr: Update to Zephyr 3.2.0. by bogdanm · Pull Request #10830 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

ports/zephyr: Update to Zephyr 3.2.0. #10830

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 2 commits into from

Conversation

bogdanm
Copy link
@bogdanm bogdanm commented Feb 23, 2023

This commit updates the Zephyr port with the changes listed in https://docs.zephyrproject.org/3.2.0/releases/release-notes-3.2.html, specifically:

  • Changed #include <zephyr/zephyr.h> to #include <zephyr/kernel.h>.
  • Changed FLASH_AREA_LABEL_EXISTS(storage) to FIXED_PARTITION_EXISTS(storage).
  • Changed Bluetooth include paths from bluetooth/ to zephyr/bluetooth.

Only minimal testing was done using a Nordic nRF5340-DK board (nrf5340dk_nrf5340_cpuapp): compile, flash, run some simple Python code), but the changes are cosmetic, not functional.

The commit was also tested to work with the recent Zephyr 3.3.0 release.

@bogdanm bogdanm changed the title ports/zephyr: Update to Zephyr 3.3.0 ports/zephyr: Update to Zephyr 3.2.0 Feb 23, 2023
@bogdanm bogdanm force-pushed the zephyr-3.3.0 branch 2 times, most recently from 8a3252d to d6eeb20 Compare February 23, 2023 19:05
@bogdanm bogdanm changed the title ports/zephyr: Update to Zephyr 3.2.0 ports/zephyr: Update to Zephyr 3.2.0. Feb 23, 2023
@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
        rp2:    +0 +0.000% PICO

This commit updates the Zephyr port with the changes listed in
https://docs.zephyrproject.org/3.2.0/releases/release-notes-3.2.html,
specifically:

- Changed `#include <zephyr/zephyr.h>` to `#include <zephyr/kernel.h>`.
- Changed `FLASH_AREA_LABEL_EXISTS(storage)` to
  `FIXED_PARTITION_EXISTS(storage)`.
- Changed Bluetooth include paths from `bluetooth/` to
  `zephyr/bluetooth`.

Only minimal testing was done using a Nordic nRF5340-DK board
(`nrf5340dk_nrf5340_cpuapp`): compile, flash, run some simple Python code),
but the changes are cosmetic, not functional.

The commit was also tested to work with the recent Zephyr 3.3.0 release.
@dpgeorge
Copy link
Member

Thanks for the contribution. But see #9335 which does the same thing. There is a discussion there about naming of peripherals, maybe you know how to solve it.

@bogdanm
Copy link
Author
bogdanm commented Feb 24, 2023

Apologies, I completely missed that one :) I wil take a look at the peripheral naming discussion there.

@bogdanm
Copy link
Author
bogdanm commented Feb 27, 2023

@dpgeorge Please let me know if you like the approach that I took in the latest commit above (a964594). If so, I will extend it to all the relevant modules (it only works for machine_pin.c right now) and I will include it in the original PR if needed. For reference, this is what the new script generates (build/gen_dt_node_names.h) for the nRF5340DK board:

#ifndef MICROPY_INCLUDED_ZEPHYR_GEN_DT_NODE_NAMES_H
#define MICROPY_INCLUDED_ZEPHYR_GEN_DT_NODE_NAMES_H

struct dt_node_name_map {
    const char *const gen_name;
    const char *const actual_name;
};

static const struct dt_node_name_map dt_node_map[] = {
    {"UART_0", "uart@8000"},
    {"I2C_1", "i2c@9000"},
    {"SPI_4", "spi@a000"},
    {"GPIO_0", "gpio@842500"},
    {"GPIO_1", "gpio@842800"},
   {NULL, NULL}
};

#endif

Tested succesfully with west build -b nrf5340dk_nrf5340_cpuapp and this code:

>>> from machine import Pin
>>> LED = Pin(("GPIO_0", 28), Pin.OUT)
>>> LED.value(1)
>>> LED.value(0)

Starting with Zephyr 3.2.0, the `label` property of DT nodes was made
obsolete, which means that is no longer possible to write:

```
pin = Pin(("GPIO_1", 21), Pin.IN)
```

Instead, a much less friendly format must be used:

```
pin = Pin(("gpio@842500", 21), Pin.IN)
```

This commit adds a new script (`gen_dt_node_names.py`) which is heavily
based on [this
script](https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/dts/gen_dts_cmake.py)
and attempts to generate and map friendly names for DT nodes. For
example, a node defined like this:

```
gpio0: gpio@842500 {
...
}
```

will generate a mapping like this:

```
struct dt_node_name_map {
    const char *const gen_name;
    const char *const actual_name;
};

static const struct dt_node_name_map dt_node_map[] = {
    {"GPIO_0", "gpio@842500"}
...
}
```

The code then checks this mapping if the node name supplied by the user
does not exist and uses the actual DT name instead.
@jimmo
Copy link
Member
jimmo commented Feb 28, 2023

Thanks for this @bogdanm -- I added some comments relevant to this PR over at #10859 (comment)

@Ayush1325
Copy link
Contributor

Maybe this should be closed in favor of #9335

@dpgeorge dpgeorge closed this Sep 22, 2024
Copy link
codecov bot commented Sep 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.50%. Comparing base (8d9a7fd) to head (de5c3ca).
Report is 1750 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10830   +/-   ##
=======================================
  Coverage   98.50%   98.50%           
=======================================
  Files         155      155           
  Lines       20540    20540           
=======================================
  Hits        20232    20232           
  Misses        308      308           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0