<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>yasuharu's Diary</title>
    <link>https://yasuharu.net/diary/</link>
    <pubDate>Tue, 14 Apr 2026 18:57:09 +0900</pubDate>
    <description/>
    <item>
      <title>Raspberry Pi Pico2 の RISC-V を OpenOCD でデバッグする</title>
      <link>https://yasuharu.net/diary/2935</link>
      <description>Raspberry Pi Pico2 では ARM Cortex-M と RISC-V の2種類のCPUを使うことができる。
デバッガを使って開発できれば便利なので、OpenOCDからRISC-Vをデバッグできる環境を作ろうと試してみた。
想定上にはまるところが多かったものの、何とか動かすことができた。
ここでははまったポイントをまとめておく。

# 前提

* CPU
  * Apple M2
* Debugger
  * Raspberry Pi Debug probe
* homebrew

```sh
% brew --version
Homebrew 5.0.7
```

# OpenOCDでlinux/parport.hが見つからない

## 状況

MacでビルドしているのでLinuxの一部のヘッダが見つからないと言われる。
Linuxのヘッダが見つからないこと自体は特に不思議はないものの、
使用するOpenOCDのリポジトリによってエラーが出たり・出なかったりする。
今回はriscv-openocdの場合に出た。

```sh
-I/opt/homebrew/Cellar/hidapi/0.15.0/include/hidapi -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Werror -g -O2 -MT src/jtag/drivers/libocdjtagdrivers_la-amt_jtagaccel.lo -MD -MP -MF src/jtag/drivers/.deps/libocdjtagdrivers_la-amt_jtagaccel.Tpo -c src/jtag/drivers/amt_jtagaccel.c -o src/jtag/drivers/libocdjtagdrivers_la-amt_jtagaccel.o
src/jtag/drivers/amt_jtagaccel.c:16:10: fatal error: 'linux/parport.h' file not found
   16 | #include &lt;linux/parport.h&gt;
      |          ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/jtag/drivers/libocdjtagdrivers_la-amt_jtagaccel.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
```

## 対処方法

ソースコードを直すのも手かもしれないが、
そもそもこのアダプタを使用することがなければ、
アダプタ自体を無効にしてしまうのが手っ取り早い。
configureで以下のように指定する。

```sh
% ./configure --disable-amtjtagaccel
```

なお、リポジトリによりエラーの状況が変わる理由は、
デフォルトで上記のJTAGアダプタを有効にするかどうかの違いだった。

# Rasbperry Piから提供されているOpenOCDを使用する必要がある

## 状況

本家のOpenOCDやriscv-openocdでは、
Raspberry PiのDebug Probe経由でのデバッグに対応していなかった。
ざっと見たところでは以下の問題があるように見えた。

* cfg関連の解釈できない部分があった（以下のエラー）
* RISC-VターゲットがSWDに対応していなかった

```sh
% ./src/openocd -d4 -c "set USE_CORE rv0" -s ./tcl -f tcl/interface/cmsis-dap.cfg -f tcl/target/rp2350.cfg

(中略)

Debug: 33 7 command.c:86 script_debug(): command - ocd_find target/swj-dp.tcl
Debug: 34 7 configuration.c:88 find_file(): found ./tcl/target/swj-dp.tcl
Debug: 35 7 command.c:86 script_debug(): command - transport select
Debug: 36 7 command.c:86 script_debug(): command - transport select
Debug: 37 7 command.c:86 script_debug(): command - transport select
Debug: 38 7 command.c:86 script_debug(): command - swd newdap rp2350 cpu -expected-id 0x00040927
Debug: 39 7 tcl.c:405 handle_jtag_newtap_args(): Creating New Tap, Chip: rp2350, Tap: cpu, Dotted: rp2350.cpu, 2 params
Debug: 40 7 core.c:1491 jtag_tap_init(): Created Tap: rp2350.cpu @ abs position 0, irlen 0, capture: 0x1 mask: 0x3
Debug: 41 7 command.c:86 script_debug(): command - dap create rp2350.dap -adiv6 -chain-position rp2350.cpu
Debug: 42 7 command.c:86 script_debug(): command - target create rp2350.rv0 riscv -dap rp2350.dap -ap-num 0xa000 -coreid 0
Debug: 43 8 command.c:462 exec_command(): Command 'target create' failed with error code -603
User : 44 8 command.c:534 command_run_line(): Unknown param: -dap, try one of: -type, -event, -work-area-virt, -work-area-phys, -work-area-size, -work-area-backup, -endian, -coreid, -chain-position, -dbgbase, -rtos, -defer-examine, -gdb-port, or -gdb-max-connections
```

## 対応方法

Rasbperry Piから提供されているOpenOCDを使えば解決する。

https://github.com/raspberrypi/openocd

SWDは元々ARMの仕様なのでRISC-Vターゲットに存在しないのは理解するものの、
ターゲットの実装が伝送路（SWD）に依存しているのは少し意外だった。

# OpenOCDのビルドに失敗する

## 状況

以下の通りWcast-alignの警告に引っかかってしまう。

```sh
depbase=`echo src/target/riscv/batch.lo | sed 's|[^/]*$|.deps/&amp;|;s|\.lo$||'`;\
        /bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.   -I./src -I./src -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\"  -I/opt/homebrew/Cellar/jimtcl/0.83/include  -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Werror  -g -O2 -MT src/target/riscv/batch.lo -MD -MP -MF $depbase.Tpo -c -o src/target/riscv/batch.lo src/target/riscv/batch.c &amp;&amp;\
        mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./src -I./src -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I/opt/homebrew/Cellar/jimtcl/0.83/include -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Werror -g -O2 -MT src/target/riscv/batch.lo -MD -MP -MF src/target/riscv/.deps/batch.Tpo -c src/target/riscv/batch.c -o src/target/riscv/batch.o
src/target/riscv/batch.c:194:24: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
  194 |                         uint32_t *data_in = (uint32_t*)batch-&gt;data_in;
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~
src/target/riscv/batch.c:243:13: error: incompatible pointer types initializing 'uint32_t *' (aka 'unsigned int *') with an expression of type 'uint8_t *const' (aka 'unsigned char *const') [-Werror,-Wincompatible-pointer-types]
  243 |                 uint32_t *data_in = batch-&gt;data_in;
      |                           ^         ~~~~~~~~~~~~~~
2 errors generated.
make[2]: *** [src/target/riscv/batch.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
```

## 対応方法

本当は良くはないものの、Wcast-alignを外すぐらいしか方法がない。
以下のようにソースコードレベルで等価な実装にするのが良いものの、
関数内で引数のポインタの値を持ってしまっているせいか、
呼び出し側で回避する方法が見当たらなかった。

```c
                        uint32_t data_in;
                        uint8_t  *dst = batch-&gt;data_in + (batch-&gt;used_scans * sizeof(uint32_t));
                        if (batch-&gt;ap) {
                                printf("batch-&gt;ap true.\n");
                                uint32_t dmi_addr = 4 * riscv_get_dmi_address(batch-&gt;target, address);
                                batch-&gt;queued_retval = mem_ap_read_u32(batch-&gt;ap, dmi_addr, &amp;data_in);
                        } else {
                                printf("batch-&gt;ap false.\n");
                                uint32_t dmi_addr = riscv_get_dmi_address(batch-&gt;target, address);
                                batch-&gt;queued_retval = riscv_dmi_read(batch-&gt;target,
                                                                                   &amp;data_in, dmi_addr);
                        }
                       memcpy(dst, &amp;data_in, sizeof(uint32_t));
```

# riscv-gnu-toolchainのgdbでエラーが出る

## 状況

riscv-gnu-toolchainをhomebrewでビルドできるようにみえるものの、
実は以下のエラーが出ていてgdbはビルドできていない。

riscv-gnu-toolchainのmakeとしては正常にビルドできているように見えていて、
エラーが検出されずにログだけ流れていくのでわかりづらい。
インストール先のディレクトリにgdbがないことから辿っていくと気づくことができる。

