Multi Source Translation Content

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multi Source Translation Content

Discussions

Sort by:
imxrt1024..5A のセキュアブート Abhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.png 署名済み画像と署名なし画像(SPTで署名済み)を比較した六角形のスナップを添付しました。 IVTには私が理解できなかったいくつかの変更点があるのがわかります。 オフセット0x1000 符号なし -> D1 00 20 41 00 20 00 60 00 00 00 00 00 00 00 00 署名済み -> D1 00 20 40 DD 22 00 60 00 00 00 00 00 00 00 00 質問1:41は私のコード内にハードコードされているIVTバージョンだと理解していますが、これを40に変更するにはどうすればよいでしょうか? 質問2。また、00 20 -> DD 22 がどのように変換されるのかも理解できません。 オフセット0x1010 これは明らかで、ここではCSFポインタが更新されています。 0x1020 符号なし -> 00 00 00 60 00 00 40 00 00 00 00 00 署名済み -> 00 00 00 60 00 A0 00 00 00 00 00 00 質問3:00 40はA0 00でどのように更新されますか? これらの質問をする理由は、私の理解では、開発チームがブート可能なバイナリを提供すれば、CSF.binを追加してIVTのCSFポインタを更新して署名するだけでよいはずなのですが、違いを見て、もっと多くのことが起こっているように感じたからです。 Re: Secure boot in imxrt1024..5A Abhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.png 以前の投稿でこの回答をいただいたので、CSFを追加してIVTでVSFFポインタを更新すればファームウェアが署名されると思っていましたが、画像にCSTで署名したいのでどうやって署名すればいいのでしょうか? すでに起動可能なイメージ(FCFB、IVT、BOOTDATA,...)を持っています。パッケージに署名して発送するだけです。どうやってそれを行うかは、hab.csfを作成しました [ヘッダ] バージョン = 4.0 #利用可能なエンジンは、ICXRT 用の DCP、SW、ANY です。 エンジン = DCP エンジン構成 = 0 証明書フォーマット = x509 署名形式 = CMS ハッシュアルゴリズム = sha256 #後続の INSTALL CSFK または Install KEY で使用するためにルート公開鍵をインストールします #HABは内部公開鍵ストアのスロット0にインストールされます # HAB は単にテーブルを再ハッシュし、融合された SRK ハッシュと比較します。 [SRKをインストール] ファイル = "keys/SRK_1_2_3_4_table.bin" #使用するSRKを指定します。このインデックスの失効ヒューズが焼損している場合、インストールは失敗します。 ソースインデックス = 0 ハッシュアルゴリズム = sha256 #HAB スロット 1 に CSF キーの証明書をインストールします [CSFKをインストール] ファイル = "crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem" 証明書フォーマット = x509 #Authenticate CSF コマンドは、実行元の CSF を認証します。 [CSFの認証] #後続の「鍵のインストール」または「データの認証」コマンドで使用するための公開鍵をインストールします #HAB が IMG 証明書をキー スロット 2 にインストールします [インストールキー] #この証明書はSRKと照合されていることを意味します 検証インデックス = 0 目標インデックス = 2 ファイル = "crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem" [データの認証] #インストールキーのターゲットインデックスと同じである必要があります 検証インデックス = 2 ブロック = 0x60001000 0x1000 0x6580 "evkmimxrt1024_iled_blinky_unsigned_original.bin" Re: Secure boot in imxrt1024..5A こんにちは、 @Abhay2080 さん。 ご質問ありがとうございます! RT1024 IVT / ブートデータの定義に基づくと、見られる差異は想定内のものであり、CSFポインタの更新に限ったものではありません。 Q1: なぜ D1 00 20 41 D1 00 20 40 になるのですか? D1 00 20 41 はIVTヘッダーで、 0xD1 はIVTタグ、 0x0020 は固定されたIVT長32バイト、最後のバイトはバージョンです。RT1024リファレンスマニュアルではIVT版を 0x40/0x41 と定義しているので、 0x40 は有効であり誤りではありません。こちらのオンラインガイドをご確認ください: https://mcuxpresso.nxp.com/mcuxsdk/latest/html/middleware/mcu_bootloader/docs/iMXRT1024_Manufacturing_User_Guide/topics/imx_rt_bootable_image.html Q2: なぜ 00 20 00 60 DD 22 00 60 になるのですか? これはIVT entry 体です。リトルエンディアン形式の場合: 00 20 00 60 = 0x60002000 DD 22 00 60 = 0x600022DD RT1024 RMは、 entry をイメージから実行される最初の命令の絶対アドレスとして定義します。AN12108では、デフォルトのエントリポイントが Reset_Handler でない場合、 entryPointAddress Reset_Handler アドレスに設定する必要があるとも記載されています。 したがって、SPTはIVTのエントリーを 0x60002000 から実際の申請エントリーポイントに更新した可能性が高いです。マップファイル/ELFシンボルテーブル内の Reset_Handler アドレスを確認してください。 Q3: なぜ 00 00 40 00 00 A0 00 00 になるのですか? 0x1020 にはブートデータがあります。 start 遺体 0x60000000 length 0x00400000 から 0x0000A000 RT1024 RMは、ブートデータにイメージの開始アドレスとイメージの長さが含まれていると定義しており、ブートROMはこの構造体からイメージのアドレスと長さを読み取ります。 そのため、SPTは最終的に生成されたブート可能/署名済みイメージのレイアウトに合わせて、長さフィールドを更新しました。 RTシリーズのHABセキュアブートの場合、最終的な署名付きイメージは単に「CSF.binを追加してCSFポインタを更新する」だけではありません。IVTヘッダー、エントリ、ブートデータの長さ、CSFポインタ、およびCSF認証データコマンドでカバーされるアドレス/長さはすべて一致している必要があります。HABはソフトウェアからハッシュをフラッシュで再計算し、署名から回収された参照ハッシュと比較します。認証済み領域が署名後に変更されると、検証は失敗します。[0dfe-E1] 推奨される方法は、CSF.binだけを手動で追加するのではなく、SPT/CSTによって生成された最終的な署名付きイメージを使用することです。 この説明がお役に立てば幸いです! よろしくお願いします、 ギャビン Re: Secure boot in imxrt1024..5A こんにちは、 @Abhay2080 さん。 良い質問ですね。重要な点は、CSTは画像自体を変更するのではなく、指定した領域のハッシュ値を計算してCSF(署名)を生成するだけであるということです。IVTエントリ、ブートデータの長さ、バージョンは一切変更されません。 そのため、SPT ではこれらのフィールドが変更されました。SPT は ELF からブートイメージを再構築し、IVT.entry (実際の Reset_Handler に) とブートデータの長さを正規化します。これらの変化は、署名の段階ではなくイメージの再構築から生まれます。CSTダイレクトフローなら再現する必要がありません。元のイメージがすでにオープン/開発状態で起動しているなら、そのエントリとバージョンはすでに正しく、そのまま維持できます。 しかし、一つだけ厳しい条件があります。あなたの [Authenticate Data] ブロック Blocks = 0x60001000 0x1000 0x6580 これはIVT全体をカバーしており、IVT CSFポインタはこの符号付き領域内に位置しています。HABはこの領域を再ハッシュし、署名と比較するため、署名後にバイトが変更されると認証が失敗します。 まさにこれが、「最初に署名してからCSFを追加し、CSFポインタを更新する」という方法が機能しない理由です。順序が間違っているのです。 CSTの署名および発送手順を正しく行う(CSTを実行する前にこれを行ってください): CSFを配置する場所を決定します(アプリの後に添付)。あなたのブロックの場合、アプリは 0x1000 + 0x6580 = 0x7580 で終わります。つまりCSFはファイルオフセット 0x7580 (メモリ 0x60007580 )から始まります。 署名する画像では、以下の設定が事前に行われます。 IVT CSF ポインタ  → CSF メモリ アドレス (例: 0x60007580 ); ブートデータの長さ → CSFを含むイメージ全体のサイズ。 FCFBとエントリは変更しないでください(FCFBはHABの範囲外です。ROMはHABの前にそれを読み取ります)。 実行: cst -i hab.csf -o csf.bin (RT1024 の場合、 hab.csf と Engine = DCP の組み合わせが正しいです)。 連結: cat prepared.bin csf.bin > signed_firmware.bin 、ステップ1のアドレスにCSFを配置し、直接フラッシュします。 つまり、 hab.csf 自体は問題ありません。唯一の解決策は署名前にCSFポインタとブートデータの長さを設定することです。署名後ではなく。 よろしくお願いします、 ギャビン
View full article
LPCマイクロコントローラの助け マイクロコントローラのLPCの熱狂に詳しい方が、私が取り組んでいる設計について手伝ってもらえないかと思っています。 全般 Re: LPC microcontroller help こんにちは、 あなたのデザインをより良くサポートするために;あなたのデザインについてもっと情報を共有するのに協力していただけますか?LPCに特定の機能を含めたい場合、ぜひご協力いただけますか? 比較検討したい、あるいは詳細を知りたいLPC(Licensed Professional Counselor:公認プロフェッショナルコンサルタント)はありますか? もし設計を考えているなら、NXPはLPC評価ボードを提供しており、例が付属しているので出発点として利用できます。 デザイン目標や要件の詳細を多く共有していただきたいほど、意図された特性に合った推奨を提供できます。 敬具、ルイス
View full article
Secure boot in imxrt1024..5A Abhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.png I have attached a snap of hex compare of signed and unsigned image (signed using SPT) i can see IVT have several changes that i didnt understand.  At 0x1000 offset Unsigned -> D1 00 20 41 00 20 00 60 00 00 00 00 00 00 00 00 Signed ->     D1 00 20 40 DD 22 00 60 00 00 00 00 00 00 00 00 Question 1 i understand that 41 is the IVT version that is hardcode inside my code how this is changed to 40? question 2. Also i dont understand  how 00 20 -> DD 22 At 0x1010 offeset This is clear as here CSF pointer got updated At 0x1020 Unsigned -> 00 00 00 60 00 00 40 00 00 00 00 00 Signed ->     00 00 00 60 00 A0 00 00 00 00 00 00 Question 3 how 00 40 is update with A0 00 The reason to ask these question is as per my understanding if development team gave bootable binary then i just need to append CSF.bin and update the CSF pointer in IVT to make it sign , but after seeing the difference i feel there are more things happening Re: Secure boot in imxrt1024..5A Abhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.png In earlier post i got this answer so i thought just appending csf and updating the vsff pointer in IVT means firmware is signed but since i want to use CST for signing the image how to do that? I already have bootable image (FCFB, IVT, BOOTDATA,...) . I just need to sign and ship the package how to do that , i have created hab.csf  [Header] Version = 4.0 #Avalibale engine are DCP, SW, ANY for IMXRT Engine = DCP Engine Configuration = 0 Certificate Format = x509 Signature Format = CMS Hash Algorithm = sha256 #Install root public key for use in subsequent INSTALL CSFK or Install KEY #HAB install in slot 0 of its internal public key store # HAB just re-hashes the table and compares against the fused SRK-hash. [Install SRK] File = "keys/SRK_1_2_3_4_table.bin" #Tell which SRK to use, installation will fail if revocation fuse with this index is burned Source index = 0 Hash Algorithm = sha256 #HAB install CSF key's cert in slot 1 [Install CSFK] File = "crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem" Certificate Format = x509 #Authenticate CSF command authenticates the CSF from which it is executed [Authenticate CSF] #Install a public key for use in subsequent Install key or Authenticate Data commands #HAB install IMG cert into key slot 2 [Install Key] #Means this cert is checked against the SRK Verification index = 0 Target index = 2 File = "crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem" [Authenticate Data] #Should be same as Target Index in Install Key Verification index = 2 Blocks = 0x60001000 0x1000 0x6580 "evkmimxrt1024_iled_blinky_unsigned_original.bin" Re: Secure boot in imxrt1024..5A Hi @Abhay2080 , Thanks for your questions! Based on the RT1024 IVT / Boot Data definition, the differences you see are expected and are not limited to the CSF pointer update. Q1: Why does D1 00 20 41 become D1 00 20 40 ? D1 00 20 41 is the IVT header: 0xD1 is the IVT tag, 0x0020 is the fixed IVT length of 32 bytes, and the last byte is the version. The RT1024 Reference Manual defines the IVT version as 0x40/0x41 , so 0x40 is valid and not an error. Please check this online guide: https://mcuxpresso.nxp.com/mcuxsdk/latest/html/middleware/mcu_bootloader/docs/iMXRT1024_Manufacturing_User_Guide/topics/imx_rt_bootable_image.html Q2: Why does 00 20 00 60 become DD 22 00 60 ? This is the IVT entry field. In little-endian format: 00 20 00 60 = 0x60002000 DD 22 00 60 = 0x600022DD The RT1024 RM defines entry as the absolute address of the first instruction to execute from the image. AN12108 also states that if the default entry point is not Reset_Handler , entryPointAddress should be set to the Reset_Handler address. So SPT likely updated the IVT entry from 0x60002000 to the actual application entry point. Please confirm the Reset_Handler address in the map file / ELF symbol table. Q3: Why does 00 00 40 00 become 00 A0 00 00 ? At 0x1020 this is Boot Data: start remains 0x60000000 length changes from 0x00400000 to 0x0000A000 The RT1024 RM defines Boot Data as containing the image start address and image length, and the Boot ROM reads the image address and length from this structure. Therefore, SPT updated the length field to match the final generated bootable/signed image layout. For RT-series HAB secure boot, the final signed image is not just “append CSF.bin + update the CSF pointer”. The IVT header, entry, Boot Data length, CSF pointer, and the address/length covered by the CSF Authenticate Data command must all be consistent. HAB recalculates the hash from the software in flash and compares it with the reference hash recovered from the signature; if an authenticated region is modified after signing, verification fails.[0dfe-E1] The recommended approach is to use the final signed image generated by SPT/CST, not to manually append CSF.bin only. I hope this clarification helps! Best regards, Gavin Re: Secure boot in imxrt1024..5A Hi @Abhay2080 , Good question. The key point is: CST does not modify your image — it only computes the hash over the region you specify and produces the CSF (signature). It never changes IVT entry, Boot Data length, or version. That is why those fields changed under SPT: SPT rebuilds the boot image from the ELF and normalizes IVT.entry (to the real Reset_Handler) and Boot Data length. Those changes come from image re-building, not from the signing step. With the CST-direct flow you do not need to reproduce them — if your original image already boots in the open/development state, its entry and version are already correct and can stay as-is. However, there is one hard requirement. Your [Authenticate Data] block Blocks = 0x60001000 0x1000 0x6580 covers the entire IVT, and the IVT CSF pointer sits inside this signed region. HAB re-hashes this region and compares it against the signature, so if any byte in it is changed after signing, authentication fails. This is exactly why "sign first, then append CSF and update the CSF pointer" does not work — the order is wrong. Correct CST sign-and-ship procedure (do this before running cst): Decide where the CSF will sit (appended after the App). With your block, App ends at 0x1000 + 0x6580 = 0x7580 , so the CSF starts at file offset 0x7580 (memory 0x60007580 ). In the image to be signed, pre-set: IVT CSF pointer  → CSF memory address (e.g. 0x60007580 ); Boot Data length → total image size including the CSF. Keep FCFB and entry unchanged (FCFB is outside the HAB scope; ROM reads it before HAB). Run: cst -i hab.csf -o csf.bin (your hab.csf with Engine = DCP is correct for RT1024). Concatenate: cat prepared.bin csf.bin > signed_firmware.bin , place CSF at the address from step 1, and flash directly. So your hab.csf itself is fine; the only fix is to set the CSF pointer and Boot Data length before signing, not after. Best regards, Gavin
View full article
IMX95 v4l2h264enc encoded frame corrupted I am using IMX95's v4l2h264enc encoder to test H264 video encoding. Test command line is below: gst-launch-1.0 -v videotestsrc pattern=ball num-buffers=150 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! v4l2h264enc ! filesink location=enc_test.h264 The video file is generated successfully, but when I try to play it with ffplay, it fails and shows error below: ffplay version 4.2.7-0ubuntu0.1 Copyright (c) 2003-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] sps_id 0 out of range [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 2 times [h264 @ 0x7fbea4002840] Overread VUI by 8 bits0KB sq= 0B f=0/0 [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] Overread VUI by 8 bits [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 26 times [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] sps_id 0 out of range [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 29 times [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] sps_id 0 out of range [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 29 times [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] sps_id 0 out of range [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 29 times [h264 @ 0x7fbea4002840] Overread VUI by 7 bits [h264 @ 0x7fbea4002840] sps_id 0 out of range [h264 @ 0x7fbea4002840] non-existing PPS 0 referenced Last message repeated 29 times Input #0, h264, from 'enc_test.h264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (Baseline), yuv420p, 1280x720, 25.17 fps, 25 tbr, 1200k tbn, 50 tbc [h264 @ 0x7fbea4007f00] Overread VUI by 8 bits Failed to open file 'enc_test.h264' or configure filtergraph From the log above, it appears that the video head is corrupted. Then I try to use gstreamer debug, and found logs below: 0:00:05.727025935 13024 0xffffa0000d00 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared My system info: Linux imx95-19x19-lpddr5-evk 6.12.49+ #9 SMP PREEMPT Wed Jul 22 11:47:53 UTC 2026 aarch64 GNU/Linux Re: IMX95 v4l2h264enc encoded frame corrupted Discussing with the AE team. Re: IMX95 v4l2h264enc encoded frame corrupted According to your hints, I try to execute two command line you provide. But none of them work. The encoded video still not playable. For command: gst-launch-1.0 -e -v videotestsrc pattern=ball num-buffers=150 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! v4l2h264enc ! h264parse config-interval=-1 ! filesink location=enc_test.h264 When I try to play the encoded video file, error is shown below: ffprobe version 4.2.7-0ubuntu0.1 Copyright (c) 2007-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 [h264 @ 0x557b5dc1e980] Format h264 detected only with low score of 1, misdetection possible! [h264 @ 0x557b5dc20380] sps_id 0 out of range Last message repeated 1 times [h264 @ 0x557b5dc20380] non-existing PPS 0 referenced Last message repeated 2 times [h264 @ 0x557b5dc20380] sps_id 0 out of range Last message repeated 1 times [h264 @ 0x557b5dc20380] non-existing PPS 0 referenced [h264 @ 0x557b5dc20380] decode_slice_header error [h264 @ 0x557b5dc20380] no frame! [h264 @ 0x557b5dc20380] non-existing PPS 0 referenced [h264 @ 0x557b5dc20380] decode_slice_header error ...... Last message repeated 1 times [h264 @ 0x557b5dc20380] decode_slice_header error [h264 @ 0x557b5dc20380] no frame! [h264 @ 0x557b5dc1e980] decoding for stream 0 failed [h264 @ 0x557b5dc1e980] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, h264, from 'enc_test.h264': Duration: N/A, bitrate: N/A Stream #0:0: Video: h264, none, 25.17 fps, 25 tbr, 1200k tbn, 50 tbc I try to debug it, and it shows warning like below: 0:00:00.129727669 2003 0xffffa8000b70 WARN v4l2bufferpool gstv4l2bufferpool.c:884:gst_v4l2_buffer_pool_start: Uncertain or not enough buffers, enabling copy threshold 0:00:00.152626502 2003 0xffffa8000d00 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared 0:00:00.153013002 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:435:gst_h264_parse_vui_parameters: failed to read uint8 for 'vui->aspect_ratio_idc', nbits: 8 0:00:00.153052211 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:516:gst_h264_parse_vui_parameters: error parsing "VUI Parameters" 0:00:00.153071752 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2155:gst_h264_parse_sps: error parsing "Sequence parameter set" 0:00:00.153092044 2003 0xffffa8000d00 WARN h264parse gsth264parse.c:993:gst_h264_parse_process_nal: failed to parse SPS: 0:00:00.153120336 2003 0xffffa8000d00 WARN h264parse gsth264parse.c:1529:gst_h264_parse_handle_frame: broken/invalid nal Type: 7 SPS, Size: 9 will be dropped 0:00:00.153205086 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2284:gst_h264_parse_pps: couldn't find associated sequence parameter set with id: 0 0:00:00.153230627 2003 0xffffa8000d00 WARN h264parse gsth264parse.c:1026:gst_h264_parse_process_nal: failed to parse PPS: 0:00:00.153418211 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2473:gst_h264_parser_parse_slice_hdr: couldn't find associated picture parameter set with id: 0 0:00:00.153690127 2003 0xffffa8000d00 WARN v4l2bufferpool gstv4l2bufferpool.c:491:gst_v4l2_buffer_pool_alloc_buffer: newly allocated buffer 0 is not free Pipeline is PREROLLED ... Setting pipeline to PLAYING ... Redistribute latency... New clock: GstSystemClock 0:00:00.180972628 2003 0xffffa8000d00 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared 0:00:00.181182169 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2473:gst_h264_parser_parse_slice_hdr: couldn't find associated picture parameter set with id: 0 0:00:00.211927795 2003 0xffffa8000d00 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared 0:00:00.212148128 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2473:gst_h264_parser_parse_slice_hdr: couldn't find associated picture parameter set with id: 0 0:00:00.242748712 2003 0xffffa8000d00 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared 0:00:00.242969462 2003 0xffffa8000d00 WARN codecparsers_h264 gsth264parser.c:2473:gst_h264_parser_parse_slice_hdr: couldn't find associated picture parameter set with id: 0 For command: gst-launch-1.0 -e -v videotestsrc pattern=ball num-buffers=150 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! v4l2h264enc ! h264parse config-interval=-1 ! mp4mux ! filesink location=enc_test.mp4 It couldn't encode a video file, it shows error like below: root@imx95-19x19-lpddr5-evk:~# GST_DEBUG=3 gst-launch-1.0 -e -v videotestsrc pattern=ball num-buffers=150 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! v4l2h264enc ! h264parse config-interval=-1 ! mp4mux ! filesink location=enc_test.mp4 Setting pipeline to PAUSED ... ====== V4L2ENC: 1.24.7 build on Jan 2 2025 07:23:23. ====== 0:00:00.078378376 2059 0xaaaadecda320 WARN v4l2 gstv4l2object.c:5350:gst_v4l2_object_probe_caps: Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument 0:00:00.079377793 2059 0xffffa8000b70 WARN aggregator gstaggregator.c:2283:gst_aggregator_query_latency_unlocked: Latency query failed Pipeline is PREROLLING ... 0:00:00.079857126 2059 0xffffa8000d00 FIXME default gstutils.c:4089:gst_element_decorate_stream_id_internal: Creating random stream-id, consider implementing a deterministic way of creating a stream-id /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)bt601, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)bt601, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)1, profile=(string)baseline, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono /GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)1, profile=(string)baseline, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono Redistribute latency... /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:sink: caps = video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)bt601, pixel-aspect-ratio=(fraction)1/1 /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)bt601, pixel-aspect-ratio=(fraction)1/1 0:00:00.140337252 2059 0xffffa8000d00 WARN v4l2bufferpool gstv4l2bufferpool.c:884:gst_v4l2_buffer_pool_start: Uncertain or not enough buffers, enabling copy threshold 0:00:00.165691544 2059 0xffffa8000e90 FIXME videoencoder gstvideoencoder.c:2408:gst_video_encoder_transform_meta_unlocked: Can't copy metadata because input frame disappeared 0:00:00.166079919 2059 0xffffa8000e90 WARN codecparsers_h264 gsth264parser.c:435:gst_h264_parse_vui_parameters: failed to read uint8 for 'vui->aspect_ratio_idc', nbits: 8 0:00:00.166119002 2059 0xffffa8000e90 WARN codecparsers_h264 gsth264parser.c:516:gst_h264_parse_vui_parameters: error parsing "VUI Parameters" 0:00:00.166138877 2059 0xffffa8000e90 WARN codecparsers_h264 gsth264parser.c:2155:gst_h264_parse_sps: error parsing "Sequence parameter set" 0:00:00.166159335 2059 0xffffa8000e90 WARN h264parse gsth264parse.c:993:gst_h264_parse_process_nal: failed to parse SPS: 0:00:00.166187127 2059 0xffffa8000e90 WARN h264parse gsth264parse.c:1529:gst_h264_parse_handle_frame: broken/invalid nal Type: 7 SPS, Size: 9 will be dropped 0:00:00.166277252 2059 0xffffa8000e90 WARN codecparsers_h264 gsth264parser.c:2284:gst_h264_parse_pps: couldn't find associated sequence parameter set with id: 0 0:00:00.166301710 2059 0xffffa8000e90 WARN h264parse gsth264parse.c:1026:gst_h264_parse_process_nal: failed to parse PPS: 0:00:00.166486835 2059 0xffffa8000e90 WARN codecparsers_h264 gsth264parser.c:2473:gst_h264_parser_parse_slice_hdr: couldn't find associated picture parameter set with id: 0 0:00:00.166826460 2059 0xffffa8000b70 WARN qtmux gstqtmux.c:6357:gst_qt_mux_video_sink_set_caps: no codec_data in h264 caps 0:00:00.166923502 2059 0xffffa8000b70 WARN qtmux gstqtmux.c:6856:gst_qt_mux_video_sink_set_caps: pad video_0 refused caps video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)1, profile=(string)baseline, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, i/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)1, profile=(string)baseline, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, parsed=(boolean)true nterlace-mode=(string)progressive, colorimetry=(string)bt601, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, parsed=(boolean)true 0:00:00.166977794 2059 0xffffa8000e90 WARN v4l2bufferpool gstv4l2bufferpool.c:491:gst_v4l2_buffer_pool_alloc_buffer: newly allocated buffer 0 is not free /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstQTMuxPad:video_0: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)1, profile=(string)baseline, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, interlace-mode=(string)progressive, colorimetry=(string)bt601, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, parsed=(boolean)true 0:00:00.167488335 2059 0xffffa8000b70 FIXME basesink gstbasesink.c:3399:gst_base_sink_default_event: stream-start event without group-id. Consider implementing group-id handling in the upstream elements /GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstAggregatorPad:src: caps = video/quicktime, variant=(string)iso /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso Pipeline is PREROLLED ... Setting pipeline to PLAYING ... 0:00:00.168202544 2059 0xffffa8000b70 WARN qtmux gstqtmux.c:5415:gst_qt_mux_add_buffer: error: format wasn't negotiated before buffer flow on pad video_0 Redistribute latency... ERROR: from element /GstPipeline:pipeline0/GstMP4Mux:mp4mux0: GStreamer error: negotiation problem. Additional debug info: /usr/src/debug/gstreamer1.0-plugins-good/1.24.7.imx/gst/isomp4/gstqtmux.c(5415): gst_qt_mux_add_buffer (): /GstPipeline:pipeline0/GstMP4Mux:mp4mux0: format wasn't negotiated before buffer flow on pad video_0 0:00:00.168413044 2059 0xffffa8000b70 FIXME aggregator gstaggregator.c:1478:gst_aggregator_loop: Subclass should call gst_aggregator_selected_samples() from its aggregate implementation. Execution ended after 0:00:00.000556000 Setting pipeline to NULL ... 0:00:00.174238335 2059 0xaaaadecda320 WARN bufferpool gstbufferpool.c:1429:gst_buffer_pool_set_flushing: can't change flushing state of inactive pool 0:00:00.199404961 2059 0xaaaadecda320 WARN bufferpool gstbufferpool.c:1429:gst_buffer_pool_set_flushing: can't change flushing state of inactive pool Freeing pipeline ... Re: IMX95 v4l2h264enc encoded frame corrupted The encoder output is probably not “video header corruption” from your test source; the pipeline is missing the H.264 parser stage that NXP’s i.MX Linux guidance expects for i.MX 8 / i.MX 95 VPU encoder pipelines. The i.MX 95 v4l2h264enc output is H.264 stream-format=byte-stream / alignment=au , and NXP documentation says h264parse/h265parse should be added because the VPU supports only byte-stream output on i.MX 8 and i.MX 95 . Use this first: gst-launch-1.0 -e -v \   videotestsrc pattern=ball num-buffers=150 ! \   video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \   v4l2h264enc ! \   h264parse config-interval=-1 ! \   filesink location=enc_test.h264 Then play it explicitly as raw H.264: ffplay -f h264 enc_test.h264 If you want a normal playable container file, use a muxer: gst-launch-1.0 -e -v \   videotestsrc pattern=ball num-buffers=150 ! \   video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \   v4l2h264enc ! \   h264parse ! \   mp4mux ! \   filesink location=enc_test.mp4 or: gst-launch-1.0 -e -v \   videotestsrc pattern=ball num-buffers=150 ! \   video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \   v4l2h264enc ! \   h264parse ! \   matroskamux ! \   filesink location=enc_test.mkv NXP’s recording examples place h264parse between the encoder and muxer/filesink path, e.g. $videoEncoderPlugin ! [h264parse] ! $MUXER ! filesink ... . For MP4, the -e option is important so GStreamer sends EOS and lets the muxer finalize the file correctly. The GStreamer message: FIXME videoencoder ... Can't copy metadata because input frame disappeared is not, by itself, proof that the H.264 bitstream header is corrupted. It is a GStreamer videoencoder metadata-copy warning/FIXME that has been seen in v4l2h264enc pipelines . The ffplay errors — Overread VUI , sps_id 0 out of range , non-existing PPS 0 referenced — are more consistent with the downstream reader seeing an H.264 stream that has not been normalized/parsed as expected, especially around SPS/PPS handling. If the parsed raw .h264 still fails, check the first bytes: xxd -l 64 enc_test.h264 For Annex-B byte-stream H.264, you should see start codes such as: 00 00 00 01 near the beginning, followed by SPS/PPS NAL units before slices. Recommended fix: insert h264parse after v4l2h264enc ; for general playback, prefer h264parse ! mp4mux ! filesink location=enc_test.mp4 rather than writing the encoder output directly to a raw .h264 file. Re: IMX95 v4l2h264enc encoded frame corrupted We can use the gstreamer to play the h264 video, and it plays well: gst-launch-1.0 filesrc location=enc_test.h264 ! decodebin ! glupload ! autovideosink so I don't think it's the v4l2h264enc issue.
View full article
imxrt1024..5A 中的安全启动 Abhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.pngAbhay2080_0-1788352073442.png 我附上了有符号图像和无符号图像(使用 SPT 签名)的十六进制比较截图。 我发现 IVT 有一些我不理解的变化。 在偏移量 0x1000 处 未签名 -> D1 00 20 41 00 20 00 60 00 00 00 00 00 00 00 00 签名 -> D1 00 20 40 DD 22 00 60 00 00 00 00 00 00 00 00 问题 1:我理解 41 是我代码中硬编码的 IVT 版本,如何将其更改为 40? 问题 2. 另外,我不明白 00 20 如何变成 DD 22 在 0x1010 偏移处 这一点很明显,因为这里的 CSF 指针已经更新了。 在 0x1020 处 无符号 -> 00 00 00 60 00 00 40 00 00 00 00 00 签名 -> 00 00 00 60 00 A0 00 00 00 00 00 00 问题 3:如何将 00 40 更新为 A0 00? 我之所以问这些问题,是因为据我理解,如果开发团队提供的是可启动二进制文件,那么我只需要追加 CSF.bin 文件并更新 IVT 中的 CSF 指针即可使其签名。但看到差异后,我觉得其中还有更多因素在起作用。 Re: Secure boot in imxrt1024..5A Abhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.pngAbhay2080_0-1788520801299.png 我在之前的帖子中得到了这个答案,所以我认为只要在 IVT 中添加 csf 并更新 vsff 指针就意味着固件已经签名,但是因为我想使用 CST 对镜像进行签名,该怎么做呢? 我已经有了可启动镜像(FCFB、IVT、BOOTDATA 等)。我只需要签名并打包发货,该怎么做呢?我已经创建了 hab.csf 文件。 [标题] 版本 = 4.0 #可用的引擎有DCP、SW、ANY,适用于IMXRT 引擎 = DCP 发动机配置 = 0 证书格式 = x509 签名格式 = CMS 哈希算法 = sha256 #安装根公钥,以便在后续的 INSTALL CSFK 或 Install KEY 中使用。 #HAB 安装在其内部公钥存储的第 0 个插槽中 # HAB 只是重新哈希表并与熔丝的 SRK 哈希进行比较。 [安装SRK] 文件 = "keys/SRK_1_2_3_4_table.bin" #请指定要使用的SRK,如果此索引的撤销熔丝被烧毁,安装将失败。 源索引 = 0 哈希算法 = sha256 #HAB 在插槽 1 中安装 CSF 密钥的证书 [安装 CSFK] 文件 = "crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem" 证书格式 = x509 #Authenticate CSF 命令用于验证执行该命令的 CSF。 [验证脑脊液] #安装公钥,以便在后续的“安装密钥”或“验证数据”命令中使用。 #HAB 将 IMG 证书安装到密钥插槽 2 中 [安装密钥] #表示此证书已根据 SRK 进行检查。 验证指数 = 0 目标指数 = 2 文件 = "crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem" [验证数据] #应与安装密钥中的目标索引相同 验证指数 = 2 Blocks = 0x60001000 0x1000 0x6580 "evkmimxrt1024_iled_blinky_unsigned_original.bin" Re: Secure boot in imxrt1024..5A 你好@Abhay2080 , 谢谢你的提问! 根据 RT1024 IVT / 启动数据定义,您看到的差异是预期的,并且不仅限于 CSF 指针更新。 问题1:为什么 D1 00 20 41 会变成 D1 00 20 40 ? D1 00 20 41 是 IVT 标头: 0xD1 是 IVT 标签, 0x0020 是固定长度为 32 字节的 IVT,最后一个字节是版本。RT1024 参考手册将 IVT 版本定义为 0x40/0x41 ,因此 0x40 是有效的,不是错误。请查看此在线指南: https://mcuxpresso.nxp.com/mcuxsdk/latest/html/middleware/mcu_bootloader/docs/iMXRT1024_Manufacturing_User_Guide/topics/imx_rt_bootable_image.html Q2:为什么 00 20 00 60 会变成 DD 22 00 60 ? 这是 IVT entry 场。小端字节序格式: 00 20 00 60 = 0x60002000 DD 22 00 60 = 0x600022DD RT1024 RM 将 entry 定义为要从映像中执行的第一条指令的绝对地址。AN12108 还指出,如果默认入口点不是 Reset_Handler ,则应将 entryPointAddress 设置为 Reset_Handler 地址。 因此,SPT 可能将 IVT 条目从 0x60002000 更新为实际的应用程序入口点。请确认映射文件/ELF符号表中的 Reset_Handler 地址。 Q3:为什么 00 00 40 00 会变成 00 A0 00 00 ? 0x1020 处是启动数据: start 遗迹 0x60000000 length 从 0x00400000 变为 0x0000A000 RT1024 RM 将启动数据定义为包含映像起始地址和映像长度,启动 ROM 从此结构中读取映像地址和长度。 因此,SPT 更新了长度字段,以匹配最终生成的可启动/签名映像布局。 对于 RT 系列 HAB 安全启动,最终签名的映像不仅仅是“附加 CSF.bin + 更新 CSF 指针”。IVT 标头、条目、启动数据长度、CSF 指针以及 CSF 身份验证数据命令所涵盖的地址/长度必须完全一致。HAB 会重新计算闪存中软件的哈希值,并将其与从签名中恢复的参考哈希值进行比较;如果在签名后修改了已认证区域,则验证失败。[0dfe-E1] 建议使用 SPT/CST 生成的最终签名镜像,而不是手动添加 CSF.bin。 希望这个解释能有所帮助! 此致, 加文 Re: Secure boot in imxrt1024..5A 你好@Abhay2080 , 问得好。关键在于:CST 不会修改您的图像——它只会计算您指定的区域的哈希值并生成 CSF(签名)。它从不更改 IVT 条目、启动数据长度或版本。 这就是为什么这些字段在 SPT 下发生变化的原因:SPT 从 ELF 重建启动映像,并将 IVT.entry(到真正的 Reset_Handler)和启动数据长度规范化。这些变化源于形象重塑,而非签约环节。使用 CST 直接流程,您无需重新创建它们——如果您的原始映像已在打开/开发状态下启动,则其条目和版本已正确,可以保持不变。 但是,有一个硬性要求。您的 [Authenticate Data] 块 Blocks = 0x60001000 0x1000 0x6580 覆盖整个 IVT,并且 IVT CSF 指针位于此有符号区域内。HAB 会重新哈希该区域并将其与签名进行比较,因此如果在签名后该区域中的任何字节发生更改,则身份验证将失败。 这正是“先签名,然后附加 CSF 并更新 CSF 指针”不起作用的原因——顺序错了。 正确的 CST 签发流程(在运行 cst 之前执行此操作): 决定 CSF 的位置(附加在应用程序之后)。在你的代码块中,App 在 0x1000 + 0x6580 = 0x7580 处结束,因此 CSF 从文件偏移量 0x7580 (内存 0x60007580 )开始。 待签名图片已预设: IVT CSF 指针 → CSF 内存地址(例如 0x60007580 ); 启动数据长度 → 包括 CSF 在内的总镜像大小。 保持 FCFB 和条目不变(FCFB 在 HAB 范围之外;ROM 在 HAB 之前读取它)。 运行: cst -i hab.csf -o csf.bin (你的 hab.csf 与 Engine = DCP 对于 RT1024 是正确的)。 连接: cat prepared.bin csf.bin > signed_firmware.bin ,将 CSF 放置在步骤 1 中的地址,并直接刷写。 所以你的 hab.csf 本身没有问题;唯一的解决方法是在签名之前设置 CSF 指针和启动数据长度,而不是之后。 此致, 加文
View full article
LPC微控制器帮助 我想请教一下,熟悉 LPC 系列微控制器的人能否帮我设计一下我正在开发的程序? 概述 Re: LPC microcontroller help 你好, 为了更好地协助您进行设计,您能否提供更多关于您设计的信息?您能否告知我们您希望在 LPC 中包含哪些具体功能? 您心中是否有想要比较或了解的LPC(持证专业证书)? 如果您心中已有设计方案,NXP 提供 LPC 评估板,这些评估板可以作为起点,因为它们附带示例。 您提供的关于设计目标和要求的细节越多,我们就越能提供符合预期特性的建议。 此致敬礼,路易斯
View full article
i.MX93 FRDMボード上のユーザーLED制御 こんにちは、みんな、 i.MX93 FRDMボードを使い始めたのですが、ボード上のRGB LEDを制御する簡単なスクリプトを書いたところ、緑色と青色のLEDしか制御できませんでした。いろいろ試してみましたが、赤色LEDが点灯したままです。 回路図によると、すべてのLEDは同様の方法で接続されており、アクティブハイで動作します。 これが私のスクリプトです。 --------------------------- #!/bin/sh 期間=1000000 set_pwm() { チップ=$1 チャネル=$2 DUTY=$3 PWM_PATH=" /sys/class/pwm/pwmchip${CHIP}/pwm${CHANNEL}" if [ ! -d "$PWM_PATH" ]; then echo "$CHANNEL" > "/sys/class/pwm/pwmchip ${CHIP} /export" 2>/dev/null フィ # まずDTYサイクルを0にリセットしてTPMドライバの制約を満たす echo 0 > "${PWM_PATH}/duty_cycle" 2>/dev/null エコー「$PERIOD」>「${PWM_PATH}/句点」 エコー「$DUTY」>「${PWM_PATH}/duty_cycle」 echo 1 > ""${PWM_PATH}/enable" 2>/dev/null } # 赤色はアクティブローです。デフォルトはOFF = 1000000 (3.3V / ハイ) RED_DUTY= ${1:-0} # 緑と青はアクティブハイです。デフォルトはOFF = 0 (0V / ロー)です。 GREEN_DUTY= ${2:-0} BLUE_DUTY= ${3:-0} # レッド -> pwmchip4、チャネル3 set_pwm 4 3 「$RED_DUTY」 # 緑 -> pwmchip0、チャネル0 set_pwm 0 0 「$GREEN_DUTY」 # ブルー -> pwmchip0、チャネル2 set_pwm 0 2 「$BLUE_DUTY」 ------------------------------------------- 赤いLED(GPIO_IO13)がledsgrp2に割り当てられているか確認しました: ピン17(IMX93_IOMUXC_GPIO_IO13):424f0000.pwm (GPIO UNCLAIMED) function pinctrl group ledsgrp2 debugfsコマンドで確認した限り、ピンGPIO_IO13はALT1モード、つまりTPM2チャネル3(PWM)に設定されています。 スクリプトを実行すると、青と緑のLEDは正常に制御できますが、赤いLEDは点灯したままです。 何か見落としていることがあるだろうか? Re: user LED control on i.MX93 FRDM board こんにちは@ilya_chepurin  赤いLEDはチャネル2です。以下のスクリプトを使ってテストしてください(L6.18.20で確認済み) #!/bin/sh # RGB LED PWM cycle test for i.MX93 EVK/FRDM. # Sequence per cycle: RED on 1s -> all off 1s -> GREEN on 1s -> all off 1s -> BLUE on 1s -> all off 1s # Usage: ./run.sh [LOOPS] LOOPS: number of full cycles, 0 = infinite, default 3 # Timing overridable via env: ON_TIME=2 REST_TIME=1 ./run.sh PERIOD=1000000 # 1 kHz period in ns ON_TIME=${ON_TIME:-1} # seconds a color stays ON REST_TIME=${REST_TIME:-1} # seconds all OFF between colors LOOPS=${1:-3} RETRIES=50 # Channel mapping and polarity (verified on this board, all ACTIVE-HIGH): # Red -> 424f0000.pwm = pwmchip1 ch2 ON=duty PERIOD OFF=duty 0 # Green -> 424e0000.pwm = pwmchip0 ch0 ON=duty PERIOD OFF=duty 0 # Blue -> 424e0000.pwm = pwmchip0 ch2 ON=duty PERIOD OFF=duty 0 RED_CHIP=1; RED_CH=2 GRN_CHIP=0; GRN_CH=0 BLU_CHIP=0; BLU_CH=2 # write_retry FILE VALUE : write VALUE to FILE, retry on transient TPM busy/-ETIME, # and confirm the value took effect. Returns 0 on success. write_retry() { t=0 while [ "$t" -lt "$RETRIES" ]; do echo "$2" > "$1" 2>/dev/null [ "$(cat "$1" 2>/dev/null)" = "$2" ] && return 0 t=$((t+1)) done echo "WARN: could not write $2 to $1" >&2 return 1 } # init_pwm CHIP CH : export (fresh), set period BEFORE duty, start disabled with duty 0. # The i.MX TPM shares a counter between channels; a stale export with period=0 makes # later period writes fail with -EBUSY, so we unexport first for a clean state. init_pwm() { P="/sys/class/pwm/pwmchip${1}" [ -d "${P}/pwm${2}" ] && echo "$2" > "${P}/unexport" 2>/dev/null echo "$2" > "${P}/export" 2>/dev/null write_retry "${P}/pwm${2}/period" "$PERIOD" # period must be set before duty write_retry "${P}/pwm${2}/duty_cycle" 0 # start OFF echo 1 > "${P}/pwm${2}/enable" 2>/dev/null } set_duty() { # CHIP CH DUTY write_retry "/sys/class/pwm/pwmchip${1}/pwm${2}/duty_cycle" "$3" } led() { # CHIP CH STATE(on|off) -- all channels active-high if [ "$3" = on ]; then set_duty "$1" "$2" "$PERIOD"; else set_duty "$1" "$2" 0; fi } all_off() { led $RED_CHIP $RED_CH off led $GRN_CHIP $GRN_CH off led $BLU_CHIP $BLU_CH off } # Init: green and blue share pwmchip0, so init green first, then blue. init_pwm $RED_CHIP $RED_CH init_pwm $GRN_CHIP $GRN_CH init_pwm $BLU_CHIP $BLU_CH trap "all_off; echo; echo interrupted, all LEDs off; exit 0" INT TERM all_off echo "start: all OFF" n=0 while :; do c=$((n+1)) echo "[cycle $c] RED on"; led $RED_CHIP $RED_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] GREEN on"; led $GRN_CHIP $GRN_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] BLUE on"; led $BLU_CHIP $BLU_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" n=$c [ "$LOOPS" -eq 0 ] && continue [ "$n" -ge "$LOOPS" ] && break done all_off echo "done ($n cycle(s)), all LEDs off" よろしくお願いします、 志明
View full article
S32K312 Change FBL after Secureboot authentication Hello NXP, I previously contacted you regarding the same issue, but I need additional assistance, so I am reaching out again. We are using the S32K312 MCU, with HSE version 2.6.0. Issue: With Secure Boot enabled, following an FBL (Flash Bootloader) change, the ECU does not boot normally (APP execution is not possible). When checking with hseImportKeySrv_t (HSE_SRV_ID_IMPORT_KEY), the result returned was KEY_EMPTY. Additionally, within Fota_S32k3_SecureBootProcess, the hseRequestResult value is also returned as KEY_EMPTY, causing retVal to be 1 (NOT_OK). Because this authentication fails, SMR Verify is failing. We attempted to perform the key injection needed for SMR verification via SU (Super User) rights authentication using CMAC, RSA, or ECDSA, but we understand that obtaining such rights requires an authentication key, which we have not been able to locate. We also attempted to erase the IVT sector, but this is not possible either, since the Life-Cycle is set to IN_FIELD. Questions: 1. Is there a way to grant SU rights? (i.e., is it possible to look up/retrieve the authentication key?) 2. Given that flashing the previous bootloader results in normal execution, does this suggest that the old META value is still remaining in the HSE? 3. When we executed Crypto_Hse_GetKeyInfo(FOTA_HSE_MU0_INSTANCE, Crypto_aKeyElementList[ElementIndex].u32HseKeyHandle), the value of Crypto_aKeyElementList[ElementIndex].u32HseKeyHandle returned as 66305. Could this indicate a mismatch in the HSE memory/slot/handle, which is causing the SMR verification to fail? (i.e., is an HSE memory/slot/handle mismatch the root cause?) 4. If we are unable to obtain the SU authentication key, and Format Key Catalog is also not supported in this state, could you please advise whether there is an official NXP recovery procedure (e.g., special access via Secure Debug Authentication, RMA, or a separate vendor provisioning procedure) that can be used to properly recover this device, which is currently in the IN_FIELD life-cycle state with a partially lost key catalog? Thank you in advance for your support. Re: S32K312 Change FBL after Secureboot authentication Lukas is currently on vacation, so I will try to answer your questions in the meantime. Q1: SU rights can be obtained in IN_FIELD via Challenge-Response (HSE_SRV_ID_SYS_AUTH_REQ / HSE_SRV_ID_SYS_AUTH_RESP), but only if the CUST/OEM authorization key was provisioned before advancing to IN_FIELD. If it was not provisioned, or the private key is not held externally, SU rights cannot be obtained and the key cannot be retrieved. Q2: Based on the fact that the old FBL works normally, it is likely that the HMAC key and original authentication tag are still intact in HSE SYS-IMG. If that is the case, the new FBL would be failing because the authentication tag was computed over the old binary and no longer matches the new one. Re-running HSE_SRV_ID_SMR_ENTRY_INSTALL with the new FBL content would fix it — but requires SU rights. Could you confirm whether this matches your setup? Q3: Handle 66305 (0x10301) decodes to NVM catalog, group 3, slot 1 — which appears to be empty. This suggests the HMAC key may be provisioned at a different slot, and the new FBL's FOTA code is referencing a wrong hardcoded handle. As a first step, please compare the authKeyHandle from the original HSE_SRV_ID_SMR_ENTRY_INSTALL call against what your new FBL's FOTA code references — they most likely differ. However, without seeing your full configuration we cannot say this with certainty. Q4: Two options: (1) If CUST/OEM authorization key was provisioned — use Challenge-Response for SU rights. (2) If ADKP was provisioned — Secure Debug Authentication unlocks JTAG for diagnostics only, not HSE NVM writes.
View full article
Adc Issue With Trigger Mode In S32 Design Studio, we are using two methods for ADC peripheral configuration. The first method uses the BCTU trigger for current sensing, while the remaining channels, such as temperature and voltage sensing, are triggered using the normal ADC chain method. When the CTU mode is configured as a trigger mode and only the three current-sensing channels are configured with the BCTU trigger, there is no noticeable current spike. However, when I include the remaining temperature and voltage channels using the normal chain method along with the current-sensing channels, the current-sensing values are affected by spikes. praveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.png There is a timing difference between the two methods: the BCTU conversion is triggered through an interrupt, while the normal ADC chain is called from a 5 ms task. praveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.png praveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.png praveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.png Could you please explain why this difference is causing the current-sensing spike and suggest how we can reduce or eliminate it? S32 SDK for S32K1 Re: Adc Issue With Trigger Mode Hi@praveen_ext It seems my colleagues and I have dealt with the same issue you're experiencing before. We've also conducted some tests following your software configuration, but we didn't encounter such a significant difference. We're unsure if you've taken any of our suggestions. Therefore, I need you to provide your test project. I will reproduce the problem on our hardware platform. If the problem can be reproduced, we can quickly provide you with a conclusion about the cause. Re: Adc Issue With Trigger Mode I have attached the test code for review. We are still observing spikes when running the BCTU trigger and the normal chain mode in trigger configuration simultaneously. Could you please help us, how we can eliminate these spikes? I have already attached the test results in my previous post Re: Adc Issue With Trigger Mode Hi@praveen_ext I recorded a video of the test using the project file you provided, without making any modifications. I connected the sampling pins to VDD externally; the results below show that I did not encounter the spikes you described. Senlent_0-1788492709905.png I also noticed that the project file you provided does not seem to match the  pictures shown in your test images. If you are able to reproduce the issue using this project, you should check your sampling circuit design—specifically, whether the input impedance at the sampling pins is too high.
View full article
i.MX95 19x19 EVK: SMMUコヒーレントテーブルウォーク(IDR0.COHACC)およびSMMUが有効なDPDK用のvfio-pci こんにちは、NXP チームの皆様、 私たちは、i.MX95 19x19 LPDDR5 EVKと公式のNXP Linux BSP LF 6.6.52_2.2.2を組み合わせた高スループット・低レイテンシのネットワーク製品を開発しています。 ユーザー空間PMDと共に、 netc関数(例: 0002:00:00.0 やSR-IOV VF)で vfio-pci を 用いてDPDKを実行する必要があります 。しかし、 SMMUが有効になると vfio-pciへのバインド が失敗します。 64バイトフレームのベンチマークでは: Linuxカーネルドライバー(fsl_enetc4😞 約17万ページ SMMUが無効になっているVFでのネイティブPMD:約456,000pps パフォーマンスの違いにより、ユーザー空間のDPDKドライバが私たちのアプリケーションに必要です。 本番システムではハードウェアによるDMA隔離が必要なため、SMMUを無効化したりenable_unsafe_noiommu_mode=1を使うことはできません。 SMMUが有効になっている場合、NETC機能をfsl_enetc4からバインド解除してvfio-pciにバインドすると、 -EINVALエラーで失敗します。 root@imx95-19x19-lpddr5-evk:~# lspci -k -s 0002:00:00.0 0002:00:00.0 Ethernet controller: Philips Semiconductors Device e101 (rev 04) Subsystem: Philips Semiconductors Device e101 Kernel driver in use: fsl_enetc4 root@imx95-19x19-lpddr5-evk:~# echo 0002:00:00.0 > /sys/bus/pci/drivers/fsl_enetc4/unbind root@imx95-19x19-lpddr5-evk:~# echo "1131 e101" > /sys/bus/pci/drivers/vfio-pci/new_id [ 143.562552] vfio-pci: probe of 0002:00:00.0 failed with error -22 Linux VFIOおよびArm SMMUコードの追跡から、この障害はSMMUのコヒーレンシー能力に関連しているようです。VFIOはIOMMU_CAP_CACHE_COHERENCYを必要とし、Arm SMMUドライバーは IDR0 に基づいてARM_SMMU_FEAT_COHERENCYを有効にします。COHACCです。 i.MX95 EVKでは、IDR0。COHACCは0を読み取り、SMMUは一貫した翻訳テーブルウォークをサポートしていないと報告されます。これにより、device_iommu_capable(..., IOMMU_CAP_CACHE_COHERENCY)がfalseを返し、vfio-pciが-EINVALで失敗します。 We understand that adding dma-coherent; to the SMMU device-tree node can force the Linux SMMUドライバー to enable ARM_SMMU_FEAT_COHERENCY. However, this also causes io-pgtable-arm to configure pgtbl_cfg.coherent_walk = true, which disables the CPU cache maintenance normally performed for page-table updates. したがって、DMAコヒーレントを有効にしたくありません。i.MX95ハードウェアがコヒーレントなSMMU変換テーブルウォークをサポートすることが確認されていない限りです。インターコネクトがSMMUテーブルウォークのためにCPUキャッシュをスヌープしない場合、動的IOMMUマッピング中にページテーブルエントリの古びやメモリ破損を引き起こす可能性があります。 NXPの皆さん、以下の点を明確にしていただけますか? i.MX95シリコン/インターコネクトは 、 CPUキャッシュの必要なキャッシュスヌーピングを含む ハードウェアコヒーレントなSMMU変換テーブルウォーク をサポートしていますか? もしコヒーレントテーブルウォークがサポートされている場合、 SMMUがコヒーレントウォークを報告する前に、インターコネクト、システムマネージャー、ATF/ファームウェア、またはその他のプラットフォーム初期化で有効化しなければならない設定はありますか? もしコヒーレントテーブルウォークがサポートされている場合、NXP推奨のデバイスツリー/ファームウェア構成は安全に有効化されるためのもので、EVK上でどのように検証できますか? も しコヒーレントテーブルウォーク が サポートされていない 場合、 SMMU/DMAのアイソレーションを有効にしたまま vfio-pciでDPDK を使用する際、NXPが推奨する本番環境で安全な方法は何ですか? i.MX95でSMMUを有効にした状態でDPDK + vfio-pciをサポートする構成について、何かご助言いただければ大変ありがたいです。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable 顧客が他の用途でSMMUを使いたいが、DPDKのバイパスは許容される場合(bootargsでiommu.passthrough=1を使ったり、dtsでSMMUノードを無効にしたくない場合)。 その後、uio-pci-genericフレームワークをバインドし、VSI-PSIメッセージングを無効にしようと試みることができます(エクスポートENETC4_VSI_MSG_DISABLE=1)。しかしVSI-PSIメッセージを無効にすると、ユーザーはpromisc、VLAN MACフィルタリング、リンク情報などのENETC機能が使えなくなります。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable DPDKチームからフィードバックがあり、以下の質問をされました。 これは既知の制約事項です。i.MX95-evkはIOキャッシュでないコヒーレントプラットフォームであり、SMMU対応のドライバ VFIO_PCI「IOMMU_CAP_CACHE_COHERENCY」に依存しており、これは公表できません。 詳細はすべてREADMEに記載されています: dpdk/nxp/README_imx95_enetc_vf_vfio at 25.11-qoriq · NXP/dpdk · GitHub dpdkのデータパスでも確認できますが、ドライバは非キャッシュ可能なメモリを使用しているか、SWキャッシュの保守命令を使っています: dpdk/drivers/net/enetc/enetc_rxtx.c at 25.11-qoriq ·NXP/dpdk ·GitHub Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable DPDKチームと話し合っています。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable こんにちは、イーピンワンさん 迅速なご返信と貴重なご意見をありがとうございます。今後、さらにご不明な点が生じた場合は、改めてご連絡させていただきます。
View full article
触发模式下的ADC问题 在 S32 设计工作室中,我们使用两种方法进行 ADC 外设配置。第一种方法使用 BCTU 触发进行电流检测,而其余通道(如温度和电压检测)则使用普通 ADC 链方法触发。 当 CTU 模式配置为触发模式,并且只有三个电流检测通道配置为 BCTU 触发时,不会出现明显的电流尖峰。但是,当我使用常规链式方法将剩余的温度和电压通道与电流检测通道一起加入时,电流检测值会受到尖峰的影响。 praveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.png 这两种方法之间存在时间差异:BCTU 转换是通过中断触发的,而正常的 ADC 链是从 5 毫秒的任务中调用的。 praveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.png praveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.png praveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.png 请问为什么这种差异会导致电流感应尖峰,并请您提出如何减少或消除这种尖峰? S32K1系列的S32SDK Re: Adc Issue With Trigger Mode 你好@ praveen_ext 看来我和我的同事之前也遇到过和你一样的问题。 我们也按照您的软件配置进行了一些测试,但没有发现如此显著的差异。我们不确定您是否采纳了我们的任何建议。 因此,我需要你提供你的测试项目。我将在我们的硬件平台上重现这个问题。如果问题能够重现,我们就能迅速为您提供有关问题原因的结论。 Re: Adc Issue With Trigger Mode 我已附上测试代码供您审核。我们仍然观察到,在触发配置中同时运行 BCTU 触发信号和正常链模式时会出现峰值。请问您能否帮我们解决一下如何消除这些峰值?我已经在之前的帖子中附上了测试结果。 Re: Adc Issue With Trigger Mode 你好@ praveen_ext 我使用您提供的项目文件录制了测试视频,没有做任何修改。 我将采样引脚外部连接到 VDD;下面的结果表明我没有遇到您描述的尖峰。 Senlent_0-1788492709905.png 我还注意到,您提供的项目文件似乎与您的测试图片中显示的图片不符。如果您能够使用此项目重现该问题,则应检查您的采样电路设计——特别是采样引脚的输入阻抗是否过高。
View full article
i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enabled Hi NXP Team, We are developing a high-throughput, low-latency networking product using the i.MX95 19x19 LPDDR5 EVK with the official NXP Linux BSP LF 6.6.52_2.2.2. We need to run DPDK with user-space PMDs using vfio-pci on NETC functions (for example, 0002:00:00.0 or SR-IOV VFs). However, binding the device to vfio-pci fails when the SMMU is enabled. In our 64-byte frame benchmark: Linux kernel driver (fsl_enetc4😞 ~170,000 pps Native PMD on a VF with SMMU disabled: ~456,000 pps The performance difference makes a user-space DPDK driver necessary for our application. We cannot disable the SMMU or use enable_unsafe_noiommu_mode=1, as our production system requires hardware-enforced DMA isolation. With the SMMU enabled, unbinding the NETC function from fsl_enetc4 and binding it to vfio-pci fails with -EINVAL: root@imx95-19x19-lpddr5-evk:~# lspci -k -s 0002:00:00.0 0002:00:00.0 Ethernet controller: Philips Semiconductors Device e101 (rev 04) Subsystem: Philips Semiconductors Device e101 Kernel driver in use: fsl_enetc4 root@imx95-19x19-lpddr5-evk:~# echo 0002:00:00.0 > /sys/bus/pci/drivers/fsl_enetc4/unbind root@imx95-19x19-lpddr5-evk:~# echo "1131 e101" > /sys/bus/pci/drivers/vfio-pci/new_id [ 143.562552] vfio-pci: probe of 0002:00:00.0 failed with error -22 From tracing the Linux VFIO and Arm SMMU code, the failure appears to be related to the SMMU coherency capability. vfio requires IOMMU_CAP_CACHE_COHERENCY, while the Arm SMMU driver enables ARM_SMMU_FEAT_COHERENCY based on IDR0.COHACC. On the i.MX95 EVK, IDR0.COHACC reads 0, so the SMMU is reported as not supporting coherent translation-table walks. This results in device_iommu_capable(..., IOMMU_CAP_CACHE_COHERENCY) returning false and vfio-pci failing with -EINVAL. We understand that adding dma-coherent; to the SMMU device-tree node can force the Linux SMMU driver to enable ARM_SMMU_FEAT_COHERENCY. However, this also causes io-pgtable-arm to configure pgtbl_cfg.coherent_walk = true, which disables the CPU cache maintenance normally performed for page-table updates. Therefore, we do not want to enable dma-coherent; unless the i.MX95 hardware is confirmed to support coherent SMMU translation-table walks. If the interconnect does not snoop CPU caches for SMMU table walks, this could potentially result in stale page-table entries and memory corruption during dynamic IOMMU mappings. Could NXP please clarify the following: Does the i.MX95 silicon/interconnect support hardware-coherent SMMU translation-table walks, including the required cache snooping of CPU caches? If coherent table walks are supported, Is there any required configuration in the interconnect, System Manager, ATF/firmware, or other platform initialization that must be enabled before the SMMU reports coherent walks? If coherent table walks are supported, what is the NXP-recommended device-tree/firmware configuration for enabling them safely, and how can this be validated on the EVK? If coherent table walks are not supported, what is NXP's recommended production-safe method for using DPDK with vfio-pci while keeping the SMMU/DMA isolation enabled? Any guidance on the supported configuration for DPDK + vfio-pci with SMMU enabled on the i.MX95 would be greatly appreciated. Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable If the customer wants to use SMMU for other use cases, but acceptable to bypass for the DPDK (does not want to use iommu.passthrough=1 in bootargs or disable SMMU node in dts). Then can try to bind the uio-pci-generic framework and disable VSI-PSI messaging (export ENETC4_VSI_MSG_DISABLE=1). But disabling VSI-PSI messages means user won’t be able to use some ENETC features like promisc, VLAN MAC filtering, link information. Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable I just got feedback from the DPDK team ask the following. This is the known limitation. The i.MX95-evk is non-IO cache coherent platform and VFIO_PCI  with SMMU enabled driver is dependent on “IOMMU_CAP_CACHE_COHERENCY” which we cannot advertise. All the details are already logged in README: dpdk/nxp/README_imx95_enetc_vf_vfio at 25.11-qoriq · NXP/dpdk · GitHub Even you can check in the dpdk data-path, the driver is either using non-cacheable memory or using SW cache maintenance instructions: dpdk/drivers/net/enetc/enetc_rxtx.c at 25.11-qoriq · NXP/dpdk · GitHub Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable Discussing with DPDK team. Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable Hi yipingwang, Thanks for the prompt reply and insight.We will get back to you if further doubts arise.
View full article
SAF9000 未使用ピン端子 こんにちは SAF9000の未接続・未使用ピンに対して特別な要件はありますか? Re: SAF9000 Unused pin terminations こんにちは、 お問い合わせいただきありがとうございます この部品番号は現在試作段階です。まだドキュメントは入手できません。 詳細については、営業担当者または認可代理店までお問い合わせください。 よろしくお願いします、 アロンドラ
View full article
トリガーモードにおけるADCの問題 S32 Design Studioでは、ADCペリフェラルの設定に2つの方法を使用しています。最初の方法はBCTUトリガーを電流検出に使用し、温度や電圧検出などの残りのチャネルは通常のADCチェーン方式でトリガーされます。 CTUモードがトリガーモードとして設定され、BCTUトリガーで3つの電流検出チャネルのみが設定されている場合、目立つ電流スパイクはありません。しかし、通常のチェーン法で残りの温度と電圧チャネルを電流感知チャネルに加えると、電流感知値がスパイクの影響を受けます。 praveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.pngpraveen_ext_0-1788357008084.png 両方法にはタイミングの違いがあります。BCTU変換は割り込みでトリガーされますが、通常のADCチェーンは5msのタスクから呼び出されます。 praveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.pngpraveen_ext_1-1788357050345.png praveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.pngpraveen_ext_2-1788357069814.png praveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.pngpraveen_ext_3-1788357094947.png なぜこの差が電流感知の急増を引き起こしているのか説明していただけますか?また、それを軽減または排除する方法を提案していただけますか? S32 SDK for S32K1 Re: Adc Issue With Trigger Mode こんにちは、@ praveen_ext どうやら私と同僚たちは、以前にもあなたと同じ問題に対処したことがあるようです。 また、あなたのソフトウェア設定に従っていくつかのテストも行いましたが、それほど大きな違いは見られませんでした。あなたが私たちの提案をどれか実行に移したかどうかは分かりません。 したがって、テストプロジェクトを提供していただく必要があります。この問題をハードウェアプラットフォーム上で再現します。問題が再現できれば、原因について迅速に結論を出すことができます。 Re: Adc Issue With Trigger Mode レビュー用のテストコードを添付しました。トリガー構成において、BCTUトリガーと通常のチェーンモードを同時に実行した場合、依然としてスパイクが発生する現象が観測されています。これらのスパイクをどうやって取り除くか、ぜひ教えていただけますか?前回の投稿で既にテスト結果を添付しました。 Re: Adc Issue With Trigger Mode こんにちは、@ praveen_ext ご提供いただいたプロジェクトファイルをそのまま使用し、一切変更を加えずにテストの動画を録画しました。 サンプリングピンを外部からVDDに接続しました。以下の結果は、あなたが述べたスパイクに遭遇しなかったことを示しています。 Senlent_0-1788492709905.png また、ご提供いただいたプロジェクトファイルが、テスト画像に表示されている画像と一致していないように見受けられました。このプロジェクトで問題を再現できれば、サンプリング回路の設計、特にサンプリングピンの入力インピーダンスが高すぎるかどうかを確認してください。
View full article
SAF9000 未使用的引脚端接 你好 SAF9000 对未连接/未使用的引脚有什么特殊要求吗? Re: SAF9000 Unused pin terminations 你好, 感谢您联系我们 该零件编号目前仍处于预生产阶段。文档尚未提供。 如需更多信息,请联系您的销售代表或授权代理商。 此致, 阿隆德拉
View full article
i.MX95 19x19 EVK:SMMU 一致性表遍历 (IDR0.COHACC) 和启用 SMMU 的 DPDK 的 vfio-pci 您好,NXP团队: 我们正在开发一款高吞吐量、低延迟的网络产品,该产品采用i.MX95 19x19 LPDDR5 EVK和官方 NXP Linux 电路板支持包 LF 6.6.52_2.2.2 。 我们需要 在NETC功能(例如 0002:00:00.0 或SR-IOV VF)上使用 vfio-pci 运行DPDK,并配合用户空间PMD使用。但是, 当SMMU启用时, 将设备绑定到vfio-pci 会失败。 在我们的 64 字节帧基准测试中: Linux 内核驱动程序( fsl_enetc4)😞 约170,000磅 在禁用SMMU的情况下,VF上的原生PMD:~456,000 pps 性能差异使得我们的应用程序需要一个用户空间的 DPDK 驱动程序。 我们不能禁用 SMMU 或使用enable_unsafe_noiommu_mode=1 ,因为我们的生产系统需要硬件强制 DMA 隔离。 启用 SMMU 后,将 NETC 函数从fsl_enetc4解绑并将其绑定到 vfio-pci会失败,并出现-EINVAL错误: root@imx95-19x19-lpddr5-evk:~# lspci -k -s 0002:00:00.0 0002:00:00.0 Ethernet controller: Philips Semiconductors Device e101 (rev 04) Subsystem: Philips Semiconductors Device e101 Kernel driver in use: fsl_enetc4 root@imx95-19x19-lpddr5-evk:~# echo 0002:00:00.0 > /sys/bus/pci/drivers/fsl_enetc4/unbind root@imx95-19x19-lpddr5-evk:~# echo "1131 e101" > /sys/bus/pci/drivers/vfio-pci/new_id [ 143.562552] vfio-pci: probe of 0002:00:00.0 failed with error -22 通过追踪 Linux VFIO 和 Arm SMMU代码,故障似乎与 SMMU 一致性功能有关。vfio需要IOMMU_CAP_CACHE_COHERENCY ,而 Arm SMMU 驱动程序基于IDR0.COHACC启用ARM_SMMU_FEAT_COHERENCY 。 在 i.MX95 EVK 上, IDR0.COHACC读取为0 ,因此报告 SMMU 不支持一致性转换表遍历。这导致device_iommu_capable(..., IOMMU_CAP_CACHE_COHERENCY)返回 false, vfio-pci失败并出现-EINVAL错误。 我们了解到,在 SMMU 设备树节点中添加`dma-coherent;`可以强制 Linux SMMU 驱动程序启用 ` ARM_SMMU_FEAT_COHERENCY` 。但是,这也会导致`io-pgtable-arm`配置`pgtbl_cfg.coherent_walk = true` ,从而禁用通常用于页表更新的 CPU 缓存维护。 因此,除非确认 i.MX95 硬件支持一致性 SMMU 转换表遍历,否则我们不建议启用DMA 一致性。如果互连架构不监听 CPU 缓存中的 SMMU 表遍历信息,则在动态 IOMMU 映射期间,可能会导致页表条目过时和内存损坏。 NXP能否澄清以下问题: i.MX95 芯片/互连是否支持硬件一致的 SMMU 转换表遍历,包括对 CPU 缓存进行必要的缓存侦听? 如果支持一致性表遍历,在 SMMU 报告一致性遍历之前,互连、系统管理器、ATF/固件或其他平台初始化中是否需要启用任何配置? 如果支持一致性表遍历, NXP 推荐的安全启用一致性表遍历的设备树/固件配置是什么?如何在 EVK 上验证这一点? 如果 不支持 一致性表遍历 ,NXP 推荐的在生产环境中安全使用 DPDK 和 vfio-pci 并保持 SMMU/DMA 隔离启用的 方法是什么 ? 对于在 i.MX95 上启用 SMMU 的DPDK + vfio-pci 的支持配置,任何指导都将不胜感激。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable 如果客户希望将 SMMU 用于其他用例,但可以接受绕过 DPDK(不想在 bootargs 中使用 iommu.passthrough=1 或在 dts 中禁用 SMMU 节点)。 然后可以尝试绑定 uio-pci-generic 框架并禁用 VSI-PSI 消息传递(导出 ENETC4_VSI_MSG_DISABLE=1)。但是禁用 VSI-PSI 消息意味着用户将无法使用某些 ENETC 功能,例如混杂模式、VLAN MAC 地址过滤和链路信息。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable 我刚刚收到 DPDK 团队的反馈,请问以下问题。 这是已知的局限性。i.MX95-evk 是一个非 IO 缓存一致性平台,启用 SMMU 的 VFIO_PCI 驱动程序依赖于“IOMMU_CAP_CACHE_COHERENCY”,我们无法对此进行宣传。 所有详细信息已记录在 README 文件中: dpdk/nxp/README_imx95_enetc_vf_vfio at 25.11-qoriq · NXP/dpdk · GitHub 即使您检查 dpdk 数据路径,也会发现驱动程序要么使用不可缓存的内存,要么使用软件缓存维护指令: dpdk/drivers/net/enetc/enetc_rxtx.c 25.11-qoriq · NXP/dpdk · GitHub Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable 与DPDK团队讨论。 Re: i.MX95 19x19 EVK: SMMU coherent table walks (IDR0.COHACC) and vfio-pci for DPDK with SMMU enable 王一平你好, 感谢您的及时回复和深入见解。如有其他疑问,我们将与您联系。
View full article
S32K312 Secureboot認証後のFBL変更 こんにちは、NXPさん。 以前同じ問題でお問い合わせしましたが、追加の支援が必要なので再度ご連絡いたします。私たちはS32K312 MCUを使用し、HSEバージョン2.6.0を使用しています。 問題:セキュアブートが有効になっている状態で、FBL(フラッシュブートローダー)を変更した後、ECUが正常に起動しない(アプリの実行ができない)。 hseImportKeySrv_t (HSE_SRV_ID_IMPORT_KEY) で確認したところ、KEY_EMPTY が返されました。さらに、Fota_S32k3_SecureBootProcess 内では、hseRequestResult の値が KEY_EMPTY として返されるため、retVal が 1 (NOT_OK) になります。この認証が失敗するため、SMR Verifyは失敗しています。 SMR検証に必要な鍵注入は、CMAC、RSA、ECDSAを用いたSU(スーパーユーザー)権利認証を試みましたが、そのような権限を取得するには認証キーが必要であることを理解しており、その鍵は特定できていません。また、IVTセクターの消去も試みましたが、ライフサイクルがIN_FIELDに設定されているため、これも不可能でした。 質問: 1. SUに権限を付与する方法はありますか?(つまり、認証キーを調べたり取得したりすることは可能でしょうか?) 2. 以前のブートローダーをフラッシュすると正常に実行されることから、古いMETA値がHSE内にまだ残っているということでしょうか? 3. Crypto_Hse_GetKeyInfo(FOTA_HSE_MU0_INSTANCE, Crypto_aKeyElementList[ElementIndex].u32HseKeyHandle) を実行したところ、Crypto_aKeyElementList[ElementIndex].u32HseKeyHandle の値は 66305 として返されました。これはHSEメモリ/スロット/ハンドルの不一致を示し、それがSMR検証の失敗の原因となるのでしょうか?(つまり、HSEメモリ/スロット/ハンドルの不一致が根本原因なのでしょうか?) 4. SU認証キーを入手できず、フォーマットキーカタログもこの州でサポートされていない場合、現在IN_FIELDライフサイクル状態で部分的に失われたキーカタログを持つこのデバイスを適切に復旧するための公式なNXP復旧手順(例:Secure Debug認証、RMA、または別のベンダープロビジョニング手順)が存在するかご助言いただけますか? サポートにあらかじめ感謝いたします。 Re: S32K312 Change FBL after Secureboot authentication ルーカスは現在休暇中なので、その間に皆さんの質問にお答えします。 Q1:SU権限はIN_FIELDでチャレンジレスポンス(HSE_SRV_ID_SYS_AUTH_REQ / HSE_SRV_ID_SYS_AUTH_RESP)で取得可能ですが、IN_FIELDに進む前にCUST/OEM認可キーがプロビジョニングされている場合に限ります。もしプロビジョニングされていなかったり、秘密鍵が外部に保持されていなければ、SU権限は取得できず、鍵の取得もできません。 Q2: 古いFBLが正常に動作していることから、HMACキーと元の認証タグはHSE SYS-IMGにまだ残っている可能性が高いです。もしそうなら、新しいFBLは認証タグが古いバイナリ上で計算され、新しいものと一致しなくなったため失敗しているはずです。新しいFBLコンテンツを使用してHSE_SRV_ID_SMR_ENTRY_INSTALLを再実行すれば問題は解決しますが、SU権限が必要です。これがあなたの設定に合っているか確認してもらえますか? Q3:ハンドル66305(0x10301)をNVMカタログ、グループ3、スロット1にデコードしますが、これは空のようです。これは、HMACキーが別のスロットにプロビジョニングされている可能性があり、新しいFBLのFOTAコードが誤ったハードコードされたハンドルを参照していることを示唆しています。まず最初に、元の HSE_SRV_ID_SMR_ENTRY_INSTALL 呼び出しの authKeyHandle と、新しい FBL の FOTA コードが参照している authKeyHandle を比較してください。おそらく両者は異なっているはずです。しかし、あなたの全構成を見ないと確実に言えません。 Q4: 選択肢は2つあります。(1) CUST/OEM認可キーがプロビジョニングされている場合、SU権利に対してチャレンジレスポンスを使用。(2) ADKPがプロビジョニングされている場合、Secure Debug認証はJTAGを診断用にのみアンロックし、HSE NVMの書き込みは解除しません。
View full article
SAF9000 Unused pin terminations Hi  Are there any special requirements for un-connected/not used pins for the SAF9000. Re: SAF9000 Unused pin terminations Hello,  Thanks for reaching us This part number is still under preproduction. Documentation is not available yet. For additional information please contact your sales representative or authorized distributor. Best regards,  Alondra
View full article
user LED control on i.MX93 FRDM board Hi all, I started to play with i.MX93 FRDM board and when I wrote a simple script to control RGB LEDs on the board, I've managed to control only Green and Blue LEDs. Red LED stays ON whatever I tried. Based on the schematics, all leds are connected in a similar manner, so they operate Active High. Here is my script: --------------------------- #!/bin/sh PERIOD=1000000 set_pwm() { CHIP=$1 CHANNEL=$2 DUTY=$3 PWM_PATH="/sys/class/pwm/pwmchip${CHIP}/pwm${CHANNEL}" if [ ! -d "$PWM_PATH" ]; then echo "$CHANNEL" > "/sys/class/pwm/pwmchip${CHIP}/export" 2>/dev/null fi # Reset duty cycle to 0 first to satisfy TPM driver constraints echo 0 > "${PWM_PATH}/duty_cycle" 2>/dev/null echo "$PERIOD" > "${PWM_PATH}/period" echo "$DUTY" > "${PWM_PATH}/duty_cycle" echo 1 > "${PWM_PATH}/enable" 2>/dev/null } # Red is Active-Low: Default OFF = 1000000 (3.3V / High) RED_DUTY=${1:-0} # Green and Blue are Active-High: Default OFF = 0 (0V / Low) GREEN_DUTY=${2:-0} BLUE_DUTY=${3:-0} # Red -> pwmchip4, Channel 3 set_pwm 4 3 "$RED_DUTY" # Green -> pwmchip0, Channel 0 set_pwm 0 0 "$GREEN_DUTY" # Blue -> pwmchip0, Channel 2 set_pwm 0 2 "$BLUE_DUTY" ------------------------------------------- I've checked that red LED (GPIO_IO13) is allocated to the ledsgrp2: pin 17 (IMX93_IOMUXC_GPIO_IO13): 424f0000.pwm (GPIO UNCLAIMED) function pinctrl group ledsgrp2 as far as I can see with debugfs commands, the pin GPIO_IO13 is configured for ALT1 mode, which is a TPM2 channel 3 (PWM). when I run the script, I can successfully control Blue and Green LEDS but Red LED stays ON. Is there something that I miss? Re: user LED control on i.MX93 FRDM board Hi @ilya_chepurin  The RED LED is channel 2, please use below script to test(verified on L6.18.20) #!/bin/sh # RGB LED PWM cycle test for i.MX93 EVK/FRDM. # Sequence per cycle: RED on 1s -> all off 1s -> GREEN on 1s -> all off 1s -> BLUE on 1s -> all off 1s # Usage: ./run.sh [LOOPS] LOOPS: number of full cycles, 0 = infinite, default 3 # Timing overridable via env: ON_TIME=2 REST_TIME=1 ./run.sh PERIOD=1000000 # 1 kHz period in ns ON_TIME=${ON_TIME:-1} # seconds a color stays ON REST_TIME=${REST_TIME:-1} # seconds all OFF between colors LOOPS=${1:-3} RETRIES=50 # Channel mapping and polarity (verified on this board, all ACTIVE-HIGH): # Red -> 424f0000.pwm = pwmchip1 ch2 ON=duty PERIOD OFF=duty 0 # Green -> 424e0000.pwm = pwmchip0 ch0 ON=duty PERIOD OFF=duty 0 # Blue -> 424e0000.pwm = pwmchip0 ch2 ON=duty PERIOD OFF=duty 0 RED_CHIP=1; RED_CH=2 GRN_CHIP=0; GRN_CH=0 BLU_CHIP=0; BLU_CH=2 # write_retry FILE VALUE : write VALUE to FILE, retry on transient TPM busy/-ETIME, # and confirm the value took effect. Returns 0 on success. write_retry() { t=0 while [ "$t" -lt "$RETRIES" ]; do echo "$2" > "$1" 2>/dev/null [ "$(cat "$1" 2>/dev/null)" = "$2" ] && return 0 t=$((t+1)) done echo "WARN: could not write $2 to $1" >&2 return 1 } # init_pwm CHIP CH : export (fresh), set period BEFORE duty, start disabled with duty 0. # The i.MX TPM shares a counter between channels; a stale export with period=0 makes # later period writes fail with -EBUSY, so we unexport first for a clean state. init_pwm() { P="/sys/class/pwm/pwmchip${1}" [ -d "${P}/pwm${2}" ] && echo "$2" > "${P}/unexport" 2>/dev/null echo "$2" > "${P}/export" 2>/dev/null write_retry "${P}/pwm${2}/period" "$PERIOD" # period must be set before duty write_retry "${P}/pwm${2}/duty_cycle" 0 # start OFF echo 1 > "${P}/pwm${2}/enable" 2>/dev/null } set_duty() { # CHIP CH DUTY write_retry "/sys/class/pwm/pwmchip${1}/pwm${2}/duty_cycle" "$3" } led() { # CHIP CH STATE(on|off) -- all channels active-high if [ "$3" = on ]; then set_duty "$1" "$2" "$PERIOD"; else set_duty "$1" "$2" 0; fi } all_off() { led $RED_CHIP $RED_CH off led $GRN_CHIP $GRN_CH off led $BLU_CHIP $BLU_CH off } # Init: green and blue share pwmchip0, so init green first, then blue. init_pwm $RED_CHIP $RED_CH init_pwm $GRN_CHIP $GRN_CH init_pwm $BLU_CHIP $BLU_CH trap "all_off; echo; echo interrupted, all LEDs off; exit 0" INT TERM all_off echo "start: all OFF" n=0 while :; do c=$((n+1)) echo "[cycle $c] RED on"; led $RED_CHIP $RED_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] GREEN on"; led $GRN_CHIP $GRN_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] BLUE on"; led $BLU_CHIP $BLU_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" n=$c [ "$LOOPS" -eq 0 ] && continue [ "$n" -ge "$LOOPS" ] && break done all_off echo "done ($n cycle(s)), all LEDs off" Best Regards, Zhiming
View full article
i.MX93 FRDM 板上的用户 LED 控制 大家好, 我开始摆弄 i.MX93 FRDM 板,当我编写一个简单的脚本来控制板上的 RGB LED 时,我只成功控制了绿色和蓝色 LED。无论我怎么尝试,红色LED灯都一直亮着。 根据原理图,所有 LED 的连接方式都类似,因此它们都采用高电平有效模式。 这是我的脚本: --------------------------- #!/bin/sh 周期=1000000 设置 PWM() { 芯片=1美元 频道=$2 关税=3美元 PWM_PATH="/sys/class/pwm/pwmchip ${CHIP} /pwm ${CHANNEL} " 如果 [ ! -d "$PWM_PATH" ]; 则 echo "$CHANNEL" > "/sys/class/pwm/pwmchip ${CHIP} /export" 2>/dev/null 菲 # 首先将占空比重置为 0,以满足 TPM 驱动器的限制 echo 0 > " ${PWM_PATH} /duty_cycle" 2>/dev/null echo "$PERIOD" > " ${PWM_PATH} /period" echo "$DUTY" > " ${PWM_PATH} /duty_cycle" echo 1 > " ${PWM_PATH} /enable" 2>/dev/null } # 红色为低电平有效:默认关闭 = 1000000 (3.3V / 高电平) RED_DUTY= ${1:-0} # 绿色和蓝色为高电平有效:默认值为OFF = 0 (0V / 低电平) 绿色职责= ${2:-0} BLUE_DUTY= ${3:-0} # 红色 -> pwmchip4,通道 3 set_pwm 4 3 "$RED_DUTY" # 绿色 -> pwmchip0,通道 0 set_pwm 0 0 "$GREEN_DUTY" # 蓝色 -> pwmchip0,通道 2 set_pwm 0 2 "$BLUE_DUTY" ------------------------------------------- 我已经检查过,红色 LED(GPIO_IO13)已分配给 ledsgrp2: 引脚 17 (IMX93_IOMUXC_GPIO_IO13): 424f0000.pwm (GPIO 未声明) 功能 pinctrl 组 ledsgrp2 根据我使用 debugfs 命令所看到的,引脚 GPIO_IO13 配置为 ALT1 模式,即 TPM2 通道 3(PWM)。 运行脚本后,我可以成功控制蓝色和绿色 LED,但红色 LED 一直亮着。 我是不是漏掉了什么? Re: user LED control on i.MX93 FRDM board 嗨@ilya_chepurin 红色LED灯为通道2,请使用以下脚本进行测试(已在L6.18.20版本上验证)。 #!/bin/sh # RGB LED PWM cycle test for i.MX93 EVK/FRDM. # Sequence per cycle: RED on 1s -> all off 1s -> GREEN on 1s -> all off 1s -> BLUE on 1s -> all off 1s # Usage: ./run.sh [LOOPS] LOOPS: number of full cycles, 0 = infinite, default 3 # Timing overridable via env: ON_TIME=2 REST_TIME=1 ./run.sh PERIOD=1000000 # 1 kHz period in ns ON_TIME=${ON_TIME:-1} # seconds a color stays ON REST_TIME=${REST_TIME:-1} # seconds all OFF between colors LOOPS=${1:-3} RETRIES=50 # Channel mapping and polarity (verified on this board, all ACTIVE-HIGH): # Red -> 424f0000.pwm = pwmchip1 ch2 ON=duty PERIOD OFF=duty 0 # Green -> 424e0000.pwm = pwmchip0 ch0 ON=duty PERIOD OFF=duty 0 # Blue -> 424e0000.pwm = pwmchip0 ch2 ON=duty PERIOD OFF=duty 0 RED_CHIP=1; RED_CH=2 GRN_CHIP=0; GRN_CH=0 BLU_CHIP=0; BLU_CH=2 # write_retry FILE VALUE : write VALUE to FILE, retry on transient TPM busy/-ETIME, # and confirm the value took effect. Returns 0 on success. write_retry() { t=0 while [ "$t" -lt "$RETRIES" ]; do echo "$2" > "$1" 2>/dev/null [ "$(cat "$1" 2>/dev/null)" = "$2" ] && return 0 t=$((t+1)) done echo "WARN: could not write $2 to $1" >&2 return 1 } # init_pwm CHIP CH : export (fresh), set period BEFORE duty, start disabled with duty 0. # The i.MX TPM shares a counter between channels; a stale export with period=0 makes # later period writes fail with -EBUSY, so we unexport first for a clean state. init_pwm() { P="/sys/class/pwm/pwmchip${1}" [ -d "${P}/pwm${2}" ] && echo "$2" > "${P}/unexport" 2>/dev/null echo "$2" > "${P}/export" 2>/dev/null write_retry "${P}/pwm${2}/period" "$PERIOD" # period must be set before duty write_retry "${P}/pwm${2}/duty_cycle" 0 # start OFF echo 1 > "${P}/pwm${2}/enable" 2>/dev/null } set_duty() { # CHIP CH DUTY write_retry "/sys/class/pwm/pwmchip${1}/pwm${2}/duty_cycle" "$3" } led() { # CHIP CH STATE(on|off) -- all channels active-high if [ "$3" = on ]; then set_duty "$1" "$2" "$PERIOD"; else set_duty "$1" "$2" 0; fi } all_off() { led $RED_CHIP $RED_CH off led $GRN_CHIP $GRN_CH off led $BLU_CHIP $BLU_CH off } # Init: green and blue share pwmchip0, so init green first, then blue. init_pwm $RED_CHIP $RED_CH init_pwm $GRN_CHIP $GRN_CH init_pwm $BLU_CHIP $BLU_CH trap "all_off; echo; echo interrupted, all LEDs off; exit 0" INT TERM all_off echo "start: all OFF" n=0 while :; do c=$((n+1)) echo "[cycle $c] RED on"; led $RED_CHIP $RED_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] GREEN on"; led $GRN_CHIP $GRN_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" echo "[cycle $c] BLUE on"; led $BLU_CHIP $BLU_CH on; sleep "$ON_TIME" echo "[cycle $c] --- off"; all_off; sleep "$REST_TIME" n=$c [ "$LOOPS" -eq 0 ] && continue [ "$n" -ge "$LOOPS" ] && break done all_off echo "done ($n cycle(s)), all LEDs off" 此致, 志明
View full article