Changes between Initial Version and Version 1 of Wsl2Build


Ignore:
Timestamp:
Apr 11, 2024, 1:39:55 PM (9 months ago)
Author:
katta
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Wsl2Build

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