| 1 | [[PageOutline]] |
| 2 | |
| 3 | == WSL2 環境で !MicroPython の Build |
| 4 | ここでは、Windows PC で、STM32系の市販されているボードに !MicroPython を実装する手順を記録します |
| 5 | |
| 6 | === WSL2 (Ubuntu) のインストール |
| 7 | STM32系のARM用のコンパイルには、この環境が最適のようです [https://se-abeaver.com/wsl2-guide/ この記事がていねい] |
| 8 | |
| 9 | * Windows11 の右クリックで[ターミナル(管理者)]を起動 |
| 10 | {{{ |
| 11 | PS C:\Users\user> wsl --install |
| 12 | }}} |
| 13 | |
| 14 | * 以下は、インストールが終わって、再起動した直後 |
| 15 | {{{ |
| 16 | Ubuntu は既にインストールされています。 |
| 17 | Ubuntu を起動しています... |
| 18 | Installing, this may take a few minutes... |
| 19 | Please create a default UNIX user account. The username does not need to match your Windows username. |
| 20 | For more information visit: https://aka.ms/wslusers |
| 21 | Enter new UNIX username: user1 |
| 22 | New password:<psword> |
| 23 | Retype new password:<psword> |
| 24 | passwd: password updated successfully |
| 25 | Installation successful! |
| 26 | To run a command as administrator (user "root"), use "sudo <command>". |
| 27 | See "man sudo_root" for details. |
| 28 | |
| 29 | Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64) |
| 30 | |
| 31 | * Documentation: https://help.ubuntu.com |
| 32 | * Management: https://landscape.canonical.com |
| 33 | * Support: https://ubuntu.com/advantage |
| 34 | |
| 35 | |
| 36 | This message is shown once a day. To disable it please create the |
| 37 | /home/user1/.hushlogin file. |
| 38 | user1@PCHOSTNAME:~$ |
| 39 | }}} |
| 40 | |
| 41 | === WSL2上のクロスコンパイル環境のセットアップ |
| 42 | * https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads |
| 43 | * {{{gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz}}} を {{{C:/ST/}}} に、ダウンロードする |
| 44 | * WSL2 で、展開しセットアップ |
| 45 | {{{ |
| 46 | user1@PCHOSTNAME:~$ ll /mnt/c/ST/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz |
| 47 | -rwxrwxrwx 1 user1 user1 490927032 Jun 4 17:30 /mnt/c/ST/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz* |
| 48 | user1@PCHOSTNAME:~$ sudo tar xJf /mnt/c/ST/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi.tar.xz |
| 49 | user1@PCHOSTNAME:~$ ll gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/ |
| 50 | total 40 |
| 51 | drwxr-xr-x 8 802 802 4096 Feb 3 2022 ./ |
| 52 | drwxr-x--- 5 user1 user1 4096 Jun 4 17:35 ../ |
| 53 | -rw-r--r-- 1 802 802 4572 Feb 3 2022 11.2-2022.02-x86_64-arm-none-eabi-manifest.txt |
| 54 | drwxr-xr-x 5 802 802 4096 Feb 2 2022 arm-none-eabi/ |
| 55 | drwxr-xr-x 2 802 802 4096 Feb 2 2022 bin/ |
| 56 | drwxr-xr-x 3 802 802 4096 Feb 2 2022 include/ |
| 57 | drwxr-xr-x 4 802 802 4096 Feb 2 2022 lib/ |
| 58 | drwxr-xr-x 3 802 802 4096 Feb 2 2022 libexec/ |
| 59 | drwxr-xr-x 8 802 802 4096 Feb 3 2022 share/ |
| 60 | user1@PCHOSTNAME:~$ mkdir gcc-arm-none-eabi |
| 61 | user1@PCHOSTNAME:~$ mkdir gcc-arm-none-eabi/DEBIAN |
| 62 | user1@PCHOSTNAME:~$ mkdir gcc-arm-none-eabi/usr |
| 63 | user1@PCHOSTNAME:~$ echo "Package: gcc-arm-none-eabi" > gcc-arm-none-eabi/DEBIAN/control |
| 64 | user1@PCHOSTNAME:~$ echo "Version: 11.2-2022.02" >> gcc-arm-none-eabi/DEBIAN/control |
| 65 | user1@PCHOSTNAME:~$ echo "Architecture: amd64" >> gcc-arm-none-eabi/DEBIAN/control |
| 66 | user1@PCHOSTNAME:~$ echo "Maintainer: maintainer" >> gcc-arm-none-eabi/DEBIAN/control |
| 67 | user1@PCHOSTNAME:~$ echo "Description: Arm Embedded toolchain" >> gcc-arm-none-eabi/DEBIAN/control |
| 68 | user1@PCHOSTNAME:~$ cat gcc-arm-none-eabi/DEBIAN/control |
| 69 | Package: gcc-arm-none-eabi |
| 70 | Version: 11.2-2022.02 |
| 71 | Architecture: amd64 |
| 72 | Maintainer: maintainer |
| 73 | Description: Arm Embedded toolchain |
| 74 | user1@PCHOSTNAME:~$ sudo mv gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/* gcc-arm-none-eabi/usr/ |
| 75 | user1@PCHOSTNAME:~$ ll gcc-arm-none-eabi/usr/ |
| 76 | drwxr-xr-x 8 user1 user1 4096 Jun 4 17:48 ./ |
| 77 | drwxr-xr-x 4 user1 user1 4096 Jun 4 17:39 ../ |
| 78 | -rw-r--r-- 1 802 802 4572 Feb 3 2022 11.2-2022.02-x86_64-arm-none-eabi-manifest.txt |
| 79 | drwxr-xr-x 5 802 802 4096 Feb 2 2022 arm-none-eabi/ |
| 80 | drwxr-xr-x 2 802 802 4096 Feb 2 2022 bin/ |
| 81 | drwxr-xr-x 3 802 802 4096 Feb 2 2022 include/ |
| 82 | drwxr-xr-x 4 802 802 4096 Feb 2 2022 lib/ |
| 83 | drwxr-xr-x 3 802 802 4096 Feb 2 2022 libexec/ |
| 84 | drwxr-xr-x 8 802 802 4096 Feb 3 2022 share/ |
| 85 | user1@PCHOSTNAME:~$ dpkg-deb --build --root-owner-group gcc-arm-none-eabi |
| 86 | dpkg-deb: building package 'gcc-arm-none-eabi' in 'gcc-arm-none-eabi.deb'. |
| 87 | user1@PCHOSTNAME:~$ sudo apt install ./gcc-arm-none-eabi.deb -y --allow-downgrades |
| 88 | [sudo] password for user1: |
| 89 | Reading package lists... Done |
| 90 | Building dependency tree... Done |
| 91 | Reading state information... Done |
| 92 | Note, selecting 'gcc-arm-none-eabi' instead of './gcc-arm-none-eabi.deb' |
| 93 | The following NEW packages will be installed: |
| 94 | gcc-arm-none-eabi |
| 95 | 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. |
| 96 | Need to get 0 B/568 MB of archives. |
| 97 | After this operation, 0 B of additional disk space will be used. |
| 98 | Get:1 /home/user1/gcc-arm-none-eabi.deb gcc-arm-none-eabi amd64 11.2-2022.02 [568 MB] |
| 99 | Selecting previously unselected package gcc-arm-none-eabi. |
| 100 | (Reading database ... 24137 files and directories currently installed.) |
| 101 | Preparing to unpack .../user1/gcc-arm-none-eabi.deb ... |
| 102 | Unpacking gcc-arm-none-eabi (11.2-2022.02) ... |
| 103 | Setting up gcc-arm-none-eabi (11.2-2022.02) ... |
| 104 | Processing triggers for install-info (6.8-4build1) ... |
| 105 | Processing triggers for man-db (2.10.2-1) ... |
| 106 | N: Download is performed unsandboxed as root as file '/home/user1/gcc-arm-none-eabi.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) |
| 107 | user1@PCHOSTNAME:~$ arm-none-eabi-gcc --version |
| 108 | arm-none-eabi-gcc (GNU Toolchain for the Arm Architecture 11.2-2022.02 (arm-11.14)) 11.2.1 20220111 |
| 109 | Copyright (C) 2021 Free Software Foundation, Inc. |
| 110 | This is free software; see the source for copying conditions. There is NO |
| 111 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 112 | |
| 113 | user1@PCHOSTNAME:~$ |
| 114 | }}} |
| 115 | |
| 116 | === !MicroPython のビルド |
| 117 | * git で、 github から clone |
| 118 | {{{ |
| 119 | user1@PCHOSTNAME:~$ git clone -b master https://github.com/micropython/micropython.git |
| 120 | Cloning into 'micropython'... |
| 121 | remote: Enumerating objects: 109194, done. |
| 122 | remote: Counting objects: 100% (36573/36573), done. |
| 123 | remote: Compressing objects: 100% (3601/3601), done. |
| 124 | remote: Total 109194 (delta 34707), reused 33068 (delta 32970), pack-reused 72621 |
| 125 | Receiving objects: 100% (109194/109194), 55.84 MiB | 7.79 MiB/s, done. |
| 126 | Resolving deltas: 100% (81706/81706), done. |
| 127 | user1@PCHOSTNAME:~$ ll |
| 128 | total 554408 |
| 129 | drwxr-xr-x 8 802 802 4096 Mar 14 17:20 arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/ |
| 130 | drwxr-xr-x 2 802 802 4096 Jun 4 17:48 gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/ |
| 131 | drwxr-xr-x 4 user1 user1 4096 Jun 4 17:39 gcc-arm-none-eabi/ |
| 132 | -rw-r--r-- 1 user1 user1 567656490 Jun 4 18:08 gcc-arm-none-eabi.deb |
| 133 | drwxr-xr-x 16 user1 user1 4096 Jun 5 10:12 micropython/ |
| 134 | user1@PCHOSTNAME:~$ cd micropython/ |
| 135 | user1@PCHOSTNAME:~/micropython$ ll |
| 136 | total 164 |
| 137 | -rw-r--r-- 1 user1 user1 43236 Jun 5 10:12 ACKNOWLEDGEMENTS |
| 138 | -rw-r--r-- 1 user1 user1 11477 Jun 5 10:12 CODECONVENTIONS.md |
| 139 | -rw-r--r-- 1 user1 user1 2640 Jun 5 10:12 CODEOFCONDUCT.md |
| 140 | -rw-r--r-- 1 user1 user1 357 Jun 5 10:12 CONTRIBUTING.md |
| 141 | -rw-r--r-- 1 user1 user1 3247 Jun 5 10:12 LICENSE |
| 142 | -rw-r--r-- 1 user1 user1 7585 Jun 5 10:12 README.md |
| 143 | drwxr-xr-x 19 user1 user1 4096 Jun 5 10:12 docs/ |
| 144 | drwxr-xr-x 8 user1 user1 4096 Jun 5 10:12 drivers/ |
| 145 | drwxr-xr-x 11 user1 user1 4096 Jun 5 10:12 examples/ |
| 146 | drwxr-xr-x 8 user1 user1 4096 Jun 5 10:12 extmod/ |
| 147 | drwxr-xr-x 30 user1 user1 4096 Jun 5 10:12 lib/ |
| 148 | drwxr-xr-x 2 user1 user1 4096 Jun 5 10:12 logo/ |
| 149 | drwxr-xr-x 3 user1 user1 4096 Jun 5 10:12 mpy-cross/ |
| 150 | drwxr-xr-x 22 user1 user1 4096 Jun 5 10:12 ports/ |
| 151 | drwxr-xr-x 2 user1 user1 4096 Jun 5 10:12 py/ |
| 152 | -rw-r--r-- 1 user1 user1 824 Jun 5 10:12 pyproject.toml |
| 153 | drwxr-xr-x 10 user1 user1 4096 Jun 5 10:12 shared/ |
| 154 | drwxr-xr-x 31 user1 user1 4096 Jun 5 10:12 tests/ |
| 155 | drwxr-xr-x 4 user1 user1 4096 Jun 5 10:12 tools/ |
| 156 | user1@PCHOSTNAME:~/micropython$ |
| 157 | }}} |