```sh
checking for the correct version of gmp.h... no
configure: error: Building GDB requires GMP 4.2+, and MPFR 3.1.0+.
Try the --with-gmp and/or --with-mpfr options to specify
their locations.  If you obtained GMP and/or MPFR from a vendor
distribution package, make sure that you have installed both the libraries
and the header files.  They may be located in separate packages.
make: *** [Makefile:631: stamps/build-gdb-newlib] Error 1
```

## 対応方法

エラーの通り、gmp, mpfrが認識していない。
riscv-gnu-toolchainのビルド手順ではgmp, mpfrをbrewから
入れているので大丈夫、とは思うものの実はパスが通っていない。

対処方法としては、stamps/build-gdb-newlib ターゲットに
明示的にwith-gmp, with-mpfrを追加すれば良い。

```sh
stamps/build-gdb-newlib: $(GDB_SRCDIR) $(GDB_SRC_GIT) $(PREPARATION_STAMP)
        rm -rf $@ $(notdir $@)
        mkdir $(notdir $@)
# CC_FOR_TARGET is required for the ld testsuite.
        cd $(notdir $@) &amp;&amp; CC_FOR_TARGET=$(NEWLIB_CC_FOR_TARGET) $&lt;/configure \
                --target=$(NEWLIB_TUPLE) \
                $(CONFIGURE_HOST) \
                --prefix=$(INSTALL_DIR) \
                 \
                --disable-werror \
                $(GDB_TARGET_FLAGS) \
                --enable-gdb \
                --disable-gas \
                --disable-binutils \
                --disable-ld \
                --disable-gold \
                --with-gmp=/opt/homebrew/ \
                --with-mpfr=/opt/homebrew/ \
                --disable-gprof
        $(MAKE) -C $(notdir $@)
        $(MAKE) -C $(notdir $@) $(INSTALL_TARGET)
        mkdir -p $(dir $@) &amp;&amp; touch $@
```

本来はautoconfのレベルでhomebrew環境かどうかを判定した上で
生成するMakefileを変えるのが良い。

また、README.mdを見ると以下のように指定する方法もありそう。
ただし、こちらは試していない。

```sh
Example: ```GCC_EXTRA_CONFIGURE_FLAGS=--with-gmp=/opt/gmp make linux```
```

# OpenOCDで接続するもRISC-Vがunavailableになる

## 状況

以下の通りunavailableになってしまう。

```sh
Debug: 210 43 target.c:726 target_examine_one(): [rp2350.rv1] Examination started
Debug: 211 43 target.c:1828 target_call_event_callbacks(): target event 19 (examine-start) for core rp2350.rv1
Debug: 212 43 riscv.c:1733 riscv_examine(): [rp2350.rv1] Starting examination
Debug: 213 43 riscv-013.c:2854 init_target(): [rp2350.rv1] Init.
Debug: 214 43 riscv-013.c:1990 examine(): [rp2350.rv1] dbgbase=0x0
Debug: 215 43 riscv-013.c:859 check_dbgbase_exists(): [rp2350.rv1] Searching for DM with DMI base address (dbgbase) = 0x0
Debug: 216 43 riscv-013.c:5505 riscv013_invalidate_cached_progbuf(): [rp2350.rv1] Invalidating progbuf cache
Debug: 217 44 riscv-013.c:2058 examine(): [rp2350.rv1] dmstatus:  0x004030a2
Debug: 218 44 riscv-013.c:2074 examine(): [rp2350.rv1] hartsellen=1
Info : 219 45 riscv-013.c:2102 examine(): [rp2350.rv1] datacount=1 progbufsize=2
Info : 220 46 riscv-013.c:2159 examine(): [rp2350.rv1] unavailable.
Error: 221 46 target.c:732 target_examine_one(): [rp2350.rv1] Examination failed
Debug: 222 46 target.c:733 target_examine_one(): [rp2350.rv1] examine() returned error code -4
Debug: 223 46 target.c:1828 target_call_event_callbacks(): target event 20 (examine-fail) for core rp2350.rv1
Warn : 224 46 target.c:781 target_examine(): target rp2350.rv1 examination failed
```

## 対応方法

Raspberry Pi Pico2(RP2350)の仕様書などを見ると、
RISC-Vを立ち上げる場合には以下のブートシーケンスになっている。

* 最初はARMが立ち上がる
* ARCHSELレジスタに使用するコアを指定する。今回の場合、RISC-Vを選択する
* リセットをかける
* RISC-Vが立ち上がる

このあたりの処理をやっているのが以下のコード。

https://github.com/raspberrypi/pico-bootrom-rp2350/blob/master/src/main/arm/varm_apis.c#L169

上記を実現するのに一番簡単のは、
すでにRISC-V向けにビルドされたバイナリを持ってくること。
例えば、以下のバイナリを持ってくる。

https://micropython.org/download/RPI_PICO2/

ちなみに、一度ARM側から以下のようにARCHSELを書いてから
ターゲットをリセットする方法も試してみたもののこれだとうまくいかなかった。
monitor resetだとリセット範囲が違うのかもしれない。

```sh
target remote localhost:3333
set {int}0x40120158 = 0x3
monitor reset
```

# ようやく動く

ここまできてようやく動かすことができた。

