Multi Source Translation Content

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

Multi Source Translation Content

Discussions

Sort by:
PIC CLBのユーレカ 特定のPIC MCU(例:pic16f13145ファミリ)には、Configurable Logic Blockと呼ばれるFPGA風のプログラム可能なロジックがあります。 私が使用しているpic16f13115は、それぞれ4入力ルックアップテーブルとDフリップフロップを備えた32個のセルで構成されています。 ツールの使い方を学ぶために、今日はPWM明るさ制御付き6つのLEDのチャーリープレックス対応を実装し、シミュレーションしました。ロジックCADキャンバスを使用する代わりに、Verilogを使用して回路を定義しました。 私は時間の半分くらいを壁に頭を打ち付けて過ごしていた。少しずつ、Verilogを正しく記述し、合成(ビルド)を行い、そしてシミュレーションを実行できるようにした。 CLBでプログラムされたロジックがCPUがスリープ状態でも動作するのは素晴らしい。セーフティに関わる用途に最適です。例えば、複雑な割り込みトリガーロジックの実装に利用できます。CLBロジックをペリフェラル入力・出力に接続する際の柔軟性は非常に高いです。これは、PICの定番となっている、扱いにくいCLCプログラマブルロジックよりもはるかに柔軟性が高い。 私のEureka体験を共有したかっただけです。
View full article
芯片版本 你好, 我正在寻找有关 MCIMX6S4AVM08AC 到 MCIMX6S4AVM08AD 的芯片版本修订的一些文档。 这次硅片版本做了哪些改动?我没有找到任何相关文件。 MCXA MCXC MCX N Re: silicon revision 嗨@FelipeBalieiro 请参考此数据表。 https://www.nxp.com/docs/en/data-sheet/IMX6SDLAEC.pdf 数据手册确认MCIMX6S4AVM08AC涵盖硅 Rev. 1.2/1.3,而MCIMX6S4AVM08AD是 Rev. 1.4,是带有 ROM 修改的新 4N81E 掩码集。 相关 ROM 修改信息可在此处找到: i.MX 6Solo/6DualLite 芯片勘误表 此致, 志明
View full article
どのNeutronコンバータがi.MX95 BSP LF6.6.52_2.2.xに一致しますか?Toolkit 1.14にはLinux_6.6.52フォルダはありません 私たちは、Toradex Verdin iMX95、B0シリコン上でNeutron NPUを有効にしており、Toradex BSP 7.7.0のYoctoリファレンスマルチメディアイメージを実行しています。これはトリゾンではありません。カーネルはNXP LF6.6.52_2.2.2をベースにした6.6.142-7.7.0-develです。/dev/neutron0が存在し、ドライバーがプローブします。 そのイメージにはNeutronのファームウェアは付属していません。「NeutronFirmware.elf」をインストールしました。およびNXP-IMX/Neutronの「NeutronKernels.bin」、LF-6.6.52_2.2.0の分岐です。ユーザースペースデリゲートとNeutronライブラリは同じブランチから構築されました。label_imageはコンテナ内で実行され、NPUに到達します。 eIQツールキット1.14.0、2025年1月28日付のインストーラーEIQ-TOOLKIT-WIN-1.14.0にはLinux_6.6.52コンバータがありません。そのインストールで最新のLinuxコンバータはLinux_6.6.36_2.1.0です。mobilenet_v1_1.0_224_quant.tflite を変換中--target imx95 はマイクロコードが0x5bfe0804のモデルを生成します。実行時に6.6.52スタックは以下を報告します。 マイクロコードのバージョンが一致しません!0x5bfe0804 (期待値 0xa186aaf2) 委任先は作成され、1つのノードが委任されましたが、分類スコアは空です。同じモデルのCPU上で、Neutronデリゲートなしではgrace_hopper.bmpの「軍服」を正しく返します。 ファームウェアとユーザー空間ライブラリをlf-6.6.36_2.1.0に置き換えるバージョンは不一致を除去し、その後6.6.52カーネルドライバは中性子推論ジョブの作成に失敗し、Neutron Driver 内部故障コード442を発生させます。6.6.36ライブラリはこのカーネルと通信できません。 eIQ Toolkitのリリースノートによると、i.MX95 BSP LF6.6.52_2.2.x用のNeutronコンバーターはeIQ Toolkit 1.14でのみ利用可能とされています。私たちが持っている1.14インストーラーには、それは含まれていません。 どのコンバーターバイナリがこのBSP用のマイクロコード0xa186aaf2を生成しており、どのeIQ ToolkitやNeutron SDKパッケージに出荷されているのでしょうか? Re: Which neutron-converter matches i.MX95 BSP LF6.6.52_2.2.x? Toolkit 1.14 has no Linux_6.6.52 fold こんにちは、 @Giorgos_Sofroniou さん。 プリビルドのコンバーターは eIQ Ubuntu 版のみで利用可能です。 よろしくお願いします、 志明
View full article
Eureka on PIC CLB Certain PIC MCUs (e.g., pic16f13145 family) have FPGA-like programmable logic called Configurable Logic Block. The pic16f13115 I'm using has 32 cells each with a 4-input lookup table and a D flip-flop. To learn to use the tools, today I implemented and simulated support for Charlieplexing of 6 LEDs with PWM brightness control. I used Verilog to define the circuit instead of using the logic CAD canvas. I was pounding my head on the wall for about half my time. Slowly, I got the Verilog right, got it to synthesize (build), then got it simulating. It is cool that the CLB programmed logic works even when the CPU is sleeping. It's perfect for safety-critical applications. Can be used, for example, to implement complex interrupt trigger logic. There is great flexibility in hooking up CLB logic to peripheral inputs and outputs. It's much more flexible than the clunkier CLC programmable logic that's been a fixture of PICs. Just thought I'd share my Eureka experience.
View full article
EIS BMS reference software source code To evaluate and develop a EIS bms we bought an evaluation board with BCC 7426 (EVBMA7X2YDT1). The problem is that the only reference software i found on NXP package manager is precompiled "SW32K358_EIS_BMU_SW_3.0_CD01_D2605" to be used in combination with "SW32K358_EIS_GUI_SW_3.0_CD01_D2605". The release documentation explain how to use the GUI with S32K358_EIS_BMU board flashing the provided .elf. Is it possible to download the source code of reference software source code, in order to use the GUI with a compatible board (RD-BESSK358BMU) which has quite the same layout (K358 with MC33665A, 2 TPL ports, Debug Header) but different pinout on SPI and UART? Seems strange it has been changed from one board to other one. Thanks Re: EIS BMS reference software source code Hi gferretts The currently released SW32K358_EIS_BMU_SW_3.0_CD01_D2605 software package primarily provides pre-compiled BMU firmware along with the corresponding EIS GUI. Based on the existing release content, No any publicly downloadable complete source code for the BMU reference software.
View full article
RT-DETR cannot fully convert to Ara240 .dvm on AraSDK 2.1.1 — unsupported ops + hybrid workaround Hello NXP community, I am converting RT-DETR object detectors for Ara240 DNPU on FRDM i.MX95, targeting AraSDK / runtime 2.1.1 only (not 3.0). I want to share findings and ask whether there is a recommended / supported path for full .dvm conversion of DETR-style models with multi-scale deformable attention. Environment ItemValue Board FRDM i.MX95 + Ara240 Runtime imx-nxp-ara2 2.1.1 (must match compiler) Compiler AraSDK 2.1.1 (ara-sdk-cnn:2.1.1, dvrun) Models tried Ultralytics rtdetr-l / rtdetr-x (HGNetv2); also reviewed HF PekingU/rtdetr_r50vd (ResNet-50-VD) ONNX export Ultralytics RTDETR.export(format="onnx", imgsz=640, batch=1, dynamic=False, opset=17) → FP32 static ONNX Quantization Done inside AraSDK (analyzer + calib images) → INT8 .dvm (not Ultralytics INT8 ONNX) Goal Full end-to-end conversion: FP32 ONNX → dvconvert → dryrun estimate → quantize → estimate → emit → .dvm that loads on runtime 2.1.1 and runs entirely on the Ara240 DNPU. Observation vs NXP HuggingFace Ara240 models Published Ara240 models such as Qwen2.5-VL / Qwen2.5-Coder convert successfully even though they are much larger. Those graphs are dominated by static MatMul / Norm / Softmax stacks and appear first-party ported. RT-DETR fails not because of size (~33–43M params), but because of operator coverage: the detection decoder uses multi-scale deformable attention and dynamic query selection. Unsupported / problematic layers (same class on Ultralytics and HF RT-DETR) PatternWhereEffect on AraSDK 2.1.1 GridSample / F.grid_sample Decoder MS deformable attention (n_points=4, 3 levels, 6 layers) Not a DNPU op; ONNX export produces many GridSample nodes (18 on Ultralytics rtdetr-l) TopK + gather / mask ops Uncertainty-minimal query selection (num_queries=300) Data-dependent indexing; converter falls back or schedule/emit fails AIFI self-attention Hybrid encoder Schedules as BDOT; estimator can crash (total_wgs: 0) Opset-17 ReduceSum (axes as input) Decoder attention path Converter rename_ReduceSum IndexError → DV_ATen (CPU) Identity / depth broadcasts e.g. Expand for GatherElements mask IR serialize abort (DVEEIR Broadcast layer is not needed / depth-dim broadcast) HuggingFace PekingU/rtdetr_r50vd uses the same deformable decoder + AIFI pattern (RTDetrMultiscaleDeformableAttention + grid_sample + topk in Transformers source). Only the backbone differs (ResNet-50-VD vs HGNet). Switching to HF does not make full DNPU conversion possible. Failures I hit (stage by stage) IR serialize (full graph) DVEEIR Broadcast layer is not needed at all … BCST … 300 Source: /model.28/Expand_1 (TopK mask expand). After Expand→Concat rewrite DVEEIR broadcast case is not supported in depth dimension along with other dims yet Still on the GatherElements / broadcast path. Full reconvert ReduceSum opset-17 → DV_ATen; Mod/Less/Xor/And → DV_ATen; conversion validation EMAX > 1e-4. Note: cannot drop to opset 13 because GridSample needs opset ≥ 16. Hybrid: backbone + encoder (exclude decoder only) Dryrun estimator: DVESIT Total WGs are not calculated properly at SINIT … BDOT,400,400,32 … total_wgs: 0 (AIFI). Emitter: DVEMCU Unknown CP kernels present in model … exit 139 (dummy/generic kernels after tolerating dryrun crash → no real .dvm). Hybrid: backbone only (pure CNN) Dryruns reach DVEQIR Serializing IR completed — this path is viable for a DNPU .dvm of the CNN backbone; AIFI + CCFM + decoder stay on CPU (onnxruntime). How I convert (working approach: hybrid) Because a full RT-DETR .dvm is not achievable on 2.1.1 with current op support, I use a parity-exact hybrid: Step 1 — Export FP32 static ONNX (Ultralytics) from ultralytics import RTDETR model = RTDETR("rtdetr-l.pt") model.export(format="onnx", imgsz=640, batch=1, dynamic=False, simplify=True, opset=17) dvrun takes this FP32 ONNX as inet/iwt. INT8 is produced later by AraSDK quantizer + calibration set. Step 2 — Extract FP32 subgraphs (ONNX extract_model) Cut at the backbone outputs (Ultralytics RT-DETR-L): Inputs: images [1,3,640,640] Outputs (DNPU / Part A): /model.3/ec/act/Relu_output_0 → [1,512,80,80] /model.7/Add_output_0 → [1,1024,40,40] /model.10/conv/Conv_output_0 → [1,256,20,20] Rest (CPU / Part B): those 3 tensors → output0 [1,300,6] from onnx import utils as onnx_utils BOUNDARY = [ "/model.3/ec/act/Relu_output_0", "/model.7/Add_output_0", "/model.10/conv/Conv_output_0", ] onnx_utils.extract_model("rtdetr-l.onnx", "partA_backbone.onnx", ["images"], BOUNDARY) onnx_utils.extract_model("rtdetr-l.onnx", "partB_rest.onnx", BOUNDARY, ["output0"]) Part A is pure CNN (Conv/Relu/MaxPool/Concat) — no GridSample / TopK / AIFI. I verified: full(images) == partB(partA(images)) with max_abs = 0 (bit-exact). Step 3 — Compile Part A with AraSDK 2.1.1 (dvrun) YAML: srcfw: onnx, inet/iwt = partA_backbone.onnx, dim 3,640,640, calib folder, ignore_mse: true if needed Host: enough RAM/swap for estimator (I used a 32 GiB RAM / ~100 GiB swap server; 16 Gi desktop OOMs easily) Keep compiler and board runtime both on 2.1.1 Success criteria: schedule serializes, emitter reports Ara2 Processor compatibility, non-empty .dvm / assets (not 0-byte kernel.lib) Step 4 — Deploy hybrid inference Load Part A .dvm on Ara240 (runtime 2.1.1). Run Part B (partB_rest.onnx) on ARM with onnxruntime. Feed DNPU feature maps into Part B → detections. Model Part A is converted into .dvm so i have tested Part A on DNPU + PART B on CPU but it give false output low detection with zero class output but both PART A onnx and PART B onnx work on A55 cpu and gives correct output. I am attaching images for reference. ORT A + B Image Hybrid A + B Questions for NXP / Kinara Is RT-DETR / Deformable DETR on the supported / validated model list for Ara240 2.1.1? Is there a planned kernel or conversion path for GridSample / multi-scale deformable attention? For AIFI-like attention, is there a recommended ONNX rewrite or constraint so BDOT schedules without total_wgs: 0? Is a hybrid (DNPU backbone + CPU decoder) the intended pattern for this architecture until kernels exist? Any official guidance on opset (16/17) vs converter ReduceSum attribute form for DETR graphs? If others have successfully produced a full RT-DETR .dvm on Ara240 2.1.1 (or 3.x), please share: export settings (Ultralytics vs HF / lyuwenyu) YAML / dvrun flags whether deformable attention was rewritten or offloaded Happy to share more logs (estimator BCST / BDOT / emitter CP-kernel messages) if useful. Thanks,          Vijay Rana Re: RT-DETR cannot fully convert to Ara240 .dvm on AraSDK 2.1.1 — unsupported ops + hybrid workaroun Hi @vijayranaACL  1. Is RT-DETR / Deformable DETR on the supported / validated model list for Ara240 2.1.1? >>>No, This model is not currently included in the support list for Ara240. 2. Is there a planned kernel or conversion path for GridSample / multi-scale deformable attention? >>>There are no plans at the moment. I need to confirm with internal team regarding the other questions before getting back to you. Could you please share the model file you tested? I can then run some tests on my i.MX95 FRDM board. B.R Re: RT-DETR cannot fully convert to Ara240 .dvm on AraSDK 2.1.1 — unsupported ops + hybrid workaroun These are the all level of model conversion files from .pt -> .onnx -> hybrid A + B -> DVM of A + int8 onnx B.  model link: https://drive.google.com/file/d/1YhxLetVxP0T85gv0qK1GT1r_T1i25f7P/view?usp=sharing
View full article
ADV7535を使用したカスタムi.MX95ボードでのHDMI起動に関するガイダンス NXPチームの皆様、こんにちは。 私はNXP i.MX95カスタムボードを開発中で、ADV7535 MIPI-DSI-to-HDMIブリッジを使用してHDMI出力を有効にしたいと考えています。 私はYocto Linux、デバイスツリー設定、HDMI初期化の初心者です。どうかステップごとにご案内いただけますか: 必要なLinuxカーネルドライバーと設定。 ADV7535およびMIPI-DSIのデバイスツリー(DTS)の変更点。 Yoctoの設定とHDMI初期化について。 参考のデバイスツリーファイル、アプリケーションノート、初心者向けのガイドなど。 再開まで今しばらくお待ちください。 Re: Guidance for HDMI Bring-Up on Custom i.MX95 Board Using ADV7535 こんにちは、 この投稿を参考にして、カスタムデザインの新しい画像を作成できます。 Yocto Projectのカスタマイズガイド 私たちのBSPにはブリッジADV7535使うために必要なすべてのドライバがあり、EVKボードのデバイスツリーを基準にしてデバイスツリー構成に組み込めます。 imx95-19x19-evk-adv7535.dtso よろしくお願いいたします。 Re: Guidance for HDMI Bring-Up on Custom i.MX95 Board Using ADV7535 i.MX95 ADV7535 HDMIデバイスツリーパッチのレビュー依頼 NXPチームの皆様、こんにちは。 私は、自作のi.MX95 15×15ボード上でADV7535 MIPI-DSI-to-HDMIブリッジを介してHDMI出力を有効にするために、デバイスツリーパッチ( hdmi_patch_imx95-15x15.patch )を作成しました。 添付したパッチを確認して、HDMI統合が正しいか確認してもらえますか? HDMI関連の変更点のみに注目してください。 注意: パッチにはイーサネット・スイッチ構成LAN9646含まれています。LAN9646関連の変更は無視し、HDMI統合のみを確認してください。 変更点に漏れや誤りがある場合はお知らせください。また、i.MX95-15x15-FRDMデバイスツリーを参照して、必要な修正案をご提案ください。 再開まで今しばらくお待ちください。 Re: Guidance for HDMI Bring-Up on Custom i.MX95 Board Using ADV7535 NXPチームの皆様、こんにちは。 参考資料を共有していただきありがとうございます。ADV7535ブリッジを使用して、自作のi.MX95 15x15ボードでHDMI出力を有効にするための手順を段階的に説明していただきたいです。 説明していただけますか? i.mx95-15x15-FRDMボードで使用されているi.mx95-15x15-FRDM.dtsiファイルを修正する必要があります。 imx95-19x19-evk-adv7535.dtsoを自分のカスタムハードウェアに適合させるにはどうすればよいですか? 3. 現在、私はi.mx95-15x15-frdmイメージレターを使用していますが、すべて検証済みなので、独自のカスタムマシンイメージを作成します。 各ステップごとに例のコードとコマンドを教えてください。デバイスツリー設定とYoctoの初心者です。 再開まで今しばらくお待ちください。 Re: Guidance for HDMI Bring-Up on Custom i.MX95 Board Using ADV7535 こんにちは、 残念ながら、ゼロから行う手順のステップバイガイドはありませんが、EVKベースの新しいレイヤーを使って変更を加えるのはGooアプローチです。前述の投稿を参照してください。 あなたの構成は、このブリッジを使った私たちのリファレンスデザインに合っているようですね。 よろしくお願いいたします。 Re: Guidance for HDMI Bring-Up on Custom i.MX95 Board Using ADV7535 親愛なる@JorgeCas様、 迅速なご返信ありがとうございます。 この投稿で共有されたパッチの変更点 @deepak_k確認していただけますか? EVKボードのADV7535 HDMI構成用の参照DTSOファイルを使用することで、同様のアプローチを採用しています。 実装を確認して、正しく動作させるために必要な追加設定や変更がないか教えていただけますか? ご意見をお聞かせいただければ幸いです。 よろしくお願いします、 アサドゥラ
View full article
EIS 电池管理系统参考软件源代码 为了评估和开发 EIS 电池管理系统,我们购买了一块带有 BCC 7426 (EVBMA7X2YDT1) 的评估板。 问题是,我在 NXP 软件包管理器上找到的唯一参考软件是预编译的“SW32K358_EIS_BMU_SW_3.0_CD01_D2605”,需要与“SW32K358_EIS_GUI_SW_3.0_CD01_D2605”结合使用。 版本文档解释了如何使用 GUI 将 S32K358_EIS_BMU 板烧录到提供的 .elf 文件中。是否可以下载参考软件源代码,以便在兼容的开发板(RD-BESSK358BMU)上使用 GUI?该开发板的布局与参考软件基本相同(K358 芯片,MC33665A 芯片,2 个 TPL 端口,调试接口),但 SPI 和 UART 的引脚排列不同。很奇怪,它竟然从一个板换到了另一个板上。 谢谢! Re: EIS BMS reference software source code 嗨gferretts 当前发布的版本 SW32K358_EIS_BMU_SW_3.0_CD01_D2605该软件包主要提供预编译的 BMU 固件以及相应的 EIS GUI。 根据现有版本内容,BMU 参考软件没有任何可公开下载的完整源代码。
View full article
ASA緊急警報処理およびオーディオソース切り替え 主な質問は、Bluetooth/CarPlay/Android 車載経由でSpotifyやFMラジオ局など、他のメディアソースが稼働している間にDABから緊急警報が届いた際の車載の挙動に関するものです。   具体的には、以下の点について技術的なご説明をいただければ幸いです。   自動ソース切り替え:ユーザーがFMラジオやSpotifyを聴いている間にDABでASA緊急警報が受信された場合、システムはどのようにして自動的にDAB緊急アナウンスに切り替わり、関連するアラート情報を表示するのでしょうか?   システム責任:この動作の原因はどのコンポーネントにあるのでしょうか?アラートの検出やトリガーはASAチップ自体が処理しているのか、それともDABレシーバやヘッドユニットが、現在アクティブなメディアソースを中断してDABオーディオにスイッチできる制御インターフェースが必要なのでしょうか?   車載統合:DABレシーバはオーディオソースと表示を直接制御するのか、それとも車載のインフォテインメントシステムにアラート通知やトリガー信号を送り、その後ソース切り替えを行いアラートを表示するのか?   規格と実装:関連するASA/DAB標準はこの挙動やレシーバと車載インフォテインメントシステム間の必要なインターフェースを定義しているのか、それともこれらの実装の詳細はレシーバメーカーや車載OEMに委ねられているのか?   技術的要件:緊急警報が現在アクティブなメディアソースを上書きできるようにするために、特定のハードウェアインターフェース、ソフトウェアAPI、制御信号、またはインフォテインメント統合の要件はありますか?   私たちの目的は、この機能が主にASAレシーバ/デコーダーによって提供されているのか、それとも車載のインフォテインメントシステムとの追加統合が必要なのかを理解することです。   関連する技術ドキュメント、システムアーキテクチャ図、実装ガイドラインなどがあれば大変ありがたいです。 Re: ASA Emergency Alert Handling and Audio Source Switching こんにちは、osmanistlink10さん NXP製品にご関心いただきありがとうございます。 質問の際、NXPの製品部品番号は何ですか?
View full article
MX8MP ENET 电压 你好, 我们正在从 MX8X 控制器迁移到 MX8MP 控制器。在旧版本中,ENET0 和 ENET1 支持 1.8V、2.5V、3.3V 电压(RMII 支持所有三种电压,RGMII 仅支持前两种电压)。 MX8MP 取消了 2.5V 选项,但允许选择 1.8V 和 3.3V。绝对最大电压为 3.8V。问题是,当 NVCC_ENET 工作电压为 2.5V 时会发生什么?2.5 不会超过绝对最大值。但是 MAC 信号是如何配置的?长期 2.5V 工作电压会产生什么样的影响? 我这么问是因为最好不要更新目前电源和VDDIO都为2.5V的旧PHY。 谢谢! Mike 通信与控制(I3C | I2C | SPI | FlexCAN | 以太网 | FlexIO) Re: MX8MP ENET voltage 谢谢你,豪尔赫。很喜欢你的头像。 🙂 Re: MX8MP ENET voltage 你好, 正如文档中所述,该接口仅支持两种电压等级,即 1.8 V 和 3.3 V。即使 2.5 V 在整体工作电压范围内,2.5 V 信号也可能不符合有效逻辑电平的规定阈值,这可能会导致不可预测的行为。 我建议此接口使用 1.8V 或 3.3V 电压。 顺祝商祺!
View full article
MX8MP ENET voltage Hello, We are migrating from an MX8X controller to MX8MP. In the older one, ENET0 and ENET1 supported voltage 1.8V, 2.5V, 3.3V (RMII all three, RGMII first two only). MX8MP removes the 2.5V option, but allows 1.8V and 3.3V choices. Absolute Vmax is 3.8V. The question is, what happens in a 2.5V operation on NVCC_ENET? 2.5 will not exceed the absolute max. But how are the MAC signals configured and what kind of impact would 2.5V operation have long term? I ask because it would be great to avoid updating the older PHY that is currently running both its supply and VDDIO on 2.5V. Thank you, Mike Communication & Control(I3C | I2C | SPI | FlexCAN | Ethernet | FlexIO) Re: MX8MP ENET voltage Thank you, Jorge. Love the avatar.  🙂 Re: MX8MP ENET voltage Hello, As mentioned in the documentation, the interface supports only two voltage levels, 1.8 V and 3.3 V. Even if 2.5 V is within the overall operating voltage range, 2.5 V signals may not meet the specified thresholds for valid logic levels, which could result in unpredictable behavior. I recommend using either 1.8 V or 3.3 V for this interface. Best regards.
View full article
S32K116 无法进入 STOP1 或 VLPS 模式,但 STOP2 模式可以正常工作。 你好, 为了节省电池电量,我的项目需要将 S32K116 置于睡眠模式。我使用的是 S32DS 3.6.1 和 SDK PlatformSDK_S32K1_S32M24,gcc 版本为 10.2。由于我不熟悉低功耗功能,所以我使用评估板 S32K116EVB-QSG 构建了一个小型测试项目。 我使用 Lptmr 作为唤醒源,它使用 LPO 1kHz 时钟。 在进入无限循环之前,蓝色 LED 会切换状态,以便区分 RESET 和唤醒。一旦进入循环,计数器就会增加,因此在进入睡眠模式之前,红色 LED 会闪烁 6 次。在睡眠模式下,Lptmr 超时后会唤醒 S32K116,Lptmr 中断处理程序会切换绿色 LED,以便我可以看到它正在被唤醒。 现在,这对于 STOP2 模式来说是可以正常工作的,但对于 STOP1 或 VLPS 模式则不行。出于沮丧,我禁用了所有能找到的时钟的监测,但这并没有什么效果。 对于 STOP1 和 VLPS,当 RESET 时,Power_Ip_GetResetRawValue() 返回 0x2000,表示停止确认错误 (SACKERR)。 我在互联网上找不到合适的应用程序/代码片段,所以我在这里分享我的问题,希望有人能帮我指出我遗漏了什么,例如,为什么当我要求控制器进入 STOP1 或 VLPS 时,控制器会 RESET。 我查阅了应用笔记 AN5425,但就我的观点而言,它并没有提供非常实用的建议。 我的代码: /*================================================================================================== * 项目:RTD AUTOSAR 4.7 * 平台:CORTEXM * 外设:S32K14X * 依赖项:无 * * Autosar版本:4.7.0 * Autosar版本:ASR_REL_4_7_REV_0000 * Autosar配置变体: 软件版本:3.0.0 * 构建版本:S32K1_RTD_3_0_0_QLP02_D2505_ASR_REL_4_7_REV_0000_20250530 * * 版权所有 2020-2025 NXP * * NXP 机密专有信息。本软件由恩智浦半导体(NXP)拥有或控制,且仅可由其授权使用。 * 严格按照适用的许可条款使用。明确地 * 接受此类条款或通过下载、安装、激活和/或以其他方式 使用本软件即表示您已阅读并同意以下条款: * 遵守并受此类许可条款的约束。如果您不同意, * 如果受适用许可条款的约束,则您不得保留、安装、 * 激活或以其他方式使用该软件。 =============================================================================================================*/ /** * @file main.c * * @addtogroup main_module 主模块文档 * @{ */ /* 包括必要的配置文件。*/ #include #include #include #include #include #include #include 枚举 { MODE_RUN = 0, MODE_VLPS , MODE_STOP1 , 模式停止2 }; bool wake_up = false; // 原型 void lptmr0_irq_handler ( void ); void power_mode_report_errors_callback ( Power_Ip_ReportErrorType Error, uint8 ErrorCode); void TestDelay ( uint32 delay) { 静态易失性uint32延迟定时器 = 0; while (DelayTimer { DelayTimer++; } 延迟定时器=0; } int main ( void ) { uint8_t wait_cnt = 0; Power_Ip_Init(&Power_Ip_HwIPsConfigPB); volatile Power_Ip_RawResetType reason = Power_Ip_GetResetRawValue(); Clock_Ip_Init(&Clock_Ip_aClockConfig[0]); Port_Ci_Port_Ip_Init( NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals); Lptmr_Gpt_Ip_Init(0, &LPTMR_0_InitConfig_PB); Power_Ip_InstallNotificationsCallback(power_mode_report_errors_callback); IntCtrl_Ip_Init(&IntCtrlConfig_0); IntCtrl_Ip_InstallHandler( LPTMR0_IRQn , lptmr0_irq_handler, NULL); // 安装 IRQ 处理程序 IntCtrl_Ip_EnableIrq( LPTMR0_IRQn ); // 启用相关 IRQ Power_Ip_SetMode (&Power_Ip_aModeConfigPB[ MODE_RUN ]); // 发出冷启动信号 Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 1U); 测试延迟(2000000/5); Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 0U); 为了(;;) { Gpio_Dio_Ip_TogglePins(RED_LED_ID_PORT, 1 < RED_LED_ID_PIN); 测试延迟(1000000/5); 如果(++wait_cnt > 10) { wait_cnt = 0; // 禁用时钟监测 Clock_Ip_DisableClockMonitor( FIRC_CLK ); Clock_Ip_DisableClockMonitor( FIRC_VLP_CLK ); Clock_Ip_DisableClockMonitor( FIRC_STOP_CLK ); Clock_Ip_DisableClockMonitor( FIRCDIV1_CLK ); Clock_Ip_DisableClockMonitor( FIRCDIV2_CLK ); Clock_Ip_DisableClockMonitor( SIRC_CLK ); Clock_Ip_DisableClockMonitor( SIRC_VLP_CLK ); Clock_Ip_DisableClockMonitor( SIRC_STOP_CLK ); Clock_Ip_DisableClockMonitor( SIRCDIV1_CLK ); Clock_Ip_DisableClockMonitor( SIRCDIV2_CLK ); Clock_Ip_DisableClockMonitor( LPO_128K_CLK ); Clock_Ip_DisableClockMonitor( LPO_32K_CLK ); Clock_Ip_DisableClockMonitor( LPO_1K_CLK ); Clock_Ip_DisableClockMonitor( SCS_CLK ); Clock_Ip_DisableClockMonitor( ADC0_CLK ); Clock_Ip_DisableClockMonitor( BUS_CLK ); Clock_Ip_DisableClockMonitor( BUS_RUN_CLK ); Clock_Ip_DisableClockMonitor( BUS_VLPR_CLK ); Clock_Ip_DisableClockMonitor( CLKOUT0_CLK ); Clock_Ip_DisableClockMonitor( CMP0_CLK ); Clock_Ip_DisableClockMonitor( CMU0_CLK ); Clock_Ip_DisableClockMonitor( CMU1_CLK ); Clock_Ip_DisableClockMonitor( CORE_CLK ); Clock_Ip_DisableClockMonitor( CORE_RUN_CLK ); Clock_Ip_DisableClockMonitor( CORE_VLPR_CLK ); Clock_Ip_DisableClockMonitor( CRC0_CLK ); Clock_Ip_DisableClockMonitor( DMA0_CLK ); Clock_Ip_DisableClockMonitor( DMAMUX0_CLK ); Clock_Ip_DisableClockMonitor( EIM0_CLK ); Clock_Ip_DisableClockMonitor( ERM0_CLK ); Clock_Ip_DisableClockMonitor( FIRC_MON1_CLK ); Clock_Ip_DisableClockMonitor( FIRC_MON2_CLK ); Clock_Ip_DisableClockMonitor( FLEXCAN0_CLK ); Clock_Ip_DisableClockMonitor( FTFC_CLK ); Clock_Ip_DisableClockMonitor( FTM0_CLK ); Clock_Ip_DisableClockMonitor( FTM0_EXT_CLK ); Clock_Ip_DisableClockMonitor( FTM1_CLK ); Clock_Ip_DisableClockMonitor( FTM1_EXT_CLK ); Clock_Ip_DisableClockMonitor( FlexIO_CLK ); Clock_Ip_DisableClockMonitor( GPIO0_CLK ); Clock_Ip_DisableClockMonitor( LPI2C0_CLK ); Clock_Ip_DisableClockMonitor( LPIT0_CLK ); Clock_Ip_DisableClockMonitor( LPO_CLK ); Clock_Ip_DisableClockMonitor( LPSPI0_CLK ); Clock_Ip_DisableClockMonitor( LPTMR0_CLK ); Clock_Ip_DisableClockMonitor( LPUART0_CLK ); Clock_Ip_DisableClockMonitor( LPUART1_CLK ); Clock_Ip_DisableClockMonitor( MPU0_CLK ); Clock_Ip_DisableClockMonitor( MSCM0_CLK ); Clock_Ip_DisableClockMonitor( PDB0_CLK ); Clock_Ip_DisableClockMonitor( PORTA_CLK ); Clock_Ip_DisableClockMonitor( PORTB_CLK ); Clock_Ip_DisableClockMonitor( PORTC_CLK ); Clock_Ip_DisableClockMonitor( PORTD_CLK ); Clock_Ip_DisableClockMonitor( PORTE_CLK ); Clock_Ip_DisableClockMonitor( RTC0_CLK ); Clock_Ip_DisableClockMonitor( RTC_CLK ); Clock_Ip_DisableClockMonitor( RUN_BUS_CLK ); Clock_Ip_DisableClockMonitor( RUN_CORE_CLK ); Clock_Ip_DisableClockMonitor( RUN_FLASH_CLK ); Clock_Ip_DisableClockMonitor( RUN_PRI_DIV_SYS_CLK ); Clock_Ip_DisableClockMonitor( RUN_SYS_CLK ); Clock_Ip_DisableClockMonitor( SCG_CLKOUT_CLK ); Clock_Ip_DisableClockMonitor( SCS_RUN_CLK ); Clock_Ip_DisableClockMonitor( SCS_VLPR_CLK ); Clock_Ip_DisableClockMonitor( SLOW_CLK ); Clock_Ip_DisableClockMonitor( SLOW_RUN_CLK ); Clock_Ip_DisableClockMonitor( SLOW_VLPR_CLK ); Clock_Ip_DisableClockMonitor( THE_LAST_PRODUCER_CLK ); Clock_Ip_DisableClockMonitor( VLPR_BUS_CLK ); Clock_Ip_DisableClockMonitor( VLPR_CORE_CLK ); Clock_Ip_DisableClockMonitor( VLPR_FLASH_CLK ); Clock_Ip_DisableClockMonitor( VLPR_PRI_DIV_SYS_CLK ); Clock_Ip_DisableClockMonitor( VLPR_SYS_CLK ); // 启用定时器中断请求并启动唤醒定时器 Lptmr_Gpt_Ip_EnableInterrupt(0); Lptmr_Gpt_Ip_StartTimer(0, 5000); // 1. 禁用系统滴答(或任何周期性中断) S32_SysTick-> CSRr &= ~S32_SysTick_CSR_ENABLE_MASK; // 2. 使用 FIRC/SOSC/SPLL 禁用/取消初始化外设 //(如果不使用 PNET,则使用 LPUART、ADC、FlexCAN 等) 3. 清除所有待处理的中断标志 (尤其是 LPTMR、PORT 等) IntCtrl_Ip_ClearPending( LPTMR0_IRQn ); // 4. 进入睡眠模式 //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_VLPS]); Power_Ip_SetMode (&Power_Ip_aModeConfigPB[ MODE_STOP1 ]); //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_STOP2]); // --- MCU 在此处唤醒 --- // 5. 检查是否发生中止 如果((IP_SMC-> PMCTRL >> 3U) & 0x1U) { /* 处理中止 */ __asm ( "NOP" ); } // 6. 重新启用系统时钟和外设 S32_SysTick-> CSRr |= S32_SysTick_CSR_ENABLE_MASK; } } } void lptmr0_irq_handler ( void ) { IntCtrl_Ip_ClearPending( LPTMR0_IRQn ); Lptmr_Gpt_Ip_StopTimer(0); 唤醒 = true; Gpio_Dio_Ip_TogglePins(GREEN_LED_ID_PORT, 1 < GREEN_LED_ID_PIN); } void power_mode_report_errors_callback ( Power_Ip_ReportErrorType Error, uint8 ErrorCode) { volatile Power_Ip_ResetType reset_type; reset_type = Power_Ip_GetResetReason(); __asm ( "NOP" ); } /** @} */ Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work 你好@fruit_spinner 巧合的是,几周前我也遇到了完全相同的问题。 我发现根本原因是 S32K1 上的 S32 SCT 具有 CMU 时钟门 默认启用。这会导致进入低电源模式时出现问题——具体来说,就是 触发信号复位,复位源由 SACKERR 位设置指示。 我已审阅并测试了您提供的演示版本,并提出以下建议: 变更内容: 1.在 S32 SCT 时钟配置界面中,禁用 CMU0 和 CMU1 的时钟门。 2. 删除或注释掉以下代码,因为它是不必要的。 Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work 您好, 非常感谢您的回复,这解决了我的问题。现在运行正常了。 此致, 惠布
View full article
STOP1やVLPSモードにS32K116できず、STOP2は動作します こんにちは、 私のプロジェクトでは、バッテリーの消費電力を抑えるために、S32K116をスリープモードにする必要があります。私はS32DS 3.6.1とSDK PlatformSDK_S32K1_S32M24、gccバージョン10.2を使っています。低消費電力機能について詳しくないので、評価ボードS32K116EVB-QSGを使用して小さなテストプロジェクトを作成しました。 私はLptmrをウェイクアップソースとして使用しており、LPOの1kHzクロックを使用しています。 終わりのないforループに入る前に青いLEDが切り替えられ、リセットとウェイクアップを区別します。ループに入るとカウンターが増え、赤いLEDが6回点滅してからスリープモードに入ります。スリープモード中はLptmrが経過し、S32K116を起動させ、Lptmr割り込みハンドラが緑色のLEDを切り替えて起動しているのを確認します。 これはSTOP2モードでは期待どおりに動作しますが、STOP1モードやVLPSモードでは動作しません。イライラして、見つけた限りすべてのクロックのクロックモニターを無効にしましたが、効果はありません。 STOP1とVLPSの場合、リセット時にPower_Ip_GetResetRawValue()は0x2000を返します。これは停止確認エラー(SACKERR)を示します。 インターネット上で適切なアプリケーションやスニペットが見つからなかったので、ここで問題を共有します。誰かが私が見落としている点、つまりSTOP1やVLPSに切り替えようと要求するとコントローラがリセットされる理由を教えてもらえればと思います。 アプリケーションノートAN5425を参照しましたが、私の意見にあまり実用的なヒントは与えられていません。 以下にコードを示します。 /*================================================================================================== * プロジェクト:RTD AUTOSAR 4.7 * プラットフォーム:CORTEXM * ペリフェラル:S32K14X * 依存関係:なし * * Autosar バージョン:4.7.0 * Autosar リビジョン:ASR_REL_4_7_REV_0000 * AUTOSAR 会議バリアント: * ソフトウェアバージョン:3.0.0 * ビルドバージョン:S32K1_RTD_3_0_0_QLP02_D2505_ASR_REL_4_7_REV_0000_20250530 * * 著作権 2020-2025 NXP * * NXPの機密情報および専有情報。このソフトウェアはNXPが所有または管理しており、以下の通りに *適用されるライセンス条項に厳密に従って使用してください。明示的に * 当該条件に同意するか、ダウンロード、インストール、アクティベート、および/またはその他 * ソフトウェアを使用することで、あなたは読んだこと、そして同意したことになります * 当該ライセンス条項を遵守し、それに拘束される。もしあなたが同意しない場合 * 該当するライセンス条項に拘束される場合、保持、インストール、 * ソフトウェアを有効化または使用してください。 == /** * @file main.c * * @addtogroup main_module メインモジュールドキュメント * @{ */ /* 必要な設定ファイルを含めます。*/ #include #include #include #include #include #include #include 列挙型 { MODE_RUN = 0、 MODE_VLPS 、 MODE_STOP1 、 モード停止2 }; bool wake_up = false; // プロトタイプ void lptmr0_irq_handler ( void ); void power_mode_report_errors_callback ( Power_Ip_ReportErrorType Error, uint8 ErrorCode); void TestDelay ( uint32 delay) { 静的揮発性uint32 DelayTimer = 0; while (DelayTimer < delay) { DelayTimer++; } 遅延タイマー=0; } int main ( void ) { uint8_t wait_cnt = 0; Power_Ip_Init(&Power_Ip_HwIPsConfigPB); volatile Power_Ip_RawResetType reason = Power_Ip_GetResetRawValue(); Clock_Ip_Init(&Clock_Ip_aClockConfig[0]); Port_Ci_Port_Ip_Init( NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals); Lptmr_Gpt_Ip_Init(0, &LPTMR_0_InitConfig_PB); Power_Ip_InstallNotificationsCallback(power_mode_report_errors_callback); IntCtrl_Ip_Init(&IntCtrlConfig_0); IntCtrl_Ip_InstallHandler( LPTMR0_IRQn , lptmr0_irq_handler, NULL); // IRQハンドラをインストールします IntCtrl_Ip_EnableIrq( LPTMR0_IRQn ); // 関係するIRQを有効にする Power_Ip_SetMode (&Power_Ip_aModeConfigPB[ MODE_RUN ]); // コールドスタートの合図 Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 1U); テスト遅延(2000000/5); Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 0U); のために(;;) { Gpio_Dio_Ip_TogglePins(RED_LED_ID_PORT, 1 < RED_LED_ID_PIN); テスト遅延(1000000/5); if (++wait_cnt > 10) { wait_cnt = 0; // 時計モニターを無効にする Clock_Ip_DisableClockMonitor( FIRC_CLK ); Clock_Ip_DisableClockMonitor( FIRC_VLP_CLK ); Clock_Ip_DisableClockMonitor( FIRC_STOP_CLK ); Clock_Ip_DisableClockMonitor( FIRCDIV1_CLK ); Clock_Ip_DisableClockMonitor( FIRCDIV2_CLK ); Clock_Ip_DisableClockMonitor( SIRC_CLK ); Clock_Ip_DisableClockMonitor( SIRC_VLP_CLK ); Clock_Ip_DisableClockMonitor( SIRC_STOP_CLK ); Clock_Ip_DisableClockMonitor( SIRCDIV1_CLK ); Clock_Ip_DisableClockMonitor( SIRCDIV2_CLK ); Clock_Ip_DisableClockMonitor( LPO_128K_CLK ); Clock_Ip_DisableClockMonitor( LPO_32K_CLK ); Clock_Ip_DisableClockMonitor( LPO_1K_CLK ); Clock_Ip_DisableClockMonitor( SCS_CLK ); Clock_Ip_DisableClockMonitor( ADC0_CLK ); Clock_Ip_DisableClockMonitor( BUS_CLK ); Clock_Ip_DisableClockMonitor( BUS_RUN_CLK ); Clock_Ip_DisableClockMonitor( BUS_VLPR_CLK ); Clock_Ip_DisableClockMonitor( CLKOUT0_CLK ); Clock_Ip_DisableClockMonitor( CMP0_CLK ); Clock_Ip_DisableClockMonitor( CMU0_CLK ); Clock_Ip_DisableClockMonitor( CMU1_CLK ); Clock_Ip_DisableClockMonitor( CORE_CLK ); Clock_Ip_DisableClockMonitor( CORE_RUN_CLK ); Clock_Ip_DisableClockMonitor( CORE_VLPR_CLK ); Clock_Ip_DisableClockMonitor( CRC0_CLK ); Clock_Ip_DisableClockMonitor( DMA0_CLK ); Clock_Ip_DisableClockMonitor( DMAMUX0_CLK ); Clock_Ip_DisableClockMonitor( EIM0_CLK ); Clock_Ip_DisableClockMonitor( ERM0_CLK ); Clock_Ip_DisableClockMonitor( FIRC_MON1_CLK ); Clock_Ip_DisableClockMonitor( FIRC_MON2_CLK ); Clock_Ip_DisableClockMonitor( FLEXCAN0_CLK ); Clock_Ip_DisableClockMonitor( FTFC_CLK ); Clock_Ip_DisableClockMonitor( FTM0_CLK ); Clock_Ip_DisableClockMonitor( FTM0_EXT_CLK ); Clock_Ip_DisableClockMonitor( FTM1_CLK ); Clock_Ip_DisableClockMonitor( FTM1_EXT_CLK ); Clock_Ip_DisableClockMonitor( FlexIO_CLK ); Clock_Ip_DisableClockMonitor( GPIO0_CLK ); Clock_Ip_DisableClockMonitor( LPI2C0_CLK ); Clock_Ip_DisableClockMonitor( LPIT0_CLK ); Clock_Ip_DisableClockMonitor( LPO_CLK ); Clock_Ip_DisableClockMonitor( LPSPI0_CLK ); Clock_Ip_DisableClockMonitor( LPTMR0_CLK ); Clock_Ip_DisableClockMonitor( LPUART0_CLK ); Clock_Ip_DisableClockMonitor( LPUART1_CLK ); Clock_Ip_DisableClockMonitor( MPU0_CLK ); Clock_Ip_DisableClockMonitor( MSCM0_CLK ); Clock_Ip_DisableClockMonitor( PDB0_CLK ); Clock_Ip_DisableClockMonitor( PORTA_CLK ); Clock_Ip_DisableClockMonitor( PORTB_CLK ); Clock_Ip_DisableClockMonitor( PORTC_CLK ); Clock_Ip_DisableClockMonitor( PORTD_CLK ); Clock_Ip_DisableClockMonitor( PORTE_CLK ); Clock_Ip_DisableClockMonitor( RTC0_CLK ); Clock_Ip_DisableClockMonitor( RTC_CLK ); Clock_Ip_DisableClockMonitor( RUN_BUS_CLK ); Clock_Ip_DisableClockMonitor( RUN_CORE_CLK ); Clock_Ip_DisableClockMonitor( RUN_FLASH_CLK ); Clock_Ip_DisableClockMonitor( RUN_PRI_DIV_SYS_CLK ); Clock_Ip_DisableClockMonitor( RUN_SYS_CLK ); Clock_Ip_DisableClockMonitor( SCG_CLKOUT_CLK ); Clock_Ip_DisableClockMonitor( SCS_RUN_CLK ); Clock_Ip_DisableClockMonitor( SCS_VLPR_CLK ); Clock_Ip_DisableClockMonitor( SLOW_CLK ); Clock_Ip_DisableClockMonitor( SLOW_RUN_CLK ); Clock_Ip_DisableClockMonitor( SLOW_VLPR_CLK ); Clock_Ip_DisableClockMonitor( THE_LAST_PRODUCER_CLK ); Clock_Ip_DisableClockMonitor( VLPR_BUS_CLK ); Clock_Ip_DisableClockMonitor( VLPR_CORE_CLK ); Clock_Ip_DisableClockMonitor( VLPR_FLASH_CLK ); Clock_Ip_DisableClockMonitor( VLPR_PRI_DIV_SYS_CLK ); Clock_Ip_DisableClockMonitor( VLPR_SYS_CLK ); // タイマーIRQを有効にしてウェイクアップタイマーを起動する Lptmr_Gpt_Ip_EnableInterrupt(0); Lptmr_Gpt_Ip_StartTimer(0, 5000); // 1. SysTick(またはその他の定期的な割り込み)を無効にする S32_SysTick-> CSRr &= ~S32_SysTick_CSR_ENABLE_MASK; // 2.FIRC/SOSC/SPLL を用いた無効化/非init化ペリフェラル // (LPUART、ADC、PNETを使用しない場合はFlexCANなど) // 3. 保留中の割り込みフラグをすべてクリアする // (特に LPTMR、PORT など) IntCtrl_Ip_ClearPending( LPTMR0_IRQn ); // 4. スリープモードに入る //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_VLPS]); Power_Ip_SetMode (&Power_Ip_aModeConfigPB[ MODE_STOP1 ]); //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_STOP2]); ---MCUはここで目覚めます--- // 5. 異常終了が発生したかどうかを確認する if ((IP_SMC-> PMCTRL >> 3U) & 0x1U) { /* 中止処理 */ __asm ( "NOP" ); } // 6.SysTickおよびペリフェラルの再有効化 S32_SysTick-> CSRr |= S32_SysTick_CSR_ENABLE_MASK; } } } void lptmr0_irq_handler ( void ) { IntCtrl_Ip_ClearPending( LPTMR0_IRQn ); Lptmr_Gpt_Ip_StopTimer(0); wake_up = true; Gpio_Dio_Ip_TogglePins(GREEN_LED_ID_PORT, 1 } void power_mode_report_errors_callback ( Power_Ip_ReportErrorType Error, uint8 ErrorCode) { volatile Power_Ip_ResetType reset_type; reset_type = Power_Ip_GetResetReason(); __asm ( "NOP" ); } /** @} */ Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work こんにちは、@fruit_spinner 実は私も数週間前に全く同じ問題に遭遇しました。 根本原因は、S32K1のS32 SCTにCMUクロックゲートが搭載されていることだと判明しました。 デフォルトで有効になっています。これは低電力モードに入るときに問題を引き起こします。具体的には、 リセットがトリガーされ、リセット元はSACKERRビットがセットされることで示されます。 ご提供いただいたデモをレビューおよびテストした結果、以下の点をご提案いたします。 変更点: 1.S32 SCTクロック設定インターフェースでは、CMU0およびCMU1のクロックゲートを無効にします。 2. 以下のコードは不要なので、削除またはコメントアウトしてください。 Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work こんにちは、 ご回答いただきありがとうございました。おかげで問題が解決しました。今は期待通りに動作しています。 よろしくお願いいたします フイブ
View full article
MX8MP ENET電圧 こんにちは、 MX8XコントローラーからMX8MPに移行しています。旧型では、ENET0とENET1は1.8V、2.5V、3.3Vの電圧をサポートしていました(RMIIは3つすべて、RGMIIは最初の2つのみ)。 MX8MPでは2.5Vのオプションは削除されましたが、1.8Vと3.3Vの選択肢は残されています。絶対最大電圧は3.8Vです。問題は、NVCC_ENETが2.5Vで動作する場合、何が起こるかということです。2.5は絶対最大値を超えません。しかし、MAC信号はどのように構成されているのか、また2.5V動作は長期的にどのような影響を与えるのか? 私が質問したのは、現在電源とVDDIOの両方が2.5Vで動作している古いPHYをアップデートせずに済むと非常に助かるからです。 ありがとうございました。 Mike 通信・制御(I3C |I2C |SPI |FlexCAN |イーサネット |FlexIO) Re: MX8MP ENET voltage ありがとう、ホルヘ。アバターが気に入りました。 🙂 Re: MX8MP ENET voltage こんにちは、 ドキュメントに記載されているように、インターフェースは1.8Vと3.3Vの2つの電圧レベルのみをサポートしています。たとえ2.5Vが全体の動作電圧範囲内であっても、2.5V信号は有効な論理レベルの指定閾値を満たさず、予測不能な挙動を引き起こす可能性があります。 このインターフェースには1.8Vか3.3Vの使用をおすすめします。 よろしくお願いいたします。
View full article
Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work Hello, For my project I need to put the S32K116 into sleep mode in order to save power on the battery. I am using S32DS 3.6.1 and SDK PlatformSDK_S32K1_S32M24, gcc version 10.2. Since I'm not familiar with the low power functionality I've built a small test project using eval board S32K116EVB-QSG. I am using the Lptmr as a wake-up source and it is using the LPO 1kHz clock. Before entering a endless for loop the blue LED is toggled so I distinguish a reset from a wake-up. Once in the loop a counter is increased so we get 6 blinks of the red LED before entering sleep mode. During sleep mode the Lptmr will elapse and wake-up the S32K116, the Lptmr interrupt handler will toggle the green LED so I can see it is being woken up. Now this works as expected for STOP2 mode but not for STOP1 nor for VLPS. Out of frustration I disable clock monitor for all clocks I could find but this makes no difference. For STOP1 and VLPS, when it is resetting Power_Ip_GetResetRawValue() returns 0x2000 which indicates Stop Acknowledge Error (SACKERR). I could not find a suitable application/snippet on the internet so I am sharing my problem here hoping someone can shine a light what I am missing i.e. why the controller resets when I am demanding it to goto STOP1 or VLPS. I consulted application note AN5425 but this does not give very practical hints to my opinion. My code: /*================================================================================================== * Project : RTD AUTOSAR 4.7 * Platform : CORTEXM * Peripheral : S32K14X * Dependencies : none * * Autosar Version : 4.7.0 * Autosar Revision : ASR_REL_4_7_REV_0000 * Autosar Conf.Variant : * SW Version : 3.0.0 * Build Version : S32K1_RTD_3_0_0_QLP02_D2505_ASR_REL_4_7_REV_0000_20250530 * * Copyright 2020-2025 NXP * * NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be * used strictly in accordance with the applicable license terms. By expressly * accepting such terms or by downloading, installing, activating and/or otherwise * using the software, you are agreeing that you have read, and that you agree to * comply with and are bound by, such license terms. If you do not agree to be * bound by the applicable license terms, then you may not retain, install, * activate or otherwise use the software. ==================================================================================================*/ /** * @file main.c * * @addtogroup main_module main module documentation * @{ */ /* Including necessary configuration files. */ #include #include #include #include #include #include #include enum { MODE_RUN = 0, MODE_VLPS, MODE_STOP1, MODE_STOP2 }; bool wake_up = false; // Proto-types void lptmr0_irq_handler(void); void power_mode_report_errors_callback(Power_Ip_ReportErrorType Error, uint8 ErrorCode); void TestDelay(uint32 delay) { static volatile uint32 DelayTimer = 0; while(DelayTimer { DelayTimer++; } DelayTimer=0; } int main(void) { uint8_t wait_cnt = 0; Power_Ip_Init(&Power_Ip_HwIPsConfigPB); volatile Power_Ip_RawResetType reason = Power_Ip_GetResetRawValue(); Clock_Ip_Init(&Clock_Ip_aClockConfig[0]); Port_Ci_Port_Ip_Init( NUM_OF_CONFIGURED_PINS_PortContainer_0_BOARD_InitPeripherals, g_pin_mux_InitConfigArr_PortContainer_0_BOARD_InitPeripherals); Lptmr_Gpt_Ip_Init(0, &LPTMR_0_InitConfig_PB); Power_Ip_InstallNotificationsCallback(power_mode_report_errors_callback); IntCtrl_Ip_Init(&IntCtrlConfig_0); IntCtrl_Ip_InstallHandler(LPTMR0_IRQn, lptmr0_irq_handler, NULL); // Install IRQ handlers IntCtrl_Ip_EnableIrq(LPTMR0_IRQn); // Enable IRQ's involved Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_RUN]); // Signal a cold start Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 1U); TestDelay(2000000/5); Gpio_Dio_Ip_WritePin(BLUE_LED_ID_PORT, BLUE_LED_ID_PIN, 0U); for(;;) { Gpio_Dio_Ip_TogglePins(RED_LED_ID_PORT, 1 << RED_LED_ID_PIN); TestDelay(1000000/5); if(++wait_cnt > 10) { wait_cnt = 0; // Disable clock monitors Clock_Ip_DisableClockMonitor(FIRC_CLK); Clock_Ip_DisableClockMonitor(FIRC_VLP_CLK); Clock_Ip_DisableClockMonitor(FIRC_STOP_CLK); Clock_Ip_DisableClockMonitor(FIRCDIV1_CLK); Clock_Ip_DisableClockMonitor(FIRCDIV2_CLK); Clock_Ip_DisableClockMonitor(SIRC_CLK); Clock_Ip_DisableClockMonitor(SIRC_VLP_CLK); Clock_Ip_DisableClockMonitor(SIRC_STOP_CLK); Clock_Ip_DisableClockMonitor(SIRCDIV1_CLK); Clock_Ip_DisableClockMonitor(SIRCDIV2_CLK); Clock_Ip_DisableClockMonitor(LPO_128K_CLK); Clock_Ip_DisableClockMonitor(LPO_32K_CLK); Clock_Ip_DisableClockMonitor(LPO_1K_CLK); Clock_Ip_DisableClockMonitor(SCS_CLK); Clock_Ip_DisableClockMonitor(ADC0_CLK); Clock_Ip_DisableClockMonitor(BUS_CLK); Clock_Ip_DisableClockMonitor(BUS_RUN_CLK); Clock_Ip_DisableClockMonitor(BUS_VLPR_CLK); Clock_Ip_DisableClockMonitor(CLKOUT0_CLK); Clock_Ip_DisableClockMonitor(CMP0_CLK); Clock_Ip_DisableClockMonitor(CMU0_CLK); Clock_Ip_DisableClockMonitor(CMU1_CLK); Clock_Ip_DisableClockMonitor(CORE_CLK); Clock_Ip_DisableClockMonitor(CORE_RUN_CLK); Clock_Ip_DisableClockMonitor(CORE_VLPR_CLK); Clock_Ip_DisableClockMonitor(CRC0_CLK); Clock_Ip_DisableClockMonitor(DMA0_CLK); Clock_Ip_DisableClockMonitor(DMAMUX0_CLK); Clock_Ip_DisableClockMonitor(EIM0_CLK); Clock_Ip_DisableClockMonitor(ERM0_CLK); Clock_Ip_DisableClockMonitor(FIRC_MON1_CLK); Clock_Ip_DisableClockMonitor(FIRC_MON2_CLK); Clock_Ip_DisableClockMonitor(FLEXCAN0_CLK); Clock_Ip_DisableClockMonitor(FTFC_CLK); Clock_Ip_DisableClockMonitor(FTM0_CLK); Clock_Ip_DisableClockMonitor(FTM0_EXT_CLK); Clock_Ip_DisableClockMonitor(FTM1_CLK); Clock_Ip_DisableClockMonitor(FTM1_EXT_CLK); Clock_Ip_DisableClockMonitor(FlexIO_CLK); Clock_Ip_DisableClockMonitor(GPIO0_CLK); Clock_Ip_DisableClockMonitor(LPI2C0_CLK); Clock_Ip_DisableClockMonitor(LPIT0_CLK); Clock_Ip_DisableClockMonitor(LPO_CLK); Clock_Ip_DisableClockMonitor(LPSPI0_CLK); Clock_Ip_DisableClockMonitor(LPTMR0_CLK); Clock_Ip_DisableClockMonitor(LPUART0_CLK); Clock_Ip_DisableClockMonitor(LPUART1_CLK); Clock_Ip_DisableClockMonitor(MPU0_CLK); Clock_Ip_DisableClockMonitor(MSCM0_CLK); Clock_Ip_DisableClockMonitor(PDB0_CLK); Clock_Ip_DisableClockMonitor(PORTA_CLK); Clock_Ip_DisableClockMonitor(PORTB_CLK); Clock_Ip_DisableClockMonitor(PORTC_CLK); Clock_Ip_DisableClockMonitor(PORTD_CLK); Clock_Ip_DisableClockMonitor(PORTE_CLK); Clock_Ip_DisableClockMonitor(RTC0_CLK); Clock_Ip_DisableClockMonitor(RTC_CLK); Clock_Ip_DisableClockMonitor(RUN_BUS_CLK); Clock_Ip_DisableClockMonitor(RUN_CORE_CLK); Clock_Ip_DisableClockMonitor(RUN_FLASH_CLK); Clock_Ip_DisableClockMonitor(RUN_PRI_DIV_SYS_CLK); Clock_Ip_DisableClockMonitor(RUN_SYS_CLK); Clock_Ip_DisableClockMonitor(SCG_CLKOUT_CLK); Clock_Ip_DisableClockMonitor(SCS_RUN_CLK); Clock_Ip_DisableClockMonitor(SCS_VLPR_CLK); Clock_Ip_DisableClockMonitor(SLOW_CLK); Clock_Ip_DisableClockMonitor(SLOW_RUN_CLK); Clock_Ip_DisableClockMonitor(SLOW_VLPR_CLK); Clock_Ip_DisableClockMonitor(THE_LAST_PRODUCER_CLK); Clock_Ip_DisableClockMonitor(VLPR_BUS_CLK); Clock_Ip_DisableClockMonitor(VLPR_CORE_CLK); Clock_Ip_DisableClockMonitor(VLPR_FLASH_CLK); Clock_Ip_DisableClockMonitor(VLPR_PRI_DIV_SYS_CLK); Clock_Ip_DisableClockMonitor(VLPR_SYS_CLK); // Enable timer IRQ and spawn wake-up timer Lptmr_Gpt_Ip_EnableInterrupt(0); Lptmr_Gpt_Ip_StartTimer(0, 5000); // 1. Disable SysTick (or any periodic interrupt) S32_SysTick->CSRr &= ~S32_SysTick_CSR_ENABLE_MASK; // 2. Disable/de-init peripherals using FIRC/SOSC/SPLL // (LPUART, ADC, FlexCAN if not using PNET, etc.) // 3. Clear any pending interrupt flags // (especially LPTMR, PORT, etc.) IntCtrl_Ip_ClearPending(LPTMR0_IRQn); // 4. Enter sleep mode //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_VLPS]); Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_STOP1]); //Power_Ip_SetMode(&Power_Ip_aModeConfigPB[MODE_STOP2]); // --- MCU wakes here --- // 5. Check if abort occurred if ((IP_SMC->PMCTRL >> 3U) & 0x1U) { /* handle abort */ __asm("NOP"); } // 6. Re-enable SysTick and peripherals S32_SysTick->CSRr |= S32_SysTick_CSR_ENABLE_MASK; } } } void lptmr0_irq_handler(void) { IntCtrl_Ip_ClearPending(LPTMR0_IRQn); Lptmr_Gpt_Ip_StopTimer(0); wake_up = true; Gpio_Dio_Ip_TogglePins(GREEN_LED_ID_PORT, 1 << GREEN_LED_ID_PIN); } void power_mode_report_errors_callback(Power_Ip_ReportErrorType Error, uint8 ErrorCode) { volatile Power_Ip_ResetType reset_type; reset_type = Power_Ip_GetResetReason(); __asm("NOP"); } /** @} */ Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work Hi@fruit_spinner As it happens, I encountered the exact same issue a few weeks ago. I discovered that the root cause was that the S32 SCT on the S32K1 has the CMU clock gate enabled by default. This causes problems when entering low-power modes—specifically, it triggers a reset, with the reset source indicated by the SACKERR bit being set. I have reviewed and tested the demo you provided, and I suggest the following modifications: 1. In the S32 SCT clock configuration interface, disable the clock gates of CMU0 and CMU1. 2. Remove or comment out the following code, as it is unnecessary. Re: Can't get S32K116 into STOP1 or VLPS mode, STOP2 does work Hi, Thanks a lot for your reply, this solved my problem. It works as expected now. regards, Huib
View full article
AB_SWAPファームウェアの初期インストール手順 HSE_B リファレンス・マニュアル (v2.7)では、ファームウェアのインストールが2つのセクションで扱われています。 - 3.2 FULL_MEM構成でのインストールプロセス - 3.3 AB_SWAP構成におけるインストールプロセス 工場出荷時のS32K3デバイスは、FULL_MEM構成になっています。これは、正しい手順がセクション3.2(FULL_MEM構成)で網羅されていることを示唆しています。 一方、インストールするファームウェアはAB_SWAPタイプです。これは、正しい一連の命令がセクション3.3(AB_SWAP構成)で網羅されていることを示唆しています。 工場出荷時の新品デバイスにAB_SWAPファームウェアをインストールするための手順は、マニュアルのどのセクションに記載されていますか? Re: Instructions for initial installation of AB_SWAP firmware こんにちは、 @FredrikMoller さん もしHSE_B Firmware リファレンス・マニュアルの3.3.1節に記載されているMUベースの方法ではなく、IVT方法でAB_SWAP構成でHSE FWをインストールするための指針をお探しの場合は、AN744810: HSE FW Install for S32K3xxを参照することをお勧めします。これは、デバイスの「セキュアファイル」セクションで利用できます。 また、「 Install HSE Firmware on S32K344 」では、FULL_MEMメモリ構成とAB_SWAPメモリ構成の両方に対してIVT方式でS32K344デバイスにHSE FWをインストールする方法を実演しています。 BR、VaneB
View full article
AB_SWAP固件初始安装说明 HSE_B 固件参考手册(v2.7)中,固件安装分为两个部分: - 3.2 FULL_MEM 配置下的安装过程 - 3.3 AB_SWAP 配置中的安装过程 出厂时,S32K3 设备将处于 FULL_MEM 配置。这表明第 3.2 节(FULL_MEM 配置)涵盖了正确的指令集。 另一方面,要安装的固件类型为 AB_SWAP。这表明第 3.3 节(AB_SWAP 配置)涵盖了正确的指令集。 手册的哪一部分包含了在刚从工厂交付的设备上安装 AB_SWAP 固件的相关说明? Re: Instructions for initial installation of AB_SWAP firmware 嗨@FredrikMoller 如果您正在寻找有关使用 IVT 方法在 AB_SWAP 配置中安装 HSE FW 的指导,而不是 HSE_B 固件参考手册第 3.3.1 节中描述的基于 MU 的方法,我建议您参考 AN744810:S32K3xx 的 HSE FW 安装。此功能位于设备的“安全文件”部分。 此外,在 S32K344 上安装 HSE 固件演示了如何使用 IVT 方法在 S32K344 设备上为 FULL_MEM 和 AB_SWAP 内存配置安装 HSE 固件。 BR,VaneB
View full article
Instructions for initial installation of AB_SWAP firmware In HSE_B Firmware Reference Manual (v2.7) installation of firmware is covered in two sections: - 3.2 Installation process in FULL_MEM configuration - 3.3 Installation process in AB_SWAP configuration With an S32K3 device delivered from factory, the device will be in FULL_MEM configuration. This suggests that the correct set of instructions are covered by section 3.2 (FULL_MEM configuration). On the other hand, the firmware to install is of type AB_SWAP. This suggests that the correct set of instruction are coverd by section 3.3 (AB_SWAP configuration). Which section in the manual contains the relevant instructions for installing AB_SWAP firmware on device freshly delivered from factory? Re: Instructions for initial installation of AB_SWAP firmware Hi @FredrikMoller  If you are looking for guidance on installing HSE FW in the AB_SWAP configuration using the IVT method, rather than the MU-based method described in Section 3.3.1 of the HSE_B Firmware Reference Manual, I recommend referring to AN744810: HSE FW Install for S32K3xx. This is available under the device's Secure Files section. Also, Install HSE Firmware on S32K344 demonstrates how to install HSE FW on an S32K344 device using the IVT method for both FULL_MEM and AB_SWAP memory configurations.  BR, VaneB
View full article
How to use the GPU of the NXP Layerscape LS1028A with Yocto How to use the GPU of the NXP Layerscape LS1028A with Yocto  Yocto Project Configuration The most modern and NXP-recommended method for developing with the LS1028A is the Layerscape Linux Distribution POC (LLDP) based on Yocto. Unlike the LSDK (which uses Flexbuild), LLDP uses Yocto/Bitbake and is the long-term supported path. 1 Host Requirements Requirement Details Operating System Ubuntu 20.04 LTS (Focal) — official recommendation RAM Minimum 8 GB (16 GB+ recommended) Disk Space Minimum 100 GB free CPU Minimum 4 cores (more cores = faster builds) Tools git, repo, python3, wget, curl, build-essential Install dependencies on Ubuntu: sudo apt-get update && sudo apt-get install -y  gawk wget git diffstat unzip texinfo gcc-multilib \   build-essential chrpath socat cpio python3 python3-pip  python3-pexpect xz-utils debianutils iputils-ping \   python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev  pylint xterm rsync curl locales zstd liblz4-tool \   repo ca-certificates # Configure git (required by repo) git config --global user.name "Your Name" git config --global user.email "[email protected]" 2 Download the LLDP Repository (Yocto for LS1028A) # Create working directory mkdir ~/lldp-ls1028a && cd ~/lldp-ls1028a # Initialize repo with the LLDP manifest (Kirkstone, kernel 5.15) repo init -u https://github.com/nxp-qoriq/yocto-sdk.git \           -b kirkstone \           -m ls-5.15.71-2.2.0_distro.xml # Sync all repositories (may tak             e 30-60 minutes) repo sync Note: For the latest version (LLDP L6.1.1, kernel 6.1), check the updated manifest at: https://github.com/nxp-qoriq/yocto-sdk 3 Set Up the Build Environment for LS1028A # Initialize Yocto environment for the LS1028A # (run from the lldp-ls1028a/ directory) DISTRO=fsl-qoriq-distro MACHINE=ls1028ardb source distro-setup-env # This automatically creates and enters the build directory # You are now in: ~/lldp-ls1028a/build_ls1028ardb/ 4 local.conf File — GPU Configuration The conf/local.conf file inside the build directory controls compilation options. For the LS1028A with GPU, verify or add: # Edit the configuration file nano conf/local.conf Key parameters for GPU and desktop: # Target machine MACHINE = "ls1028ardb" # Distribution with GPU and Wayland support DISTRO = "fsl-qoriq-distro" # Enable display and GPU features DISTRO_FEATURES:append = " wayland opengl" # GPU driver: use Etnaviv (open-source) for LS1028A # DO NOT use imx-gpu-viv (i.MX only, requires ARCH_MXC) PREFERRED_PROVIDER_virtual/libgl = "mesa" PREFERRED_PROVIDER_virtual/libgles1 = "mesa" PREFERRED_PROVIDER_virtual/libgles2 = "mesa" PREFERRED_PROVIDER_virtual/egl = "mesa" # Enable OpenCL support via Vivante GPU IMAGE_INSTALL:append = " clinfo" # Accept NXP proprietary licenses (required for GPU firmware) LICENSE_FLAGS_ACCEPTED = "nxp-proprietary" # Parallel build threads (adjust to your host PC) BB_NUMBER_THREADS = "8" PARALLEL_MAKE = "-j 8" # (Optional) Use ccache to speed up recompilations INHERIT += "ccache" 5 Required Yocto Layers (bblayers.conf) Verify that conf/bblayers.conf includes these layers: cat conf/bblayers.conf It must contain at least: BBLAYERS ?= " \   ${BSPDIR}/sources/poky/meta \   ${BSPDIR}/sources/poky/meta-poky \   ${BSPDIR}/sources/meta-openembedded/meta-oe \   ${BSPDIR}/sources/meta-openembedded/meta-multimedia \   ${BSPDIR}/sources/meta-openembedded/meta-python \   ${BSPDIR}/sources/meta-openembedded/meta-networking \   ${BSPDIR}/sources/meta-freescale \   ${BSPDIR}/sources/meta-qoriq \   ${BSPDIR}/sources/meta-nxp-desktop \ " The meta-nxp-desktop layer is what provides GPU support for the LS1028A with the ls-image-desktop image. 6 Build the Image with GPU Support # Recommended: Desktop image with full GPU support (LS1028A only) # Includes: GNOME desktop, Weston/Wayland, Vivante GPU drivers, OpenCL bitbake ls-image-desktop # Alternative: download all packages first before building # (useful for catching network errors before the long build) bitbake ls-image-desktop --runall fetch bitbake ls-image-desktop # Minimal: main image without desktop (no GPU by default) bitbake ls-image-main # Lite: minimal image bitbake ls-image-lite Estimated build time: Between 4 and 8 hours on the first build (depending on host hardware). Incremental builds are much faster. 7 Install the Image to the SD Card After compilation, output files are located in: tmp/deploy/images/ls1028ardb/ # Identify the SD card (verify with lsblk) lsblk # Install image using flex-installer (included in the SDK) flex-installer \   -b tmp/deploy/images/ls1028ardb/boot_ls1028ardb.tgz \   -f tmp/deploy/images/ls1028ardb/firmware_ls1028ardb_sdboot.img \   -r tmp/deploy/images/ls1028ardb/ls-image-desktop-ls1028ardb.tar.zst \   -d /dev/sdX    # replace with your SD device Practical Example: OpenCL Application on LS1028A This example shows how to compile and run a program that uses the GC7000UL GPU to add two vectors with OpenCL. 8.1 Source Code: vector_add.cl (OpenCL Kernel) Create the kernel file on the LS1028A board: # On the LS1028A (via serial or SSH) cat > /home/root/vector_add.cl << 'EOF' __kernel void vector_add(     __global const float* a,     __global const float* b,     __global float* c,     const int n) {     int gid = get_global_id(0);     if (gid < n) {         c[gid] = a[gid] + b[gid];     } } 8.2 Source Code: vector_add.c (OpenCL Host) cat > /home/root/vector_add.c << 'EOF' #include #include #include #include #define VECTOR_SIZE 1024 int main() {     cl_platform_id   platform;     cl_device_id     device;     cl_context       context;     cl_command_queue queue;     cl_program       program;     cl_kernel        kernel;     cl_mem           buf_a, buf_b, buf_c;     cl_int           err;     // 1. Get Vivante GPU platform and device     err = clGetPlatformIDs(1, &platform, NULL);     err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);     // Print device name     char device_name[128];     clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name), device_name, NULL);     printf("GPU detected: %s\n", device_name);     // 2. Create context and command queue     context = clCreateContext(NULL, 1, &device, NULL, NULL, &err);     queue   = clCreateCommandQueue(context, device, 0, &err);     // 3. Read kernel source from file     FILE* f = fopen("vector_add.cl", "r");     fseek(f, 0, SEEK_END);     size_t src_size = ftell(f);     rewind(f);     char* src=(char*)malloc(src_size + 1);     fread(src, 1, src_size, f);     src[src_size] = '\0';     fclose(f);     // 4. Compile OpenCL program     program = clCreateProgramWithSource(context, 1, (const char**)&src, &src_size, &err);     err = clBuildProgram(program, 1, &device, NULL, NULL, NULL);     if (err != CL_SUCCESS) {         char log[2048];         clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,                               sizeof(log), log, NULL);         printf("Compilation error:\n%s\n", log);         return 1;     }     kernel = clCreateKernel(program, "vector_add", &err);     // 5. Prepare input data     float* h_a = (float*)malloc(VECTOR_SIZE * sizeof(float));     float* h_b = (float*)malloc(VECTOR_SIZE * sizeof(float));     float* h_c = (float*)malloc(VECTOR_SIZE * sizeof(float));     for (int i = 0; i < VECTOR_SIZE; i++) {         h_a[i] = (float)i;         h_b[i] = (float)(VECTOR_SIZE - i);     }     // 6. Create GPU buffers     buf_a = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,                            VECTOR_SIZE * sizeof(float), h_a, &err);     buf_b = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,                            VECTOR_SIZE * sizeof(float), h_b, &err);     buf_c = clCreateBuffer(context, CL_MEM_WRITE_ONLY,                            VECTOR_SIZE * sizeof(float), NULL, &err);     // 7. Set kernel arguments and execute on GPU     int n = VECTOR_SIZE;     clSetKernelArg(kernel, 0, sizeof(cl_mem), &buf_a);     clSetKernelArg(kernel, 1, sizeof(cl_mem), &buf_b);     clSetKernelArg(kernel, 2, sizeof(cl_mem), &buf_c);     clSetKernelArg(kernel, 3, sizeof(int), &n);     size_t global_size = VECTOR_SIZE;     err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL,                                   &global_size, NULL, 0, NULL, NULL);     clFinish(queue);     // 8. Read result     clEnqueueReadBuffer(queue, buf_c, CL_TRUE, 0,                         VECTOR_SIZE * sizeof(float), h_c, 0, NULL, NULL);     // 9. Verify result (each element should equal VECTOR_SIZE = 1024)     int ok = 1;     for (int i = 0; i < VECTOR_SIZE; i++) {         if (h_c[i] != (float)VECTOR_SIZE) { ok = 0; break; }     }     printf("Result: %s\n", ok ? "CORRECT - GPU works!" : "CALCULATION ERROR");     printf("Example: a[0]=%.0f + b[0]=%.0f = c[0]=%.0f\n",            h_a[0], h_b[0], h_c[0]);     // Free resources     clReleaseMemObject(buf_a); clReleaseMemObject(buf_b); clReleaseMemObject(buf_c);     clReleaseKernel(kernel); clReleaseProgram(program);     clReleaseCommandQueue(queue); clReleaseContext(context);     free(h_a); free(h_b); free(h_c); free(src);     return 0; } 8.3 Compile and Run on the LS1028A On the LS1028A board (connected via serial or SSH): # Install build tools and OpenCL headers apt-get install -y gcc clinfo ocl-icd-libopencl1 opencl-headers # Compile gcc -o vector_add vector_add.c -lOpenCL -I/usr/include # Run ./vector_add Expected output: GPU detected: Vivante OpenCL Device GC7000UL.6202.0000 Result: CORRECT - GPU works! Example: a[0]=0 + b[0]=1024 = c[0]=1024 12.4 Yocto Recipe to Include the Example in the Image To include the example directly in the Yocto image, create a recipe in your custom layer: mkdir -p ~/lldp-ls1028a/sources/meta-my-layer/recipes-examples/opencl-vector/files cp vector_add.c vector_add.cl \    ~/lldp-ls1028a/sources/meta-my-layer/recipes-examples/opencl-vector/files/ Recipe file opencl-vector_1.0.bb: SUMMARY = "OpenCL vector addition example for LS1028A GPU" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" SRC_URI = "file://vector_add.c \            file://vector_add.cl" DEPENDS = "virtual/opencl-icd opencl-headers" S = "${WORKDIR}" do_compile() {     ${CC} ${CFLAGS} -o vector_add vector_add.c -lOpenCL ${LDFLAGS} } do_install() {     install -d ${D}${bindir}     install -m 0755 vector_add ${D}${bindir}/     install -d ${D}/home/root     install -m 0644 vector_add.cl ${D}/home/root/ } FILES:${PN} += "/home/root/vector_add.cl" Add to local.conf and rebuild: IMAGE_INSTALL:append = " opencl-vector" bitbake ls-image-desktop Practical Example: OpenGL ES Rendering with Wayland/Weston This example shows how to render an animated triangle using OpenGL ES 2.0 with EGL on the Weston (Wayland) compositor — the standard "Hello World" of embedded graphics on the GC7000UL GPU. 9.1 Graphics Stack Diagram C Application      ↓ OpenGL ES 2.0  (libGLESv2.so — Vivante GC7000UL)      ↓ EGL 1.4        (libEGL.so — interface between GLES and Wayland)      ↓ Wayland Client (libwayland-client, libwayland-egl)      ↓ Weston Compositor (DRM/KMS + Mali-DP500)      ↓ DisplayPort → 4K Monitor 9.2 Install Dependencies On the LS1028A (with ls-image-desktop): apt-get install -y libgles2-mesa-dev libegl1-mesa-dev libwayland-dev libwayland-egl-backend-dev gcc pkg-config 9.3 Source Code: triangle_gles.c cat > /home/root/triangle_gles.c << 'EOF' /**  * OpenGL ES 2.0 + EGL + Wayland example  * Renders a colored spinning triangle on the Vivante GC7000UL GPU of the LS1028A  * Compile: gcc -o triangle_gles triangle_gles.c -lwayland-client -lwayland-egl -lEGL -lGLESv2 -lm  */ #include #include #include #include #include #include #include #include #define WIDTH  800 #define HEIGHT 600 static struct wl_display       *wl_display    = NULL; static struct wl_compositor    *wl_compositor = NULL; static struct wl_shell         *wl_shell      = NULL; static struct wl_surface       *wl_surface    = NULL; static struct wl_shell_surface *shell_surface = NULL; static struct wl_egl_window    *egl_window    = NULL; static EGLDisplay egl_display; static EGLContext egl_context; static EGLSurface egl_surface; static const char *vertex_shader_src=     "attribute vec2 a_position;          \n"     "attribute vec3 a_color;             \n"     "varying vec3 v_color;               \n"     "uniform float u_angle;              \n"     "void main() {                       \n"     "  float c = cos(u_angle);           \n"     "  float s = sin(u_angle);           \n"     "  vec2 rot = vec2(                  \n"     "    a_position.x*c - a_position.y*s,\n"     "    a_position.x*s + a_position.y*c \n"     "  );                                \n"     "  gl_Position = vec4(rot, 0.0, 1.0);\n"     "  v_color = a_color;                \n"     "}                                   \n"; static const char *fragment_shader_src=     "precision mediump float;            \n"     "varying vec3 v_color;               \n"     "void main() {                       \n"     "  gl_FragColor = vec4(v_color, 1.0);\n"     "}                                   \n"; /* Vertices: position (x,y) + color (r,g,b) */ static const float vertices[] = {      0.0f,  0.8f,  1.0f, 0.0f, 0.0f,   /* Top    - Red   */     -0.7f, -0.5f,  0.0f, 1.0f, 0.0f,   /* Left   - Green */      0.7f, -0.5f,  0.0f, 0.0f, 1.0f,   /* Right  - Blue  */ }; static void registry_global(void *data, struct wl_registry *reg,                              uint32_t name, const char *iface, uint32_t ver) {     if (strcmp(iface, "wl_compositor") == 0)         wl_compositor = wl_registry_bind(reg, name, &wl_compositor_interface, 1);     else if (strcmp(iface, "wl_shell") == 0)         wl_shell = wl_registry_bind(reg, name, &wl_shell_interface, 1); } static void registry_global_remove(void *d, struct wl_registry *r, uint32_t n) {} static const struct wl_registry_listener registry_listener = {     registry_global, registry_global_remove }; static GLuint compile_shader(GLenum type, const char *src) {     GLuint shader = glCreateShader(type);     glShaderSource(shader, 1, &src, NULL);     glCompileShader(shader);     GLint ok; glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);     if (!ok) {         char log[512]; glGetShaderInfoLog(shader, 512, NULL, log);         printf("Shader error: %s\n", log); exit(1);     }     return shader; } int main() {     wl_display = wl_display_connect(NULL);     if (!wl_display) { printf("Error: could not connect to Wayland\n"); return 1; }     struct wl_registry *registry = wl_display_get_registry(wl_display);     wl_registry_add_listener(registry, &registry_listener, NULL);     wl_display_dispatch(wl_display);     wl_display_roundtrip(wl_display);     wl_surface = wl_compositor_create_surface(wl_compositor);     shell_surface = wl_shell_get_shell_surface(wl_shell, wl_surface);     wl_shell_surface_set_toplevel(shell_surface);     egl_display = eglGetDisplay((EGLNativeDisplayType)wl_display);     eglInitialize(egl_display, NULL, NULL);     eglBindAPI(EGL_OPENGL_ES_API);     EGLint config_attribs[] = {         EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,         EGL_RED_SIZE,   8, EGL_GREEN_SIZE, 8,         EGL_BLUE_SIZE,  8, EGL_ALPHA_SIZE, 0,         EGL_DEPTH_SIZE, 16, EGL_NONE     };     EGLConfig egl_config; EGLint num_configs;     eglChooseConfig(egl_display, config_attribs, &egl_config, 1, &num_configs);     EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };     egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, ctx_attribs);     egl_window  = wl_egl_window_create(wl_surface, WIDTH, HEIGHT);     egl_surface = eglCreateWindowSurface(egl_display, egl_config,                                           (EGLNativeWindowType)egl_window, NULL);     eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);     printf("GPU: %s\n", glGetString(GL_RENDERER));     printf("OpenGL ES Version: %s\n", glGetString(GL_VERSION));     GLuint vs = compile_shader(GL_VERTEX_SHADER,   vertex_shader_src);     GLuint fs = compile_shader(GL_FRAGMENT_SHADER, fragment_shader_src);     GLuint program = glCreateProgram();     glAttachShader(program, vs); glAttachShader(program, fs);     glLinkProgram(program); glUseProgram(program);     GLint pos_loc   = glGetAttribLocation(program,  "a_position");     GLint color_loc = glGetAttribLocation(program,  "a_color");     GLint angle_loc = glGetUniformLocation(program, "u_angle");     glViewport(0, 0, WIDTH, HEIGHT);     float angle = 0.0f;     int frames = 0;     printf("Rendering spinning triangle (Ctrl+C to exit)...\n");     while (1) {         wl_display_dispatch_pending(wl_display);         glClearColor(0.1f, 0.1f, 0.15f, 1.0f);         glClear(GL_COLOR_BUFFER_BIT);         glUniform1f(angle_loc, angle);         glEnableVertexAttribArray(pos_loc);         glVertexAttribPointer(pos_loc,   2, GL_FLOAT, GL_FALSE, 5*sizeof(float), vertices);         glEnableVertexAttribArray(color_loc);         glVertexAttribPointer(color_loc, 3, GL_FLOAT, GL_FALSE, 5*sizeof(float), vertices + 2);         glDrawArrays(GL_TRIANGLES, 0, 3);         eglSwapBuffers(egl_display, egl_surface);         angle += 0.02f;         if (angle > 6.2832f) angle -= 6.2832f;         frames++;         if (frames % 300 == 0)             printf("Frame %d — angle: %.2f rad\n", frames, angle);     }     eglDestroyContext(egl_display, egl_context);     eglDestroySurface(egl_display, egl_surface);     eglTerminate(egl_display);     wl_display_disconnect(wl_display);     return 0; } 9.4 Compile and Run # Compile gcc -o triangle_gles triangle_gles.c \     -lwayland-client -lwayland-egl \     -lEGL -lGLESv2 -lm # Make sure Weston is running and set Wayland environment export XDG_RUNTIME_DIR=/run/user/0 export WAYLAND_DISPLAY=wayland-0 # Run ./triangle_gles Expected terminal output: GPU: Vivante GC7000UL OpenGL ES Version: OpenGL ES 3.1 V6.4.3.p4.398061 Rendering spinning triangle (Ctrl+C to exit)... Frame 300 — angle: 6.00 rad Frame 600 — angle: 5.68 rad A RGB triangle spinning on a dark background will appear on screen, rendered by the GC7000UL GPU. 9.5 Yocto Recipe SUMMARY = "OpenGL ES 2.0 spinning triangle example — LS1028A" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" SRC_URI = "file://triangle_gles.c" DEPENDS = "virtual/libgles2 virtual/egl wayland" S = "${WORKDIR}" do_compile() {     ${CC} ${CFLAGS} -o triangle_gles triangle_gles.c \         -lwayland-client -lwayland-egl -lEGL -lGLESv2 -lm ${LDFLAGS} } do_install() {     install -d ${D}${bindir}     install -m 0755 triangle_gles ${D}${bindir}/ } 9.6 Yocto Recipe for OpenCV with GPU Add to local.conf: IMAGE_INSTALL:append = " opencv python3-opencv" PACKAGECONFIG:append:pn-opencv = " opencl" bitbake ls-image-desktop References: 1) https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/layerscape-processors:QORIQ-ARM 2) https://www.khronos.org/news/permalink/vivante-gc7000-gpus 3) Layerscape Software Development Kit User Guide for Yocto : https://docs.nxp.com/bundle/GUID-E5527A77-2F97-4244-BF9C-D08F068EFD16/page/GUID-B386D634-B9B1-4980-AA56-9C705D7FBC52.html?gad_source=1&gad_campaignid=24106955438&gclid=EAIaIQobChMI3cKf4KqZlwMVbnJ_AB17dwoGEAAYASAAEgJURPD_BwE Regards  
View full article
Transformed and Quantized your model with NPU of the MX8Mplus  Introduction In this article, we will explain in this article which steps you have to take to transform and quantize your model with different TensorFlow versions. We are only looking into post training quantization. We are using the MX8MPlus EVK run our model that have a dedicated neural network accelerator IP from VeriSilicon (Vivante VIP8000). Press enter or click to view image in full size i.mx8MPlus block diagram from NXP Is the neural processing unit (NPU) from NXP need a fully int8 quantized model we have to look into full int8 quantization of a TensorFlow lite or PyTorch model. Both libraries are supported with the eIQ library from NXP. Here we will only look into the TensorFlow variant. The general overview on how to do post training quantization can be found on the TensorFlow website.  The operations for floating point are more complex than for integer (arithmetic’s, avoiding overflow). This results in the ability to use only the much simpler and smaller arithmetic units instead of the larger floating-point units. ​ ​The physical space needed for float32 operation much larger than for int8. This results in:​ Lower power consumption, ​ Less heat development, ​ The ability to join more calculation units decreasing inference time. Prerequisite To create the code on your PC first, we recommend using Anaconda with a virtual environment running Python 3.6, TensorFlow 2.x, numpy, opencv-python and pandas. Post training quantization with TensorFlow Version 2.x If you created and trained a model via tf.keras there are three similar ways of quantizing the model. First Method — Quantizing a Trained Model Directly The trained TensorFlow model has to be converted into a TFlite model and can be directly quantize as described in the following code block. For the trained model we exemplary use the updated tf,keras_vggface model based on the work of rcmalli . The transformation starts at line 28. from keras_vggface_TF.utils import preprocess_input from keras_vggface_TF.vggfaceTF import VGGFace converter.inference_output_type = tf.int8   import tensorflow as tf import numpy as np tfVersion=tf.version.VERSION.replace(".", "") # can be used as savename print(tf.version.VERSION) # TRAIN A MODEL pretrained_model = VGGFace(model='resnet50', include_top=False, input_shape=(224, 224, 3), pooling='avg') # pooling: None, avg or max #Create a generator for representative Dataset folderpath='./All_croped_images/' def prepare(img):          img = np.expand_dims(img,0).astype(np.float32)          img = preprocess_input(img, version=2) return img repDatagen=tf.keras.preprocessing.image.ImageDataGenerator(preprocessing_function=prepare) datagen=repDatagen.flow_from_directory(folderpath,target_size=(224,224),batch_size=1) def representative_dataset_gen():       for _ in range(10):       Img = datagen.next()       yield [img[0]] #CONVERT YOUR MODEL TO TFLITE AND QUANTIZE TO INT8 converter = tf.lite.TFLiteConverter.from_keras_model(pretrained_model) converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.representative_dataset = representative_dataset_gen converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] converter.experimental_new_converter = True converter.target_spec.supported_types = [tf.int8] converter.inference_input_type = tf.int8 quantized_tflite_model = converter.convert() #SAVE THE QUANTIZED MODEL AS TFLITE FILE open('quant_model.tflite' , "wb").write(quantized_tflite_model) After loading/training your model you first have to create a representative data set. The representative data set is used by the converter to get the max and min values to be able to estimate the scaling factor. This limits the error introduced by the quantization from float32 to intX. The error comes from the different number-space of float and int. Converting from float to int8 limits the number-space to integer values between -128 to 127. Calibrating the model on the dynamic range of the input limits this error. Here you can just loop through your images or create a generator as in our example. We used the tf.keras.preprocessing.image.ImageDataGenerator() to yield images and do the necessary prepossessing on the images. As a generator you can of course also use the tf.data.Dataset.from_tensors() or … from.tensor_slices(). Just keep in mind to do the same pre-processing on your data here as you did on the data you trained your network with (normalization, resizing, de-noising, …). This can all be packed into the preprocessing_function call of the generator (line 19). The conversion starts at line 28. A simple TensorFlow lite conversion would look like this: converter = tf.lite.TFLiteConverter.from_keras_model(pretrained_model) tflite_model = converter.convert() open('model.tflite' , "wb").write(tflite_model) The quantization part is in-between: converter = tf.lite.TFLiteConverter.from_keras_model(pretrained_model) converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.representative_dataset = representative_dataset_gen converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] converter.experimental_new_converter = True converter.target_spec.supported_types = [tf.int8] converter.inference_input_type = tf.int8 converter.inteference_output_type=tf.int8 quantized_tflite_model = converter.convert() open('quant_model.tflite' , "wb").write(quantized_tflite_model) Line 3 : optimizations other than default are deprecated. No other options are available at the moment (Year 2020). Line 4 : Here we set the representative data set. Line 5 : Here we make sure that we have a full conversion to int8. Without this option, only the weights and biases would be converted but not the activations. This is used when we only want to reduce the model size. However, our NPU needs full int8 quantization. Having the activations still in floating point would result in overall floating-point and could not run on the NPU. Line 6: Enables MLIR-based conversion instead of TOCO conversion, which enables RNN support, easier error tracking. Line 7: Sets the internal constant value to int8. The target_spec corresponds with the TFLITE_BUILTINS from line 5. Line 9 and 10: Set also the input to int8. This is fully available from TF 2.3 Now if we convert the model using TF2.3 with experimental_new_converter=True inference_input_type=tf.int8 inference_output_type=tf.int8 we receive the following model: However if we do not set the inference_input_type and inference_output_type we receive following model: So the effect is that you can determine which input data type the model accepts and returns. This can be important if you work with an embedded camera, as included with the MX8MPEVK. The mipi camera returns 8bit values, so if you want to spare a conversion to float32 int8 input can be handy. But be aware, if you use a model without prediction layers to gain e.g., embeddings, an int8 output will result in very poor performance. Here an output of float32 is recommended. This shows that each problem needs a specific solution. Second and Third Method — Quantize a Saved Model from *.h5 or *.pb Files If you already have your model, you most likely have it saved somewhere either as an Keras h5 file or a TensorFlow protocol buffer pb. We will quickly save our model using TF2.3: import tensorflow as tf f rom keras_vggface_TF.vggfaceTF import VGGFace pretrained_model = VGGFace(model='resnet50', include_top=False, input_shape=(224, 224, 3), pooling='avg') # pooling: None, avg or max # Saving as a protocol buffer !mkdir -p saved_model pretrained_model.save('saved_model/my_model') #saving as a h5 file (if your Tensorflow Version is < 2.0 use this) !mkdir -p keras_model pretrained_model.save('keras_model/my_model.h5') Following the conversion and quantization is very similar as in Method One. The only difference is how we load the model in with the converter. Either load the model and continue as in Method One. #Load the h5 model pretrained_model = tf.keras.models.load_model('my_model.h5') #Then use the converter as before converter = tf.lite.TFLiteConverter.from_keras_model(pretrained_model) Or load the h5 model directly. When using TensorFlow version 2 and above you have to use a compatible converter: # Or load the h5 model from file # TensorFlow version >2.x converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(saved_model_dir + h5_modelname) #works now also with TF2.x # TensorFlowversion < 2.0 converter = tf.lite.TFLiteConverter.from_keras_model_file(saved_model_dir + h5_modelname) If you load from a TensorFlow pb file use: # Or load the pb file from the modelfolder # TensorFlow version >2.x converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) # the folder contains the pb file and a assets and variables folder Converting with TensorFlow Versions below 2.0 If you want to convert a model written in TensorFlow version < 1.15.3 using Keras, not all options are available for TFlite conversion and quantization. The best way is to save the model with the TensorFlow version it was created in (e.g., rcmalli keras-vggface was trained in TF 1.13.2). I would suggest not using the “saving and freeze graph” method to create a pb file as the pb files differ between TF1 and TF2. The TFLiteConverter.from_saved_model does not work, creating quite a hassle to achieve quantization. I would suggest using the above mentioned method using Keras: import keras …. pretrained_model.save('my_model.h5') Then convert and quantize your model with a TensorFlow version from 1.15.3 onward. From this version on a lot of functions where added in preparation for TF2. I suggest using the latest version.  Regards
View full article