Merge remote-tracking branch 'adafruit/main' into add-os-utime-function
This commit is contained in:
commit
de7a9c38fc
56
.github/workflows/build.yml
vendored
56
.github/workflows/build.yml
vendored
@ -30,12 +30,12 @@ jobs:
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Get CP deps
|
||||
@ -92,25 +92,25 @@ jobs:
|
||||
working-directory: tests
|
||||
- name: Build mpy-cross.static-aarch64
|
||||
run: make -C mpy-cross -j2 -f Makefile.static-aarch64
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross.static-aarch64
|
||||
path: mpy-cross/mpy-cross.static-aarch64
|
||||
- name: Build mpy-cross.static-raspbian
|
||||
run: make -C mpy-cross -j2 -f Makefile.static-raspbian
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross.static-raspbian
|
||||
path: mpy-cross/mpy-cross.static-raspbian
|
||||
- name: Build mpy-cross.static
|
||||
run: make -C mpy-cross -j2 -f Makefile.static
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross.static-amd64-linux
|
||||
path: mpy-cross/mpy-cross.static
|
||||
- name: Build mpy-cross.static-mingw
|
||||
run: make -C mpy-cross -j2 -f Makefile.static-mingw
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross.static-x64-windows
|
||||
path: mpy-cross/mpy-cross.static.exe
|
||||
@ -149,12 +149,12 @@ jobs:
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Get CP deps
|
||||
@ -174,19 +174,19 @@ jobs:
|
||||
msgfmt --version
|
||||
- name: Build mpy-cross
|
||||
run: make -C mpy-cross -j2
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross-macos-11-x64
|
||||
path: mpy-cross/mpy-cross
|
||||
- name: Build mpy-cross (arm64)
|
||||
run: make -C mpy-cross -j2 -f Makefile.m1 V=2
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross-macos-11-arm64
|
||||
path: mpy-cross/mpy-cross-arm64
|
||||
- name: Make universal binary
|
||||
run: lipo -create -output mpy-cross-macos-universal mpy-cross/mpy-cross mpy-cross/mpy-cross-arm64
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy-cross-macos-11-universal
|
||||
path: mpy-cross-macos-universal
|
||||
@ -207,7 +207,7 @@ jobs:
|
||||
needs: test
|
||||
if: ${{ needs.test.outputs.build-doc == 'True' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
@ -218,7 +218,7 @@ jobs:
|
||||
tools/describe || git log --parents HEAD~4..
|
||||
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install dependencies
|
||||
@ -229,20 +229,20 @@ jobs:
|
||||
pip install -r requirements-ci.txt -r requirements-doc.txt
|
||||
- name: Build and Validate Stubs
|
||||
run: make check-stubs -j2
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: stubs
|
||||
path: circuitpython-stubs/dist/*
|
||||
- name: Test Documentation Build (HTML)
|
||||
run: sphinx-build -E -W -b html -D version=${{ env.CP_VERSION }} -D release=${{ env.CP_VERSION }} . _build/html
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: docs
|
||||
path: _build/html
|
||||
- name: Test Documentation Build (LaTeX/PDF)
|
||||
run: |
|
||||
make latexpdf
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: docs
|
||||
path: _build/latex
|
||||
@ -276,10 +276,10 @@ jobs:
|
||||
if: ${{ needs.test.outputs.boards-arm != '[]' }}
|
||||
steps:
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
@ -306,7 +306,7 @@ jobs:
|
||||
working-directory: tools
|
||||
env:
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
@ -329,10 +329,10 @@ jobs:
|
||||
if: ${{ needs.test.outputs.boards-riscv != '[]' }}
|
||||
steps:
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
@ -358,7 +358,7 @@ jobs:
|
||||
working-directory: tools
|
||||
env:
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
@ -385,7 +385,7 @@ jobs:
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
@ -395,7 +395,7 @@ jobs:
|
||||
run: |
|
||||
tools/describe || git log --parents HEAD~4..
|
||||
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v3
|
||||
name: Fetch IDF tool cache
|
||||
id: idf-cache
|
||||
with:
|
||||
@ -449,7 +449,7 @@ jobs:
|
||||
IDF_PATH: ${{ github.workspace }}/ports/espressif/esp-idf
|
||||
IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
@ -471,10 +471,10 @@ jobs:
|
||||
if: ${{ needs.test.outputs.boards-aarch != '[]' }}
|
||||
steps:
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
@ -514,7 +514,7 @@ jobs:
|
||||
working-directory: tools
|
||||
env:
|
||||
BOARDS: ${{ matrix.board }}
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.board }}
|
||||
path: bin/${{ matrix.board }}
|
||||
|
4
.github/workflows/create_website_pr.yml
vendored
4
.github/workflows/create_website_pr.yml
vendored
@ -16,12 +16,12 @@ jobs:
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Get CP deps
|
||||
|
2
.github/workflows/ports_windows.yml
vendored
2
.github/workflows/ports_windows.yml
vendored
@ -71,7 +71,7 @@ jobs:
|
||||
which python; python --version; python -c "import cascadetoml"
|
||||
which python3; python3 --version; python3 -c "import cascadetoml"
|
||||
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
fetch-depth: 1
|
||||
|
10
.github/workflows/pre-commit.yml
vendored
10
.github/workflows/pre-commit.yml
vendored
@ -16,9 +16,9 @@ jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2.2.0
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- name: Install deps
|
||||
@ -29,17 +29,17 @@ jobs:
|
||||
run: git submodule update --init extmod/ulab
|
||||
- name: Set PY
|
||||
run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
- uses: pre-commit/action@v1.1.0
|
||||
- uses: pre-commit/action@v3.0.0
|
||||
- name: Make patch
|
||||
if: failure()
|
||||
run: git diff > ~/pre-commit.patch
|
||||
- name: Upload patch
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: patch
|
||||
path: ~/pre-commit.patch
|
||||
|
@ -225,22 +225,7 @@ STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_
|
||||
const char *old_path = mp_obj_str_get_str(path_in);
|
||||
const char *new_path = mp_obj_str_get_str(path_out);
|
||||
|
||||
// Check to see if we're moving a directory into itself. This occurs when we're moving a
|
||||
// directory where the old path is a prefix of the new and the next character is a "/" and thus
|
||||
// preserves the original directory name.
|
||||
FILINFO fno;
|
||||
FRESULT res = f_stat(&self->fatfs, old_path, &fno);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError_fresult(res);
|
||||
}
|
||||
if ((fno.fattrib & AM_DIR) != 0 &&
|
||||
strlen(new_path) > strlen(old_path) &&
|
||||
new_path[strlen(old_path)] == '/' &&
|
||||
strncmp(old_path, new_path, strlen(old_path)) == 0) {
|
||||
mp_raise_OSError(MP_EINVAL);
|
||||
}
|
||||
|
||||
res = f_rename(&self->fatfs, old_path, new_path);
|
||||
FRESULT res = f_rename(&self->fatfs, old_path, new_path);
|
||||
if (res == FR_EXIST) {
|
||||
// if new_path exists then try removing it (but only if it's a file)
|
||||
fat_vfs_remove_internal(vfs_in, path_out, 0); // 0 == file attribute
|
||||
|
@ -4816,6 +4816,21 @@ FRESULT f_rename (
|
||||
DEF_NAMBUF
|
||||
|
||||
|
||||
// Check to see if we're moving a directory into itself. This occurs when we're moving a
|
||||
// directory where the old path is a prefix of the new and the next character is a "/" and thus
|
||||
// preserves the original directory name.
|
||||
FILINFO fno;
|
||||
res = f_stat(fs, path_old, &fno);
|
||||
if (res != FR_OK) {
|
||||
return res;
|
||||
}
|
||||
if ((fno.fattrib & AM_DIR) != 0 &&
|
||||
strlen(path_new) > strlen(path_old) &&
|
||||
path_new[strlen(path_old)] == '/' &&
|
||||
strncmp(path_old, path_new, strlen(path_old)) == 0) {
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
|
||||
res = find_volume(fs, FA_WRITE); /* Get logical drive of the old object */
|
||||
if (res == FR_OK) {
|
||||
djo.obj.fs = fs;
|
||||
|
@ -65,6 +65,11 @@ msgstr "output:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c harus int atau char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2106,6 +2111,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -117,6 +117,10 @@ msgstr ""
|
||||
msgid "%q init failed"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/dualbank/__init__.c
|
||||
msgid "%q is %q"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q length must be %d"
|
||||
msgstr ""
|
||||
@ -211,7 +215,7 @@ msgstr ""
|
||||
msgid "%q, %q, and %q must all be the same length"
|
||||
msgstr ""
|
||||
|
||||
#: py/objint.c
|
||||
#: py/objint.c shared-bindings/storage/__init__.c
|
||||
msgid "%q=%q"
|
||||
msgstr ""
|
||||
|
||||
|
@ -67,6 +67,11 @@ msgstr " výstup:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c vyžaduje int nebo char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2095,6 +2100,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -66,6 +66,11 @@ msgstr " Ausgabe:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c erwartet Int oder Char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2132,6 +2137,10 @@ msgstr "UART wird wieder Initialisiert"
|
||||
msgid "UART write"
|
||||
msgstr "UART wird geschrieben"
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB beschäftigt"
|
||||
|
@ -71,6 +71,11 @@ msgstr " έξοδος:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c απαιτεί int ή char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2104,6 +2109,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -69,6 +69,11 @@ msgstr " output:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c requires int or char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2108,6 +2113,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB busy"
|
||||
|
@ -69,6 +69,11 @@ msgstr " salida:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c requiere int o char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2140,6 +2145,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB ocupado"
|
||||
|
@ -61,6 +61,11 @@ msgstr " output:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c nangangailangan ng int o char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2094,6 +2099,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -70,6 +70,11 @@ msgstr " sortie :\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c nécessite un chiffre entier 'int' ou un caractère 'char'"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2161,6 +2166,10 @@ msgstr "Ré-initialisation du UART"
|
||||
msgid "UART write"
|
||||
msgstr "Écriture UART"
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "L'USB est occupé"
|
||||
|
@ -60,6 +60,11 @@ msgstr ""
|
||||
msgid "%%c requires int or char"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2077,6 +2082,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -66,6 +66,11 @@ msgstr " output:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c necessita di int o char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2104,6 +2109,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -65,6 +65,11 @@ msgstr " 出力:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c にはintまたはcharが必要"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2090,6 +2095,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -61,6 +61,11 @@ msgstr " 산출:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c 전수(int)또는 캐릭터(char)필요합니다"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2080,6 +2085,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -63,6 +63,11 @@ msgstr " uitvoer:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c vereist een int of char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2101,6 +2106,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -65,6 +65,11 @@ msgstr " wyjście:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c wymaga int lub char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2088,6 +2093,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -67,6 +67,11 @@ msgstr " saída:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c requer int ou char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2146,6 +2151,10 @@ msgstr "Reinicialização do UART"
|
||||
msgid "UART write"
|
||||
msgstr "Escrita UART"
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB ocupado"
|
||||
|
@ -68,6 +68,11 @@ msgstr " вывод:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c требует int или char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2126,6 +2131,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -67,6 +67,11 @@ msgstr " utdata:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c kräver int eller char"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2122,6 +2127,10 @@ msgstr "UART omstart"
|
||||
msgid "UART write"
|
||||
msgstr "UART-skrivning"
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB upptaget"
|
||||
|
52
locale/tr.po
52
locale/tr.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2022-08-29 18:20+0000\n"
|
||||
"PO-Revision-Date: 2022-10-10 18:23+0000\n"
|
||||
"Last-Translator: Boran Roni <boranroniurtekin@gmail.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: tr\n"
|
||||
@ -15,7 +15,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.14.1-dev\n"
|
||||
"X-Generator: Weblate 4.14.1\n"
|
||||
|
||||
#: main.c
|
||||
msgid ""
|
||||
@ -70,6 +70,11 @@ msgstr " çıktı:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c int veya char tipine ihtiyaç duyar"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -167,7 +172,7 @@ msgstr "%q >= %d olmalıdır"
|
||||
#: shared-bindings/analogbufio/BufferedIn.c
|
||||
#: shared-bindings/audiocore/RawSample.c
|
||||
msgid "%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"
|
||||
msgstr ""
|
||||
msgstr "%q 'h', 'H', 'b' yada 'B' tipi bir bytearray /array olmalı"
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must be a string"
|
||||
@ -375,7 +380,7 @@ msgstr "fonksiyon dışında 'yield'"
|
||||
|
||||
#: py/compile.c
|
||||
msgid "*x must be assignment target"
|
||||
msgstr ""
|
||||
msgstr "*x atama hedefi olmalıdır"
|
||||
|
||||
#: py/obj.c
|
||||
msgid ", in %q\n"
|
||||
@ -486,7 +491,7 @@ msgstr "Halihazırda duyuruluyor."
|
||||
|
||||
#: ports/atmel-samd/common-hal/canio/Listener.c
|
||||
msgid "Already have all-matches listener"
|
||||
msgstr ""
|
||||
msgstr "Tüm eşleşmelerle eşleşen dinleyiciniz var"
|
||||
|
||||
#: shared-module/memorymonitor/AllocationAlarm.c
|
||||
#: shared-module/memorymonitor/AllocationSize.c
|
||||
@ -605,15 +610,15 @@ msgstr "Parlaklık ayarlanabilir değil"
|
||||
#: shared-bindings/_bleio/UUID.c
|
||||
#, c-format
|
||||
msgid "Buffer + offset too small %d %d %d"
|
||||
msgstr ""
|
||||
msgstr "Buffer + offset çok küçük %d %d %d"
|
||||
|
||||
#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
|
||||
msgid "Buffer elements must be 4 bytes long or less"
|
||||
msgstr ""
|
||||
msgstr "Buffer elementleri 4 bit olmak zorunda"
|
||||
|
||||
#: shared-bindings/framebufferio/FramebufferDisplay.c
|
||||
msgid "Buffer is not a bytearray."
|
||||
msgstr "Arabellek bayt dizisi değil"
|
||||
msgstr "Buffer bir bytearray değil."
|
||||
|
||||
#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c
|
||||
#: shared-bindings/framebufferio/FramebufferDisplay.c
|
||||
@ -632,12 +637,12 @@ msgstr "Arabellek boyutu 512'nin katı olmalı"
|
||||
|
||||
#: ports/stm/common-hal/sdioio/SDCard.c shared-bindings/floppyio/__init__.c
|
||||
msgid "Buffer must be a multiple of 512 bytes"
|
||||
msgstr ""
|
||||
msgstr "Buffer 512 bitin katı olmalı"
|
||||
|
||||
#: shared-bindings/_bleio/PacketBuffer.c
|
||||
#, c-format
|
||||
msgid "Buffer too short by %d bytes"
|
||||
msgstr ""
|
||||
msgstr "Buffer bitten %d daha az"
|
||||
|
||||
#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c
|
||||
msgid "Buffers must be same size"
|
||||
@ -653,7 +658,7 @@ msgstr "Veriyolu pini %d kullanımda"
|
||||
|
||||
#: shared-bindings/_bleio/UUID.c
|
||||
msgid "Byte buffer must be 16 bytes."
|
||||
msgstr ""
|
||||
msgstr "Bit buffer'ı 16bit olmalı."
|
||||
|
||||
#: shared-bindings/aesio/aes.c
|
||||
msgid "CBC blocks must be multiples of 16 bytes"
|
||||
@ -661,11 +666,11 @@ msgstr "CBC blokları 16 baytın katları şeklinde olmalı"
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "CIRCUITPY drive could not be found or created."
|
||||
msgstr "CIRCUITPY sürücüsü bulunamadı veya oluşturulamadı"
|
||||
msgstr "CIRCUITPY sürücüsü bulunamadı veya oluşturulamadı."
|
||||
|
||||
#: ports/espressif/common-hal/espidf/__init__.c ports/espressif/esp_error.c
|
||||
msgid "CRC or checksum was invalid"
|
||||
msgstr ""
|
||||
msgstr "CRC yada checksum geçersiz"
|
||||
|
||||
#: py/objtype.c
|
||||
msgid "Call super().__init__() before accessing native object."
|
||||
@ -712,15 +717,16 @@ msgstr "Değerler silinemez"
|
||||
#: ports/nrf/common-hal/digitalio/DigitalInOut.c
|
||||
#: ports/raspberrypi/common-hal/digitalio/DigitalInOut.c
|
||||
msgid "Cannot get pull while in output mode"
|
||||
msgstr ""
|
||||
msgstr "Çıkış modundayken çekme alınamıyor"
|
||||
|
||||
#: ports/nrf/common-hal/microcontroller/Processor.c
|
||||
msgid "Cannot get temperature"
|
||||
msgstr ""
|
||||
msgstr "Isı okunamadı"
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
#, fuzzy
|
||||
msgid "Cannot have scan responses for extended, connectable advertisements."
|
||||
msgstr ""
|
||||
msgstr "Genişletilmiş, bağlanabilir reklamlar için tarama yanıtları yapılamaz."
|
||||
|
||||
#: ports/espressif/common-hal/alarm/pin/PinAlarm.c
|
||||
msgid "Cannot pull on input-only pin."
|
||||
@ -779,7 +785,7 @@ msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "CircuitPython core code crashed hard. Whoops!\n"
|
||||
msgstr ""
|
||||
msgstr "CircuitPython kor kodu patladı. Haydaaa!\n"
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "CircuitPython was unable to allocate the heap."
|
||||
@ -791,17 +797,17 @@ msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Clock unit in use"
|
||||
msgstr ""
|
||||
msgstr "Saat ünitesi kullanımda"
|
||||
|
||||
#: shared-bindings/_bleio/Connection.c
|
||||
msgid ""
|
||||
"Connection has been disconnected and can no longer be used. Create a new "
|
||||
"connection."
|
||||
msgstr ""
|
||||
msgstr "Bağlantı koparıldı ve tekrar kullanılamaz. Yeni bir bağlantı kurun."
|
||||
|
||||
#: py/persistentcode.c
|
||||
msgid "Corrupt .mpy file"
|
||||
msgstr ""
|
||||
msgstr "Bozuk .mpy dosyası"
|
||||
|
||||
#: ports/espressif/common-hal/neopixel_write/__init__.c
|
||||
msgid "Could not retrieve clock"
|
||||
@ -813,7 +819,7 @@ msgstr ""
|
||||
|
||||
#: shared-bindings/pwmio/PWMOut.c
|
||||
msgid "Could not start PWM"
|
||||
msgstr ""
|
||||
msgstr "PWM başlatılamadı"
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Could not start interrupt, RX busy"
|
||||
@ -2096,6 +2102,10 @@ msgstr ""
|
||||
msgid "UART write"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr ""
|
||||
|
@ -69,6 +69,11 @@ msgstr " shūchū:\n"
|
||||
msgid "%%c requires int or char"
|
||||
msgstr "%%c xūyào zhěngshù huòzhě zìfú"
|
||||
|
||||
#: main.c
|
||||
#, c-format
|
||||
msgid "%02X"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -2125,6 +2130,10 @@ msgstr "UART chóngxīn qǐdòng"
|
||||
msgid "UART write"
|
||||
msgstr "UART xiě rù"
|
||||
|
||||
#: main.c
|
||||
msgid "UID:"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/usb_hid/Device.c
|
||||
msgid "USB busy"
|
||||
msgstr "USB fán máng"
|
||||
|
@ -73,46 +73,37 @@
|
||||
#include "peripheral_clk_config.h"
|
||||
|
||||
#define ADC_TEMP_SAMPLE_LENGTH 4
|
||||
#define INT1V_VALUE_FLOAT 1.0
|
||||
#define INT1V_DIVIDER_1000 1000.0
|
||||
#define ADC_12BIT_FULL_SCALE_VALUE_FLOAT 4095.0
|
||||
#define INT1V_VALUE_FLOAT MICROPY_FLOAT_CONST(1.0)
|
||||
#define INT1V_DIVIDER_1000 MICROPY_FLOAT_CONST(1000.0)
|
||||
#define ADC_12BIT_FULL_SCALE_VALUE_FLOAT MICROPY_FLOAT_CONST(4095.0)
|
||||
|
||||
// channel argument (ignored in calls below)
|
||||
#define IGNORED_CHANNEL 0
|
||||
|
||||
// Decimal to fraction conversion. (adapted from ASF sample).
|
||||
STATIC float convert_dec_to_frac(uint8_t val) {
|
||||
float float_val = (float)val;
|
||||
if (val < 10) {
|
||||
return float_val / 10.0;
|
||||
} else if (val < 100) {
|
||||
return float_val / 100.0;
|
||||
} else {
|
||||
return float_val / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Extract the production calibration data information from NVM (adapted from ASF sample),
|
||||
// then calculate the temperature
|
||||
//
|
||||
// This code performs almost all operations with scaled integers. For
|
||||
// instance, tempR is in units of 1/10°C, INT1VR is in units of 1mV, etc,
|
||||
// This is important to reduce the code size of the function. The effect on
|
||||
// precision is a ~.9°C difference vs the floating point algorithm on an
|
||||
// approximate 0..60°C range with a difference of ~.5°C at 25°C. When the fine
|
||||
// calculation step is skipped, the additional error approximately doubles.
|
||||
//
|
||||
// To save code size, rounding is neglected. However, trying to add back rounding
|
||||
// (by computing (a + b/2) / b instead of just a / b) actually didn't help
|
||||
// accuracy anyway.
|
||||
#ifdef SAMD21
|
||||
STATIC float calculate_temperature(uint16_t raw_value) {
|
||||
volatile uint32_t val1; /* Temperature Log Row Content first 32 bits */
|
||||
volatile uint32_t val2; /* Temperature Log Row Content another 32 bits */
|
||||
uint8_t room_temp_val_int; /* Integer part of room temperature in °C */
|
||||
uint8_t room_temp_val_dec; /* Decimal part of room temperature in °C */
|
||||
uint8_t hot_temp_val_int; /* Integer part of hot temperature in °C */
|
||||
uint8_t hot_temp_val_dec; /* Decimal part of hot temperature in °C */
|
||||
int8_t room_int1v_val; /* internal 1V reference drift at room temperature */
|
||||
int8_t hot_int1v_val; /* internal 1V reference drift at hot temperature*/
|
||||
|
||||
float tempR; // Production Room temperature
|
||||
float tempH; // Production Hot temperature
|
||||
float INT1VR; // Room temp 2's complement of the internal 1V reference value
|
||||
float INT1VH; // Hot temp 2's complement of the internal 1V reference value
|
||||
uint16_t ADCR; // Production Room temperature ADC value
|
||||
uint16_t ADCH; // Production Hot temperature ADC value
|
||||
float VADCR; // Room temperature ADC voltage
|
||||
float VADCH; // Hot temperature ADC voltage
|
||||
uint32_t val1; /* Temperature Log Row Content first 32 bits */
|
||||
uint32_t val2; /* Temperature Log Row Content another 32 bits */
|
||||
int room_temp_val_int; /* Integer part of room temperature in °C */
|
||||
int room_temp_val_dec; /* Decimal part of room temperature in °C */
|
||||
int hot_temp_val_int; /* Integer part of hot temperature in °C */
|
||||
int hot_temp_val_dec; /* Decimal part of hot temperature in °C */
|
||||
int room_int1v_val; /* internal 1V reference drift at room temperature */
|
||||
int hot_int1v_val; /* internal 1V reference drift at hot temperature*/
|
||||
|
||||
uint32_t *temp_log_row_ptr = (uint32_t *)NVMCTRL_TEMP_LOG;
|
||||
|
||||
@ -120,32 +111,29 @@ STATIC float calculate_temperature(uint16_t raw_value) {
|
||||
temp_log_row_ptr++;
|
||||
val2 = *temp_log_row_ptr;
|
||||
|
||||
room_temp_val_int = (uint8_t)((val1 & FUSES_ROOM_TEMP_VAL_INT_Msk) >> FUSES_ROOM_TEMP_VAL_INT_Pos);
|
||||
room_temp_val_dec = (uint8_t)((val1 & FUSES_ROOM_TEMP_VAL_DEC_Msk) >> FUSES_ROOM_TEMP_VAL_DEC_Pos);
|
||||
room_temp_val_int = ((val1 & FUSES_ROOM_TEMP_VAL_INT_Msk) >> FUSES_ROOM_TEMP_VAL_INT_Pos);
|
||||
room_temp_val_dec = ((val1 & FUSES_ROOM_TEMP_VAL_DEC_Msk) >> FUSES_ROOM_TEMP_VAL_DEC_Pos);
|
||||
|
||||
hot_temp_val_int = (uint8_t)((val1 & FUSES_HOT_TEMP_VAL_INT_Msk) >> FUSES_HOT_TEMP_VAL_INT_Pos);
|
||||
hot_temp_val_dec = (uint8_t)((val1 & FUSES_HOT_TEMP_VAL_DEC_Msk) >> FUSES_HOT_TEMP_VAL_DEC_Pos);
|
||||
hot_temp_val_int = ((val1 & FUSES_HOT_TEMP_VAL_INT_Msk) >> FUSES_HOT_TEMP_VAL_INT_Pos);
|
||||
hot_temp_val_dec = ((val1 & FUSES_HOT_TEMP_VAL_DEC_Msk) >> FUSES_HOT_TEMP_VAL_DEC_Pos);
|
||||
|
||||
// necessary casts: must interpret 8 bits as signed
|
||||
room_int1v_val = (int8_t)((val1 & FUSES_ROOM_INT1V_VAL_Msk) >> FUSES_ROOM_INT1V_VAL_Pos);
|
||||
hot_int1v_val = (int8_t)((val2 & FUSES_HOT_INT1V_VAL_Msk) >> FUSES_HOT_INT1V_VAL_Pos);
|
||||
|
||||
ADCR = (uint16_t)((val2 & FUSES_ROOM_ADC_VAL_Msk) >> FUSES_ROOM_ADC_VAL_Pos);
|
||||
ADCH = (uint16_t)((val2 & FUSES_HOT_ADC_VAL_Msk) >> FUSES_HOT_ADC_VAL_Pos);
|
||||
int ADCR = ((val2 & FUSES_ROOM_ADC_VAL_Msk) >> FUSES_ROOM_ADC_VAL_Pos);
|
||||
int ADCH = ((val2 & FUSES_HOT_ADC_VAL_Msk) >> FUSES_HOT_ADC_VAL_Pos);
|
||||
|
||||
tempR = room_temp_val_int + convert_dec_to_frac(room_temp_val_dec);
|
||||
tempH = hot_temp_val_int + convert_dec_to_frac(hot_temp_val_dec);
|
||||
int tempR = 10 * room_temp_val_int + room_temp_val_dec;
|
||||
int tempH = 10 * hot_temp_val_int + hot_temp_val_dec;
|
||||
|
||||
INT1VR = 1 - ((float)room_int1v_val / INT1V_DIVIDER_1000);
|
||||
INT1VH = 1 - ((float)hot_int1v_val / INT1V_DIVIDER_1000);
|
||||
int INT1VR = 1000 - room_int1v_val;
|
||||
int INT1VH = 1000 - hot_int1v_val;
|
||||
|
||||
VADCR = ((float)ADCR * INT1VR) / ADC_12BIT_FULL_SCALE_VALUE_FLOAT;
|
||||
VADCH = ((float)ADCH * INT1VH) / ADC_12BIT_FULL_SCALE_VALUE_FLOAT;
|
||||
int VADCR = ADCR * INT1VR;
|
||||
int VADCH = ADCH * INT1VH;
|
||||
|
||||
float VADC; /* Voltage calculation using ADC result for Coarse Temp calculation */
|
||||
float VADCM; /* Voltage calculation using ADC result for Fine Temp calculation. */
|
||||
float INT1VM; /* Voltage calculation for reality INT1V value during the ADC conversion */
|
||||
|
||||
VADC = ((float)raw_value * INT1V_VALUE_FLOAT) / ADC_12BIT_FULL_SCALE_VALUE_FLOAT;
|
||||
int VADC = raw_value * 1000;
|
||||
|
||||
// Hopefully compiler will remove common subepxressions here.
|
||||
|
||||
@ -153,21 +141,31 @@ STATIC float calculate_temperature(uint16_t raw_value) {
|
||||
// 1b as mentioned in data sheet section "Temperature Sensor Characteristics"
|
||||
// of Electrical Characteristics. (adapted from ASF sample code).
|
||||
// Coarse Temp Calculation by assume INT1V=1V for this ADC conversion
|
||||
float coarse_temp = tempR + (((tempH - tempR) / (VADCH - VADCR)) * (VADC - VADCR));
|
||||
int coarse_temp = tempR + (tempH - tempR) * (VADC - VADCR) / (VADCH - VADCR);
|
||||
|
||||
#if CIRCUITPY_FULL_BUILD
|
||||
// Calculation to find the real INT1V value during the ADC conversion
|
||||
int INT1VM; /* Voltage calculation for reality INT1V value during the ADC conversion */
|
||||
|
||||
INT1VM = INT1VR + (((INT1VH - INT1VR) * (coarse_temp - tempR)) / (tempH - tempR));
|
||||
|
||||
VADCM = ((float)raw_value * INT1VM) / ADC_12BIT_FULL_SCALE_VALUE_FLOAT;
|
||||
int VADCM = raw_value * INT1VM;
|
||||
|
||||
// Fine Temp Calculation by replace INT1V=1V by INT1V = INT1Vm for ADC conversion
|
||||
float fine_temp = tempR + (((tempH - tempR) / (VADCH - VADCR)) * (VADCM - VADCR));
|
||||
float fine_temp = tempR + (((tempH - tempR) * (VADCM - VADCR)) / (VADCH - VADCR));
|
||||
|
||||
return fine_temp;
|
||||
return fine_temp / 10;
|
||||
#else
|
||||
return coarse_temp / 10.;
|
||||
#endif
|
||||
}
|
||||
#endif // SAMD21
|
||||
|
||||
#ifdef SAM_D5X_E5X
|
||||
// Decimal to fraction conversion. (adapted from ASF sample).
|
||||
STATIC float convert_dec_to_frac(uint8_t val) {
|
||||
return val / MICROPY_FLOAT_CONST(10.);
|
||||
}
|
||||
STATIC float calculate_temperature(uint16_t TP, uint16_t TC) {
|
||||
uint32_t TLI = (*(uint32_t *)FUSES_ROOM_TEMP_VAL_INT_ADDR & FUSES_ROOM_TEMP_VAL_INT_Msk) >> FUSES_ROOM_TEMP_VAL_INT_Pos;
|
||||
uint32_t TLD = (*(uint32_t *)FUSES_ROOM_TEMP_VAL_DEC_ADDR & FUSES_ROOM_TEMP_VAL_DEC_Msk) >> FUSES_ROOM_TEMP_VAL_DEC_Pos;
|
||||
|
39
ports/espressif/boards/bpi_picow_s3/board.c
Normal file
39
ports/espressif/boards/bpi_picow_s3/board.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
void board_init(void) {
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO43);
|
||||
common_hal_never_reset_pin(&pin_GPIO44);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
37
ports/espressif/boards/bpi_picow_s3/mpconfigboard.h
Normal file
37
ports/espressif/boards/bpi_picow_s3/mpconfigboard.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "BPI-PicoW-S3"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S3"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO48)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
|
||||
|
||||
#define DOUBLE_TAP_PIN (&pin_GPIO34)
|
20
ports/espressif/boards/bpi_picow_s3/mpconfigboard.mk
Normal file
20
ports/espressif/boards/bpi_picow_s3/mpconfigboard.mk
Normal file
@ -0,0 +1,20 @@
|
||||
USB_VID = 0x303A
|
||||
USB_PID = 0x812C
|
||||
USB_PRODUCT = "BPI-PicoW-S3"
|
||||
USB_MANUFACTURER = "BananaPi"
|
||||
|
||||
IDF_TARGET = esp32s3
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# The default queue depth of 16 overflows on release builds,
|
||||
# so increase it to 32.
|
||||
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 80m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 8MB
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
58
ports/espressif/boards/bpi_picow_s3/pins.c
Normal file
58
ports/espressif/boards/bpi_picow_s3/pins.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO47) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO38) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO39) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO7) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO46) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO46) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO8) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO9) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO10) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP29_A3), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO11) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
47
ports/espressif/boards/bpi_picow_s3/sdkconfig
Normal file
47
ports/espressif/boards/bpi_picow_s3/sdkconfig
Normal file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# Component config
|
||||
#
|
||||
#
|
||||
# ESP32S3-Specific
|
||||
#
|
||||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
CONFIG_SPIRAM_MODE_QUAD=y
|
||||
# CONFIG_SPIRAM_MODE_OCT is not set
|
||||
# CONFIG_SPIRAM_TYPE_AUTO is not set
|
||||
CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
|
||||
CONFIG_SPIRAM_SIZE=2097152
|
||||
#
|
||||
# PSRAM Clock and CS IO for ESP32S3
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM Clock and CS IO for ESP32S3
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
# CONFIG_SPIRAM_SPEED_120M is not set
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_SPIRAM_SPEED_40M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
# end of SPI RAM config
|
||||
|
||||
# end of ESP32S3-Specific
|
||||
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="BPI-PicoW-S3"
|
||||
# end of LWIP
|
||||
|
||||
# end of Component config
|
@ -32,6 +32,8 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_ota_ops.h"
|
||||
|
||||
#include "supervisor/flash.h"
|
||||
|
||||
static const esp_partition_t *update_partition = NULL;
|
||||
static esp_ota_handle_t update_handle = 0;
|
||||
|
||||
|
@ -87,3 +87,10 @@ bool common_hal_ssl_sslcontext_get_check_hostname(ssl_sslcontext_obj_t *self) {
|
||||
void common_hal_ssl_sslcontext_set_check_hostname(ssl_sslcontext_obj_t *self, bool value) {
|
||||
self->ssl_config.skip_common_name = !value;
|
||||
}
|
||||
|
||||
void common_hal_ssl_sslcontext_load_cert_chain(ssl_sslcontext_obj_t *self, mp_buffer_info_t *cert_buf, mp_buffer_info_t *key_buf) {
|
||||
self->ssl_config.clientcert_buf = cert_buf->buf;
|
||||
self->ssl_config.clientcert_bytes = cert_buf->len + 1;
|
||||
self->ssl_config.clientkey_buf = key_buf->buf;
|
||||
self->ssl_config.clientkey_bytes = key_buf->len + 1;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/internal_flash.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@ -32,27 +33,52 @@
|
||||
|
||||
#include "extmod/vfs.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "lib/oofatfs/ff.h"
|
||||
|
||||
#include "components/spi_flash/include/esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_partition.h"
|
||||
|
||||
#include "supervisor/filesystem.h"
|
||||
#include "supervisor/flash.h"
|
||||
#include "supervisor/usb.h"
|
||||
|
||||
STATIC const esp_partition_t *_partition;
|
||||
#define OP_READ 0
|
||||
#define OP_WRITE 1
|
||||
|
||||
// TODO: Split the caching out of supervisor/shared/external_flash so we can use it.
|
||||
#define SECTOR_SIZE 4096
|
||||
STATIC uint8_t _cache[SECTOR_SIZE];
|
||||
STATIC uint32_t _cache_lba = 0xffffffff;
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
#if FF_MAX_SS == FF_MIN_SS
|
||||
#define SECSIZE(fs) (FF_MIN_SS)
|
||||
#else
|
||||
#define SECSIZE(fs) ((fs)->ssize)
|
||||
#endif // FF_MAX_SS == FF_MIN_SS
|
||||
STATIC DWORD fatfs_bytes(void) {
|
||||
FATFS *fatfs = filesystem_circuitpy();
|
||||
return (fatfs->csize * SECSIZE(fatfs)) * (fatfs->n_fatent - 2);
|
||||
}
|
||||
STATIC bool storage_extended = true;
|
||||
STATIC const esp_partition_t *_partition[2];
|
||||
#else
|
||||
STATIC const esp_partition_t *_partition[1];
|
||||
#endif // CIRCUITPY_STORAGE_EXTEND
|
||||
|
||||
void supervisor_flash_init(void) {
|
||||
_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
|
||||
if (_partition[0] != NULL) {
|
||||
return;
|
||||
}
|
||||
_partition[0] = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
|
||||
ESP_PARTITION_SUBTYPE_DATA_FAT,
|
||||
NULL);
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
_partition[1] = esp_ota_get_next_update_partition(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t supervisor_flash_get_block_size(void) {
|
||||
@ -60,19 +86,61 @@ uint32_t supervisor_flash_get_block_size(void) {
|
||||
}
|
||||
|
||||
uint32_t supervisor_flash_get_block_count(void) {
|
||||
return _partition->size / FILESYSTEM_BLOCK_SIZE;
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
return ((storage_extended) ? (_partition[0]->size + _partition[1]->size) : _partition[0]->size) / FILESYSTEM_BLOCK_SIZE;
|
||||
#else
|
||||
return _partition[0]->size / FILESYSTEM_BLOCK_SIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void port_internal_flash_flush(void) {
|
||||
|
||||
}
|
||||
|
||||
STATIC void single_partition_rw(const esp_partition_t *partition, uint8_t *data,
|
||||
const uint32_t offset, const uint32_t size_total, const bool op) {
|
||||
if (op == OP_READ) {
|
||||
esp_partition_read(partition, offset, data, size_total);
|
||||
} else {
|
||||
esp_partition_erase_range(partition, offset, size_total);
|
||||
esp_partition_write(partition, offset, _cache, size_total);
|
||||
}
|
||||
}
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
STATIC void multi_partition_rw(uint8_t *data,
|
||||
const uint32_t offset, const uint32_t size_total, const bool op) {
|
||||
if (offset > _partition[0]->size) {
|
||||
// only r/w partition 1
|
||||
single_partition_rw(_partition[1], data, (offset - _partition[0]->size), size_total, op);
|
||||
} else if ((offset + size_total) > _partition[0]->size) {
|
||||
// first r/w partition 0, then partition 1
|
||||
uint32_t size_0 = _partition[0]->size - offset;
|
||||
uint32_t size_1 = size_total - size_0;
|
||||
if (op == OP_READ) {
|
||||
esp_partition_read(_partition[0], offset, data, size_0);
|
||||
esp_partition_read(_partition[1], 0, (data + size_0), size_1);
|
||||
} else {
|
||||
esp_partition_erase_range(_partition[0], offset, size_0);
|
||||
esp_partition_write(_partition[0], offset, _cache, size_0);
|
||||
esp_partition_erase_range(_partition[1], 0, size_1);
|
||||
esp_partition_write(_partition[1], 0, (_cache + size_0), size_1);
|
||||
}
|
||||
} else {
|
||||
// only r/w partition 0
|
||||
single_partition_rw(_partition[0], data, offset, size_total, op);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
|
||||
esp_partition_read(_partition,
|
||||
block * FILESYSTEM_BLOCK_SIZE,
|
||||
dest,
|
||||
num_blocks * FILESYSTEM_BLOCK_SIZE);
|
||||
return 0;
|
||||
const uint32_t offset = block * FILESYSTEM_BLOCK_SIZE;
|
||||
const uint32_t read_total = num_blocks * FILESYSTEM_BLOCK_SIZE;
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
multi_partition_rw(dest, offset, read_total, OP_READ);
|
||||
#else
|
||||
single_partition_rw(_partition[0], dest, offset, read_total, OP_READ);
|
||||
#endif
|
||||
return 0; // success
|
||||
}
|
||||
|
||||
mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks) {
|
||||
@ -82,12 +150,8 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
|
||||
uint32_t block_address = lba + block;
|
||||
uint32_t sector_offset = block_address / blocks_per_sector * SECTOR_SIZE;
|
||||
uint8_t block_offset = block_address % blocks_per_sector;
|
||||
|
||||
if (_cache_lba != block_address) {
|
||||
esp_partition_read(_partition,
|
||||
sector_offset,
|
||||
_cache,
|
||||
SECTOR_SIZE);
|
||||
supervisor_flash_read_blocks(_cache, sector_offset / FILESYSTEM_BLOCK_SIZE, blocks_per_sector);
|
||||
_cache_lba = sector_offset;
|
||||
}
|
||||
for (uint8_t b = block_offset; b < blocks_per_sector; b++) {
|
||||
@ -100,15 +164,34 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
|
||||
FILESYSTEM_BLOCK_SIZE);
|
||||
block++;
|
||||
}
|
||||
esp_partition_erase_range(_partition, sector_offset, SECTOR_SIZE);
|
||||
esp_partition_write(_partition,
|
||||
sector_offset,
|
||||
_cache,
|
||||
SECTOR_SIZE);
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
multi_partition_rw(_cache, sector_offset, SECTOR_SIZE, OP_WRITE);
|
||||
#else
|
||||
single_partition_rw(_partition[0], _cache, sector_offset, SECTOR_SIZE, OP_READ);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0; // success
|
||||
}
|
||||
|
||||
void supervisor_flash_release_cache(void) {
|
||||
}
|
||||
|
||||
void supervisor_flash_set_extended(bool extended) {
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
storage_extended = extended;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool supervisor_flash_get_extended(void) {
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
return storage_extended;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void supervisor_flash_update_extended(void) {
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
storage_extended = (_partition[0]->size < fatfs_bytes());
|
||||
#endif
|
||||
}
|
||||
|
29
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/board.c
Normal file
29
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/board.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2022 Fabian Affolter <fabian@affolter-engineering.ch>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
|
||||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
@ -0,0 +1,4 @@
|
||||
#define MICROPY_HW_BOARD_NAME "VCC-GND Studio YD RP2040"
|
||||
#define MICROPY_HW_MCU_NAME "rp2040"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO23)
|
11
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/mpconfigboard.mk
Normal file
11
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/mpconfigboard.mk
Normal file
@ -0,0 +1,11 @@
|
||||
USB_VID = 0x2E8A
|
||||
USB_PID = 0x102E
|
||||
USB_PRODUCT = "YD-RP2040"
|
||||
USB_MANUFACTURER = "VCC-GND Studio"
|
||||
|
||||
CHIP_VARIANT = RP2040
|
||||
CHIP_FAMILY = rp2
|
||||
|
||||
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ,W25Q32JVxQ,W25Q128JVxQ"
|
||||
|
||||
CIRCUITPY__EVE = 1
|
@ -0,0 +1 @@
|
||||
// Put board-specific pico-sdk definitions here. This file must exist.
|
56
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/pins.c
Normal file
56
ports/raspberrypi/boards/vcc_gnd_yd_rp2040/pins.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP29_A3), MP_ROM_PTR(&pin_GPIO29) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_RGB), MP_ROM_PTR(&pin_GPIO23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO24) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) },
|
||||
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
@ -821,6 +821,16 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
|
||||
|
||||
MICROPY_PY_LWIP_EXIT
|
||||
|
||||
DEBUG_printf("registering socket in socketpool_socket_accept()\n");
|
||||
if (!register_open_socket(socket2)) {
|
||||
DEBUG_printf("collecting garbage to open socket\n");
|
||||
gc_collect();
|
||||
if (!register_open_socket(socket2)) {
|
||||
mp_raise_RuntimeError(translate("Out of sockets"));
|
||||
}
|
||||
}
|
||||
mark_user_socket(socket2);
|
||||
|
||||
// output values
|
||||
memcpy(ip, &(socket2->pcb.tcp->remote_ip), NETUTILS_IPV4ADDR_BUFSIZE);
|
||||
*port = (mp_uint_t)socket2->pcb.tcp->remote_port;
|
||||
@ -1070,6 +1080,9 @@ int socketpool_socket_recv_into(socketpool_socket_obj_t *socket,
|
||||
ret = lwip_raw_udp_receive(socket, (byte *)buf, len, NULL, NULL, &_errno);
|
||||
break;
|
||||
}
|
||||
if (ret < 0) {
|
||||
return -_errno;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,10 @@ void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t *self) {
|
||||
|
||||
void common_hal_ssl_sslcontext_load_verify_locations(ssl_sslcontext_obj_t *self,
|
||||
const char *cadata) {
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
|
||||
// self->crt_bundle_attach = NULL;
|
||||
// self->use_global_ca_store = false;
|
||||
// self->cacert_buf = (const unsigned char *)cadata;
|
||||
// self->cacert_bytes = strlen(cadata) + 1;
|
||||
self->crt_bundle_attach = NULL;
|
||||
self->use_global_ca_store = false;
|
||||
self->cacert_buf = (const unsigned char *)cadata;
|
||||
self->cacert_bytes = *cadata ? strlen(cadata) + 1 : 0;
|
||||
}
|
||||
|
||||
void common_hal_ssl_sslcontext_set_default_verify_paths(ssl_sslcontext_obj_t *self) {
|
||||
@ -61,3 +59,8 @@ bool common_hal_ssl_sslcontext_get_check_hostname(ssl_sslcontext_obj_t *self) {
|
||||
void common_hal_ssl_sslcontext_set_check_hostname(ssl_sslcontext_obj_t *self, bool value) {
|
||||
self->check_name = value;
|
||||
}
|
||||
|
||||
void common_hal_ssl_sslcontext_load_cert_chain(ssl_sslcontext_obj_t *self, mp_buffer_info_t *cert_buf, mp_buffer_info_t *key_buf) {
|
||||
self->cert_buf = *cert_buf;
|
||||
self->key_buf = *key_buf;
|
||||
}
|
||||
|
@ -36,4 +36,5 @@ typedef struct {
|
||||
const unsigned char *cacert_buf;
|
||||
size_t cacert_bytes;
|
||||
int (*crt_bundle_attach)(mbedtls_ssl_config *conf);
|
||||
mp_buffer_info_t cert_buf, key_buf;
|
||||
} ssl_sslcontext_obj_t;
|
||||
|
@ -100,7 +100,7 @@ STATIC int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) {
|
||||
mp_obj_t sock = *(mp_obj_t *)ctx;
|
||||
|
||||
// mp_uint_t out_sz = sock_stream->write(sock, buf, len, &err);
|
||||
mp_int_t out_sz = common_hal_socketpool_socket_send(sock, buf, len);
|
||||
mp_int_t out_sz = socketpool_socket_send(sock, buf, len);
|
||||
DEBUG("socket_send() -> %d", out_sz);
|
||||
if (out_sz < 0) {
|
||||
int err = -out_sz;
|
||||
@ -118,7 +118,7 @@ STATIC int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) {
|
||||
STATIC int _mbedtls_ssl_recv(void *ctx, byte *buf, size_t len) {
|
||||
mp_obj_t sock = *(mp_obj_t *)ctx;
|
||||
|
||||
mp_int_t out_sz = common_hal_socketpool_socket_recv_into(sock, buf, len);
|
||||
mp_int_t out_sz = socketpool_socket_recv_into(sock, buf, len);
|
||||
DEBUG("socket_recv() -> %d", out_sz);
|
||||
if (out_sz < 0) {
|
||||
int err = -out_sz;
|
||||
@ -174,7 +174,14 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t
|
||||
if (self->crt_bundle_attach != NULL) {
|
||||
mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
|
||||
self->crt_bundle_attach(&o->conf);
|
||||
// } else if(self->cacert_buf && self->cacert_bytes) { // TODO: user bundle
|
||||
} else if (self->cacert_buf && self->cacert_bytes) {
|
||||
ret = mbedtls_x509_crt_parse(&o->cacert, self->cacert_buf, self->cacert_bytes);
|
||||
if (ret != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
|
||||
mbedtls_ssl_conf_ca_chain(&o->conf, &o->cacert, NULL);
|
||||
|
||||
} else {
|
||||
mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_NONE);
|
||||
}
|
||||
@ -197,6 +204,21 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t
|
||||
|
||||
mbedtls_ssl_set_bio(&o->ssl, &o->sock, _mbedtls_ssl_send, _mbedtls_ssl_recv, NULL);
|
||||
|
||||
if (self->cert_buf.buf != NULL) {
|
||||
ret = mbedtls_pk_parse_key(&o->pkey, self->key_buf.buf, self->key_buf.len + 1, NULL, 0);
|
||||
if (ret != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
ret = mbedtls_x509_crt_parse(&o->cert, self->cert_buf.buf, self->cert_buf.len + 1);
|
||||
if (ret != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = mbedtls_ssl_conf_own_cert(&o->conf, &o->cert, &o->pkey);
|
||||
if (ret != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
cleanup:
|
||||
mbedtls_pk_free(&o->pkey);
|
||||
@ -208,7 +230,7 @@ cleanup:
|
||||
mbedtls_entropy_free(&o->entropy);
|
||||
|
||||
if (ret == MBEDTLS_ERR_SSL_ALLOC_FAILED) {
|
||||
mp_raise_OSError(MP_ENOMEM);
|
||||
mp_raise_type(&mp_type_MemoryError);
|
||||
} else if (ret == MBEDTLS_ERR_PK_BAD_INPUT_DATA) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("invalid key"));
|
||||
} else if (ret == MBEDTLS_ERR_X509_BAD_INPUT_DATA) {
|
||||
@ -277,8 +299,7 @@ void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t *self) {
|
||||
mbedtls_entropy_free(&self->entropy);
|
||||
}
|
||||
|
||||
void common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, const char *host, size_t hostlen, uint32_t port) {
|
||||
common_hal_socketpool_socket_connect(self->sock, host, hostlen, port);
|
||||
STATIC void do_handshake(ssl_sslsocket_obj_t *self) {
|
||||
int ret;
|
||||
while ((ret = mbedtls_ssl_handshake(&self->ssl)) != 0) {
|
||||
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
@ -304,7 +325,7 @@ cleanup:
|
||||
mbedtls_entropy_free(&self->entropy);
|
||||
|
||||
if (ret == MBEDTLS_ERR_SSL_ALLOC_FAILED) {
|
||||
mp_raise_OSError(MP_ENOMEM);
|
||||
mp_raise_type(&mp_type_MemoryError);
|
||||
} else if (ret == MBEDTLS_ERR_PK_BAD_INPUT_DATA) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("invalid key"));
|
||||
} else if (ret == MBEDTLS_ERR_X509_BAD_INPUT_DATA) {
|
||||
@ -314,6 +335,11 @@ cleanup:
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, const char *host, size_t hostlen, uint32_t port) {
|
||||
common_hal_socketpool_socket_connect(self->sock, host, hostlen, port);
|
||||
do_handshake(self);
|
||||
}
|
||||
|
||||
bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t *self) {
|
||||
return self->closed;
|
||||
}
|
||||
|
@ -77,6 +77,7 @@
|
||||
#define MBEDTLS_AES_C
|
||||
#define MBEDTLS_ASN1_PARSE_C
|
||||
#define MBEDTLS_ASN1_WRITE_C
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_BIGNUM_C
|
||||
#define MBEDTLS_CIPHER_C
|
||||
#define MBEDTLS_CTR_DRBG_C
|
||||
@ -90,6 +91,7 @@
|
||||
#define MBEDTLS_MD5_C
|
||||
#define MBEDTLS_OID_C
|
||||
#define MBEDTLS_PKCS5_C
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_PK_C
|
||||
#define MBEDTLS_PK_PARSE_C
|
||||
#define MBEDTLS_PLATFORM_C
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/alarm/pin/PinAlarm.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "peripherals/exti.h"
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "shared-bindings/alarm/time/TimeAlarm.h"
|
||||
#include "shared-bindings/time/__init__.h"
|
||||
#include "supervisor/port.h"
|
||||
#include "peripherals/rtc.h"
|
||||
|
||||
#include STM32_HAL_H
|
||||
|
@ -28,9 +28,12 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
|
||||
|
||||
#include "shared-bindings/analogio/AnalogOut.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
|
@ -28,11 +28,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "supervisor/board.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
// The HAL is sparse on obtaining register information, so we use the LLs here.
|
||||
#if (CPY_STM32H7)
|
||||
|
@ -26,9 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "pins.h"
|
||||
|
||||
#if defined(TFBGA216)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
@ -29,14 +29,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
#include STM32_HAL_H
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "timers.h"
|
||||
|
||||
// A single timer is shared amongst all PulseOut objects under the assumption that
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include STM32_HAL_H
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
|
@ -26,13 +26,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared/timeutils/timeutils.h"
|
||||
#include "shared-bindings/rtc/__init__.h"
|
||||
#include "common-hal/rtc/RTC.h"
|
||||
#include "shared-bindings/rtc/RTC.h"
|
||||
#include "supervisor/port.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#include "peripherals/rtc.h"
|
||||
|
||||
|
@ -28,11 +28,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "py/mpstate.h"
|
||||
#include "py/gc.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
|
||||
void mp_hal_delay_us(mp_uint_t delay) {
|
||||
common_hal_mcu_delay_us(delay);
|
||||
|
@ -26,9 +26,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/misc.h"
|
||||
|
||||
#include "peripherals/exti.h"
|
||||
|
||||
|
@ -29,9 +29,6 @@
|
||||
#include STM32_HAL_H
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared/timeutils/timeutils.h"
|
||||
|
||||
// Default period for ticks is 1/1024 second
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "timers.h"
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
|
@ -29,12 +29,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extmod/vfs.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "supervisor/flash.h"
|
||||
#include "supervisor/shared/safe_mode.h"
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "supervisor/background_callback.h"
|
||||
#include "supervisor/board.h"
|
||||
#include "supervisor/port.h"
|
||||
#include "shared/timeutils/timeutils.h"
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
|
@ -27,9 +27,7 @@
|
||||
|
||||
|
||||
#include "supervisor/usb.h"
|
||||
#include "shared/runtime/interrupt_char.h"
|
||||
#include "shared/readline/readline.h"
|
||||
#include "lib/tinyusb/src/device/usbd.h"
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
|
@ -401,6 +401,9 @@ CFLAGS += -DCIRCUITPY_STATUS_BAR=$(CIRCUITPY_STATUS_BAR)
|
||||
CIRCUITPY_STORAGE ?= 1
|
||||
CFLAGS += -DCIRCUITPY_STORAGE=$(CIRCUITPY_STORAGE)
|
||||
|
||||
CIRCUITPY_STORAGE_EXTEND ?= $(CIRCUITPY_DUALBANK)
|
||||
CFLAGS += -DCIRCUITPY_STORAGE_EXTEND=$(CIRCUITPY_STORAGE_EXTEND)
|
||||
|
||||
CIRCUITPY_STRUCT ?= 1
|
||||
CFLAGS += -DCIRCUITPY_STRUCT=$(CIRCUITPY_STRUCT)
|
||||
|
||||
|
17
py/gc.c
17
py/gc.c
@ -138,7 +138,6 @@ void gc_init(void *start, void *end) {
|
||||
MP_STATE_MEM(gc_alloc_table_start) = (byte *)start;
|
||||
|
||||
#if MICROPY_ENABLE_FINALISER
|
||||
size_t gc_finaliser_table_byte_len = (MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB + BLOCKS_PER_FTB - 1) / BLOCKS_PER_FTB;
|
||||
MP_STATE_MEM(gc_finaliser_table_start) = MP_STATE_MEM(gc_alloc_table_start) + MP_STATE_MEM(gc_alloc_table_byte_len) + 1;
|
||||
#endif
|
||||
|
||||
@ -147,18 +146,16 @@ void gc_init(void *start, void *end) {
|
||||
MP_STATE_MEM(gc_pool_end) = end;
|
||||
|
||||
#if MICROPY_ENABLE_FINALISER
|
||||
size_t gc_finaliser_table_byte_len = (MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB + BLOCKS_PER_FTB - 1) / BLOCKS_PER_FTB;
|
||||
(void)gc_finaliser_table_byte_len; // avoid unused variable diagnostic if asserts are disabled
|
||||
assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len);
|
||||
#endif
|
||||
|
||||
// Clear ATBs plus one more byte. The extra byte might be read when we read the final ATB and
|
||||
// then try to count its tail. Clearing the byte ensures it is 0 and ends the chain. Without an
|
||||
// FTB, it'll just clear the pool byte early.
|
||||
memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len) + 1);
|
||||
|
||||
#if MICROPY_ENABLE_FINALISER
|
||||
// clear FTBs
|
||||
memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len);
|
||||
#endif
|
||||
// Clear ATBs & finalisers (if enabled). This also clears the extra byte
|
||||
// which appears between ATBs and finalisers that ensures every chain in
|
||||
// the ATB terminates, rather than erroneously using bits from the
|
||||
// finalisers.
|
||||
memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_pool_start) - MP_STATE_MEM(gc_alloc_table_start));
|
||||
|
||||
// Set first free ATB index to the start of the heap.
|
||||
for (size_t i = 0; i < MICROPY_ATB_INDICES; i++) {
|
||||
|
@ -26,6 +26,10 @@
|
||||
|
||||
#include "shared-bindings/dualbank/__init__.h"
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
#include "supervisor/flash.h"
|
||||
#endif
|
||||
|
||||
//| """DUALBANK Module
|
||||
//|
|
||||
//| The `dualbank` module adds ability to update and switch
|
||||
@ -55,6 +59,14 @@
|
||||
//| """
|
||||
//| ...
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
STATIC void raise_error_if_storage_extended(void) {
|
||||
if (supervisor_flash_get_extended()) {
|
||||
mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q is %q"), MP_QSTR_storage, MP_QSTR_extended);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//| def flash(buffer: ReadableBuffer, offset: int = 0) -> None:
|
||||
//| """Writes one of two app partitions at the given offset.
|
||||
//|
|
||||
@ -70,6 +82,10 @@ STATIC mp_obj_t dualbank_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t
|
||||
{ MP_QSTR_offset, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} },
|
||||
};
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
raise_error_if_storage_extended();
|
||||
#endif
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
@ -94,6 +110,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(dualbank_flash_obj, 0, dualbank_flash);
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t dualbank_switch(void) {
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
raise_error_if_storage_extended();
|
||||
#endif
|
||||
common_hal_dualbank_switch();
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -104,7 +104,11 @@ MP_PROPERTY_GETTER(mcu_processor_reset_reason_obj,
|
||||
//| temperature: Optional[float]
|
||||
//| """The on-chip temperature, in Celsius, as a float. (read-only)
|
||||
//|
|
||||
//| Is `None` if the temperature is not available."""
|
||||
//| Is `None` if the temperature is not available.
|
||||
//|
|
||||
//| .. note :: On small SAMD21 builds without external flash,
|
||||
//| the reported temperature has reduced accuracy and precision, to save code space.
|
||||
//| """
|
||||
STATIC mp_obj_t mcu_processor_get_temperature(mp_obj_t self) {
|
||||
float temperature = common_hal_mcu_processor_get_temperature();
|
||||
return isnan(temperature) ? mp_const_none : mp_obj_new_float(temperature);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extmod/vfs.h"
|
||||
#include "py/objtuple.h"
|
||||
#include "py/objlist.h"
|
||||
#include "py/objproperty.h"
|
||||
@ -52,6 +53,47 @@ STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args
|
||||
return MP_OBJ_FROM_PTR(s);
|
||||
}
|
||||
|
||||
//| def load_cert_chain(self, certfile: str, keyfile: str) -> None:
|
||||
//| """Load a private key and the corresponding certificate.
|
||||
//|
|
||||
//| The certfile string must be the path to a single file in PEM format
|
||||
//| containing the certificate as well as any number of CA certificates
|
||||
//| needed to establish the certificate's authenticity. The keyfile string
|
||||
//| must point to a file containing the private key.
|
||||
//| """
|
||||
|
||||
STATIC void get_file_contents(mp_obj_t name_obj, mp_buffer_info_t *bufinfo) {
|
||||
mp_obj_t file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), name_obj, MP_OBJ_NEW_QSTR(MP_QSTR_rb));
|
||||
mp_obj_t dest[2];
|
||||
mp_load_method(file, MP_QSTR_read, dest);
|
||||
mp_obj_t result = mp_call_method_n_kw(0, 0, dest);
|
||||
mp_get_buffer_raise(result, bufinfo, MP_BUFFER_READ);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t ssl_sslcontext_load_cert_chain(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_certfile, ARG_keyfile };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_certfile, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_keyfile, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
};
|
||||
ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
mp_buffer_info_t cert_buf, key_buf;
|
||||
get_file_contents(args[ARG_certfile].u_obj, &cert_buf);
|
||||
if (args[ARG_keyfile].u_obj != mp_const_none) {
|
||||
get_file_contents(args[ARG_keyfile].u_obj, &key_buf);
|
||||
} else {
|
||||
key_buf = cert_buf;
|
||||
}
|
||||
|
||||
common_hal_ssl_sslcontext_load_cert_chain(self, &cert_buf, &key_buf);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_load_cert_chain_obj, 1, ssl_sslcontext_load_cert_chain);
|
||||
|
||||
//| def load_verify_locations(self, cadata: Optional[str] = None) -> None:
|
||||
//| """Load a set of certification authority (CA) certificates used to validate
|
||||
//| other peers' certificates."""
|
||||
@ -146,6 +188,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 1, ssl_sslcont
|
||||
|
||||
STATIC const mp_rom_map_elem_t ssl_sslcontext_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&ssl_sslcontext_wrap_socket_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_load_cert_chain), MP_ROM_PTR(&ssl_sslcontext_load_cert_chain_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_load_verify_locations), MP_ROM_PTR(&ssl_sslcontext_load_verify_locations_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_default_verify_paths), MP_ROM_PTR(&ssl_sslcontext_set_default_verify_paths_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_check_hostname), MP_ROM_PTR(&ssl_sslcontext_check_hostname_obj) },
|
||||
|
@ -46,5 +46,6 @@ void common_hal_ssl_sslcontext_set_default_verify_paths(ssl_sslcontext_obj_t *se
|
||||
|
||||
bool common_hal_ssl_sslcontext_get_check_hostname(ssl_sslcontext_obj_t *self);
|
||||
void common_hal_ssl_sslcontext_set_check_hostname(ssl_sslcontext_obj_t *self, bool value);
|
||||
void common_hal_ssl_sslcontext_load_cert_chain(ssl_sslcontext_obj_t *self, mp_buffer_info_t *cert_buf, mp_buffer_info_t *key_buf);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLCONTEXT_H
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/storage/__init__.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#include "supervisor/flash.h"
|
||||
|
||||
//| """Storage management
|
||||
//|
|
||||
@ -150,7 +151,7 @@ STATIC mp_obj_t storage_getmount(const mp_obj_t mnt_in) {
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
|
||||
|
||||
//| def erase_filesystem() -> None:
|
||||
//| def erase_filesystem(extended: Optional[bool] = None) -> None:
|
||||
//| """Erase and re-create the ``CIRCUITPY`` filesystem.
|
||||
//|
|
||||
//| On boards that present USB-visible ``CIRCUITPY`` drive (e.g., SAMD21 and SAMD51),
|
||||
@ -160,16 +161,38 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
|
||||
//| This function can be called from the REPL when ``CIRCUITPY``
|
||||
//| has become corrupted.
|
||||
//|
|
||||
//| :param bool extended: On boards that support ``dualbank`` module
|
||||
//| and the ``extended`` parameter, the ``CIRCUITPY`` storage can be
|
||||
//| extended by setting this to `True`. If this isn't provided or
|
||||
//| set to `None` (default), the existing configuration will be used.
|
||||
//|
|
||||
//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and
|
||||
//| CircuitPython will restart on certain boards."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t storage_erase_filesystem(void) {
|
||||
common_hal_storage_erase_filesystem();
|
||||
STATIC mp_obj_t storage_erase_filesystem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_extended };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_extended, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
bool extended = (args[ARG_extended].u_obj == mp_const_none) ? supervisor_flash_get_extended() : mp_obj_is_true(args[ARG_extended].u_obj);
|
||||
common_hal_storage_erase_filesystem(extended);
|
||||
#else
|
||||
if (mp_obj_is_true(args[ARG_extended].u_obj)) {
|
||||
mp_raise_NotImplementedError_varg(translate("%q=%q"), MP_QSTR_extended, MP_QSTR_True);
|
||||
}
|
||||
common_hal_storage_erase_filesystem(false);
|
||||
#endif
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(storage_erase_filesystem_obj, storage_erase_filesystem);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(storage_erase_filesystem_obj, 0, storage_erase_filesystem);
|
||||
|
||||
//| def disable_usb_drive() -> None:
|
||||
//| """Disable presenting ``CIRCUITPY`` as a USB mass storage device.
|
||||
|
@ -37,7 +37,7 @@ void common_hal_storage_umount_path(const char *path);
|
||||
void common_hal_storage_umount_object(mp_obj_t vfs_obj);
|
||||
void common_hal_storage_remount(const char *path, bool readonly, bool disable_concurrent_write_protection);
|
||||
mp_obj_t common_hal_storage_getmount(const char *path);
|
||||
void common_hal_storage_erase_filesystem(void);
|
||||
void common_hal_storage_erase_filesystem(bool extended);
|
||||
|
||||
bool common_hal_storage_disable_usb_drive(void);
|
||||
bool common_hal_storage_enable_usb_drive(void);
|
||||
|
@ -38,7 +38,45 @@
|
||||
//| """
|
||||
//| ...
|
||||
|
||||
STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj_t tb_obj, mp_obj_t limit_obj) {
|
||||
STATIC void traceback_exception_common(bool is_print_exception, mp_print_t *print, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_exc, ARG_value, ARG_tb, ARG_limit, ARG_file, ARG_chain };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_value, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_tb, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_file, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
mp_obj_t value = args[ARG_value].u_obj;
|
||||
if (value == MP_OBJ_NULL) {
|
||||
value = args[ARG_exc].u_obj;
|
||||
}
|
||||
mp_obj_t tb_obj = args[ARG_tb].u_obj;
|
||||
mp_obj_t limit_obj = args[ARG_limit].u_obj;
|
||||
|
||||
if (args[ARG_file].u_obj != mp_const_none) {
|
||||
if (!is_print_exception) {
|
||||
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
|
||||
mp_arg_error_terse_mismatch();
|
||||
#else
|
||||
mp_raise_msg_varg(&mp_type_TypeError, MP_ERROR_TEXT("unexpected keyword argument '%q'"), MP_QSTR_file);
|
||||
#endif
|
||||
|
||||
}
|
||||
#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
|
||||
mp_get_stream_raise(args[ARG_file].u_obj, MP_STREAM_OP_WRITE);
|
||||
print->data = MP_OBJ_TO_PTR(args[ARG_file].u_obj);
|
||||
print->print_strn = mp_stream_write_adaptor;
|
||||
#else
|
||||
mp_raise_NotImplementedError(translate("file write is not available"));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!mp_obj_is_exception_instance(value)) {
|
||||
mp_raise_TypeError(translate("invalid exception"));
|
||||
}
|
||||
@ -53,7 +91,9 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
|
||||
mp_obj_exception_t *exc = mp_obj_exception_get_native(value);
|
||||
mp_obj_traceback_t *trace_backup = exc->traceback;
|
||||
|
||||
if (tb_obj != mp_const_none && print_tb) {
|
||||
if (tb_obj == MP_OBJ_NULL) {
|
||||
/* Print the traceback's exception as is */
|
||||
} else if (tb_obj != mp_const_none && print_tb) {
|
||||
exc->traceback = mp_arg_validate_type(tb_obj, &mp_type_traceback, MP_QSTR_tb);
|
||||
} else {
|
||||
exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
@ -64,14 +104,24 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
|
||||
}
|
||||
|
||||
//| def format_exception(
|
||||
//| etype: Type[BaseException],
|
||||
//| value: BaseException,
|
||||
//| tb: TracebackType,
|
||||
//| exc: BaseException | Type[BaseException],
|
||||
//| /,
|
||||
//| value: Optional[BaseException] = None,
|
||||
//| tb: Optional[TracebackType] = None,
|
||||
//| limit: Optional[int] = None,
|
||||
//| chain: Optional[bool] = True,
|
||||
//| ) -> None:
|
||||
//| ) -> List[str]:
|
||||
//| """Format a stack trace and the exception information.
|
||||
//|
|
||||
//| If the exception value is passed in ``exc``, then this exception value and its
|
||||
//| associated traceback are used. This is compatible with CPython 3.10 and newer.
|
||||
//|
|
||||
//| If the exception value is passed in ``value``, then any value passed in for
|
||||
//| ``exc`` is ignored. ``value`` is used as the exception value and the
|
||||
//| traceback in the ``tb`` argument is used. In this case, if ``tb`` is None,
|
||||
//| no traceback will be shown. This is compatible with CPython 3.5 and
|
||||
//| newer.
|
||||
//|
|
||||
//| The arguments have the same meaning as the corresponding arguments
|
||||
//| to print_exception(). The return value is a list of strings, each
|
||||
//| ending in a newline and some containing internal newlines. When
|
||||
@ -80,54 +130,50 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
|
||||
//|
|
||||
//| .. note:: Setting ``chain`` will have no effect as chained exceptions are not yet implemented.
|
||||
//|
|
||||
//| :param Type[BaseException] etype: This is ignored and inferred from the type of ``value``.
|
||||
//| :param BaseException value: The exception. Must be an instance of `BaseException`.
|
||||
//| :param TracebackType tb: The traceback object. If `None`, the traceback will not be printed.
|
||||
//| :param exc: The exception. Must be an instance of `BaseException`. Unused if value is specified.
|
||||
//| :param value: If specified, is used in place of ``exc``.
|
||||
//| :param TracebackType tb: When value is alsp specified, ``tb`` is used in place of the exception's own traceback. If `None`, the traceback will not be printed.
|
||||
//| :param int limit: Print up to limit stack trace entries (starting from the caller’s frame) if limit is positive.
|
||||
//| Otherwise, print the last ``abs(limit)`` entries. If limit is omitted or None, all entries are printed.
|
||||
//| :param bool chain: If `True` then chained exceptions will be printed (note: not yet implemented).
|
||||
//|
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_chain };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
mp_print_t print;
|
||||
vstr_t vstr;
|
||||
vstr_init_print(&vstr, 0, &print);
|
||||
traceback_exception_common(&print, args[ARG_value].u_obj, args[ARG_tb].u_obj, args[ARG_limit].u_obj);
|
||||
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
||||
traceback_exception_common(false, &print, n_args, pos_args, kw_args);
|
||||
mp_obj_t output = mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
||||
return mp_obj_new_list(1, &output);
|
||||
}
|
||||
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_format_exception);
|
||||
|
||||
//| def print_exception(
|
||||
//| etype: Type[BaseException],
|
||||
//| value: BaseException,
|
||||
//| tb: TracebackType,
|
||||
//| exc: BaseException | Type[BaseException],
|
||||
//| /,
|
||||
//| value: Optional[BaseException] = None,
|
||||
//| tb: Optional[TracebackType] = None,
|
||||
//| limit: Optional[int] = None,
|
||||
//| file: Optional[io.FileIO] = None,
|
||||
//| chain: Optional[bool] = True,
|
||||
//| ) -> None:
|
||||
//|
|
||||
//| """Prints exception information and stack trace entries.
|
||||
//|
|
||||
//| If the exception value is passed in ``exc``, then this exception value and its
|
||||
//| associated traceback are used. This is compatible with CPython 3.10 and newer.
|
||||
//|
|
||||
//| If the exception value is passed in ``value``, then any value passed in for
|
||||
//| ``exc`` is ignored. ``value`` is used as the exception value and the
|
||||
//| traceback in the ``tb`` argument is used. In this case, if ``tb`` is None,
|
||||
//| no traceback will be shown. This is compatible with CPython 3.5 and
|
||||
//| newer.
|
||||
//|
|
||||
//| .. note:: Setting ``chain`` will have no effect as chained exceptions are not yet implemented.
|
||||
//|
|
||||
//| :param Type[BaseException] etype: This is ignored and inferred from the type of ``value``.
|
||||
//| :param BaseException value: The exception. Must be an instance of `BaseException`.
|
||||
//| :param TracebackType tb: The traceback object. If `None`, the traceback will not be printed.
|
||||
//| :param exc: The exception. Must be an instance of `BaseException`. Unused if value is specified.
|
||||
//| :param value: If specified, is used in place of ``exc``.
|
||||
//| :param tb: When value is alsp specified, ``tb`` is used in place of the exception's own traceback. If `None`, the traceback will not be printed.
|
||||
//| :param int limit: Print up to limit stack trace entries (starting from the caller’s frame) if limit is positive.
|
||||
//| Otherwise, print the last ``abs(limit)`` entries. If limit is omitted or None, all entries are printed.
|
||||
//| :param io.FileIO file: If file is omitted or `None`, the output goes to `sys.stderr`; otherwise it should be an open
|
||||
@ -139,31 +185,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_f
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_file, ARG_chain };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_file, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
mp_print_t print = mp_plat_print;
|
||||
if (args[ARG_file].u_obj != mp_const_none) {
|
||||
#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
|
||||
mp_get_stream_raise(args[ARG_file].u_obj, MP_STREAM_OP_WRITE);
|
||||
print.data = MP_OBJ_TO_PTR(args[ARG_file].u_obj);
|
||||
print.print_strn = mp_stream_write_adaptor;
|
||||
#else
|
||||
mp_raise_NotImplementedError(translate("file write is not available"));
|
||||
#endif
|
||||
}
|
||||
|
||||
traceback_exception_common(&print, args[ARG_value].u_obj, args[ARG_tb].u_obj, args[ARG_limit].u_obj);
|
||||
traceback_exception_common(true, &print, n_args, pos_args, kw_args);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 0, traceback_print_exception);
|
||||
|
@ -267,11 +267,14 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
|
||||
filesystem_set_internal_concurrent_write_protection(!disable_concurrent_write_protection);
|
||||
}
|
||||
|
||||
void common_hal_storage_erase_filesystem(void) {
|
||||
void common_hal_storage_erase_filesystem(bool extended) {
|
||||
#if CIRCUITPY_USB
|
||||
usb_disconnect();
|
||||
#endif
|
||||
mp_hal_delay_ms(1000);
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
supervisor_flash_set_extended(extended);
|
||||
#endif
|
||||
(void)filesystem_init(false, true); // Force a re-format. Ignore failure.
|
||||
common_hal_mcu_reset();
|
||||
// We won't actually get here, since we're resetting.
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) __builtin_expect((x), 1)
|
||||
#endif
|
||||
@ -35,6 +37,7 @@
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
void *memcpy(void *dst, const void *src, size_t n) {
|
||||
#if CIRCUITPY_FULL_BUILD
|
||||
if (likely(!(((uintptr_t)dst) & 3) && !(((uintptr_t)src) & 3))) {
|
||||
// pointers aligned
|
||||
uint32_t *d = dst;
|
||||
@ -56,7 +59,9 @@ void *memcpy(void *dst, const void *src, size_t n) {
|
||||
// copy byte
|
||||
*((uint8_t*)d) = *((const uint8_t*)s);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// unaligned access, copy bytes
|
||||
uint8_t *d = dst;
|
||||
const uint8_t *s = src;
|
||||
@ -93,6 +98,7 @@ void *memmove(void *dest, const void *src, size_t n) {
|
||||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n) {
|
||||
#if CIRCUITPY_FULL_BUILD
|
||||
if (c == 0 && ((uintptr_t)s & 3) == 0) {
|
||||
// aligned store of 0
|
||||
uint32_t *s32 = s;
|
||||
@ -106,7 +112,9 @@ void *memset(void *s, int c, size_t n) {
|
||||
if (n & 1) {
|
||||
*((uint8_t*)s32) = 0;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
uint8_t *s2 = s;
|
||||
for (; n > 0; n--) {
|
||||
*s2++ = c;
|
||||
|
@ -50,4 +50,8 @@ void supervisor_flash_init_vfs(struct _fs_user_mount_t *vfs);
|
||||
void supervisor_flash_flush(void);
|
||||
void supervisor_flash_release_cache(void);
|
||||
|
||||
void supervisor_flash_set_extended(bool extended);
|
||||
bool supervisor_flash_get_extended(void);
|
||||
void supervisor_flash_update_extended(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SUPERVISOR_FLASH_H
|
||||
|
@ -143,16 +143,22 @@ bool filesystem_init(bool create_allowed, bool force_create) {
|
||||
} else if (res != FR_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vfs->str = "/";
|
||||
vfs->len = 1;
|
||||
vfs->obj = MP_OBJ_FROM_PTR(vfs_fat);
|
||||
vfs->next = NULL;
|
||||
|
||||
MP_STATE_VM(vfs_mount_table) = vfs;
|
||||
|
||||
// The current directory is used as the boot up directory.
|
||||
// It is set to the internal flash filesystem by default.
|
||||
MP_STATE_PORT(vfs_cur) = vfs;
|
||||
|
||||
#if CIRCUITPY_STORAGE_EXTEND
|
||||
supervisor_flash_update_extended();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/mphal.h"
|
||||
|
||||
#include "supervisor/shared/cpu.h"
|
||||
#include "supervisor/shared/display.h"
|
||||
@ -62,6 +63,13 @@ byte console_uart_rx_buf[64];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_USB || CIRCUITPY_CONSOLE_UART
|
||||
// Flag to note whether this is the first write after connection.
|
||||
// Delay slightly on the first write to allow time for the host to set up things,
|
||||
// including turning off echo mode.
|
||||
static bool _first_write_done = false;
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_USB_VENDOR
|
||||
bool tud_vendor_connected(void);
|
||||
#endif
|
||||
@ -144,6 +152,10 @@ void serial_early_init(void) {
|
||||
}
|
||||
|
||||
void serial_init(void) {
|
||||
#if CIRCUITPY_USB || CIRCUITPY_CONSOLE_UART
|
||||
_first_write_done = false;
|
||||
#endif
|
||||
|
||||
port_serial_init();
|
||||
}
|
||||
|
||||
@ -301,8 +313,11 @@ void serial_write_substring(const char *text, uint32_t length) {
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_CONSOLE_UART
|
||||
if (!_first_write_done) {
|
||||
mp_hal_delay_ms(50);
|
||||
_first_write_done = true;
|
||||
}
|
||||
int uart_errcode;
|
||||
|
||||
common_hal_busio_uart_write(&console_uart, (const uint8_t *)text, length, &uart_errcode);
|
||||
#endif
|
||||
|
||||
@ -321,6 +336,11 @@ void serial_write_substring(const char *text, uint32_t length) {
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_USB
|
||||
// Delay the very first write
|
||||
if (tud_cdc_connected() && !_first_write_done) {
|
||||
mp_hal_delay_ms(50);
|
||||
_first_write_done = true;
|
||||
}
|
||||
uint32_t count = 0;
|
||||
if (tud_cdc_connected()) {
|
||||
while (count < length) {
|
||||
|
@ -15,13 +15,13 @@ except Exception as exc:
|
||||
print("\nNo Trace:")
|
||||
traceback.print_exception(None, exc, None)
|
||||
print("\nDefault Trace:")
|
||||
traceback.print_exception(None, exc, exc.__traceback__)
|
||||
traceback.print_exception(exc)
|
||||
print("\nLimit=1 Trace:")
|
||||
traceback.print_exception(None, exc, exc.__traceback__, limit=1)
|
||||
print("\nLimit=0 Trace:")
|
||||
traceback.print_exception(None, exc, exc.__traceback__, limit=0)
|
||||
print("\nLimit=-1 Trace:")
|
||||
traceback.print_exception(None, exc, exc.__traceback__, limit=-1)
|
||||
print("".join(traceback.format_exception(None, exc, exc.__traceback__, limit=-1)), end="")
|
||||
|
||||
|
||||
class NonNativeException(Exception):
|
||||
|
@ -70,6 +70,11 @@ try:
|
||||
except OSError as e:
|
||||
print(e.errno == uerrno.ENOENT)
|
||||
|
||||
try:
|
||||
vfs.rename("foo_dir", "foo_dir/inside_itself")
|
||||
except OSError as e:
|
||||
print(e.errno == uerrno.EINVAL)
|
||||
|
||||
# file in dir
|
||||
with open("foo_dir/file-in-dir.txt", "w+t") as f:
|
||||
f.write("data in file")
|
||||
|
@ -1,6 +1,7 @@
|
||||
True
|
||||
True
|
||||
True
|
||||
True
|
||||
b'data in file'
|
||||
True
|
||||
[('sub_file.txt', 32768, 0, 11), ('file.txt', 32768, 0, 12)]
|
||||
|
@ -48,6 +48,14 @@ except json.decoder.JSONDecodeError as exc:
|
||||
raise
|
||||
|
||||
|
||||
def set_output(name, value):
|
||||
if "GITHUB_OUTPUT" in os.environ:
|
||||
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
|
||||
print(f"{name}={value}", file=f)
|
||||
else:
|
||||
print("Would set GitHub actions output {name} to '{value}'")
|
||||
|
||||
|
||||
def set_boards_to_build(build_all):
|
||||
# Get boards in json format
|
||||
boards_info_json = build_board_info.get_board_mapping()
|
||||
@ -161,7 +169,7 @@ def set_boards_to_build(build_all):
|
||||
|
||||
# Set the step outputs for each architecture
|
||||
for arch in arch_to_boards:
|
||||
print("::set-output name=boards-" + arch + "::" + json.dumps(sorted(arch_to_boards[arch])))
|
||||
set_output(f"boards-{arch}", json.dumps(sorted(arch_to_boards[arch])))
|
||||
|
||||
|
||||
def set_docs_to_build(build_all):
|
||||
@ -177,7 +185,7 @@ def set_docs_to_build(build_all):
|
||||
|
||||
# Set the step outputs
|
||||
print("Building docs:", doc_match)
|
||||
print("::set-output name=build-doc::" + str(doc_match))
|
||||
set_output(f"build-doc", doc_match)
|
||||
|
||||
|
||||
def check_changed_files():
|
||||
|
Loading…
Reference in New Issue
Block a user