```sh
% ./src/openocd  -c "adapter speed 5000" -s ./tcl -f tcl/interface/cmsis-dap.cfg -f tcl/target/rp2350-riscv.cfg
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in testing
Making all in tcl_commands
make[3]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all-am'.
make[2]: Nothing to be done for `all-am'.
Open On-Chip Debugger 0.12.0+dev-00002-gcd4873400 (2025-12-27-22:18)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 5000 kHz
Info : [rp2350.rv0] Hardware thread awareness created
Info : [rp2350.rv1] Hardware thread awareness created
ocd_process_reset_inner
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E6647C74036C1832
Warn : ***
Warn : *** Old Raspberry Pi Debugprobe firmware detected (1.0.1)
Warn : *** Using low-performance workaround
Warn : *** Please update to the latest release at:
Warn : *** https://github.com/raspberrypi/debugprobe/releases/latest
Warn : ***
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 5000 kHz
Info : SWD DPIDR 0x4c013477 DPv3
Info : [rp2350.rv0] datacount=1 progbufsize=2
Info : [rp2350.rv0] Disabling abstract command reads from CSRs.
Info : [rp2350.rv0] Disabling abstract command writes to CSRs.
Info : [rp2350.rv0] Core 0 could not be made part of halt group 1.
Info : [rp2350.rv0] Examined RISC-V core
Info : [rp2350.rv0]  XLEN=32, misa=0x40901105
Info : [rp2350.rv0] Examination succeed
Info : [rp2350.rv1] datacount=1 progbufsize=2
Info : [rp2350.rv1] Disabling abstract command reads from CSRs.
Info : [rp2350.rv1] Disabling abstract command writes to CSRs.
Info : [rp2350.rv1] Core 1 could not be made part of halt group 1.
Info : [rp2350.rv1] Examined RISC-V core
Info : [rp2350.rv1]  XLEN=32, misa=0x40901105
Info : [rp2350.rv1] Examination succeed
Info : [rp2350.rv0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
…

gdb側はこんな感じ。

```sh
(gdb) target remote localhost:3333
A program is being debugged already.  Kill it? (y or n) y
Remote connection closed
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.

Thread 1 "rp2350.rv0" received signal SIGTRAP, Trace/breakpoint trap.
0x100478bc in ?? ()
(gdb) info all-registers
zero           0x0	0
ra             0x2001041c	0x2001041c
sp             0x20010400	0x20010400
gp             0x200071e0	0x200071e0
tp             0x0	0x0
t0             0x80000102	-2147483390
```</description>
      <guid>https://yasuharu.net/diary/2935</guid>
      <pubDate>Wed, 31 Dec 2025 04:47:20 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>2025年8月14日</title>
      <link>https://yasuharu.net/diary/2934</link>
      <description>投稿テスト</description>
      <guid>https://yasuharu.net/diary/2934</guid>
      <pubDate>Wed, 13 Aug 2025 18:57:10 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>aarch64なUbuntuでlibncurses5を導入する</title>
      <link>https://yasuharu.net/diary/2933</link>
      <description>困ったことにUbuntu公式のリポジトリにはaarch64向けにはlibncurses5のビルド済みバイナリがない。
i386, amd64 はあるのだけれども。

この問題は、ARMから配布されているビルド済みのgcc（hostはaarch64, targetはarm）を使おうと思う場合にあたってしまう。
誰がそんな変わったクロスコンパイルするんだという話もありそうだけど、MacでVM(UTM)入れて、なんてしてたら引っかかってしまった。

そんな経緯でlibncurses5をビルドして用意するということをしてみた。
ただ、思いの外にこの方法にも落とし穴があった。
問題点を記載すると以下の通り。

・単純にlibncurses5を持ってきてビルドしても、以下の問題がある
　・aarch64に対応していないなど、諸々のビルドの問題がある
　・仮にビルドできたとしても、version symbolが存在せず、実行時に警告が出る（ただ、実行はできる）
・実はx86系で配布されているビルド済みlibncurses5は、ncurses6系列を使ってビルドされている

結局、libncurses6をビルドして、libncurses5のI/Fにあうようにするしかなさそう。
手順をまとめたのが以下の通り。

```sh
wget https://ftp.gnu.org/gnu/ncurses/ncurses-6.5.tar.gz
tar xvf ncurses-6.5.tar.gz
cd ncurses-6.5
./configure --with-shared --with-termlib --with-versioned-syms --with-abi-version=5
make
sudo cp ./lib/libncurses.so.5.9 /lib/aarch64-linux-gnu/.
sudo cp ./lib/libtinfo.so.5.9 /lib/aarch64-linux-gnu/.
```

なお、configureのオプションは本当はもう少し必要だったりする。
x86向けに配布されているものと同じようにしたい場合は、
以下からビルドスクリプトをダウンロードして
CONFARGS, CONFARGS-LEGACY あたりを参考にすると正しいものができる。

https://packages.ubuntu.com/focal/libncurses5
</description>
      <guid>https://yasuharu.net/diary/2933</guid>
      <pubDate>Tue, 31 Dec 2024 05:41:02 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>U-Bootのwgetコマンドへの不具合修正パッチを投稿してみた</title>
      <link>https://yasuharu.net/diary/2932</link>
      <description>U-Bootのwgetコマンドを使っているとたまに転送に失敗することがあり、
不具合を追っていった結果、2つほど不具合がありました。
以下2つのパッチを作成して、無事mergeされました。

https://github.com/u-boot/u-boot/commit/cab7867cff33f9c21025102ea9ca3b26e362fb52
https://github.com/u-boot/u-boot/commit/beac9581531d7882df8c1de653db18fb3ab4100a

1つ目のパッチを最初にMLに投稿したところ、別の不具合に心当たりある？とのこと。
実はすでにその問題には気づいていて、
1つ目のパッチを1週間ほど手元でテストする中で発生しており、
問題点と修正方法は目星がついている状況でした。
早速2つ目のパッチを作成、テストしてMLに投稿し、
無事が解消したとの連絡があり安心しました。

ただ、まだ何かおかしいところがあるようなので、引き続き調査は必要そうです。
</description>
      <guid>https://yasuharu.net/diary/2932</guid>
      <pubDate>Sat, 20 Apr 2024 00:04:12 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>Raspberry Pi 4Bでは、Raspberry Pi OSとmainlineのLinux Kernelでserial0, serial1の割当が違う</title>
      <link>https://yasuharu.net/diary/2931</link>
      <description>Raspberry Pi 4Bでは、Raspberry Pi OSのmainlineのDeviceTreeは、serial0がシリアルコンソール（mini UART側）になるようになっている。
おそらく、過去のRaspberry Piシリーズと同じようにserial0がシリアルコンソールになるように合わせていると推測。
Rasbperry Pi OSの場合は以下の辺りでその対応付の変更をしている。

https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/bcm2711-rpi-4-b.dts#L250-L288

mainlineの場合は、serial1がシリアルコンソールとなっている。
なお、Rasbperry Piのシリーズによって定義が異なるので、注意して確認したほうが良さそう。</description>
      <guid>https://yasuharu.net/diary/2931</guid>
      <pubDate>Sun, 15 Oct 2023 08:28:55 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>最新の Linux Kernel を各環境でビルドして動かしてみる(2023/8/6)</title>
      <link>https://yasuharu.net/diary/2930</link>
      <description>ここ数年の Linux Kernel はかなり安定しているとは思っていて、滅多にハングする状況を見ることをなくなりました。
でも、本当にそうなのか気になります。
気が向いたときに最新の Linux Kernel をいくつかのアーキテクチャでビルドして動かしてみた結果をまとめてみます。

■ 以下の情報に関する注意点

 * ファームウェアやブートローダ、ユーザランドは適当なので、現時点で再現性はないです
 * あくまでも起動プロセスを見ているだけです。長時間動作させた場合や高負荷時の条件では、別の問題が発生する可能性があります

■ 結果 (mainline)

バージョン : 6.5-rc4

 * Raspberry Pi 2 (arm)
   * 問題なし
   * DTSの配置先が変わっている。arch/arm/boot/dts/bcm2836-rpi-2-b.dtb -&gt; arch/arm/boot/dts/broadcom/bcm2836-rpi-2-b.dtb
     * 以前からdtsディレクトリのファイルは多かったので、整理されるとありがたい

 * VisionFive 2 (riscv)
    * ルートファイルシステムのマウントで止まる
    * ドライバはロードされているものの、microSDの挿抜で何もログがでていないので、認識していない？
[    0.121509] sdhci: Secure Digital Host Controller Interface driver
[    0.121528] sdhci: Copyright(c) Pierre Ossman
[    0.121643] sdhci-pltfm: SDHCI platform and OF driver helper
…
[    1.123265] Waiting for root device /dev/mmcblk1p4...
   * MMC_DW_STARFIVE がデフォルトでnだったので、yにしてみたものの変わらず
   * DTSを確かめてみるとそもそも定義がなかった
     * VisionFive2のカーネルのリポジトリを見ると定義があったので、これを使えばできそうには見えるものの、電源レギュレータとかも参照していて単純なコピペでは無理

■ 結果 (-rt)

バージョン : 6.4.6-rt8

 * Raspberry Pi 2 (arm)
   * 問題なし</description>
      <guid>https://yasuharu.net/diary/2930</guid>
      <pubDate>Sun, 06 Aug 2023 08:01:39 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>OpenOCDを使ってVisionFive2のJTAGデバッグ</title>
      <link>https://yasuharu.net/diary/2909</link>
      <description>単純なアタッチは以下の通りでできた。
https://forum.rvspace.org/t/connecting-to-visionfive-s-jtag-port-a-short-guide/514/1

ホスト側のJTAG I/Fには秋月のFT232HLを使用した。

アタッチしてデバッグまでは特に問題なくできるものの、
TRSTnをアサートしてもリセットがかからない。
これができれば、リセットベクタからデバッグができるのだけどなぁ。。。

手順は以下の通り。

1. FT232HLのOpenOCDの設定にTRSTn関連の端子設定をする
2. gdbからmonitor resetコマンドを実行する

念のためオシロでTRSTnの端子を見ると、ちゃんと一定時間Lにアサートしていた。
アサート時間が短いのかなと思い、monitor jtag_ntrst_assert_widthで調整をしてみても変わらず。
ホスト側は特に問題なさそう。

ターゲット側の問題のような感じはするけど、はっきりとはわからず。
仕様書は抜粋版しか公開されていないようなので、ここからも情報は得られなかった。

—

そうなると、U-Bootだとresetコマンドが実行できるのはなんでだろう？
抜粋版の仕様書にリセットレジスタの記載があるので、これを叩いているのだろうか。

ソースを見てみる。
U-BootのCONFIG_SYSRESET_SBIが経っていて、resetコマンド実行時にU-BootからOpenSBIに落ちている。
OpenSBIでは、I2Cでregulatorのレジスタのresetビットを叩いている…。
これは望んでいた方法ではないな。。。</description>
      <guid>https://yasuharu.net/diary/2909</guid>
      <pubDate>Sat, 05 Aug 2023 07:13:07 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>VisionFive2でLinuxを起動する</title>
      <link>https://yasuharu.net/diary/2908</link>
      <description>VisionFive2 8GByteが届きました。
早速、配布されているイメージからLinuxを起動してみました。
SDにイメージを書き込んでOK、とは行かなかったので、Linuxを起動させるまでの手順を書いておきます。

試したイメージはDebian Image 69です。
またターゲットとの通信はUARTを使用しました。
以下は起動することだけを目的としているので、必ずしも正しい方法とは限らないことにご注意ください。

ダウンロードしたイメージをMicroSDに書き込みます。
32GByteのMicorSDを使用しました。

UARTをPCとつないで、電源を投入します。
UARTからは以下のログが出力されます（必要な部分だけ抜粋しています）。

```sh
Loading Environment from SPIFlash... SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment
…
Enter choice: 1
1:      Debian GNU/Linux bookworm/sid 5.15.0-starfive
Retrieving file: /boot/initrd.img-5.15.0-starfive
9684953 bytes read in 411 ms (22.5 MiB/s)
Retrieving file: /boot/vmlinuz-5.15.0-starfive
…
append: root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 single
Retrieving file: /boot/dtbs/starfive/starfive_visionfive2.dtb
Failed to load '/boot/dtbs/starfive/starfive_visionfive2.dtb'
kernel_comp_addr_r or kernel_comp_size is not provided!
…
```

U-Bootの環境変数が壊れている（もしくは書かれていない）ため、デフォルトの環境変数を読んでいます。
デフォルトでも必要なことは書かれており、Linux Kernelの起動は行おうとしています。
ただ、DTBが見つからず、エラーとなっていました。

MicorSDの中身をPCで見てみると、それっぽいDTBが見つかります。

```sh
/mnt/boot$ find .
…
./dtbs/starfive/jh7110-evb-usbdevice.dtb
./dtbs/starfive/jh7110-evb.dtb
./dtbs/starfive/jh7110-fpga.dtb
./dtbs/starfive/jh7110-visionfive-v2-A10.dtb
./dtbs/starfive/jh7110-visionfive-v2-A11.dtb
./dtbs/starfive/jh7110-visionfive-v2-ac108.dtb
./dtbs/starfive/jh7110-visionfive-v2-wm8960.dtb
./dtbs/starfive/jh7110-visionfive-v2.dtb
./dtbs/starfive/evb-overlay
```

ロードしようとしているファイル名にコピーします。

```sh
/mnt/boot/dtbs/starfive$ sudo cp jh7110-visionfive-v2.dtb starfive_visionfive2.dtb
```

ひとまず、先ほどのエラーはこれで消えます。
次に問題になるのは以下の部分。

```sh
kernel_comp_addr_r or kernel_comp_size is not provided!
```

Linux Kernelのdecompress先のアドレスとサイズが設定されていないとエラーとなります。

これらを設定します。
この辺りは、8GByteもRAMがあるのでざっくりと取っておけば間違いはないです。

bdinfoでDRAMの開始アドレスと（U-Bootの）DTBの配置先、リロケート先を確認しておきます。
startが0x4000_0000(+1GByte)です。
DTBの配置先とリロケート先は4GByteの手前ぐらいなので、ここは避けたほうが良さそうです。

```sh
StarFive # bdinfo
boot_params = 0x0000000000000000
DRAM bank   = 0x0000000000000000
-&gt; start    = 0x0000000040000000
-&gt; size     = 0x0000000200000000
relocaddr   = 0x00000000fff4e000
reloc off   = 0x00000000bfd4e000
fdt_blob    = 0x00000000fffc97f0
```

また、U-BootがロードするLinuxのDTBの配置先とLinux Kernelのアドレスを確認します。
先頭1GByteから64MByteと96MByteの位置に取っています。
また一時的にloadaddrも使用しているので、ここも避けたほうが良さそうです。

```sh
fdt_addr_r=0x46000000
kernel_addr_r=0x44000000
loadaddr=0xa0000000
```

以上から展開先は1GByteから+256MByteの0x5000_0000を設定しています。
サイズは16MByteを指定します。
（以降のログでは起動していますが、後から考えると16MByteは少ない可能性があるため、もっと増やしたほうが良いです）

```sh
# setenv kernel_comp_addr_r 0x50000000
# setenv kernel_comp_size 0x1000000
```

ここまでできたら、後はブートするのみです。

```sh
# run bootcmd
```

以下に起動までのログを示します。

```sh
U-Boot SPL 2021.10 (Oct 31 2022 - 12:11:37 +0800)
DDR version: dc2e84f0.
Trying to boot from SPI

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ &lt; | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name             : StarFive VisionFive V2
Platform Features         : medeleg
Platform HART Count       : 5
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 4000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Firmware Base             : 0x40000000
Firmware Size             : 360 KB
Runtime SBI Version       : 0.3

Domain0 Name              : root
Domain0 Boot HART         : 1
Domain0 HARTs             : 0*,1*,2*,3*,4*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000040200000
Domain0 Next Arg1         : 0x0000000042200000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes

Boot HART ID              : 1
Boot HART Domain          : root
Boot HART Priv Version    : v1.11
Boot HART Base ISA        : rv64imafdcbx
Boot HART ISA Extensions  : none
Boot HART PMP Count       : 8
Boot HART PMP Granularity : 4096
Boot HART PMP Address Bits: 34
Boot HART MHPM Count      : 2
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


U-Boot 2021.10 (Oct 31 2022 - 12:11:37 +0800), Build: jenkins-VF2_515_Branch_SDK_Release-10


CPU:   rv64imacu
Model: StarFive VisionFive V2
DRAM:  8 GiB
MMC:   sdio0@16010000: 0, sdio1@16020000: 1
Loading Environment from SPIFlash... SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

StarFive EEPROM format v2

--------EEPROM INFO--------
Vendor : StarFive Technology Co., Ltd.
Product full SN: VF7110A1-2250-D008E000-00001168
data version: 0x2
PCB revision: 0xa1
BOM revision: A
Ethernet MAC0 address: 6c:cf:39:00:1c:9f
Ethernet MAC1 address: 6c:cf:39:00:1c:a0
--------EEPROM INFO--------

In:    serial@10000000
Out:   serial@10000000
Err:   serial@10000000
Model: StarFive VisionFive V2
Net:   eth0: ethernet@16030000, eth1: ethernet@16040000
switch to partitions #0, OK
mmc1 is current device
found device 1
bootmode flash device 1
Can't set block device
Failed to load '/boot/uEnv.txt'
Hit any key to stop autoboot:  0
Can't set block device
Importing environment from mmc1 ...
## Warning: Input data exceeds 1048576 bytes - truncated
## Info: input data size = 1048578 = 0x100002
## Error: "boot2" not defined
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:2...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
823 bytes read in 5 ms (160.2 KiB/s)
U-Boot menu
1:      Debian GNU/Linux bookworm/sid 5.15.0-starfive
2:      Debian GNU/Linux bookworm/sid 5.15.0-starfive (rescue target)
Enter choice: 1:        Debian GNU/Linux bookworm/sid 5.15.0-starfive
Retrieving file: /boot/initrd.img-5.15.0-starfive
9684953 bytes read in 411 ms (22.5 MiB/s)
Retrieving file: /boot/vmlinuz-5.15.0-starfive
8015200 bytes read in 340 ms (22.5 MiB/s)
append: root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
Retrieving file: /boot/dtbs/starfive/starfive_visionfive2.dtb
47546 bytes read in 10 ms (4.5 MiB/s)
kernel_comp_addr_r or kernel_comp_size is not provided!
2:      Debian GNU/Linux bookworm/sid 5.15.0-starfive (rescue target)
Retrieving file: /boot/initrd.img-5.15.0-starfive
9684953 bytes read in 411 ms (22.5 MiB/s)
Retrieving file: /boot/vmlinuz-5.15.0-starfive
8015200 bytes read in 340 ms (22.5 MiB/s)
append: root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 single
Retrieving file: /boot/dtbs/starfive/starfive_visionfive2.dtb
47546 bytes read in 10 ms (4.5 MiB/s)
kernel_comp_addr_r or kernel_comp_size is not provided!
SCRIPT FAILED: continuing...
Card did not respond to voltage select! : -110

** Unable to read file ubootefi.var **
Failed to load EFI variables
Scanning mmc 1:3...
ethernet@16030000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
phy_startup() failed: -110FAILED: -110ethernet@16040000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
phy_startup() failed: -110FAILED: -110ethernet@16030000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
phy_startup() failed: -110FAILED: -110ethernet@16040000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
phy_startup() failed: -110FAILED: -110StarFive # setenv kernel_comp_addr_r 0x50000000
StarFive # setenv kernel_comp_size 0x1000000
StarFive # run bootcmd
Can't set block device
Importing environment from mmc1 ...
## Error: "boot2" not defined
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:2...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
823 bytes read in 5 ms (160.2 KiB/s)
U-Boot menu
1:      Debian GNU/Linux bookworm/sid 5.15.0-starfive
2:      Debian GNU/Linux bookworm/sid 5.15.0-starfive (rescue target)
Enter choice: 1
1:      Debian GNU/Linux bookworm/sid 5.15.0-starfive
Retrieving file: /boot/initrd.img-5.15.0-starfive
9684953 bytes read in 412 ms (22.4 MiB/s)
Retrieving file: /boot/vmlinuz-5.15.0-starfive
8015200 bytes read in 340 ms (22.5 MiB/s)
append: root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
Retrieving file: /boot/dtbs/starfive/starfive_visionfive2.dtb
47546 bytes read in 9 ms (5 MiB/s)
   Uncompressing Kernel Image
Moving Image from 0x44000000 to 0x40200000, end=41767000
## Flattened Device Tree blob at 46000000
   Booting using the fdt blob at 0x46000000
   Using Device Tree in place at 0000000046000000, end 000000004600e9b9

Starting kernel ...

clk u5_dw_i2c_clk_core already disabled
clk u5_dw_i2c_clk_apb already disabled
[    0.000000] Linux version 5.15.0-starfive (sw_buildbot@mdcsw02) (riscv64-unknown-linux-gnu-gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP Mon Dec 19 07:56:37 EST 2022
[    0.000000] OF: fdt: Ignoring memory range 0x40000000 - 0x40200000
[    0.000000] Machine model: StarFive VisionFive V2
[    0.000000] earlycon: uart0 at MMIO32 0x0000000010000000 (options '115200')
[    0.000000] printk: bootconsole [uart0] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] OF: reserved mem: failed to allocate memory for node 'linux,cma'
[    0.000000] cma: Reserved 16 MiB at 0x00000000bf000000
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000040200000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000013fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040200000-0x00000000c010ffff]
[    0.000000]   node   0: [mem 0x00000000c0110000-0x00000000c01fffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x000000013fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040200000-0x000000013fffffff]
[    0.000000] SBI specification v0.3 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10000
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI RFENCE extension detected
[    0.000000] SBI v0.2 HSM extension detected
[    0.000000] CPU with hartid=0 is not available
[    0.000000] CPU with hartid=0 is not available

[    0.000000] riscv: ISA extensions acdfim
[    0.000000] riscv: ELF capabilities acdfim
[    0.000000] percpu: Embedded 17 pages/cpu s31528 r8192 d29912 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 1033735
[    0.000000] Kernel command line: root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
[    0.000000] Unknown command line parameters: stmmaceth=chain_mode:1 selinux=0
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: mapped [mem 0x00000000fb000000-0x00000000ff000000] (64MB)
[    0.000000] Memory: 3942888K/4192256K available (9884K kernel code, 4982K rwdata, 4096K rodata, 2191K init, 401K bss, 232984K reserved, 16384K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] rcu:     RCU debug extended QS entry/exit.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] CPU with hartid=0 is not available
[    0.000000] riscv-intc: unable to find hart id for /cpus/cpu@0/interrupt-controller
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: plic@c000000: mapped 136 interrupts with 4 handlers for 9 contexts.
[    0.000000] random: get_random_bytes called from start_kernel+0x4d0/0x6e2 with crng_init=0
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 881590404240 ns
[    0.000000] sched_clock: 64 bits at 4MHz, resolution 250ns, wraps every 2199023255500ns
[    0.008967] clocksource: timer@13050000.ch0: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.020277] clocksource: timer@13050000.ch1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.031594] clocksource: timer@13050000.ch2: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.042905] clocksource: timer@13050000.ch3: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.054353] Console: colour dummy device 80x25
[    0.060256] printk: console [tty0] enabled
[    0.064799] Calibrating delay loop (skipped), value calculated using timer frequency.. 8.00 BogoMIPS (lpj=40000)
[    0.076009] pid_max: default: 32768 minimum: 301
[    0.081239] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.089463] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.099335] ASID allocator disabled
[    0.103269] rcu: Hierarchical SRCU implementation.
[    0.108694] EFI services will not be available.
[    0.114024] smp: Bringing up secondary CPUs ...
[    0.120417] smp: Brought up 1 node, 4 CPUs
[    0.125987] devtmpfs: initialized
[    0.135789] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.146636] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.154663] pinctrl core: initialized pinctrl subsystem
[    0.161100] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.168134] cpuidle: using governor menu
[    0.190004] platform soc:dsi-output: Fixing up cyclic dependency with 29400000.dc8200
[    0.199088] platform 295d0000.mipi: Fixing up cyclic dependency with soc:dsi-output
[    0.207842] platform 29590000.hdmi: Fixing up cyclic dependency with 29400000.dc8200
[    0.225951] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[    0.233348] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.243400] vgaarb: loaded
[    0.246584] SCSI subsystem initialized
[    0.250972] usbcore: registered new interface driver usbfs
[    0.257054] usbcore: registered new interface driver hub
[    0.262914] usbcore: registered new device driver usb
[    0.268728] mc: Linux media interface: v0.10
[    0.273439] videodev: Linux video capture interface: v2.00
[    0.279635] Advanced Linux Sound Architecture Driver Initialized.
[    0.286651] Bluetooth: Core ver 2.22
[    0.290614] NET: Registered PF_BLUETOOTH protocol family
[    0.296454] Bluetooth: HCI device and connection manager initialized
[    0.303451] Bluetooth: HCI socket layer initialized

[    0.308818] Bluetooth: L2CAP socket layer initialized
[    0.314389] Bluetooth: SCO socket layer initialized
[    0.320090] clocksource: Switched to clocksource riscv_clocksource
[    0.332768] NET: Registered PF_INET protocol family
[    0.338772] IP idents hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.350050] tcp_listen_portaddr_hash hash table entries: 2048 (order: 4, 81920 bytes, linear)
[    0.359548] TCP established hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.368654] TCP bind hash table entries: 32768 (order: 8, 1048576 bytes, linear)
[    0.377896] TCP: Hash tables configured (established 32768 bind 32768)
[    0.385350] UDP hash table entries: 2048 (order: 5, 196608 bytes, linear)
[    0.393085] UDP-Lite hash table entries: 2048 (order: 5, 196608 bytes, linear)
[    0.401432] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.408117] RPC: Registered named UNIX socket transport module.
[    0.414654] RPC: Registered udp transport module.
[    0.419824] RPC: Registered tcp transport module.
[    0.425001] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.432662] PCI: CLS 0 bytes, default 64
[    0.437540] Initialise system trusted keyrings
[    0.440391] Unpacking initramfs...
[    0.442591] workingset: timestamp_bits=62 max_order=20 bucket_order=0
[    0.458172] NFS: Registering the id_resolver key type
[    0.463792] Key type id_resolver registered
[    0.468404] Key type id_legacy registered
[    0.472952] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.480355] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.488553] ntfs: driver 2.1.32 [Flags: R/W].
[    0.493638] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.500768] fuse: init (API version 7.34)
[    0.536216] NET: Registered PF_ALG protocol family
[    0.541542] Key type asymmetric registered
[    0.546056] Asymmetric key parser 'x509' registered
[    0.551522] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.559674] io scheduler mq-deadline registered
[    0.564695] io scheduler kyber registered
[    0.655630] clk-starfive-jh7110 13020000.clock-controller: starfive JH7110 clkgen init successfully.
[    0.666899] L2CACHE: DataError @ 0x00000000.08040140
[    0.672493] L2CACHE: DataFail @ 0x00000000.0804000C
[    0.677961] L2CACHE: No. of Banks in the cache: 8
[    0.683181] L2CACHE: No. of ways per bank: 16
[    0.687991] L2CACHE: Sets per bank: 256
[    0.692242] L2CACHE: Bytes per cache block: 64
[    0.697149] L2CACHE: Index of the largest way enabled: 15
[    0.703455] jh7110-pmu 17030000.power-controller: registered 8 power domains
[    0.773166] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
[    0.783097] @@#########################@@
[    0.825259] @@ dev ptr:ffffffe0bfedc000/1500/1
[    0.830436] PVR_K:  1: Read BVNC 36.50.54.182 from HW device registers
[    0.837714] PVR_K:  1: RGX Device registered BVNC 36.50.54.182 with 1 core in the system
[    0.847944] [drm] Initialized pvr 1.17.6210866 20170530 for 18000000.gpu on minor 0
[    0.869026] loop: module loaded
[    0.875003] spi-nor spi0.0: gd25lq128d (16384 Kbytes)
[    1.090678] Freeing initrd memory: 9456K
[    1.111323] 3 fixed-partitions partitions found on MTD device 13010000.spi.0
[    1.119119] Creating 3 MTD partitions on "13010000.spi.0":
[    1.125199] 0x000000000000-0x000000020000 : "spl"
[    1.132172] 0x000000100000-0x000000400000 : "uboot"
[    1.139080] 0x000000f00000-0x000001000000 : "data"
[    1.147008] libphy: Fixed MDIO Bus: probed

[    1.153018] CAN device driver interface
[    1.157850] starfive-eth-plat 16030000.ethernet: force_sf_dma_mode is ignored if force_thresh_dma_mode is set.
[    1.169283] starfive-eth-plat 16030000.ethernet: User ID: 0x41, Synopsys ID: 0x52
[    1.177561] starfive-eth-plat 16030000.ethernet:     DWMAC4/5
[    1.183627] starfive-eth-plat 16030000.ethernet: DMA HW capability register supported
[    1.192274] starfive-eth-plat 16030000.ethernet: RX Checksum Offload Engine supported
[    1.200914] starfive-eth-plat 16030000.ethernet: Wake-Up On Lan supported
[    1.208389] starfive-eth-plat 16030000.ethernet: TSO supported
[    1.214841] starfive-eth-plat 16030000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    1.224074] starfive-eth-plat 16030000.ethernet: Enabled Flow TC (entries=1)
[    1.231856] starfive-eth-plat 16030000.ethernet: TSO feature enabled
[    1.238853] starfive-eth-plat 16030000.ethernet: Using 40 bits DMA width
[    1.498340] libphy: stmmac: probed
[    1.502151] YT8531 Gigabit Ethernet stmmac-0:00: attached PHY driver (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[    1.513100] YT8531 Gigabit Ethernet stmmac-0:01: attached PHY driver (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[    1.525258] starfive-eth-plat 16040000.ethernet: force_sf_dma_mode is ignored if force_thresh_dma_mode is set.
[    1.536672] starfive-eth-plat 16040000.ethernet: User ID: 0x41, Synopsys ID: 0x52
[    1.544951] starfive-eth-plat 16040000.ethernet:     DWMAC4/5
[    1.551018] starfive-eth-plat 16040000.ethernet: DMA HW capability register supported
[    1.559648] starfive-eth-plat 16040000.ethernet: RX Checksum Offload Engine supported
[    1.568291] starfive-eth-plat 16040000.ethernet: Wake-Up On Lan supported
[    1.575782] starfive-eth-plat 16040000.ethernet: TSO supported
[    1.582233] starfive-eth-plat 16040000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    1.591480] starfive-eth-plat 16040000.ethernet: Enabled Flow TC (entries=1)
[    1.599243] starfive-eth-plat 16040000.ethernet: TSO feature enabled
[    1.606252] starfive-eth-plat 16040000.ethernet: Using 40 bits DMA width
[    1.864194] libphy: stmmac: probed
[    1.867967] YT8512B Ethernet stmmac-1:00: attached PHY driver (mii_bus:phy_addr=stmmac-1:00, irq=POLL)
[    1.878273] YT8512B Ethernet stmmac-1:03: attached PHY driver (mii_bus:phy_addr=stmmac-1:03, irq=POLL)
[    1.890152] Intel(R) Wireless WiFi driver for Linux
[    1.897468] cdns3-starfive 10210000.usbdrd: usb mode 2 2.0 probe success
[    1.905661] usbcore: registered new interface driver uas
[    1.911596] usbcore: registered new interface driver usb-storage
[    1.930426] starfive-rtc 17040000.rtc: registered as rtc0
[    1.936395] starfive-rtc 17040000.rtc: setting system clock to 2001-01-01T00:00:00 UTC (978307200)
[    1.946442] i2c_dev: i2c /dev entries driver
[    1.951408] usbcore: registered new interface driver uvcvideo
[    1.958909] starfive-wdt 13070000.wdog: Heartbeat: timeout=15, count/2=180000000 (0aba9500)
[    1.968664] Bluetooth: HCI UART driver ver 2.3
[    1.973591] Bluetooth: HCI UART protocol H4 registered
[    1.979470] starfive-cpufreq soc:starfive,jh7110-cpufreq: Failed to get regulator for cpu!
[    1.988614] starfive-cpufreq soc:starfive,jh7110-cpufreq: Failed to init starfive cpu dvfs info
[    1.998753] sdhci: Secure Digital Host Controller Interface driver
[    2.005592] sdhci: Copyright(c) Pierre Ossman
[    2.010437] Synopsys Designware Multimedia Card Interface Driver
[    2.017361] sdhci-pltfm: SDHCI platform and OF driver helper
[    2.024429] jh7110-sec 16000000.crypto: Unable to request sec_m dma channel in DMA channel
[    2.033575] jh7110-sec 16000000.crypto: Cannot initial dma chan
[    2.040410] usbcore: registered new interface driver usbhid
[    2.046561] usbhid: USB HID core driver
[    2.051056] usbcore: registered new interface driver snd-usb-audio
[    2.061142] NET: Registered PF_PACKET protocol family
[    2.066734] can: controller area network core
[    2.071652] NET: Registered PF_CAN protocol family
[    2.076944] can: raw protocol
[    2.080229] can: broadcast manager protocol
[    2.084851] can: netlink gateway - max_hops=1
[    2.089963] Bluetooth: RFCOMM TTY layer initialized
[    2.095385] Bluetooth: RFCOMM socket layer initialized
[    2.101101] Bluetooth: RFCOMM ver 1.11
[    2.105269] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    2.111143] Bluetooth: BNEP filters: protocol multicast
[    2.116916] Bluetooth: BNEP socket layer initialized
[    2.122578] 9pnet: Installing 9P2000 support
[    2.127344] Key type dns_resolver registered

[    2.132830] Loading compiled-in X.509 certificates
[    2.174109] starfive_jh7110-pinctrl 13040000.gpio: SiFive GPIO chip registered 64 GPIOs
[    2.183785] starfive_jh7110-pinctrl 17020000.gpio: SiFive GPIO chip registered 4 GPIOs
[    2.192770] pl08xdmac 16008000.sec_dma: initialized 8 virtual memcpy channels
[    2.200677] pl08xdmac 16008000.sec_dma: initialized 16 virtual slave channels
[    2.210216] debugfs: Directory '16008000.sec_dma' with parent 'dmaengine' already present!
[    2.219364] pl08xdmac 16008000.sec_dma: DMA: PL080 rev0 at 0x16008000 irq 23
[    2.227426] ssp-pl022 10060000.spi: ARM PL022 driver for StarFive SoC platform, device ID: 0x00041022
[    2.237631] ssp-pl022 10060000.spi: mapped registers from 0x0000000010060000 to (____ptrval____)
[    2.247779] ssp-pl022 10060000.spi: Requested frequency: 10000000 Hz is unsupported,select by default 8250000 Hz
[    2.259395] ssp-pl022 10060000.spi: will use autosuspend for runtime pm, delay 100ms
[    2.269288] i2c 2-0045: Fixing up cyclic dependency with 295d0000.mipi
[    2.276782] seeed_panel 2-0045: Unknown Atmel firmware revision: 0x00
[    2.284121] i2c 2-0019: Fixing up cyclic dependency with 295d0000.mipi
[    2.292743] at24 5-0050: supply vcc not found, using dummy regulator
[    2.300588] at24 5-0050: 512 byte 24c04 EEPROM, writable, 16 bytes/write
[    2.309908] axp15060-regulator 5-0036: Register mipi_0p9 done! vol range:900 ~ 900 mV
[    2.320057] axp15060-regulator 5-0036: Register hdmi_1p8 done! vol range:1800 ~ 1800 mV
[    2.330401] axp15060-regulator 5-0036: Register hdmi_0p9 done! vol range:900 ~ 900 mV
[    2.340571] axp15060-regulator 5-0036: Register cpu_vdd done! vol range:500 ~ 1540 mV
[    2.350006] i2c 6-0010: Fixing up cyclic dependency with 19800000.vin_sysctl
[    2.358206] imx219 6-0010: supply VANA not found, using dummy regulator
[    2.365642] imx219 6-0010: supply VDIG not found, using dummy regulator
[    2.373006] imx219 6-0010: supply VDDL not found, using dummy regulator
[    2.387798] imx219 6-0010: failed to read chip id 219
[    2.393606] imx219: probe of 6-0010 failed with error -5
[    2.402042] pcie_plda 2b000000.pcie: host bridge /soc/pcie@2B000000 ranges:
[    2.409769] pcie_plda 2b000000.pcie:      MEM 0x0030000000..0x0037ffffff -&gt; 0x0030000000
[    2.418741] pcie_plda 2b000000.pcie:      MEM 0x0900000000..0x093fffffff -&gt; 0x0900000000
[    2.427723] ATR entry: 0x0940000000 -&gt; 0x0000000000 [0x0010000000] (param: 0x000001)
[    2.436293] ATR entry: 0x0030000000 -&gt; 0x0030000000 [0x0008000000] (param: 0x000000)
[    2.444856] ATR entry: 0x0900000000 -&gt; 0x0900000000 [0x0040000000] (param: 0x000000)
[    2.800188] pcie_plda 2b000000.pcie: Port link up.
[    2.805633] pcie_plda 2b000000.pcie: PCI host bridge to bus 0000:00
[    2.812571] pci_bus 0000:00: root bus resource [bus 00-ff]
[    2.818623] pci_bus 0000:00: root bus resource [mem 0x30000000-0x37ffffff]
[    2.826224] pci_bus 0000:00: root bus resource [mem 0x900000000-0x93fffffff pref]
[    2.834517] pci 0000:00:00.0: [1556:1111] type 01 class 0x060400
[    2.841163] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0xffffffff 64bit pref]
[    2.849191] pci 0000:00:00.0: supports D1 D2
[    2.853911] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[    2.864775] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    2.873759] pci 0000:01:00.0: [1106:3483] type 00 class 0x0c0330
[    2.880415] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit]
[    2.887980] pci 0000:01:00.0: PME# supported from D0 D3cold
[    2.897488] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    2.904828] pci 0000:00:00.0: BAR 0: no space for [mem size 0x100000000 64bit pref]
[    2.913301] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x100000000 64bit pref]
[    2.922154] pci 0000:00:00.0: BAR 8: assigned [mem 0x30000000-0x300fffff]
[    2.929638] pci 0000:01:00.0: BAR 0: assigned [mem 0x30000000-0x30000fff 64bit]
[    2.937731] pci 0000:00:00.0: PCI bridge to [bus 01]
[    2.943218] pci 0000:00:00.0:   bridge window [mem 0x30000000-0x300fffff]
[    2.950815] pci 0000:00:00.0: enabling device (0000 -&gt; 0002)
[    2.957057] pci 0000:01:00.0: enabling device (0000 -&gt; 0002)
[    2.963338] pci 0000:01:00.0: quirk_usb_early_handoff+0x0/0x9d4 took 12238 usecs
[    2.971727] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    2.977509] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 1
[    2.986085] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000040000000890
[    2.996243] pcie_plda 2b000000.pcie: msi#0 address_hi 0x0 address_lo 0x190
[    3.004224] xhci_hcd 0000:01:00.0: xHCI Host Controller
[    3.010000] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 2
[    3.018191] xhci_hcd 0000:01:00.0: Host supports USB 3.0 SuperSpeed

[    3.025844] hub 1-0:1.0: USB hub found
[    3.030016] hub 1-0:1.0: 1 port detected
[    3.035395] hub 2-0:1.0: USB hub found
[    3.039570] hub 2-0:1.0: 4 ports detected
[    3.046871] pcie_plda 2c000000.pcie: host bridge /soc/pcie@2C000000 ranges:
[    3.054619] pcie_plda 2c000000.pcie:      MEM 0x0038000000..0x003fffffff -&gt; 0x0038000000
[    3.063576] pcie_plda 2c000000.pcie:      MEM 0x0980000000..0x09bfffffff -&gt; 0x0980000000
[    3.072567] ATR entry: 0x09c0000000 -&gt; 0x0000000000 [0x0010000000] (param: 0x000001)
[    3.081134] ATR entry: 0x0038000000 -&gt; 0x0038000000 [0x0008000000] (param: 0x000000)
[    3.089680] ATR entry: 0x0980000000 -&gt; 0x0980000000 [0x0040000000] (param: 0x000000)
[    3.250164] usb usb2-port2: over-current condition
[    3.350168] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[    3.410143] usb usb2-port4: over-current condition
[    3.520348] pcie_plda 2c000000.pcie: Port link down, exit.
[    3.540223] clk-starfive-jh7110-vout 295c0000.clock-controller: starfive JH7110 clk_vout init successfully.
[    3.561252] hub 1-1:1.0: USB hub found
[    3.562674] clk-starfive-jh7110-isp 19810000.clock-controller: starfive JH7110 clk_isp init successfully.
[    3.565610] hub 1-1:1.0: 4 ports detected
[    3.576608] dw_axi_dmac_platform 16050000.dma-controller: DesignWare AXI DMA Controller, 4 channels
[    3.591411] printk: console [ttyS0] disabled
[    3.616354] 10000000.serial: ttyS0 at MMIO 0x10000000 (irq = 17, base_baud = 1500000) is a 16550A
[    3.626209] printk: console [ttyS0] enabled
[    3.626209] printk: console [ttyS0] enabled
[    3.635018] printk: bootconsole [uart0] disabled
[    3.635018] printk: bootconsole [uart0] disabled
[    3.645246] jh7110-vin 19800000.vin_sysctl: stfcamss probe enter!
[    3.653400] jh7110-vin 19800000.vin_sysctl: stfcamss probe success!
[    3.662192] dwmmc_starfive 16010000.sdio0: IDMAC supports 32-bit address mode.
[    3.662711] dwmmc_starfive 16020000.sdio1: IDMAC supports 32-bit address mode.
[    3.669488] dwmmc_starfive 16010000.sdio0: Using internal DMA controller.
[    3.676786] dwmmc_starfive 16020000.sdio1: Using internal DMA controller.
[    3.676973] jh7110-sec 16000000.crypto: will run requests pump with realtime priority
[    3.680184] jh7110-sec 16000000.crypto: Initialized
[    3.681285] starfive-i2s 120b0000.i2stx_4ch0:  designware: play supported
[    3.681295] starfive-i2s 120b0000.i2stx_4ch0: designware: i2s master mode supported
[    3.681484] sf-mipi-dphy-tx 295e0000.mipi-dphy: sf_dphy_probe begin
[    3.681498] sf-mipi-dphy-tx 295e0000.mipi-dphy: ===&gt; sf_dphy_probe enter, 445
[    3.681627] sf-mipi-dphy-tx 295e0000.mipi-dphy: control ECO
[    3.681647] sf-mipi-dphy-tx 295e0000.mipi-dphy: supply mipi_1p8 not found, using dummy regulator
[    3.681929] sf-mipi-dphy-tx 295e0000.mipi-dphy: sf_dphy_probe end
[    3.682122] cdns-dsi 295d0000.mipi: dsi_sys_clk = 297000000
[    3.682361] cdns-dsi 295d0000.mipi: starfive dsi bind end
[    3.683603] dwmmc_starfive 16010000.sdio0: Version ID is 290a
[    3.684906] of_cfs_init
[    3.684954] of_cfs_init: OK
[    3.685470] starfive-pwmdac 100b0000.pwmdac: clk_apb0 = 49500000, clk_pwmdac_apb = 49500000, clk_pwmdac_core = 4068493
[    3.685912] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    3.690450] dwmmc_starfive 16020000.sdio1: Version ID is 290a
[    3.698353] dwmmc_starfive 16010000.sdio0: DW MMC controller at irq 29,32 bit host data width,32 deep fifo
[    3.703293] dwmmc_starfive 16020000.sdio1: DW MMC controller at irq 30,32 bit host data width,32 deep fifo
[    3.710201] mmc_host mmc0: card is non-removable.
[    3.717889] mmc_host mmc1: card is polling.
[    3.806912] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    3.834563] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    3.835994] starfive soc:display-subsystem: bound 29400000.dc8200 (ops 0xffffffff80e75af8)
[    3.843223] cfg80211: failed to load regulatory.db
[    3.856322] innohdmi-starfive 29590000.hdmi: inno hdmi bind begin
[    3.863843] innohdmi-starfive 29590000.hdmi: [drm:inno_hdmi_bind] registered Inno HDMI I2C bus driver success
[    3.873931] innohdmi-starfive 29590000.hdmi: HDMI&amp;AUDIO register done.

[    3.880496] innohdmi-starfive 29590000.hdmi: inno hdmi bind end
[    3.886423] starfive soc:display-subsystem: bound 29590000.hdmi (ops 0xffffffff80e768a8)
[    3.894549] vs-simple-encoder soc:dsi-output: encoder_bind begin
[    3.900594] no panel, -517
[    3.903306] vs-simple-encoder soc:dsi-output: encoder_bind error
[    3.909315] starfive soc:display-subsystem: bound soc:dsi-output (ops 0xffffffff80e764f0)
[    3.917893] [drm] Initialized starfive 1.0.0 20191101 for soc:display-subsystem on minor 1
[    3.940109] mmc_host mmc0: Bus speed (slot 0) = 198000000Hz (slot req 400000Hz, actual 399193HZ div = 248)
[    4.020218] mmc_host mmc1: Bus speed (slot 0) = 198000000Hz (slot req 400000Hz, actual 399193HZ div = 248)
[    4.272444] mmc_host mmc1: Bus speed (slot 0) = 198000000Hz (slot req 50000000Hz, actual 49500000HZ div = 2)
[    4.282563] mmc1: new high speed SDHC card at address 1234
[    4.289656] mmcblk1: mmc1:1234 SA32G 28.8 GiB
[    4.296892] random: fast init done
[    4.306974] GPT:Primary header thinks Alt. header is not at the end of the disk.
[    4.314458] GPT:32767999 != 60456959
[    4.318054] GPT:Alternate GPT header not at the end of the disk.
[    4.324104] GPT:32767999 != 60456959
[    4.327700] GPT: Use GNU Parted to correct GPT errors.
[    4.332962]  mmcblk1: p1 p2 p3
[    4.390178] mmc_host mmc0: Bus speed (slot 0) = 198000000Hz (slot req 300000Hz, actual 300000HZ div = 330)
[    4.830160] mmc_host mmc0: Bus speed (slot 0) = 198000000Hz (slot req 200000Hz, actual 200000HZ div = 495)
[    5.280204] mmc_host mmc0: Bus speed (slot 0) = 198000000Hz (slot req 100000Hz, actual 100000HZ div = 990)
[    6.010170] ALSA device list:
[    6.013194]   #0: Starfive-PWMDAC-Sound-Card
[    6.017518]   #1: Starfive-HDMI-Sound-Card
[    6.026630] Freeing unused kernel image (initmem) memory: 2188K
[    6.032927] Run /init as init process
```

```sh
root@starfive:~# cat /proc/cpuinfo
processor       : 0
hart            : 1
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc

processor       : 1
hart            : 2
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc

processor       : 2
hart            : 3
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc

processor       : 3
hart            : 4
isa             : rv64imafdc
mmu             : sv39
uarch           : sifive,u74-mc
```
</description>
      <guid>https://yasuharu.net/diary/2908</guid>
      <pubDate>Mon, 09 Jan 2023 12:39:55 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>今年もよろしくお願いいたします</title>
      <link>https://yasuharu.net/diary/2907</link>
      <description>今年もよろしくお願いいたします。

年末はスキーをしてきました。
3年ぶりともなると、元々うまくもないのがさらにひどいことに…。
翌日は筋肉痛がひどかったです。

年々、この日記に書くことも減ってきてしまっていますが、
今年も気が向いたら書こうかなとは思います。</description>
      <guid>https://yasuharu.net/diary/2907</guid>
      <pubDate>Thu, 05 Jan 2023 00:24:57 +0000</pubDate>
      <author>yasuharu</author>
    </item>
    <item>
      <title>SDカードリーダが壊れた</title>
      <link>https://yasuharu.net/diary/2906</link>
      <description>Raspberry PiでLinuxのブート周りをいろいろといじっているうちに、
MicroSDのパーティション情報が認識されなくなりました。
何かの拍子にMicorSDのデータを壊したかなと思い、Raspberry Pi OSのイメージを再度書き直してみるも状況は変わらず。
いくつか調べてみると、USB接続のSDカードリーダに問題があったようでした。

2つSDカードリーダを用意して、同じMicroSDを読んだ結果が以下です。

■ 壊れたSDカードリーダ

```sh
$ sudo hexdump -C /dev/sdb | head
00000000  ba b8 00 10 8a 90 b8 00  b0 b8 00 00 8a 98 8a 80  |................|
00000010  bb ba 00 38 bb 00 02 b9  00 02 b3 a0 aa 21 02 00  |...8.........!..|
00000020  00 ba ba 03 38 00 31 0b  83 82 10 81 ba ba 03 31  |....8.1........1|
00000030  b3 ab 12 b0 02 b0 01 bb  00 38 b2 80 8a 30 01 8b  |.........8...0..|
00000040  08 02 89 13 aa 00 38 00  00 ab ba 00 00 00 00 00  |......8.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  39 a0 91 29 00 00 00 00  |........9..)....|
000001c0  01 00 08 03 a0 bb 00 20  00 00 00 00 08 00 00 03  |....... ........|
000001d0  a0 bb 83 3b a0 bb 00 20  08 00 00 20 83 01 00 00  |...;... ... ....|
```

■ 正常なSDカードリーダ

```sh
$ sudo hexdump -C /dev/sdc | head
00000000  fa b8 00 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |................|
00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|
00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|
00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 01 8b  |.........|...t..|
00000040  4c 02 cd 13 ea 00 7c 00  00 eb fe 00 00 00 00 00  |L.....|.........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  3d e4 95 29 00 00 00 00  |........=..)....|
000001c0  01 40 0c 03 e0 ff 00 20  00 00 00 00 08 00 00 03  |.@..... ........|
000001d0  e0 ff 83 3f e0 ff 00 20  08 00 00 60 c7 01 00 00  |...?... ...`....|
```

SDカードのデータ線は4bitなので、4bit単位で化けている部分を探すと以下の規則性です。

```sh
0 -&gt; 4
1 -&gt; 5
2 -&gt; 6
…
9 -&gt; d
a -&gt; e
b -&gt; f
```

つまり、3bit目が化けているので、DATA2の信号線に何らかの問題が出ていると考えられます。
前後のデータに依存性があるわけではなく、ランダムにDATA2がHighになっているようです。

化けるときは常にHighになる方向なので、どこかで短絡している可能性があるのかなとは思います。
MicorSDの端子ではDATA2の近くにVCCは見当たらないので、基板上かコントローラの中で何らかの問題が発生しているのでしょうか。

かなり古いもので、十分役に立ってくれたので、これは捨てようと思います。
再現性の低い問題ではなく、わりとわかりやすい壊れ方してくれたのはありがたいことでした。</description>
      <guid>https://yasuharu.net/diary/2906</guid>
      <pubDate>Sun, 06 Feb 2022 13:13:49 +0000</pubDate>
      <author>yasuharu</author>
    </item>
  </channel>
</rss>
